private boolean writeMetaData ( final boolean isClean ) { if ( readOnly ) { return true ; } final WriteBuffer wbuf = storage . set ( 0 ) ; final ByteBuffer buf = wbuf . buf ( ) ; boolean isOK = false ; // @formatter:off buf . putInt ( MAGIC_1 ) . putInt ( blockSize ) . putInt ( b_order_leaf ) . putInt ( b_order_internal ) . putInt ( storageBlock ) . putInt ( rootIdx ) . putInt ( lowIdx ) . putInt ( highIdx ) . putInt ( elements ) . putInt ( height ) . putInt ( maxInternalNodes ) . putInt ( maxLeafNodes ) . put ( ( byte ) ( isClean ? 0xEA : 0x00 ) ) . putInt ( MAGIC_2 ) . flip ( ) ; // @formatter:on isOK = wbuf . save ( ) ; if ( isClean ) { storage . sync ( ) ; } try { if ( isClean ) { SimpleBitSet . serializeToFile ( fileFreeBlocks , freeBlocks ) ; } else { fileFreeBlocks . delete ( ) ; } } catch ( IOException e ) { log . error ( "IOException in writeMetaData(" + isClean + ")" , e ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( this . getClass ( ) . getName ( ) + "::writeMetaData() elements=" + elements + " rootIdx=" + rootIdx + " lastNodeId=" + storageBlock + " freeBlocks=" + freeBlocks . cardinality ( ) ) ; } return isOK ; }
Write metadata to file