Package com.antlersoft.odb

Examples of com.antlersoft.odb.ObjectStoreException


            {
                return new ClassIterator( entry.objectStreams);
            }
            catch ( IOException ioe)
            {
                throw new ObjectStoreException( "Creating iterator:", ioe);
            }
        }
        finally
        {
            classChangeLock.leaveProtected();
View Full Code Here


                        result.objectStreams=new StreamPair( allocator,
                            factory.getCustomizer( toFind));
                    }
                    catch ( Exception dae)
                    {
                        throw new ObjectStoreException( "Failed creating allocator "+
                            result.fileName+" for class "+result.className, dae);
                    }
                }
                else
                {
                    classIndex=classEntries.size();
                    result=new ClassEntry();
                    result.reuseCount=0;
                    result.index=classEntries.size();
                    result.className=toFind.getName();
                    result.fileName=Integer.toString( classIndex);
                    result.indices=new ArrayList();
                    try
                    {
                        DiskAllocator allocator=manager.createDiskAllocator(result.fileName, 128, DiskAllocator.FORCE_CREATE);
                        result.objectStreams=new StreamPair( allocator,
                            factory.getCustomizer( toFind));
                    }
                    catch ( Exception dae)
                    {
                        throw new ObjectStoreException( "Failed creating allocator "+
                            result.fileName+" for class "+result.className, dae);
                    }
                    classEntries.add( result);
                }
                classMap.put( toFind, result);
View Full Code Here

        {
            entry.startPageOffset=streams.writeImmovableObject( startPage, 0);
        }
        catch ( IOException ioe)
        {
            throw new ObjectStoreException( "I/O error creating index start page",
                ioe);
        }
        catch ( DiskAllocatorException dae)
        {
            throw new ObjectStoreException( "Error creating index start page:",
                dae);
        }
        entry.index=new Index( manager, entry, streams);
        startPage.thisPage=entry.index.getTopKey();
        manager.addNewIndexPageToCache( startPage);
View Full Code Here

        streams.enterProtected();
        evaluatePageStatistics( result, entry.startPageOffset);
      }
      catch ( ClassNotFoundException cnfe)
      {
        throw new ObjectStoreException( "getStatistics ", cnfe);
      }
      catch ( DiskAllocatorException dae)
      {
        throw new ObjectStoreException( "getStatistics allocator error ", dae);
      }
      catch ( IOException ioe)
      {
        throw new ObjectStoreException( "getStatistic io error", ioe);
      }
      finally
      {
        streams.leaveProtected();
      }
View Full Code Here

        streams.enterProtected();
        validateIndexPage(freeSet, entry.startPageOffset, null);
      }
      catch ( ClassNotFoundException cnfe)
      {
        throw new ObjectStoreException( "validate ", cnfe);
      }
      catch ( DiskAllocatorException dae)
      {
        throw new ObjectStoreException( "validate allocator error ", dae);
      }
      catch ( IOException ioe)
      {
        throw new ObjectStoreException( "validate io error", ioe);
      }
      finally
      {
        streams.leaveProtected();
      }
View Full Code Here

      IndexPage page=(IndexPage)streams.readImmovableObject(offset);
      Comparable previous=null;
      if ( parentKey!=null)
      {
        if ( parentKey.compareTo( page.keyArray[0])!=0)
          throw new ObjectStoreException( "Key in parent page doesn't match first key in child");
      }
      for ( int i=0; i<page.size; ++i)
      {
        Comparable next=page.keyArray[i];
        if ( previous!=null)
        {
          if ( previous.compareTo(next)>=0)
            throw new ObjectStoreException( "Keys in wrong order in index page");
        }
        previous=next;
        if ( page.reuseArray==null)
        {
          validateIndexPage( freeSet, page.nextOffsetArray[i], previous);
        }
        else if (freeSet != null)
        {
          DAKey objKey=new DAKey( page.nextOffsetArray[i], page.reuseArray[i]);
          Serializable obj=manager.retrieve( objKey);
          Comparable compareKey=entry.generator.generateKey( obj);
          if ( ! entry.unique)
          {
            compareKey=new UniqueKey(compareKey,objKey);
          }
           if ( compareKey.compareTo( previous)!=0)
            throw new ObjectStoreException( "Keys fail to compare");
           if (freeSet.contains(objKey.index))
           {
             throw new ObjectStoreException("Free set contains object index for object " + obj.toString());
           }
        }
      }
    }
View Full Code Here

    private void insertKey( DAKey objectRef, Comparable key)
        throws ObjectStoreException
    {
        FindResult fr=findKey( key);
        if ( fr.keyMatched)
            throw new ObjectStoreException( "Duplicate value for index: "
                +entry.indexName);
        if ( fr.offset==0)
            fixParentKey( fr.page, fr.page.keyArray[0], key);
        System.arraycopy( fr.page.nextOffsetArray, fr.offset,
            fr.page.nextOffsetArray, fr.offset+1, fr.page.size-fr.offset);
View Full Code Here

                parent.thisPage=new IndexPageKey( this,
                    streams.writeImmovableObject( parent, 0), null);
            }
            catch ( IOException ioe)
            {
                throw new ObjectStoreException( "I/O error creating index page",
                    ioe);
            }
            catch ( DiskAllocatorException dae)
            {
                throw new ObjectStoreException( "Error creating index page:",
                    dae);
            }
            entry.startPageOffset=parent.thisPage.offset;
            topKey=parent.thisPage;
            toSplit.thisPage.parent=parent.thisPage;
            manager.dirtyClassList();
            manager.addNewIndexPageToCache( parent);

            splitParentPosition=1;
        }
        else
        {
            parent=manager.getIndexPageByKey( toSplit.thisPage.parent);
            splitParentPosition=binarySearch( parent.keyArray, 0, parent.size-1,
                toSplit.keyArray[0]);
            if ( splitParentPosition<0)
                throw new ObjectStoreException(
                    "Index corrupt: splitting page");
            splitParentPosition++;
        }
        int splitPosition=toSplit.size/2;
        IndexPage newPage=new IndexPage();
        newPage.nextOffsetArray=new int[entry.pageCount];
        System.arraycopy( toSplit.nextOffsetArray, splitPosition,
            newPage.nextOffsetArray, 0, toSplit.size-splitPosition);
        newPage.keyArray=new Comparable[entry.pageCount];
        System.arraycopy( toSplit.keyArray, splitPosition,
            newPage.keyArray, 0, toSplit.size-splitPosition);
        if ( toSplit.reuseArray==null)
            newPage.reuseArray=null;
        else
        {
            newPage.reuseArray=new int[entry.pageCount];
            System.arraycopy( toSplit.reuseArray, splitPosition,
                newPage.reuseArray, 0, toSplit.size-splitPosition);
        }
        newPage.size=toSplit.size-splitPosition;
        newPage.modified=true;
        try
        {
            newPage.thisPage=new IndexPageKey( this,
                streams.writeImmovableObject( newPage, 0), toSplit.thisPage.parent);
        }
        catch ( IOException ioe)
        {
            throw new ObjectStoreException( "I/O error creating index page",
                ioe);
        }
        catch ( DiskAllocatorException dae)
        {
            throw new ObjectStoreException( "Error creating index page:",
                dae);
        }

        toSplit.size=splitPosition;
        for ( int i=splitPosition; i<entry.pageCount; i++)
View Full Code Here

    private void removeKey( DAKey objectRef, Comparable key)
        throws ObjectStoreException
    {
        FindResult fr=findKey( key);
        if ( ! fr.keyMatched)
            throw new ObjectStoreException( "Missing value for index: "
                +entry.indexName);
        if ( fr.offset==0 && fr.page.thisPage.parent!=null)
        {
            if ( fr.page.size==1)
            {
View Full Code Here

            IndexPage parent=manager.getIndexPageByKey(
                newInitial.thisPage.parent);
            int parentPosition=binarySearch( parent.keyArray, 0,
                parent.size-1, oldStartValue);
            if ( parentPosition<0)
                throw new ObjectStoreException(
                    "Index corrupt when changing initial value");
            parent.keyArray[parentPosition]=newStartValue;
            parent.modified=true;
            if ( parentPosition==0)
            {
View Full Code Here

TOP

Related Classes of com.antlersoft.odb.ObjectStoreException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.