public void readEntries(TableKelp table,InSegment reader,SegmentEntryCallback cb){
  TempBuffer tBuf=TempBuffer.createLarge();
  byte[] buffer=tBuf.buffer();
  InStore sIn=reader.getStoreRead();
  byte[] tableKey=new byte[TableKelp.TABLE_KEY_SIZE];
  for (int ptr=length() - BLOCK_SIZE; ptr > 0; ptr-=BLOCK_SIZE) {
    sIn.read(getAddress() + ptr,buffer,0,buffer.length);
    int index=0;
    long seq=BitsUtil.readLong(buffer,index);
    index+=8;
    if (seq != getSequence()) {
      log.warning(L.l("Invalid sequence {0} expected {1} at 0x{2}",seq,getSequence(),Long.toHexString(getAddress() + ptr)));
      break;
    }
    System.arraycopy(buffer,index,tableKey,0,tableKey.length);
    index+=tableKey.length;
    if (!Arrays.equals(tableKey,_tableKey)) {
      log.warning(L.l("Invalid table {0} table {1} at 0x{2}",Hex.toShortHex(tableKey),Hex.toShortHex(_tableKey),Long.toHexString(getAddress() + ptr)));
      break;
    }
    int head=index;
    while (head < BLOCK_SIZE && buffer[head] != 0) {
      head=readEntry(table,buffer,head,cb,getAddress());
    }
    boolean isCont=buffer[head + 1] != 0;
    if (!isCont) {
      break;
    }
  }
  tBuf.free();
}

public void readEntries ( TableKelp table , InSegment reader , SegmentEntryCallback cb ) { TempBuffer tBuf = TempBuffer . createLarge ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; InStore sIn = reader . getStoreRead ( ) ; byte [ ] tableKey = new byte [ TableKelp . TABLE_KEY_SIZE ] ; for ( int ptr = length ( ) - BLOCK_SIZE ; ptr > 0 ; ptr -= BLOCK_SIZE ) { sIn . read ( getAddress ( ) + ptr , buffer , 0 , buffer . length ) ; int index = 0 ; long seq = BitsUtil . readLong ( buffer , index ) ; index += 8 ; if ( seq != getSequence ( ) ) { log . warning ( L . l ( "Invalid sequence {0} expected {1} at 0x{2}" , seq , getSequence ( ) , Long . toHexString ( getAddress ( ) + ptr ) ) ) ; break ; } System . arraycopy ( buffer , index , tableKey , 0 , tableKey . length ) ; index += tableKey . length ; if ( ! Arrays . equals ( tableKey , _tableKey ) ) { log . warning ( L . l ( "Invalid table {0} table {1} at 0x{2}" , Hex . toShortHex ( tableKey ) , Hex . toShortHex ( _tableKey ) , Long . toHexString ( getAddress ( ) + ptr ) ) ) ; break ; } int head = index ; while ( head < BLOCK_SIZE && buffer [ head ] != 0 ) { head = readEntry ( table , buffer , head , cb , getAddress ( ) ) ; } boolean isCont = buffer [ head + 1 ] != 0 ; if ( ! isCont ) { break ; } } tBuf . free ( ) ; }
reads index entries from the segment . the index is at the tail of the segment , written backwards in blocks . the final block has the first entries , and the next to last has the second set of entries .
