Ejemplo n.º 1
0
 @Override
 public long[] load(BoboIndexReader reader) throws IOException {
   IndexReader innerReader = reader.getInnerReader();
   if (innerReader instanceof ZoieSegmentReader) {
     ZoieSegmentReader zoieReader = (ZoieSegmentReader) innerReader;
     return zoieReader.getUIDArray();
   } else {
     throw new IOException("inner reader not instance of " + ZoieSegmentReader.class);
   }
 }
Ejemplo n.º 2
0
 @Override
 protected void persist(long uid, byte[] data) throws IOException {
   Document doc = new Document();
   doc.add(new Field(_field, data));
   ZoieSegmentReader.fillDocumentID(doc, uid);
   _idxWriter.addDocument(doc);
 }
Ejemplo n.º 3
0
    ReaderData(IndexReader reader) throws IOException {
      this.reader = reader;
      long minUID = Long.MAX_VALUE;
      long maxUID = Long.MIN_VALUE;

      uidMap = new Long2IntRBTreeMap();
      uidMap.defaultReturnValue(-1);
      int maxDoc = reader.maxDoc();
      if (maxDoc == 0) {
        _minUID = Long.MIN_VALUE;
        _maxUID = Long.MIN_VALUE;
        return;
      }
      TermPositions tp = null;
      byte[] payloadBuffer = new byte[8]; // four bytes for a long
      try {
        tp = reader.termPositions(ZoieSegmentReader.UID_TERM);
        while (tp.next()) {
          int doc = tp.doc();
          assert doc < maxDoc;

          tp.nextPosition();
          tp.getPayload(payloadBuffer, 0);
          long uid = ZoieSegmentReader.bytesToLong(payloadBuffer);
          if (uid < minUID) minUID = uid;
          if (uid > maxUID) maxUID = uid;
          uidMap.put(uid, doc);
        }
      } finally {
        if (tp != null) {
          tp.close();
        }
      }

      _minUID = minUID;
      _maxUID = maxUID;
    }