static PageChildren read(FileStore fileStore,long pos,int mapId,long filePos,long maxPos){
  ByteBuffer buff;
  int maxLength=DataUtils.getPageMaxLength(pos);
  if (maxLength == DataUtils.PAGE_LARGE) {
    buff=fileStore.readFully(filePos,128);
    maxLength=buff.getInt();
  }
  maxLength=(int)Math.min(maxPos - filePos,maxLength);
  int length=maxLength;
  if (length < 0) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"Illegal page length {0} reading at {1}; max pos {2} ",length,filePos,maxPos);
  }
  buff=fileStore.readFully(filePos,length);
  int chunkId=DataUtils.getPageChunkId(pos);
  int offset=DataUtils.getPageOffset(pos);
  int start=buff.position();
  int pageLength=buff.getInt();
  if (pageLength > maxLength) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"File corrupted in chunk {0}, expected page length =< {1}, got {2}",chunkId,maxLength,pageLength);
  }
  buff.limit(start + pageLength);
  short check=buff.getShort();
  int m=DataUtils.readVarInt(buff);
  if (m != mapId) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"File corrupted in chunk {0}, expected map id {1}, got {2}",chunkId,mapId,m);
  }
  int checkTest=DataUtils.getCheckValue(chunkId) ^ DataUtils.getCheckValue(offset) ^ DataUtils.getCheckValue(pageLength);
  if (check != (short)checkTest) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"File corrupted in chunk {0}, expected check value {1}, got {2}",chunkId,checkTest,check);
  }
  int len=DataUtils.readVarInt(buff);
  int type=buff.get();
  boolean node=(type & 1) == DataUtils.PAGE_TYPE_NODE;
  if (!node) {
    return null;
  }
  long[] children=new long[len + 1];
  for (int i=0; i <= len; i++) {
    children[i]=buff.getLong();
  }
  return new PageChildren(pos,children);
}

static PageChildren read ( FileStore fileStore , long pos , int mapId , long filePos , long maxPos ) { ByteBuffer buff ; int maxLength = DataUtils . getPageMaxLength ( pos ) ; if ( maxLength == DataUtils . PAGE_LARGE ) { buff = fileStore . readFully ( filePos , 128 ) ; maxLength = buff . getInt ( ) ; } maxLength = ( int ) Math . min ( maxPos - filePos , maxLength ) ; int length = maxLength ; if ( length < 0 ) { throw DataUtils . newIllegalStateException ( DataUtils . ERROR_FILE_CORRUPT , "Illegal page length {0} reading at {1}; max pos {2} " , length , filePos , maxPos ) ; } buff = fileStore . readFully ( filePos , length ) ; int chunkId = DataUtils . getPageChunkId ( pos ) ; int offset = DataUtils . getPageOffset ( pos ) ; int start = buff . position ( ) ; int pageLength = buff . getInt ( ) ; if ( pageLength > maxLength ) { throw DataUtils . newIllegalStateException ( DataUtils . ERROR_FILE_CORRUPT , "File corrupted in chunk {0}, expected page length =< {1}, got {2}" , chunkId , maxLength , pageLength ) ; } buff . limit ( start + pageLength ) ; short check = buff . getShort ( ) ; int m = DataUtils . readVarInt ( buff ) ; if ( m != mapId ) { throw DataUtils . newIllegalStateException ( DataUtils . ERROR_FILE_CORRUPT , "File corrupted in chunk {0}, expected map id {1}, got {2}" , chunkId , mapId , m ) ; } int checkTest = DataUtils . getCheckValue ( chunkId ) ^ DataUtils . getCheckValue ( offset ) ^ DataUtils . getCheckValue ( pageLength ) ; if ( check != ( short ) checkTest ) { throw DataUtils . newIllegalStateException ( DataUtils . ERROR_FILE_CORRUPT , "File corrupted in chunk {0}, expected check value {1}, got {2}" , chunkId , checkTest , check ) ; } int len = DataUtils . readVarInt ( buff ) ; int type = buff . get ( ) ; boolean node = ( type & 1 ) == DataUtils . PAGE_TYPE_NODE ; if ( ! node ) { return null ; } long [ ] children = new long [ len + 1 ] ; for ( int i = 0 ; i <= len ; i ++ ) { children [ i ] = buff . getLong ( ) ; } return new PageChildren ( pos , children ) ; }
read an inner node page from the buffer , but ignore the keys and values .
