/** * Stores the copied pages into the CopiedPages B-tree * * @param name The B-tree name * @param revision The revision * @param copiedPages The pages that have been copied while creating this revision * @throws IOException If we weren't able to store the data on disk */ /* No Qualifier */void storeCopiedPages( String name, long revision, long[] copiedPages ) throws IOException { RevisionName revisionName = new RevisionName( revision, name ); copiedPageBtree.insert( revisionName, copiedPages ); }
/** * {@inheritDoc} */ @Override public RevisionName deserialize( ByteBuffer buffer ) throws IOException { // The revision long revision = buffer.getLong(); // The name's length int len = buffer.getInt(); switch ( len ) { case 0: return new RevisionName( revision, "" ); case -1: return new RevisionName( revision, null ); default: byte[] nameBytes = new byte[len]; buffer.get( nameBytes ); return new RevisionName( revision, Strings.utf8ToString( nameBytes ) ); } } }
/** * {@inheritDoc} */ @Override public RevisionName deserialize( BufferHandler bufferHandler ) throws IOException { byte[] revisionBytes = bufferHandler.read( 8 ); long revision = LongSerializer.deserialize( revisionBytes ); byte[] lengthBytes = bufferHandler.read( 4 ); int len = IntSerializer.deserialize( lengthBytes ); switch ( len ) { case 0: return new RevisionName( revision, "" ); case -1: return new RevisionName( revision, null ); default: byte[] nameBytes = bufferHandler.read( len ); return new RevisionName( revision, Strings.utf8ToString( nameBytes ) ); } }
/** * A static method used to deserialize a RevisionName from a byte array. * * @param in The byte array containing the RevisionName * @param start the position in the byte[] we will deserialize the RevisionName from * @return A RevisionName instance */ public RevisionName fromBytes( byte[] in, int start ) { // The buffer must be 8 bytes plus 4 bytes long (the revision is a long, and the name is a String if ( ( in == null ) || ( in.length < 12 + start ) ) { throw new SerializerCreationException( "Cannot extract a RevisionName from a buffer with not enough bytes" ); } long revision = LongSerializer.deserialize( in, start ); String name = StringSerializer.deserialize( in, 8 + start ); RevisionName revisionName = new RevisionName( revision, name ); return revisionName; }
/** * A static method used to deserialize a RevisionName from a byte array. * * @param in The byte array containing the RevisionName * @param start the position in the byte[] we will deserialize the RevisionName from * @return A RevisionName instance */ /* no qualifier*/static RevisionName deserialize( byte[] in, int start ) { // The buffer must be 8 bytes plus 4 bytes long (the revision is a long, and the name is a String if ( ( in == null ) || ( in.length < 12 + start ) ) { throw new SerializerCreationException( "Cannot extract a RevisionName from a buffer with not enough bytes" ); } long revision = LongSerializer.deserialize( in, start ); String name = StringSerializer.deserialize( in, 8 + start ); RevisionName revisionName = new RevisionName( revision, name ); return revisionName; }
/** * Add a newly closd transaction into the closed transaction queue */ /* no qualifier */<K, V> void releaseTransaction( ReadTransaction<K, V> readTransaction ) { RevisionName revisionName = new RevisionName( readTransaction.getRevision(), readTransaction.getBtreeHeader().getBtree().getName() ); //closedTransactionsQueue.add( revisionName ); }
/** * 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(); }
RevisionName revisionName = new RevisionName( revision, btree.getName() );
RevisionName key = new RevisionName( rv, name );