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


Java SortedDocValues.getValueCount方法代码示例

本文整理汇总了Java中org.apache.lucene.index.SortedDocValues.getValueCount方法的典型用法代码示例。如果您正苦于以下问题:Java SortedDocValues.getValueCount方法的具体用法?Java SortedDocValues.getValueCount怎么用?Java SortedDocValues.getValueCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.index.SortedDocValues的用法示例。


在下文中一共展示了SortedDocValues.getValueCount方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:21,代码来源:DocValuesFacets.java

示例3: 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);
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:ReverseOrdFieldSource.java

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

示例5: 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

示例6: 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

示例7: globalMaxOrd

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public long globalMaxOrd(IndexSearcher indexSearcher, String type) {
    DirectoryReader indexReader = (DirectoryReader) indexSearcher.getIndexReader();
    if (indexReader.leaves().isEmpty()) {
        return 0;
    } else {
        LeafReaderContext atomicReaderContext = indexReader.leaves().get(0);
        IndexParentChildFieldData globalFieldData = indexFieldData.loadGlobal(indexReader);
        AtomicParentChildFieldData afd = globalFieldData.load(atomicReaderContext);
        SortedDocValues values = afd.getOrdinalsValues(type);
        return values.getValueCount();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:ValuesSource.java

示例8: accumSingle

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
/** accumulates per-segment single-valued facet counts */
static void accumSingle(int counts[], int startTermIndex, SortedDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
  if (startTermIndex == -1 && (map == null || si.getValueCount() < disi.cost()*10)) {
    // no prefixing, not too many unique values wrt matching docs (lucene/facets heuristic): 
    //   collect separately per-segment, then map to global ords
    accumSingleSeg(counts, si, disi, subIndex, map);
  } else {
    // otherwise: do collect+map on the fly
    accumSingleGeneric(counts, startTermIndex, si, disi, subIndex, map);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:12,代码来源:DocValuesFacets.java

示例9: 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();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:37,代码来源:CollapsingQParserPlugin.java

示例10: CollapsingFieldValueCollector

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public CollapsingFieldValueCollector(int maxDoc,
                                     int segments,
                                     SortedDocValues values,
                                     int nullPolicy,
                                     String field,
                                     boolean max,
                                     boolean needsScores,
                                     FieldType fieldType,
                                     IntIntOpenHashMap boostDocs,
                                     FunctionQuery funcQuery, IndexSearcher searcher) throws IOException{

  this.maxDoc = maxDoc;
  this.contexts = new AtomicReaderContext[segments];
  this.values = values;
  int valueCount = values.getValueCount();
  this.nullPolicy = nullPolicy;
  this.needsScores = needsScores;
  this.boostDocs = boostDocs;
  if(funcQuery != null) {
    this.fieldValueCollapse =  new ValueSourceCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, funcQuery, searcher, values);
  } else {
    if(fieldType instanceof TrieIntField) {
      this.fieldValueCollapse = new IntValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, values);
    } else if(fieldType instanceof TrieLongField) {
      this.fieldValueCollapse =  new LongValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, values);
    } else if(fieldType instanceof TrieFloatField) {
      this.fieldValueCollapse =  new FloatValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, values);
    } else {
      throw new IOException("min/max must be either TrieInt, TrieLong or TrieFloat.");
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:CollapsingQParserPlugin.java

示例11: 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

示例12: CollapsingScoreCollector

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public CollapsingScoreCollector(int maxDoc,
                                int segments,
                                SortedDocValues values,
                                int nullPolicy,
                                IntOpenHashSet 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.
    Iterator<IntCursor> it = this.boostDocs.iterator();
    while(it.hasNext()) {
      IntCursor cursor = it.next();
      this.collapsedSet.set(cursor.value);
    }
  }
  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();
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:29,代码来源:CollapsingQParserPlugin.java

示例13: CollapsingFieldValueCollector

import org.apache.lucene.index.SortedDocValues; //导入方法依赖的package包/类
public CollapsingFieldValueCollector(int maxDoc,
                                     int segments,
                                     SortedDocValues values,
                                     int nullPolicy,
                                     String field,
                                     boolean max,
                                     boolean needsScores,
                                     FieldType fieldType,
                                     IntOpenHashSet boostDocs,
                                     FunctionQuery funcQuery, IndexSearcher searcher) throws IOException{

  this.maxDoc = maxDoc;
  this.contexts = new AtomicReaderContext[segments];
  this.values = values;
  int valueCount = values.getValueCount();
  this.nullPolicy = nullPolicy;
  this.needsScores = needsScores;
  this.boostDocs = boostDocs;
  if(funcQuery != null) {
    this.fieldValueCollapse =  new ValueSourceCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, funcQuery, searcher);
  } else {
    if(fieldType instanceof TrieIntField) {
      this.fieldValueCollapse = new IntValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs);
    } else if(fieldType instanceof TrieLongField) {
      this.fieldValueCollapse =  new LongValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs);
    } else if(fieldType instanceof TrieFloatField) {
      this.fieldValueCollapse =  new FloatValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs);
    } else {
      throw new IOException("min/max must be either TrieInt, TrieLong or TrieFloat.");
    }
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:33,代码来源:CollapsingQParserPlugin.java

示例14: 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.getValueCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。