proj.zoie.api.ZoieSegmentReader类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中proj.zoie.api.ZoieSegmentReader类的一些代码示例,展示了ZoieSegmentReader类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoieSegmentReader类的具体详情如下:
包路径:proj.zoie.api.ZoieSegmentReader
类名称:ZoieSegmentReader

ZoieSegmentReader介绍

暂无

代码示例

代码示例来源:origin: com.linkedin.zoie/zoie-core

@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);
}

代码示例来源:origin: com.linkedin.zoie/zoie-core

zr = new ZoieSegmentReader<R>(sr,_decorator);
  String segmentName = zr.getSegmentName();
  _starts[i]=startCount;
  i++;
  startCount+=zr.maxDoc();
R decoratedReader = subReader.getDecoratedReader();
decoratedList.add(decoratedReader);

代码示例来源:origin: com.linkedin.zoie/zoie-core

public DocIDMapper<?> getDocIDMapper(ZoieMultiReader<?> multireader) {
  final ZoieSegmentReader<?>[] subreaders =(ZoieSegmentReader<?>[])(multireader.getSequentialSubReaders());
  final int[] starts = multireader.getStarts();
  for (int i = 0; i < subreaders.length; ++i){
    ZoieSegmentReader<?> subReader = subreaders[i];
    DocIDMapper<?> mapper = subReader.getDocIDMaper();
    if (mapper == null){
      mapper = new DocIDMapperImpl(subReader.getUIDArray());
    }
    subReader.setDocIDMapper(mapper);
  }
final DocIDMapper[] mappers = new DocIDMapper[subreaders.length];
for(int i=0; i< subreaders.length; i++)
{
 mappers[i] = subreaders[i].getDocIDMaper();
}
final int bound = subreaders.length-1;
  return new DefaultDocIDMapper(bound, mappers, starts);
  
}

代码示例来源:origin: senseidb/zoie

private void init() throws IOException {
 for (ZoieSegmentReader<R> subReader : _subZoieReaders) {
  String segmentName = subReader.getSegmentName();
  _readerMap.put(segmentName, subReader);
 }
 ArrayList<R> decoratedList = new ArrayList<R>(_subZoieReaders.size());
 for (ZoieSegmentReader<R> subReader : _subZoieReaders) {
  R decoratedReader = subReader.getDecoratedReader();
  decoratedList.add(decoratedReader);
 }
 _decoratedReaders = decoratedList;
}

代码示例来源:origin: com.senseidb.zoie/zoie-core

@Override
 public AtomicReader wrap(AtomicReader reader) {
  if (!(reader instanceof SegmentReader)) {
   throw new IllegalStateException("reader not insance of " + SegmentReader.class);
  }
  try {
   if (_readerMap != null && !_readerMap.isEmpty()) {
    SegmentReader sr = (SegmentReader) reader;
    String segmentName = sr.getSegmentName();
    ZoieSegmentReader<R> zoieSegmentReader = _readerMap.get(segmentName);
    if (zoieSegmentReader != null && zoieSegmentReader.getInnerReader() == sr) {
     return new ZoieSegmentReader<R>(zoieSegmentReader, sr);
    }
   }
   return new ZoieSegmentReader<R>(reader, _decorator);
  } catch (IOException e) {
   e.printStackTrace();
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: senseidb/zoie

@Override
 public DocIDMapper getDocIDMapper(final ZoieMultiReader<?> reader) throws IOException {
  final ZoieSegmentReader<?>[] zoieSegmentReaders = reader.getSubReaders();
  final DocIDMapper[] mappers = new DocIDMapper[zoieSegmentReaders.length];
  for (int i = 0; i < zoieSegmentReaders.length; ++i) {
   // reuse DocIDMapper since ZoieSegmentReader may be reused
   if (zoieSegmentReaders[i].getDocIDMapper() != null) {
    mappers[i] = zoieSegmentReaders[i].getDocIDMapper();
   } else {
    mappers[i] = getDocIDMapper(zoieSegmentReaders[i]);
    zoieSegmentReaders[i].setDocIDMapper(mappers[i]);
   }
  }

  return new DocIDMapper() {

   @Override
   public int getDocID(long uid) {
    int docid;
    for (int i = mappers.length - 1; i >= 0; --i) {
     docid = mappers[i].getDocID(uid);
     if (docid != DocIDMapper.NOT_FOUND) {
      return docid + reader.getSubReaderBase(i);
     }
    }
    return DocIDMapper.NOT_FOUND;
   }
  };
 }
}

代码示例来源:origin: com.senseidb/sensei-core

@SuppressWarnings("unchecked")
@Override
public void finalizeSegment(BoboSegmentReader reader, FacetCountCollector[] facetCountCollectors) {
 if (docIdIndex > 0) {
  ZoieSegmentReader<?> zoieReader = (ZoieSegmentReader<?>) (reader.getInnerReader());
  DocIDMapperImpl docIDMapper = (DocIDMapperImpl) zoieReader.getDocIDMapper();
  Serializable mapResult = mapReduceStrategy.map(new DefaultIntArray(partialDocIds),
   docIdIndex, zoieReader.getUIDArray(), fieldAccessorFactory.getAccessor(facetInfos, reader,
    docIDMapper), new FacetCountAccessor(facetCountCollectors));
  if (mapResult != null) {
   result.getMapResults().add(mapResult);
  }
 }
 docIdIndex = 0;
}

代码示例来源:origin: senseidb/zoie

@Override
public DocIDMapper getDocIDMapper(final ZoieSegmentReader<?> reader) throws IOException {
 // Don't use getLiveDocs of ZoieSegmentReader, since ZoieSegmentReader take into account
 // pending delete doc
 return new DocIDMapperImpl(reader.getUIDArray());
}

代码示例来源:origin: com.senseidb/sensei-core

DocIDMapper mapper = zoieSegmentReader.getDocIDMapper();
if (mapper == null) return;
int docId = mapper.getDocID(uid);
 return;
BoboSegmentReader decoratedReader = zoieSegmentReader.getDecoratedReader();
for (String facet : facets) {
 Object facetData = decoratedReader.getFacetData(facet);

代码示例来源:origin: senseidb/zoie

@Override
 public DocIdSet getDocIdSet(AtomicReaderContext ctx, Bits acceptDocs) throws IOException {
  SegmentReader reader = (SegmentReader) (ctx.reader());
  int idx = -1;
  for (int i = 0; i < _subZoieReaders.length; ++i) {
   if (_subZoieReaders[i].getSegmentName().equals(reader.getSegmentName())) {
    idx = i;
    break;
   }
  }
  if (idx == -1) {
   throw new IOException("Can't find sub-reader");
  }
  return new UIDDocIdSet(_filteredIDs, _subZoieReaders[idx].getDocIDMapper());
 }
}

代码示例来源:origin: com.linkedin.zoie/zoie-core

int maxDocs = sr.maxDoc();
boolean hasDeletes = false;
if (zoieSegmentReader.numDocs() != numDocs || zoieSegmentReader.maxDoc() != maxDocs){
  hasDeletes = true;
zoieSegmentReader = new ZoieSegmentReader<R>(zoieSegmentReader,sr,hasDeletes);
zoieSegmentReader = new ZoieSegmentReader<R>(sr,_decorator);

代码示例来源:origin: senseidb/zoie

@Override
public Bits getLiveDocs() {
 ensureOpen();
 return new Bits() {
  @Override
  public boolean get(int index) {
   int[] delSet = _currentDelDocIds;
   if (delSet != null && Arrays.binarySearch(delSet, index) >= 0) {
    return false;
   }
   Bits liveDocs = in.getLiveDocs();
   if (liveDocs == null) {
    return true;
   }
   return liveDocs.get(index);
  }
  @Override
  public int length() {
   return in.getLiveDocs().length();
  }
 };
}

代码示例来源:origin: com.senseidb/sensei-core

@SuppressWarnings("unchecked")
 @Override
 public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
  if (context.reader() instanceof ZoieSegmentReader) {
   ZoieSegmentReader<BoboSegmentReader> zoieReader = (ZoieSegmentReader<BoboSegmentReader>) context
     .reader();
   List<DocIdSet> docIdSetList = new ArrayList<DocIdSet>(1);
   docIdSetList.add(buildFilterSet(zoieReader.getDecoratedReader()));
   return new OrDocIdSet(docIdSetList);
  } else {
   throw new IllegalStateException("reader not instance of " + ZoieSegmentReader.class);
  }
 }
}

代码示例来源:origin: senseidb/zoie

/**
 * makes exact shallow copy of a given ZoieSegmentReader
 * @throws IOException
 */
public ZoieSegmentReader<R> copy() throws IOException {
 return new ZoieSegmentReader<R>(this, this.in);
}

代码示例来源:origin: senseidb/zoie

public void commitDeletes() {
 ZoieSegmentReader<R>[] subReaders = getSubReaders();
 if (subReaders != null && subReaders.length > 0) {
  for (ZoieSegmentReader<R> subReader : subReaders) {
   subReader.commitDeletes();
  }
 }
}

代码示例来源:origin: com.linkedin.zoie/zoie-core

public ZoieSegmentReader(IndexReader in, IndexReaderDecorator<R> decorator)
    throws IOException {
  super(in,decorator);
  if (!(in instanceof SegmentReader)){
    throw new IllegalStateException("ZoieSegmentReader can only be constucted from "+SegmentReader.class);
  }
  init(in);
  _decoratedReader = (decorator == null ? null : decorator.decorate(this));
}

代码示例来源:origin: com.senseidb/sensei-core

BytesRef bytesRef = zoieSegmentReader.getStoredValue(doc);
  if (bytesRef != null) {
   hit.setStoredValue(bytesRef.bytes);
hit.setUID(zoieSegmentReader.getUID(doc));
hit.setDocid(finalDoc);
hit.setScore(score);

代码示例来源:origin: com.senseidb/sensei-core

throws IOException {
ZoieSegmentReader<?> zoieReader = (ZoieSegmentReader<?>) (reader.getInnerReader());
DocIDMapper docidMapper = zoieReader.getDocIDMapper();
 if (!zoieReader.isDeletedInMask(docId)) {
  return new SingleDocRandmAccessDocIdSet(docidList.getInt(0));
 } else {
final IntArrayDocIdSet intArraySet = new IntArrayDocIdSet(docidList.size());
for (int docId : docidList) {
 if (!zoieReader.isDeletedInMask(docId)) {
  intArraySet.addDoc(docId);

代码示例来源:origin: com.senseidb.zoie/zoie-core

public BytesRef getStoredValue(long uid) throws IOException {
 int docid = _docIDMapper.getDocID(uid);
 if (docid < 0) return null;
 int idx = readerIndex(docid);
 if (idx < 0) return null;
 ZoieSegmentReader<R> subReader = _subZoieReaders.get(idx);
 return subReader.getStoredValue(docid);
}

代码示例来源:origin: com.senseidb/sensei-core

@Override
public IntArray getDocArray(BoboSegmentReader boboIndexReader) {
 ZoieSegmentReader<?> zoieReader = (ZoieSegmentReader<?>) (boboIndexReader.getInnerReader());
 DocIDMapperImpl docIDMapper = (DocIDMapperImpl) zoieReader.getDocIDMapper();
 return new DefaultIntArray(docIDMapper.getDocArray());
}

相关文章