本文整理汇总了Java中org.apache.lucene.index.SortedDocValues.getOrd方法的典型用法代码示例。如果您正苦于以下问题:Java SortedDocValues.getOrd方法的具体用法?Java SortedDocValues.getOrd怎么用?Java SortedDocValues.getOrd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.index.SortedDocValues
的用法示例。
在下文中一共展示了SortedDocValues.getOrd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verify
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
private void verify(RandomAccessOrds values, int maxDoc) {
for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) {
final SortedDocValues selected = mode.select(values);
for (int i = 0; i < maxDoc; ++i) {
final long actual = selected.getOrd(i);
int expected = -1;
values.setDocument(i);
for (int j = 0; j < values.cardinality(); ++j) {
if (expected == -1) {
expected = (int) values.ordAt(j);
} else {
if (mode == MultiValueMode.MIN) {
expected = Math.min(expected, (int)values.ordAt(j));
} else if (mode == MultiValueMode.MAX) {
expected = Math.max(expected, (int)values.ordAt(j));
}
}
}
assertEquals(mode.toString() + " docId=" + i, expected, actual);
}
}
}
示例2: correctBuggyOrds
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
private SortedDocValues correctBuggyOrds(final SortedDocValues in) {
final int maxDoc = state.segmentInfo.getDocCount();
for (int i = 0; i < maxDoc; i++) {
if (in.getOrd(i) == 0) {
return in; // ok
}
}
// we had ord holes, return an ord-shifting-impl that corrects the bug
return new SortedDocValues() {
@Override
public int getOrd(int docID) {
return in.getOrd(docID) - 1;
}
@Override
public BytesRef lookupOrd(int ord) {
return in.lookupOrd(ord+1);
}
@Override
public int getValueCount() {
return in.getValueCount() - 1;
}
};
}
示例3: accumSingleSeg
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
/** "typical" single-valued faceting: not too many unique values, no prefixing. maps to global ordinals as a separate step */
static void accumSingleSeg(int counts[], SortedDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
// First count in seg-ord space:
final int segCounts[];
if (map == null) {
segCounts = counts;
} else {
segCounts = new int[1+si.getValueCount()];
}
int doc;
while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
segCounts[1+si.getOrd(doc)]++;
}
// migrate to global ords (if necessary)
if (map != null) {
migrateGlobal(counts, segCounts, subIndex, map);
}
}
示例4: getValues
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();
final AtomicReader r = SlowCompositeReaderWrapper.wrap(topReader);
final int off = readerContext.docBase;
final SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(r, field);
final int end = sindex.getValueCount();
return new IntDocValues(this) {
@Override
public int intVal(int doc) {
return (end - sindex.getOrd(doc+off) - 1);
}
};
}
示例5: accumIntervalsSingle
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
private void accumIntervalsSingle(SortedDocValues sdv, DocIdSetIterator disi, Bits bits) throws IOException {
// First update the ordinals in the intervals to this segment
for (FacetInterval interval : intervals) {
interval.updateContext(sdv);
}
int doc;
while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
if (bits != null && bits.get(doc) == false) {
continue;
}
int ord = sdv.getOrd(doc);
if (ord >= 0) {
accumInterval(ord);
}
}
}
示例6: getValues
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();
final AtomicReader r = topReader instanceof CompositeReader
? new SlowCompositeReaderWrapper((CompositeReader)topReader)
: (AtomicReader) topReader;
final int off = readerContext.docBase;
final SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(r, field);
final int end = sindex.getValueCount();
return new IntDocValues(this) {
@Override
public int intVal(int doc) {
return (end - sindex.getOrd(doc+off) - 1);
}
};
}
示例7: correctBuggyOrds
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
private SortedDocValues correctBuggyOrds(final SortedDocValues in) {
final int maxDoc = state.segmentInfo.getDocCount();
for (int i = 0; i < maxDoc; i++) {
if (in.getOrd(i) == 0) {
return in; // ok
}
}
// we had ord holes, return an ord-shifting-impl that corrects the bug
return new SortedDocValues() {
@Override
public int getOrd(int docID) {
return in.getOrd(docID) - 1;
}
@Override
public void lookupOrd(int ord, BytesRef result) {
in.lookupOrd(ord+1, result);
}
@Override
public int getValueCount() {
return in.getValueCount() - 1;
}
};
}
示例8: correctBuggyOrds
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
private SortedDocValues correctBuggyOrds(final SortedDocValues in) {
final int maxDoc = state.segmentInfo.getDocCount();
for (int i = 0; i < maxDoc; i++) {
if (in.getOrd(i) == 0) {
return in; // ok
}
}
// we had ord holes, return an ord-shifting-impl that corrects the bug
return new SortedDocValues() {
@Override
public int getOrd(int docID) {
return in.getOrd(docID) - 1;
}
@Override
public void lookupOrd(int ord, BytesRef result) {
in.lookupOrd(ord+1, result);
}
@Override
public int getValueCount() {
return in.getValueCount() - 1;
}
};
}
示例9: doPostCollection
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
@Override
protected void doPostCollection() throws IOException {
IndexReader indexReader = context().searcher().getIndexReader();
for (LeafReaderContext ctx : indexReader.leaves()) {
Scorer childDocsScorer = childFilter.scorer(ctx);
if (childDocsScorer == null) {
continue;
}
DocIdSetIterator childDocsIter = childDocsScorer.iterator();
final LeafBucketCollector sub = collectableSubAggregators.getLeafCollector(ctx);
final SortedDocValues globalOrdinals = valuesSource.globalOrdinalsValues(parentType, ctx);
// Set the scorer, since we now replay only the child docIds
sub.setScorer(new ConstantScoreScorer(null, 1f,childDocsIter));
final Bits liveDocs = ctx.reader().getLiveDocs();
for (int docId = childDocsIter.nextDoc(); docId != DocIdSetIterator.NO_MORE_DOCS; docId = childDocsIter.nextDoc()) {
if (liveDocs != null && liveDocs.get(docId) == false) {
continue;
}
long globalOrdinal = globalOrdinals.getOrd(docId);
if (globalOrdinal != -1) {
long bucketOrd = parentOrdToBuckets.get(globalOrdinal);
if (bucketOrd != -1) {
collectBucket(sub, docId, bucketOrd);
if (multipleBucketsPerParentOrd) {
long[] otherBucketOrds = parentOrdToOtherBuckets.get(globalOrdinal);
if (otherBucketOrds != null) {
for (long otherBucketOrd : otherBucketOrds) {
collectBucket(sub, docId, otherBucketOrd);
}
}
}
}
}
}
}
}
示例10: doPostCollection
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
@Override
protected void doPostCollection() throws IOException {
IndexReader indexReader = context().searchContext().searcher().getIndexReader();
for (LeafReaderContext ctx : indexReader.leaves()) {
Scorer childDocsScorer = childFilter.scorer(ctx);
if (childDocsScorer == null) {
continue;
}
DocIdSetIterator childDocsIter = childDocsScorer.iterator();
final LeafBucketCollector sub = collectableSubAggregators.getLeafCollector(ctx);
final SortedDocValues globalOrdinals = valuesSource.globalOrdinalsValues(parentType, ctx);
// Set the scorer, since we now replay only the child docIds
sub.setScorer(ConstantScorer.create(childDocsIter, null, 1f));
final Bits liveDocs = ctx.reader().getLiveDocs();
for (int docId = childDocsIter.nextDoc(); docId != DocIdSetIterator.NO_MORE_DOCS; docId = childDocsIter.nextDoc()) {
if (liveDocs != null && liveDocs.get(docId) == false) {
continue;
}
long globalOrdinal = globalOrdinals.getOrd(docId);
if (globalOrdinal != -1) {
long bucketOrd = parentOrdToBuckets.get(globalOrdinal);
if (bucketOrd != -1) {
collectBucket(sub, docId, bucketOrd);
if (multipleBucketsPerParentOrd) {
long[] otherBucketOrds = parentOrdToOtherBuckets.get(globalOrdinal);
if (otherBucketOrds != null) {
for (long otherBucketOrd : otherBucketOrds) {
collectBucket(sub, docId, otherBucketOrd);
}
}
}
}
}
}
}
}
示例11: getGeoPointValues
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
@Override
public MultiGeoPointValues getGeoPointValues() {
final RandomAccessOrds ords = ordinals.ordinals();
final SortedDocValues singleOrds = DocValues.unwrapSingleton(ords);
final GeoPoint point = new GeoPoint(Double.NaN, Double.NaN);
if (singleOrds != null) {
final GeoPointValues values = new GeoPointValues() {
@Override
public GeoPoint get(int docID) {
final int ord = singleOrds.getOrd(docID);
if (ord >= 0) {
return point.resetFromIndexHash(indexedPoints.get(ord));
}
return point.reset(Double.NaN, Double.NaN);
}
};
return FieldData.singleton(values, DocValues.docsWithValue(singleOrds, maxDoc));
}
return new MultiGeoPointValues() {
@Override
public GeoPoint valueAt(int index) {
return point.resetFromIndexHash(indexedPoints.get(ords.ordAt(index)));
}
@Override
public void setDocument(int docId) {
ords.setDocument(docId);
}
@Override
public int count() {
return ords.cardinality();
}
};
}
示例12: accumSingleGeneric
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
/** accumulates per-segment single-valued facet counts, mapping to global ordinal space on-the-fly */
static void accumSingleGeneric(int counts[], int startTermIndex, SortedDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
final LongValues ordmap = map == null ? null : map.getGlobalOrds(subIndex);
int doc;
while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
int term = si.getOrd(doc);
if (map != null && term >= 0) {
term = (int) ordmap.get(term);
}
int arrIdx = term-startTermIndex;
if (arrIdx>=0 && arrIdx<counts.length) counts[arrIdx]++;
}
}
示例13: CollapsingScoreCollector
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public CollapsingScoreCollector(int maxDoc,
int segments,
SortedDocValues values,
int nullPolicy,
IntIntOpenHashMap boostDocs) {
this.maxDoc = maxDoc;
this.contexts = new AtomicReaderContext[segments];
this.collapsedSet = new FixedBitSet(maxDoc);
this.boostDocs = boostDocs;
if(this.boostDocs != null) {
//Set the elevated docs now.
IntOpenHashSet boostG = new IntOpenHashSet();
Iterator<IntIntCursor> it = this.boostDocs.iterator();
while(it.hasNext()) {
IntIntCursor cursor = it.next();
int i = cursor.key;
this.collapsedSet.set(i);
int ord = values.getOrd(i);
if(ord > -1) {
boostG.add(ord);
}
}
boostOrds = boostG.toArray();
Arrays.sort(boostOrds);
}
this.values = values;
int valueCount = values.getValueCount();
this.ords = new int[valueCount];
Arrays.fill(this.ords, -1);
this.scores = new float[valueCount];
Arrays.fill(this.scores, -Float.MAX_VALUE);
this.nullPolicy = nullPolicy;
if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) {
nullScores = new FloatArrayList();
}
}
示例14: FieldValueCollapse
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public FieldValueCollapse(int maxDoc,
String field,
int nullPolicy,
boolean max,
boolean needsScores,
IntIntOpenHashMap boostDocs,
SortedDocValues values) {
this.field = field;
this.nullPolicy = nullPolicy;
this.max = max;
this.needsScores = needsScores;
this.collapsedSet = new FixedBitSet(maxDoc);
this.boostDocs = boostDocs;
if(this.boostDocs != null) {
IntOpenHashSet boostG = new IntOpenHashSet();
Iterator<IntIntCursor> it = boostDocs.iterator();
while(it.hasNext()) {
IntIntCursor cursor = it.next();
int i = cursor.key;
this.collapsedSet.set(i);
int ord = values.getOrd(i);
if(ord > -1) {
boostG.add(ord);
}
}
this.boostOrds = boostG.toArray();
Arrays.sort(this.boostOrds);
}
}
示例15: accumSingle
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
/** accumulates per-segment single-valued facet counts, mapping to global ordinal space */
// specialized since the single-valued case is simpler: you don't have to deal with missing count, etc
static void accumSingle(int counts[], int startTermIndex, SortedDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
int doc;
while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
int term = si.getOrd(doc);
if (map != null) {
term = (int) map.getGlobalOrd(subIndex, term);
}
int arrIdx = term-startTermIndex;
if (arrIdx>=0 && arrIdx<counts.length) counts[arrIdx]++;
}
}