private boolean readMetaHeader ( ) throws IOException { try ( ReadStream is = openRead ( 0 , META_SEGMENT_SIZE ) ) { int crc = 17 ; long magic = BitsUtil . readLong ( is ) ; if ( magic != KELP_MAGIC ) { System . out . println ( "WRONG_MAGIC: " + magic ) ; return false ; } crc = Crc32Caucho . generate ( crc , magic ) ; _nonce = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , _nonce ) ; int headers = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , headers ) ; for ( int i = 0 ; i < headers ; i ++ ) { int key = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , key ) ; int value = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , value ) ; } int count = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , count ) ; ArrayList < Integer > segmentSizes = new ArrayList <> ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int size = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , size ) ; segmentSizes . add ( size ) ; } int crcFile = BitsUtil . readInt ( is ) ; if ( crc != crcFile ) { System . out . println ( "MISMATCHED_CRC: " + crcFile ) ; return false ; } _metaSegment = new SegmentExtent10 ( 0 , 0 , META_SEGMENT_SIZE ) ; _segmentId = 1 ; _metaOffset = is . position ( ) ; } return true ; }
Reads the initial metadata for the store file as a whole .