/** * Set the root page * @param rootPage the rootPage to set */ /* no qualifier */void setRootPage( Page<K, V> rootPage ) { this.rootPage = rootPage; this.rootPageOffset = ( ( AbstractPage<K, V> ) rootPage ).getOffset(); }
public String toString() { StringBuilder sb = new StringBuilder(); sb.append( "\n copiedPage = <" ); boolean isFirst = true; for ( Page<K, V> copiedPage : getCopiedPages() ) { if ( isFirst ) { isFirst = false; } else { sb.append( ", " ); } sb.append( ( ( AbstractPage<K, V> ) copiedPage ).getOffset() ); } sb.append( ">" ); return sb.toString(); } }
/** * Serialize a Node's Value. We store the two offsets of the child page. */ private <K, V> int serializeNodeValue( PersistedNode<K, V> node, int pos, List<byte[]> serializedData ) throws IOException { // For a node, we just store the children's offsets Page<K, V> child = node.getReference( pos ); // The first offset byte[] buffer = LongSerializer.serialize( ( ( AbstractPage<K, V> ) child ).getOffset() ); serializedData.add( buffer ); int dataSize = buffer.length; // The last offset buffer = LongSerializer.serialize( ( ( AbstractPage<K, V> ) child ).getLastOffset() ); serializedData.add( buffer ); dataSize += buffer.length; return dataSize; }
/** * Add a new <btree, revision> tuple into the CopiedPages B-tree. * * @param name The B-tree name * @param revision The B-tree revision * @param btreeHeaderOffset The B-tree offset * @throws IOException If the update failed */ /* no qualifier */<K, V> void addInCopiedPagesBtree( String name, long revision, List<Page<K, V>> pages ) throws IOException { RevisionName revisionName = new RevisionName( revision, name ); long[] pageOffsets = new long[pages.size()]; int pos = 0; for ( Page<K, V> page : pages ) { pageOffsets[pos++] = ( ( AbstractPage<K, V> ) page ).getOffset(); } copiedPageBtree.insert( revisionName, pageOffsets ); // Update the CopiedPageBtree offset currentCopiedPagesBtreeOffset = ( ( AbstractBTree<RevisionName, long[]> ) copiedPageBtree ).getBtreeHeader().getBTreeHeaderOffset(); }
long pageOffset = ( ( AbstractPage<K, V> ) page ).getOffset();
/** * Store a reference to an old rootPage into the Revision B-tree * * @param btree The B-tree we want to keep an old RootPage for * @param rootPage The old rootPage * @throws IOException If we have an issue while writing on disk */ /* No qualifier */<K, V> void storeRootPage( BTree<K, V> btree, Page<K, V> rootPage ) throws IOException { if ( !isKeepRevisions() ) { return; } if ( btree == copiedPageBtree ) { return; } NameRevision nameRevision = new NameRevision( btree.getName(), rootPage.getRevision() ); ( ( AbstractBTree<NameRevision, Long> ) btreeOfBtrees ).insert( nameRevision, ( ( AbstractPage<K, V> ) rootPage ).getOffset(), 0 ); if ( LOG_CHECK.isDebugEnabled() ) { MavibotInspector.check( this ); } }
/** * Create a new holder storing an offset and a SoftReference containing the element. * * @param page The element to store into a SoftReference */ public PersistedPageHolder( BTree<K, V> btree, Page<K, V> page ) { // DO NOT keep the reference to Page, it will be fetched from cache when needed super( btree, null ); cache = ( ( PersistedBTree<K, V> ) btree ).getCache(); recordManager = ( ( PersistedBTree<K, V> ) btree ).getRecordManager(); offset = ( ( AbstractPage<K, V> ) page ).getOffset(); lastOffset = ( ( AbstractPage<K, V> ) page ).getLastOffset(); ( ( AbstractPage<K, V> ) page ).setOffset( offset ); ( ( AbstractPage<K, V> ) page ).setLastOffset( lastOffset ); cache.put( offset, page ); }
rm.updateBtreeHeader( btree, ( ( AbstractPage<K, V> ) rootPage ).getOffset() );