public LSMRTreeWithAntiMatterTuplesFlushCursor(TreeTupleSorter rTreeTupleSorter, TreeTupleSorter bTreeTupleSorter, int[] comparatorFields, IBinaryComparatorFactory[] comparatorFactories) { this.rTreeTupleSorter = rTreeTupleSorter; this.bTreeTupleSorter = bTreeTupleSorter; this.comparatorFields = comparatorFields; cmp = MultiComparator.create(comparatorFactories); }
public LSMRTreeCursorInitialState(ITreeIndexFrameFactory rtreeLeafFrameFactory, ITreeIndexFrameFactory rtreeInteriorFrameFactory, ITreeIndexFrameFactory btreeLeafFrameFactory, MultiComparator btreeCmp, ILSMHarness lsmHarness, int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray, ISearchOperationCallback searchCallback, List<ILSMComponent> operationalComponents) { this.rtreeLeafFrameFactory = rtreeLeafFrameFactory; this.rtreeInteriorFrameFactory = rtreeInteriorFrameFactory; this.btreeLeafFrameFactory = btreeLeafFrameFactory; this.btreeCmp = btreeCmp; this.lsmHarness = lsmHarness; this.comparatorFields = comparatorFields; this.hilbertCmp = MultiComparator.create(linearizerArray); this.searchCallback = searchCallback; this.operationalComponents = operationalComponents; }
public ExternalBTreeWithBuddyOpContext(ILSMIndex index, IBinaryComparatorFactory[] btreeCmpFactories, IBinaryComparatorFactory[] buddyBtreeCmpFactories, ISearchOperationCallback searchCallback, int targetIndexVersion, ILSMHarness lsmHarness, ITreeIndexFrameFactory btreeInteriorFrameFactory, ITreeIndexFrameFactory btreeLeafFrameFactory, ITreeIndexFrameFactory buddyBtreeLeafFrameFactory, ITracer tracer) { super(index, null, null, null, searchCallback, null, tracer); this.targetIndexVersion = targetIndexVersion; this.bTreeCmp = MultiComparator.create(btreeCmpFactories); this.buddyBTreeCmp = MultiComparator.create(buddyBtreeCmpFactories); searchInitialState = new LSMBTreeWithBuddyCursorInitialState(btreeInteriorFrameFactory, btreeLeafFrameFactory, buddyBtreeLeafFrameFactory, lsmHarness, MultiComparator.create(btreeCmpFactories), MultiComparator.create(buddyBtreeCmpFactories), NoOpOperationCallback.INSTANCE, null); }
public ExternalRTreeOpContext(ILSMIndex index, IBinaryComparatorFactory[] rtreeCmpFactories, IBinaryComparatorFactory[] btreeCmpFactories, ISearchOperationCallback searchCallback, int targetIndexVersion, ILSMHarness lsmHarness, int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray, ITreeIndexFrameFactory rtreeLeafFrameFactory, ITreeIndexFrameFactory rtreeInteriorFrameFactory, ITreeIndexFrameFactory btreeLeafFrameFactory, ITracer tracer) { super(index, null, null, null, searchCallback, null, tracer); this.targetIndexVersion = targetIndexVersion; this.bTreeCmp = MultiComparator.create(btreeCmpFactories); this.rTreeCmp = MultiComparator.create(rtreeCmpFactories); initialState = new LSMRTreeCursorInitialState(rtreeLeafFrameFactory, rtreeInteriorFrameFactory, btreeLeafFrameFactory, bTreeCmp, lsmHarness, comparatorFields, linearizerArray, searchCallback, componentHolder); }
public AbstractOperationCallbackTest() { this.keySerdes = new ISerializerDeserializer[] { IntegerSerializerDeserializer.INSTANCE }; this.cmp = MultiComparator.create(SerdeUtils.serdesToComparatorFactories(keySerdes, keySerdes.length)); bloomFilterKeyFields = new int[NUM_KEY_FIELDS]; for (int i = 0; i < NUM_KEY_FIELDS; ++i) { bloomFilterKeyFields[i] = i; } }
@SuppressWarnings("rawtypes") public String printTree(IBTreeLeafFrame leafFrame, IBTreeInteriorFrame interiorFrame, ISerializerDeserializer[] keySerdes) throws Exception { MultiComparator cmp = MultiComparator.create(cmpFactories); byte treeHeight = getTreeHeight(leafFrame); StringBuilder strBuilder = new StringBuilder(); printTree(rootPage, null, false, leafFrame, interiorFrame, treeHeight, keySerdes, strBuilder, cmp); return strBuilder.toString(); }
@SuppressWarnings("rawtypes") public String printTree(IRTreeLeafFrame leafFrame, IRTreeInteriorFrame interiorFrame, ISerializerDeserializer[] keySerdes) throws Exception { MultiComparator cmp = MultiComparator.create(cmpFactories); byte treeHeight = getTreeHeight(leafFrame); StringBuilder strBuilder = new StringBuilder(); printTree(rootPage, null, false, leafFrame, interiorFrame, treeHeight, keySerdes, strBuilder, cmp); return strBuilder.toString(); }
public TreeTupleSorter(int fileId, IBinaryComparatorFactory[] comparatorFactories, ITreeIndexFrame leafFrame1, ITreeIndexFrame leafFrame2, IBufferCache bufferCache, int[] comparatorFields) { this.fileId = fileId; this.leafFrame1 = leafFrame1; this.leafFrame2 = leafFrame2; this.bufferCache = bufferCache; this.comparatorFields = comparatorFields; tPointers = new int[INITIAL_SIZE * 2]; frameTuple1 = leafFrame1.createTupleReference(); frameTuple2 = leafFrame2.createTupleReference(); currentTupleIndex = 0; cmp = MultiComparator.create(comparatorFactories); }
public RTreeOpContext(IRTreeLeafFrame leafFrame, IRTreeInteriorFrame interiorFrame, IPageManager freePageManager, IBinaryComparatorFactory[] cmpFactories, IModificationOperationCallback modificationCallback) { if (cmpFactories[0] != null) { this.cmp = MultiComparator.create(cmpFactories); } else { this.cmp = null; } this.interiorFrame = interiorFrame; this.leafFrame = leafFrame; this.freePageManager = freePageManager; this.metaFrame = freePageManager.createMetadataFrame(); this.modificationCallback = modificationCallback; pathList = new PathList(INITIAL_HEIGHT, INITIAL_HEIGHT); NSNUpdates = new ArrayList<>(); LSNUpdates = new ArrayList<>(); }
@Override public void updateFilter(ILSMComponentFilter filter, List<ITupleReference> filterTuples, IExtendedModificationOperationCallback opCallback) throws HyracksDataException { MultiComparator filterCmp = MultiComparator.create(filter.getFilterCmpFactories()); for (ITupleReference tuple : filterTuples) { filter.update(tuple, filterCmp, opCallback); } }
public OnDiskInvertedIndexOpContext(BTree btree) throws HyracksDataException { // TODO: Ignore opcallbacks for now. btreeAccessor = btree.createAccessor(NoOpIndexAccessParameters.INSTANCE); btreeCursor = btreeAccessor.createSearchCursor(false); searchCmp = MultiComparator.create(btree.getComparatorFactories()); if (btree.getComparatorFactories().length > 1) { prefixSearchCmp = MultiComparator.create(btree.getComparatorFactories(), 0, 1); } }
public LSMInvertedIndexMergeCursor(ILSMIndexOperationContext opCtx) { this.opCtx = (LSMInvertedIndexOpContext) opCtx; outputTokenElement = null; outputKeyElement = null; needPushElementIntoKeyQueue = false; IInvertedIndex invertedIndex = (IInvertedIndex) this.opCtx.getIndex(); this.outputTuple = new TokenKeyPairTuple(invertedIndex.getTokenTypeTraits().length, invertedIndex.getInvListTypeTraits().length); this.tokenCmp = MultiComparator.create(invertedIndex.getTokenCmpFactories()); this.keyCmp = MultiComparator.create(invertedIndex.getInvListCmpFactories()); this.tokenQueueCmp = new PriorityQueueComparator(tokenCmp); this.keyQueueCmp = new PriorityQueueComparator(keyCmp); }
public static MultiComparator getSearchMultiComparator(IBinaryComparatorFactory[] cmpFactories, ITupleReference searchKey) { if (searchKey == null || cmpFactories.length == searchKey.getFieldCount()) { return MultiComparator.create(cmpFactories); } IBinaryComparator[] newCmps = new IBinaryComparator[searchKey.getFieldCount()]; for (int i = 0; i < searchKey.getFieldCount(); i++) { newCmps[i] = cmpFactories[i].createBinaryComparator(); } return new MultiComparator(newCmps); }
public static MultiComparator getSearchMultiComparator(IBinaryComparatorFactory[] cmpFactories, ITupleReference searchKey) { if (searchKey == null || cmpFactories.length == searchKey.getFieldCount()) { return MultiComparator.create(cmpFactories); } IBinaryComparator[] newCmps = new IBinaryComparator[searchKey.getFieldCount()]; for (int i = 0; i < searchKey.getFieldCount(); i++) { newCmps[i] = cmpFactories[i].createBinaryComparator(); } return new MultiComparator(newCmps); }
public InvertedListMerger(IHyracksTaskContext ctx, IInvertedIndex invIndex, ISimpleFrameBufferManager bufferManager) throws HyracksDataException { this.invListCmp = MultiComparator.create(invIndex.getInvListCmpFactories()); this.prevSearchResult = new InvertedIndexSearchResult(invIndex.getInvListTypeTraits(), ctx, bufferManager); this.newSearchResult = new InvertedIndexSearchResult(invIndex.getInvListTypeTraits(), ctx, bufferManager); }
public AbstractOnDiskInvertedIndexBulkLoader(float btreeFillFactor, boolean verifyInput, long numElementsHint, boolean checkIfEmptyIndex, int startPageId) throws HyracksDataException { this.verifyInput = verifyInput; this.invListCmp = MultiComparator.create(invListCmpFactories); if (verifyInput) { allCmp = MultiComparator.create(btree.getComparatorFactories(), invListCmpFactories); } else { allCmp = null; } this.btreeTupleBuilder = new ArrayTupleBuilder(btree.getFieldCount()); this.btreeTupleReference = new ArrayTupleReference(); this.lastTupleBuilder = new ArrayTupleBuilder(numTokenFields + numInvListKeys); this.lastTuple = new ArrayTupleReference(); this.btreeBulkloader = btree.createBulkLoader(btreeFillFactor, verifyInput, numElementsHint, checkIfEmptyIndex); currentPageId = startPageId; currentPage = bufferCache.confiscatePage(BufferedFileHandle.getDiskPageId(fileId, currentPageId)); invListBuilder.setTargetBuffer(currentPage.getBuffer().array(), 0); queue = bufferCache.createFIFOQueue(); }
@Override public IChainedComponentBulkLoader createFilterBulkLoader() throws HyracksDataException { return new FilterBulkLoader(getLSMComponentFilter(), getMetadataHolder(), getLsmIndex().getFilterManager(), getLsmIndex().getTreeFields(), getLsmIndex().getFilterFields(), MultiComparator.create(getLSMComponentFilter().getFilterCmpFactories())); }
@Override public void scanDiskComponents(ILSMIndexOperationContext ictx, IIndexCursor cursor) throws HyracksDataException { if (!isPrimaryIndex()) { throw HyracksDataException.create(ErrorCode.DISK_COMPONENT_SCAN_NOT_ALLOWED_FOR_SECONDARY_INDEX); } LSMBTreeOpContext ctx = (LSMBTreeOpContext) ictx; List<ILSMComponent> operationalComponents = ctx.getComponentHolder(); MultiComparator comp = MultiComparator.create(getComparatorFactories()); ISearchPredicate pred = new RangePredicate(null, null, true, true, comp, comp); ctx.getSearchInitialState().reset(pred, operationalComponents); ctx.getSearchInitialState().setDiskComponentScan(true); ((LSMBTreeSearchCursor) cursor).open(ctx.getSearchInitialState(), pred); }
@Override public void validate() throws HyracksDataException { btree.validate(); // Scan the btree and validate the order of elements in each inverted-list. IIndexAccessor btreeAccessor = btree.createAccessor(NoOpIndexAccessParameters.INSTANCE); try { MultiComparator btreeCmp = MultiComparator.create(btree.getComparatorFactories()); RangePredicate rangePred = new RangePredicate(null, null, true, true, btreeCmp, btreeCmp); IIndexCursor btreeCursor = btreeAccessor.createSearchCursor(false); try { btreeAccessor.search(btreeCursor, rangePred); try { doValidate(btreeCursor); } finally { btreeCursor.close(); } } finally { btreeCursor.destroy(); } } finally { btreeAccessor.destroy(); } }
private void diskOrderScan(ITreeIndexCursor icursor, RTreeOpContext ctx) throws HyracksDataException { TreeIndexDiskOrderScanCursor cursor = (TreeIndexDiskOrderScanCursor) icursor; ctx.reset(); MultiComparator cmp = MultiComparator.create(cmpFactories); SearchPredicate searchPred = new SearchPredicate(null, cmp); int currentPageId = bulkloadLeafStart; int maxPageId = freePageManager.getMaxPageId(ctx.getMetaFrame()); ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), currentPageId), false); page.acquireReadLatch(); try { cursor.setBufferCache(bufferCache); cursor.setFileId(getFileId()); cursor.setCurrentPageId(currentPageId); cursor.setMaxPageId(maxPageId); ctx.getCursorInitialState().setOriginialKeyComparator(ctx.getCmp()); ctx.getCursorInitialState().setPage(page); cursor.open(ctx.getCursorInitialState(), searchPred); } catch (Exception e) { page.releaseReadLatch(); bufferCache.unpin(page); throw HyracksDataException.create(e); } }