當前位置: 首頁>>代碼示例>>Java>>正文


Java LeafReaderContext.reader方法代碼示例

本文整理匯總了Java中org.apache.lucene.index.LeafReaderContext.reader方法的典型用法代碼示例。如果您正苦於以下問題:Java LeafReaderContext.reader方法的具體用法?Java LeafReaderContext.reader怎麽用?Java LeafReaderContext.reader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.index.LeafReaderContext的用法示例。


在下文中一共展示了LeafReaderContext.reader方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: load

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
public AtomicNumericFieldData load(LeafReaderContext context) {
    final LeafReader reader = context.reader();
    final String field = fieldName;

    switch (numericType) {
        case HALF_FLOAT:
            return new SortedNumericHalfFloatFieldData(reader, field);
        case FLOAT:
            return new SortedNumericFloatFieldData(reader, field);
        case DOUBLE:
            return new SortedNumericDoubleFieldData(reader, field);
        default:
            return new SortedNumericLongFieldData(reader, field, numericType);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:SortedNumericDVIndexFieldData.java

示例2: loadDirect

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
public AtomicGeoPointFieldData loadDirect(LeafReaderContext context) throws Exception {
    LeafReader reader = context.reader();

    Terms terms = reader.terms(getFieldNames().indexName());
    AtomicGeoPointFieldData data = null;
    // TODO: Use an actual estimator to estimate before loading.
    NonEstimatingEstimator estimator = new NonEstimatingEstimator(breakerService.getBreaker(CircuitBreaker.FIELDDATA));
    if (terms == null) {
        data = AbstractAtomicGeoPointFieldData.empty(reader.maxDoc());
        estimator.afterLoad(null, data.ramBytesUsed());
        return data;
    }
    return (Version.indexCreated(indexSettings).before(Version.V_2_2_0)) ?
        loadLegacyFieldData(reader, estimator, terms, data) : loadFieldData22(reader, estimator, terms, data);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,代碼來源:GeoPointArrayIndexFieldData.java

示例3: testSimple

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
/** 
 * test version lookup actually works
 */
public void testSimple() throws Exception {
    Directory dir = newDirectory();
    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
    Document doc = new Document();
    doc.add(new Field(UidFieldMapper.NAME, "6", UidFieldMapper.Defaults.FIELD_TYPE));
    doc.add(new NumericDocValuesField(VersionFieldMapper.NAME, 87));
    writer.addDocument(doc);
    DirectoryReader reader = DirectoryReader.open(writer);
    LeafReaderContext segment = reader.leaves().get(0);
    PerThreadIDAndVersionLookup lookup = new PerThreadIDAndVersionLookup(segment.reader());
    // found doc
    DocIdAndVersion result = lookup.lookup(new BytesRef("6"), null, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(0, result.docId);
    // not found doc
    assertNull(lookup.lookup(new BytesRef("7"), null, segment));
    // deleted doc
    assertNull(lookup.lookup(new BytesRef("6"), new Bits.MatchNoBits(1), segment));
    reader.close();
    writer.close();
    dir.close();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,代碼來源:VersionLookupTests.java

示例4: completionStats

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
/**
 * Returns total in-heap bytes used by all suggesters.  This method has CPU cost <code>O(numIndexedFields)</code>.
 *
 * @param fieldNamePatterns if non-null, any completion field name matching any of these patterns will break out its in-heap bytes
 * separately in the returned {@link CompletionStats}
 */
public static CompletionStats completionStats(IndexReader indexReader, String ... fieldNamePatterns) {
    long sizeInBytes = 0;
    ObjectLongHashMap<String> completionFields = null;
    if (fieldNamePatterns != null  && fieldNamePatterns.length > 0) {
        completionFields = new ObjectLongHashMap<>(fieldNamePatterns.length);
    }
    for (LeafReaderContext atomicReaderContext : indexReader.leaves()) {
        LeafReader atomicReader = atomicReaderContext.reader();
        try {
            Fields fields = atomicReader.fields();
            for (String fieldName : fields) {
                Terms terms = fields.terms(fieldName);
                if (terms instanceof CompletionTerms) {
                    // TODO: currently we load up the suggester for reporting its size
                    long fstSize = ((CompletionTerms) terms).suggester().ramBytesUsed();
                    if (fieldNamePatterns != null && fieldNamePatterns.length > 0 && Regex.simpleMatch(fieldNamePatterns, fieldName)) {
                        completionFields.addTo(fieldName, fstSize);
                    }
                    sizeInBytes += fstSize;
                }
            }
        } catch (IOException ioe) {
            throw new ElasticsearchException(ioe);
        }
    }
    return new CompletionStats(sizeInBytes, completionFields == null ? null : new FieldMemoryStats(completionFields));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:34,代碼來源:CompletionFieldStats.java

示例5: setSegmentAndDocument

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
public void setSegmentAndDocument(LeafReaderContext context, int docId) {
    if (this.reader == context.reader() && this.docId == docId) {
        // if we are called with the same document, don't invalidate source
        return;
    }
    this.reader = context.reader();
    this.source = null;
    this.sourceAsBytes = null;
    this.docId = docId;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:SourceLookup.java

示例6: load

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
public AtomicGeoPointFieldData load(LeafReaderContext context) {
    try {
        LeafReader reader = context.reader();
        FieldInfo info = reader.getFieldInfos().fieldInfo(fieldName);
        if (info != null) {
            checkCompatible(info);
        }
        return new LatLonPointDVAtomicFieldData(DocValues.getSortedNumeric(reader, fieldName));
    } catch (IOException e) {
        throw new IllegalStateException("Cannot load doc values", e);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,代碼來源:AbstractLatLonPointDVIndexFieldData.java

示例7: testTwoDocuments

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
/** 
 * test version lookup with two documents matching the ID
 */
public void testTwoDocuments() throws Exception {
    Directory dir = newDirectory();
    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
    Document doc = new Document();
    doc.add(new Field(UidFieldMapper.NAME, "6", UidFieldMapper.Defaults.FIELD_TYPE));
    doc.add(new NumericDocValuesField(VersionFieldMapper.NAME, 87));
    writer.addDocument(doc);
    writer.addDocument(doc);
    DirectoryReader reader = DirectoryReader.open(writer);
    LeafReaderContext segment = reader.leaves().get(0);
    PerThreadIDAndVersionLookup lookup = new PerThreadIDAndVersionLookup(segment.reader());
    // return the last doc when there are duplicates
    DocIdAndVersion result = lookup.lookup(new BytesRef("6"), null, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(1, result.docId);
    // delete the first doc only
    FixedBitSet live = new FixedBitSet(2);
    live.set(1);
    result = lookup.lookup(new BytesRef("6"), live, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(1, result.docId);
    // delete the second doc only
    live.clear(1);
    live.set(0);
    result = lookup.lookup(new BytesRef("6"), live, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(0, result.docId);
    // delete both docs
    assertNull(lookup.lookup(new BytesRef("6"), new Bits.MatchNoBits(2), segment));
    reader.close();
    writer.close();
    dir.close();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:40,代碼來源:VersionLookupTests.java

示例8: load

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
public AtomicNumericFieldData load(LeafReaderContext context) {
    final LeafReader reader = context.reader();
    final String field = fieldNames.indexName();

    switch (numericType) {
        case FLOAT:
            return new SortedNumericFloatFieldData(reader, field);
        case DOUBLE:
            return new SortedNumericDoubleFieldData(reader, field);
        default:
            return new SortedNumericLongFieldData(reader, field);
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:15,代碼來源:SortedNumericDVIndexFieldData.java

示例9: load

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
public AtomicOrdinalsFieldData load(LeafReaderContext context) {
    return new SortedSetDVBytesAtomicFieldData(context.reader(), fieldNames.indexName());
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:5,代碼來源:SortedSetDVOrdinalsIndexFieldData.java

示例10: LeafIndexLookup

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
public LeafIndexLookup(LeafReaderContext ctx) {
    reader = ctx.reader();
    parentReader = ReaderUtil.getTopLevelContext(ctx).reader();
    indexSearcher = new IndexSearcher(parentReader);
    indexSearcher.setQueryCache(null);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:7,代碼來源:LeafIndexLookup.java

示例11: doSetNextReader

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
protected void doSetNextReader(LeafReaderContext context) throws IOException {
    reader = context.reader();
    uidValues = uidFieldData.load(context).getBytesValues();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:6,代碼來源:QueriesLoaderCollector.java

示例12: load

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
public BinaryDVAtomicFieldData load(LeafReaderContext context) {
    return new BinaryDVAtomicFieldData(context.reader(), fieldName);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:BinaryDVIndexFieldData.java

示例13: testSingleValueAllSet

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
public void testSingleValueAllSet() throws Exception {
    fillSingleValueAllSet();
    IndexFieldData indexFieldData = getForField("value");
    List<LeafReaderContext> readerContexts = refreshReader();
    for (LeafReaderContext readerContext : readerContexts) {
        AtomicFieldData fieldData = indexFieldData.load(readerContext);
        assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed()));

        SortedBinaryDocValues bytesValues = fieldData.getBytesValues();

        bytesValues.setDocument(0);
        assertThat(bytesValues.count(), equalTo(1));
        assertThat(bytesValues.valueAt(0), equalTo(new BytesRef(two())));
        bytesValues.setDocument(1);
        assertThat(bytesValues.count(), equalTo(1));
        assertThat(bytesValues.valueAt(0), equalTo(new BytesRef(one())));
        bytesValues.setDocument(2);
        assertThat(bytesValues.count(), equalTo(1));
        assertThat(bytesValues.valueAt(0), equalTo(new BytesRef(three())));

        assertValues(bytesValues, 0, two());
        assertValues(bytesValues, 1, one());
        assertValues(bytesValues, 2, three());

        IndexSearcher searcher = new IndexSearcher(readerContext.reader());
        TopFieldDocs topDocs;

        topDocs = searcher.search(new MatchAllDocsQuery(), 10,
                new Sort(new SortField("value", indexFieldData.comparatorSource(null, MultiValueMode.MIN, null))));
        assertThat(topDocs.totalHits, equalTo(3));
        assertThat(topDocs.scoreDocs[0].doc, equalTo(1));
        assertThat(toString(((FieldDoc) topDocs.scoreDocs[0]).fields[0]), equalTo(one()));
        assertThat(topDocs.scoreDocs[1].doc, equalTo(0));
        assertThat(toString(((FieldDoc) topDocs.scoreDocs[1]).fields[0]), equalTo(two()));
        assertThat(topDocs.scoreDocs[2].doc, equalTo(2));
        assertThat(toString(((FieldDoc) topDocs.scoreDocs[2]).fields[0]), equalTo(three()));

        topDocs = searcher.search(new MatchAllDocsQuery(), 10,
                new Sort(new SortField("value", indexFieldData.comparatorSource(null, MultiValueMode.MAX, null), true)));
        assertThat(topDocs.totalHits, equalTo(3));
        assertThat(topDocs.scoreDocs[0].doc, equalTo(2));
        assertThat(topDocs.scoreDocs[1].doc, equalTo(0));
        assertThat(topDocs.scoreDocs[2].doc, equalTo(1));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:46,代碼來源:AbstractFieldDataImplTestCase.java

示例14: doSetNextReader

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
@Override
protected void doSetNextReader(LeafReaderContext context) throws IOException {
    super.doSetNextReader(context);
    collector.getLeafCollector(context);
    currentReader = context.reader();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:7,代碼來源:FieldVisitorCollector.java

示例15: setNextReader

import org.apache.lucene.index.LeafReaderContext; //導入方法依賴的package包/類
public void setNextReader(LeafReaderContext context) throws IOException {
    currentReader = context.reader();
    for (LuceneCollectorExpression expr : collectorExpressions) {
        expr.setNextReader(context);
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:7,代碼來源:FetchCollector.java


注:本文中的org.apache.lucene.index.LeafReaderContext.reader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。