Search in sources :

Example 1 with AtomicParentChildFieldData

use of org.elasticsearch.index.fielddata.AtomicParentChildFieldData in project elasticsearch by elastic.

the class ParentChildIndexFieldData method localGlobalDirect.

@Override
public IndexParentChildFieldData localGlobalDirect(DirectoryReader indexReader) throws Exception {
    final long startTime = System.nanoTime();
    long ramBytesUsed = 0;
    final Map<String, OrdinalMapAndAtomicFieldData> perType = new HashMap<>();
    for (String type : parentTypes) {
        final AtomicParentChildFieldData[] fieldData = new AtomicParentChildFieldData[indexReader.leaves().size()];
        for (LeafReaderContext context : indexReader.leaves()) {
            fieldData[context.ord] = load(context);
        }
        final OrdinalMap ordMap = buildOrdinalMap(fieldData, type);
        ramBytesUsed += ordMap.ramBytesUsed();
        perType.put(type, new OrdinalMapAndAtomicFieldData(ordMap, fieldData));
    }
    final AtomicParentChildFieldData[] fielddata = new AtomicParentChildFieldData[indexReader.leaves().size()];
    for (int i = 0; i < fielddata.length; ++i) {
        fielddata[i] = new GlobalAtomicFieldData(parentTypes, perType, i);
    }
    breakerService.getBreaker(CircuitBreaker.FIELDDATA).addWithoutBreaking(ramBytesUsed);
    if (logger.isDebugEnabled()) {
        logger.debug("global-ordinals [_parent] took [{}]", new TimeValue(System.nanoTime() - startTime, TimeUnit.NANOSECONDS));
    }
    return new GlobalFieldData(indexReader, fielddata, ramBytesUsed, perType);
}
Also used : HashMap(java.util.HashMap) AtomicParentChildFieldData(org.elasticsearch.index.fielddata.AtomicParentChildFieldData) OrdinalMap(org.apache.lucene.index.MultiDocValues.OrdinalMap) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) TimeValue(org.elasticsearch.common.unit.TimeValue)

Aggregations

HashMap (java.util.HashMap)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 OrdinalMap (org.apache.lucene.index.MultiDocValues.OrdinalMap)1 TimeValue (org.elasticsearch.common.unit.TimeValue)1 AtomicParentChildFieldData (org.elasticsearch.index.fielddata.AtomicParentChildFieldData)1