Esempio n. 1
0
 /**
  * Build a block from the given string.
  *
  * @param s the string
  * @return the block
  */
 public static Chunk fromString(String s) {
   HashMap<String, String> map = DataUtils.parseMap(s);
   int id = Integer.parseInt(map.get("id"));
   Chunk c = new Chunk(id);
   c.start = Long.parseLong(map.get("start"));
   c.length = Integer.parseInt(map.get("length"));
   c.pageCount = Integer.parseInt(map.get("pageCount"));
   c.maxLength = Long.parseLong(map.get("maxLength"));
   c.maxLengthLive = Long.parseLong(map.get("maxLengthLive"));
   c.metaRootPos = Long.parseLong(map.get("metaRoot"));
   c.time = Long.parseLong(map.get("time"));
   c.version = Long.parseLong(map.get("version"));
   return c;
 }
Esempio n. 2
0
 /**
  * Read the header from the byte buffer.
  *
  * @param buff the source buffer
  * @param start the start of the chunk in the file
  * @return the chunk
  */
 static Chunk fromHeader(ByteBuffer buff, long start) {
   if (buff.get() != 'c') {
     throw DataUtils.newIllegalStateException("File corrupt reading chunk at position {0}", start);
   }
   int length = buff.getInt();
   int chunkId = buff.getInt();
   int pageCount = buff.getInt();
   long metaRootPos = buff.getLong();
   long maxLength = buff.getLong();
   long maxLengthLive = buff.getLong();
   Chunk c = new Chunk(chunkId);
   c.length = length;
   c.pageCount = pageCount;
   c.start = start;
   c.metaRootPos = metaRootPos;
   c.maxLength = maxLength;
   c.maxLengthLive = maxLengthLive;
   return c;
 }