public LSMRTreeWithAntiMatterTuplesFlushCursor(TreeTupleSorter rTreeTupleSorter, TreeTupleSorter bTreeTupleSorter, int[] comparatorFields, IBinaryComparatorFactory[] comparatorFactories) { this.rTreeTupleSorter = rTreeTupleSorter; this.bTreeTupleSorter = bTreeTupleSorter; this.comparatorFields = comparatorFields; cmp = MultiComparator.create(comparatorFactories); }
protected int compare(MultiComparator cmp, ITupleReference tupleA, ITupleReference tupleB) throws HyracksDataException { return cmp.compare(tupleA, tupleB); }
@Override public void setMultiComparator(MultiComparator cmp) { this.cmp = cmp; cmpFrameTuple.setFieldCount(cmp.getKeyFieldCount()); frameTuple.setFieldCount(cmp.getKeyFieldCount()); previousFt.setFieldCount(cmp.getKeyFieldCount()); }
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 boolean isPointPredicate(MultiComparator originalKeyComparator) throws HyracksDataException { if (getLowKey() == null) { return false; } if (getHighKey() == null) { return false; } if (!isLowKeyInclusive()) { return false; } if (!isHighKeyInclusive()) { return false; } if (getLowKeyComparator().getKeyFieldCount() != getHighKeyComparator().getKeyFieldCount()) { return false; } if (getLowKeyComparator().getKeyFieldCount() != originalKeyComparator.getKeyFieldCount()) { return false; } return originalKeyComparator.compare(getLowKey(), getHighKey()) == 0; } }
@Override public int getChildPageIdIfIntersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp) throws HyracksDataException { frameTuple.setFieldCount(cmp.getKeyFieldCount()); frameTuple.resetByTupleIndex(this, tupleIndex); int maxFieldPos = cmp.getKeyFieldCount() / 2; for (int i = 0; i < maxFieldPos; i++) { int j = maxFieldPos + i; int c = cmp.getComparators()[i].compare(tuple.getFieldData(i), tuple.getFieldStart(i), tuple.getFieldLength(i), frameTuple.getFieldData(j), frameTuple.getFieldStart(j), frameTuple.getFieldLength(j)); if (c > 0) { return -1; } c = cmp.getComparators()[i].compare(tuple.getFieldData(j), tuple.getFieldStart(j), tuple.getFieldLength(j), frameTuple.getFieldData(i), frameTuple.getFieldStart(i), frameTuple.getFieldLength(i)); if (c < 0) { return -1; } } return buf.getInt(getChildPointerOff(frameTuple)); }
public static MultiComparator create(IBinaryComparatorFactory[] cmpFactories) { IBinaryComparator[] cmps = new IBinaryComparator[cmpFactories.length]; for (int i = 0; i < cmpFactories.length; i++) { cmps[i] = cmpFactories[i].createBinaryComparator(); } if (cmps.length == 1) { return new SingleComparator(cmps); } else { return new MultiComparator(cmps); } }
private ArrayList<KeyPartition> getKeyPartitions(BTreeFieldPrefixNSMLeafFrame frame, MultiComparator cmp, int occurrenceThreshold) throws HyracksDataException { IBinaryComparator[] cmps = cmp.getComparators(); int fieldCount = typeTraits.length;
FindTupleMode mode, FindTupleNoExactMatchPolicy matchPolicy) throws HyracksDataException { if (searchKey.getFieldCount() == frameTuple.getFieldCount()) { int maxFieldPos = multiCmp.getKeyFieldCount() / 2; for (int i = 0; i < frame.getTupleCount(); i++) { frameTuple.resetByTupleIndex(frame, i); for (int j = 0; j < maxFieldPos; j++) { int k = maxFieldPos + j; int c1 = multiCmp.getComparators()[j].compare(frameTuple.getFieldData(j), frameTuple.getFieldStart(j), frameTuple.getFieldLength(j), searchKey.getFieldData(j), searchKey.getFieldStart(j), searchKey.getFieldLength(j)); break; int c2 = multiCmp.getComparators()[k].compare(frameTuple.getFieldData(k), frameTuple.getFieldStart(k), frameTuple.getFieldLength(k), searchKey.getFieldData(k), searchKey.getFieldStart(k), searchKey.getFieldLength(k)); int remainingFieldCount = frameTuple.getFieldCount() - multiCmp.getKeyFieldCount(); for (int j = multiCmp.getKeyFieldCount(); j < multiCmp.getKeyFieldCount() + remainingFieldCount; j++) { if (!compareField(searchKey, frameTuple, j)) { foundTuple = false;
tupleBuilder = new ArrayTupleBuilder(originalKeyCmp.getKeyFieldCount()); TupleUtils.copyTuple(tupleBuilder, frameTuple, originalKeyCmp.getKeyFieldCount()); reconciliationTuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray()); if (originalKeyCmp.compare(reconciliationTuple, frameTuple) == 0) { return true; } else {
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 create(IBinaryComparatorFactory[] cmpFactories, int startIndex, int numCmps) { IBinaryComparator[] cmps = new IBinaryComparator[numCmps]; for (int i = startIndex; i < startIndex + numCmps; i++) { cmps[i] = cmpFactories[i].createBinaryComparator(); } if (cmps.length == 1) { return new SingleComparator(cmps); } else { return new MultiComparator(cmps); } }
for (int i = 0; i < maxFieldPos; i++) { int j = maxFieldPos + i; int c = ctx.getCmp().getComparators()[i].compare(tuple.getFieldData(i), tuple.getFieldStart(i), tuple.getFieldLength(i), tuple.getFieldData(j), tuple.getFieldStart(j), tuple.getFieldLength(j));
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; }
@Override public boolean satisfy(ITupleReference minTuple, ITupleReference maxTuple, MultiComparator filterCmp) throws HyracksDataException { if (maxTuple != null && this.minTuple != null) { int c = filterCmp.compare(maxTuple, this.minTuple); if (c < 0) { return false; } } if (minTuple != null && this.maxTuple != null) { int c = filterCmp.compare(minTuple, this.maxTuple); if (c > 0) { return false; } } return true; }
@Override public ITreeIndexTupleReference createTupleReference() { ITreeIndexTupleReference tuple = tupleWriter.createTupleReference(); tuple.setFieldCount(cmp.getKeyFieldCount()); return tuple; }
public static boolean containsRegion(ITupleReference tuple1, ITupleReference tuple2, MultiComparator cmp, IPrimitiveValueProvider[] keyValueProviders) throws HyracksDataException { int maxFieldPos = cmp.getKeyFieldCount() / 2; for (int i = 0; i < maxFieldPos; i++) { int j = maxFieldPos + i; int c = cmp.getComparators()[i].compare(tuple1.getFieldData(i), tuple1.getFieldStart(i), tuple1.getFieldLength(i), tuple2.getFieldData(i), tuple2.getFieldStart(i), tuple2.getFieldLength(i)); if (c > 0) { return false; } c = cmp.getComparators()[j].compare(tuple1.getFieldData(j), tuple1.getFieldStart(j), tuple1.getFieldLength(j), tuple2.getFieldData(j), tuple2.getFieldStart(j), tuple2.getFieldLength(j)); if (c < 0) { return false; } } return true; } }
public static MultiComparator create(IBinaryComparatorFactory[]... cmpFactories) { int size = 0; for (int i = 0; i < cmpFactories.length; i++) { size += cmpFactories[i].length; } IBinaryComparator[] cmps = new IBinaryComparator[size]; int x = 0; for (int i = 0; i < cmpFactories.length; i++) { for (int j = 0; j < cmpFactories[i].length; j++) { cmps[x++] = cmpFactories[i][j].createBinaryComparator(); } } if (cmps.length == 1) { return new SingleComparator(cmps); } else { return new MultiComparator(cmps); } } }
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); }
/** * Checks whether the search tuple is greater than the last element in the current block of the cursor. * If so, the cursor needs to load next block of the inverted list. * * @param searchTuple * @param invListCmp * @return true if the search tuple is greater than the last element in the current block of the cursor * false if the search tuple is equal to or less than the last element in the current block of the cursor * @throws HyracksDataException */ private boolean needToReadNextBlock(ITupleReference searchTuple, MultiComparator invListCmp) throws HyracksDataException { if (moreBlocksToRead && invListCmp.compare(searchTuple, bufferEndElementTuple) > 0) { return true; } return false; }