Search in sources :

Example 1 with ICursorInitialState

use of org.apache.hyracks.storage.common.ICursorInitialState in project asterixdb by apache.

the class LSMInvertedIndex method search.

@Override
public void search(ILSMIndexOperationContext ictx, IIndexCursor cursor, ISearchPredicate pred) throws HyracksDataException {
    List<ILSMComponent> operationalComponents = ictx.getComponentHolder();
    int numComponents = operationalComponents.size();
    boolean includeMutableComponent = false;
    ArrayList<IIndexAccessor> indexAccessors = new ArrayList<>(numComponents);
    ArrayList<IIndexAccessor> deletedKeysBTreeAccessors = new ArrayList<>(numComponents);
    for (int i = 0; i < operationalComponents.size(); i++) {
        ILSMComponent component = operationalComponents.get(i);
        if (component.getType() == LSMComponentType.MEMORY) {
            includeMutableComponent = true;
            IIndexAccessor invIndexAccessor = ((LSMInvertedIndexMemoryComponent) component).getInvIndex().createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            indexAccessors.add(invIndexAccessor);
            IIndexAccessor deletedKeysAccessor = ((LSMInvertedIndexMemoryComponent) component).getDeletedKeysBTree().createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            deletedKeysBTreeAccessors.add(deletedKeysAccessor);
        } else {
            IIndexAccessor invIndexAccessor = ((LSMInvertedIndexDiskComponent) component).getInvIndex().createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            indexAccessors.add(invIndexAccessor);
            IIndexAccessor deletedKeysAccessor = ((LSMInvertedIndexDiskComponent) component).getDeletedKeysBTree().createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            deletedKeysBTreeAccessors.add(deletedKeysAccessor);
        }
    }
    ICursorInitialState initState = createCursorInitialState(pred, ictx, includeMutableComponent, indexAccessors, deletedKeysBTreeAccessors, operationalComponents);
    cursor.open(initState, pred);
}
Also used : ICursorInitialState(org.apache.hyracks.storage.common.ICursorInitialState) ILSMComponent(org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent) ArrayList(java.util.ArrayList) IIndexAccessor(org.apache.hyracks.storage.common.IIndexAccessor)

Example 2 with ICursorInitialState

use of org.apache.hyracks.storage.common.ICursorInitialState in project asterixdb by apache.

the class LSMInvertedIndex method createCursorInitialState.

private ICursorInitialState createCursorInitialState(ISearchPredicate pred, IIndexOperationContext ictx, boolean includeMutableComponent, ArrayList<IIndexAccessor> indexAccessors, ArrayList<IIndexAccessor> deletedKeysBTreeAccessors, List<ILSMComponent> operationalComponents) {
    ICursorInitialState initState;
    PermutingTupleReference keysOnlyTuple = createKeysOnlyTupleReference();
    MultiComparator keyCmp = MultiComparator.create(invListCmpFactories);
    // Distinguish between regular searches and range searches (mostly used in merges).
    if (pred instanceof InvertedIndexSearchPredicate) {
        initState = new LSMInvertedIndexSearchCursorInitialState(keyCmp, keysOnlyTuple, indexAccessors, deletedKeysBTreeAccessors, ((LSMInvertedIndexMemoryComponent) memoryComponents.get(currentMutableComponentId.get())).getDeletedKeysBTree().getLeafFrameFactory(), ictx, includeMutableComponent, getLsmHarness(), operationalComponents);
    } else {
        LSMInvertedIndexMemoryComponent mutableComponent = (LSMInvertedIndexMemoryComponent) memoryComponents.get(currentMutableComponentId.get());
        InMemoryInvertedIndex memInvIndex = (InMemoryInvertedIndex) mutableComponent.getInvIndex();
        MultiComparator tokensAndKeysCmp = MultiComparator.create(memInvIndex.getBTree().getComparatorFactories());
        initState = new LSMInvertedIndexRangeSearchCursorInitialState(tokensAndKeysCmp, keyCmp, keysOnlyTuple, ((LSMInvertedIndexMemoryComponent) memoryComponents.get(currentMutableComponentId.get())).getDeletedKeysBTree().getLeafFrameFactory(), includeMutableComponent, getLsmHarness(), indexAccessors, deletedKeysBTreeAccessors, pred, operationalComponents);
    }
    return initState;
}
Also used : PermutingTupleReference(org.apache.hyracks.storage.am.common.tuples.PermutingTupleReference) ICursorInitialState(org.apache.hyracks.storage.common.ICursorInitialState) MultiComparator(org.apache.hyracks.storage.common.MultiComparator) InvertedIndexSearchPredicate(org.apache.hyracks.storage.am.lsm.invertedindex.search.InvertedIndexSearchPredicate) InMemoryInvertedIndex(org.apache.hyracks.storage.am.lsm.invertedindex.inmemory.InMemoryInvertedIndex)

Aggregations

ICursorInitialState (org.apache.hyracks.storage.common.ICursorInitialState)2 ArrayList (java.util.ArrayList)1 PermutingTupleReference (org.apache.hyracks.storage.am.common.tuples.PermutingTupleReference)1 ILSMComponent (org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent)1 InMemoryInvertedIndex (org.apache.hyracks.storage.am.lsm.invertedindex.inmemory.InMemoryInvertedIndex)1 InvertedIndexSearchPredicate (org.apache.hyracks.storage.am.lsm.invertedindex.search.InvertedIndexSearchPredicate)1 IIndexAccessor (org.apache.hyracks.storage.common.IIndexAccessor)1 MultiComparator (org.apache.hyracks.storage.common.MultiComparator)1