当前位置: 首页>>代码示例>>Java>>正文


Java SortedDocValues.lookupOrd方法代码示例

本文整理汇总了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;
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:Lucene40DocValuesReader.java

示例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;
    }
  };
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:Lucene40DocValuesReader.java

示例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;
    }
  };
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:27,代码来源:Lucene40DocValuesReader.java

示例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);
      }
    }
  };
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:32,代码来源:SecureAtomicReader.java

示例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();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:57,代码来源:ParentChildFieldDataTests.java


注:本文中的org.apache.lucene.index.SortedDocValues.lookupOrd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。