use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.
the class AbstractLSMDiskComponentWithBuddyBulkLoader method delete.
@Override
public void delete(ITupleReference tuple) throws HyracksDataException {
try {
ITupleReference t;
if (indexTuple != null) {
indexTuple.reset(tuple);
t = indexTuple;
} else {
t = tuple;
}
buddyBTreeBulkLoader.add(t);
if (bloomFilterBuilder != null) {
bloomFilterBuilder.add(t);
}
updateFilter(tuple);
} catch (HyracksDataException e) {
//deleting a key multiple times is OK
if (e.getErrorCode() != ErrorCode.DUPLICATE_KEY) {
cleanupArtifacts();
throw e;
}
} catch (Exception e) {
cleanupArtifacts();
throw e;
}
if (isEmptyComponent) {
isEmptyComponent = false;
}
}
use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.
the class AbstractLSMDiskComponentWithBuddyBulkLoader method add.
@Override
public void add(ITupleReference tuple) throws HyracksDataException {
try {
ITupleReference t;
if (indexTuple != null) {
indexTuple.reset(tuple);
t = indexTuple;
} else {
t = tuple;
}
indexBulkLoader.add(t);
updateFilter(tuple);
} catch (Exception e) {
cleanupArtifacts();
throw e;
}
if (isEmptyComponent) {
isEmptyComponent = false;
}
}
use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.
the class AbstractLSMDiskComponentBulkLoader method add.
@Override
public void add(ITupleReference tuple) throws HyracksDataException {
try {
ITupleReference t;
if (indexTuple != null) {
indexTuple.reset(tuple);
t = indexTuple;
} else {
t = tuple;
}
indexBulkLoader.add(t);
if (bloomFilterBuilder != null) {
bloomFilterBuilder.add(t);
}
updateFilter(tuple);
} catch (Exception e) {
cleanupArtifacts();
throw e;
}
if (isEmptyComponent) {
isEmptyComponent = false;
}
}
use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.
the class AbstractLSMDiskComponentBulkLoader method delete.
@Override
public void delete(ITupleReference tuple) throws HyracksDataException {
ILSMTreeTupleWriter tupleWriter = (ILSMTreeTupleWriter) ((AbstractTreeIndexBulkLoader) indexBulkLoader).getLeafFrame().getTupleWriter();
tupleWriter.setAntimatter(true);
try {
ITupleReference t;
if (indexTuple != null) {
indexTuple.reset(tuple);
t = indexTuple;
} else {
t = tuple;
}
indexBulkLoader.add(t);
updateFilter(tuple);
} catch (Exception e) {
cleanupArtifacts();
throw e;
} finally {
tupleWriter.setAntimatter(false);
}
if (isEmptyComponent) {
isEmptyComponent = false;
}
}
use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.
the class LSMBTreeFilterMergeTestDriver method runTest.
@Override
protected void runTest(ISerializerDeserializer[] fieldSerdes, int numKeys, BTreeLeafFrameType leafType, ITupleReference lowKey, ITupleReference highKey, ITupleReference prefixLowKey, ITupleReference prefixHighKey) throws Exception {
OrderedIndexTestContext ctx = createTestContext(fieldSerdes, numKeys, leafType, true);
ctx.getIndex().create();
ctx.getIndex().activate();
// to determine which field types to generate.
if (fieldSerdes[0] instanceof IntegerSerializerDeserializer) {
orderedIndexTestUtils.bulkLoadIntTuples(ctx, numTuplesToInsert, true, getRandom());
} else if (fieldSerdes[0] instanceof UTF8StringSerializerDeserializer) {
orderedIndexTestUtils.bulkLoadStringTuples(ctx, numTuplesToInsert, true, getRandom());
}
int maxTreesToMerge = AccessMethodTestsConfig.LSM_BTREE_MAX_TREES_TO_MERGE;
ILSMIndexAccessor accessor = (ILSMIndexAccessor) ctx.getIndexAccessor();
IBinaryComparator comp = ctx.getComparatorFactories()[0].createBinaryComparator();
for (int i = 0; i < maxTreesToMerge; i++) {
int flushed = 0;
for (; flushed < i; flushed++) {
Pair<ITupleReference, ITupleReference> minMax = null;
if (fieldSerdes[0] instanceof IntegerSerializerDeserializer) {
minMax = orderedIndexTestUtils.insertIntTuples(ctx, numTuplesToInsert, true, getRandom());
} else {
minMax = orderedIndexTestUtils.insertStringTuples(ctx, numTuplesToInsert, true, getRandom());
}
if (minMax != null) {
ILSMComponentFilter f = ((LSMBTree) ctx.getIndex()).getCurrentMemoryComponent().getLSMComponentFilter();
Pair<ITupleReference, ITupleReference> obsMinMax = filterToMinMax(f);
Assert.assertEquals(0, TreeIndexTestUtils.compareFilterTuples(obsMinMax.getLeft(), minMax.getLeft(), comp));
Assert.assertEquals(0, TreeIndexTestUtils.compareFilterTuples(obsMinMax.getRight(), minMax.getRight(), comp));
}
StubIOOperationCallback stub = new StubIOOperationCallback();
BlockingIOOperationCallbackWrapper waiter = new BlockingIOOperationCallbackWrapper(stub);
accessor.scheduleFlush(waiter);
waiter.waitForIO();
if (minMax != null) {
Pair<ITupleReference, ITupleReference> obsMinMax = filterToMinMax(stub.getLastNewComponent().getLSMComponentFilter());
Assert.assertEquals(0, TreeIndexTestUtils.compareFilterTuples(obsMinMax.getLeft(), minMax.getLeft(), comp));
Assert.assertEquals(0, TreeIndexTestUtils.compareFilterTuples(obsMinMax.getRight(), minMax.getRight(), comp));
}
}
List<ILSMDiskComponent> flushedComponents = ((LSMBTree) ctx.getIndex()).getImmutableComponents();
MutablePair<ITupleReference, ITupleReference> expectedMergeMinMax = null;
for (ILSMDiskComponent f : flushedComponents) {
Pair<ITupleReference, ITupleReference> componentMinMax = filterToMinMax(f.getLSMComponentFilter());
if (expectedMergeMinMax == null) {
expectedMergeMinMax = MutablePair.of(componentMinMax.getLeft(), componentMinMax.getRight());
}
if (TreeIndexTestUtils.compareFilterTuples(expectedMergeMinMax.getLeft(), componentMinMax.getLeft(), comp) > 0) {
expectedMergeMinMax.setLeft(componentMinMax.getLeft());
}
if (TreeIndexTestUtils.compareFilterTuples(expectedMergeMinMax.getRight(), componentMinMax.getRight(), comp) < 0) {
expectedMergeMinMax.setRight(componentMinMax.getRight());
}
}
accessor.scheduleMerge(NoOpIOOperationCallbackFactory.INSTANCE.createIoOpCallback(), ((LSMBTree) ctx.getIndex()).getImmutableComponents());
flushedComponents = ((LSMBTree) ctx.getIndex()).getImmutableComponents();
Pair<ITupleReference, ITupleReference> mergedMinMax = filterToMinMax(flushedComponents.get(0).getLSMComponentFilter());
Assert.assertEquals(0, TreeIndexTestUtils.compareFilterTuples(expectedMergeMinMax.getLeft(), mergedMinMax.getLeft(), comp));
Assert.assertEquals(0, TreeIndexTestUtils.compareFilterTuples(expectedMergeMinMax.getRight(), mergedMinMax.getRight(), comp));
orderedIndexTestUtils.checkPointSearches(ctx);
orderedIndexTestUtils.checkScan(ctx);
orderedIndexTestUtils.checkDiskOrderScan(ctx);
orderedIndexTestUtils.checkRangeSearch(ctx, lowKey, highKey, true, true);
if (prefixLowKey != null && prefixHighKey != null) {
orderedIndexTestUtils.checkRangeSearch(ctx, prefixLowKey, prefixHighKey, true, true);
}
}
ctx.getIndex().deactivate();
ctx.getIndex().destroy();
}
Aggregations