本文整理汇总了Java中org.apache.lucene.index.SortedDocValues.lookupOrd方法的典型用法代码示例。如果您正苦于以下问题:Java SortedDocValues.lookupOrd方法的具体用法?Java SortedDocValues.lookupOrd怎么用?Java SortedDocValues.lookupOrd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.index.SortedDocValues
的用法示例。
在下文中一共展示了SortedDocValues.lookupOrd方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
};
}
示例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 void lookupOrd(int ord, BytesRef result) {
in.lookupOrd(ord+1, result);
}
@Override
public int getValueCount() {
return in.getValueCount() - 1;
}
};
}
示例3: 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;
}
};
}
示例4: getSortedDocValues
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
@Override
public SortedDocValues getSortedDocValues(String field) throws IOException {
final SortedDocValues sortedDocValues = in.getSortedDocValues(field);
if (sortedDocValues == null) {
return null;
}
return new SortedDocValues() {
@Override
public void lookupOrd(int ord, BytesRef result) {
sortedDocValues.lookupOrd(ord, result);
}
@Override
public int getValueCount() {
return sortedDocValues.getValueCount();
}
@Override
public int getOrd(int docID) {
try {
if (_accessControl.hasAccess(ReadType.SORTED_DOC_VALUE, docID)) {
return sortedDocValues.getOrd(docID);
}
return -1; // Default missing value.
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例5: testThreads
import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public void testThreads() throws Exception {
final ParentChildIndexFieldData indexFieldData = getForField(childType);
final DirectoryReader reader = ElasticsearchDirectoryReader.wrap(
DirectoryReader.open(writer), new ShardId(new Index("test", ""), 0));
final IndexParentChildFieldData global = indexFieldData.loadGlobal(reader);
final AtomicReference<Exception> error = new AtomicReference<>();
final int numThreads = scaledRandomIntBetween(3, 8);
final Thread[] threads = new Thread[numThreads];
final CountDownLatch latch = new CountDownLatch(1);
final Map<Object, BytesRef[]> expected = new HashMap<>();
for (LeafReaderContext context : reader.leaves()) {
AtomicParentChildFieldData leafData = global.load(context);
SortedDocValues parentIds = leafData.getOrdinalsValues(parentType);
final BytesRef[] ids = new BytesRef[parentIds.getValueCount()];
for (int j = 0; j < parentIds.getValueCount(); ++j) {
final BytesRef id = parentIds.lookupOrd(j);
if (id != null) {
ids[j] = BytesRef.deepCopyOf(id);
}
}
expected.put(context.reader().getCoreCacheKey(), ids);
}
for (int i = 0; i < numThreads; ++i) {
threads[i] = new Thread() {
@Override
public void run() {
try {
latch.await();
for (int i = 0; i < 100000; ++i) {
for (LeafReaderContext context : reader.leaves()) {
AtomicParentChildFieldData leafData = global.load(context);
SortedDocValues parentIds = leafData.getOrdinalsValues(parentType);
final BytesRef[] expectedIds = expected.get(context.reader().getCoreCacheKey());
for (int j = 0; j < parentIds.getValueCount(); ++j) {
final BytesRef id = parentIds.lookupOrd(j);
assertEquals(expectedIds[j], id);
}
}
}
} catch (Exception e) {
error.compareAndSet(null, e);
}
}
};
threads[i].start();
}
latch.countDown();
for (Thread thread : threads) {
thread.join();
}
if (error.get() != null) {
throw error.get();
}
}