コード例 #1
0
 /** decodes the contexts at the current position */
 protected Set<BytesRef> decodeContexts(BytesRef scratch, ByteArrayDataInput tmpInput) {
   tmpInput.reset(scratch.bytes);
   tmpInput.skipBytes(scratch.length - 2); // skip to context set size
   short ctxSetSize = tmpInput.readShort();
   scratch.length -= 2;
   final Set<BytesRef> contextSet = new HashSet<>();
   for (short i = 0; i < ctxSetSize; i++) {
     tmpInput.setPosition(scratch.length - 2);
     short curContextLength = tmpInput.readShort();
     scratch.length -= 2;
     tmpInput.setPosition(scratch.length - curContextLength);
     BytesRef contextSpare = new BytesRef(curContextLength);
     tmpInput.readBytes(contextSpare.bytes, 0, curContextLength);
     contextSpare.length = curContextLength;
     contextSet.add(contextSpare);
     scratch.length -= curContextLength;
   }
   return contextSet;
 }
コード例 #2
0
 /** decodes the payload at the current position */
 protected BytesRef decodePayload(BytesRef scratch, ByteArrayDataInput tmpInput) {
   tmpInput.reset(scratch.bytes);
   tmpInput.skipBytes(scratch.length - 2); // skip to payload size
   short payloadLength = tmpInput.readShort(); // read payload size
   tmpInput.setPosition(scratch.length - 2 - payloadLength); // setPosition to start of payload
   BytesRef payloadScratch = new BytesRef(payloadLength);
   tmpInput.readBytes(payloadScratch.bytes, 0, payloadLength); // read payload
   payloadScratch.length = payloadLength;
   scratch.length -= 2; // payload length info (short)
   scratch.length -= payloadLength; // payload
   return payloadScratch;
 }