Ejemplo n.º 1
0
  public CustomObject load(Paged p, int page) {
    ByteBuffer bb = p.slice(SliceType.READ, page, 1);
    try {
      // check the magic
      Buffer magicBuffer = new Buffer(MAGIC.length);
      bb.get(magicBuffer.data);
      if (!MAGIC.equals(magicBuffer)) throw new IllegalArgumentException("unknown page type");

      CustomObject co = new CustomObject(bb.getLong());
      bb.get(co.data);
      return co;
    } finally {
      p.unslice(bb);
    }
  }