| package edu.uci.ics.hyracks.storage.am.lsm.rtree; |
| |
| import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer; |
| import edu.uci.ics.hyracks.api.io.FileReference; |
| import edu.uci.ics.hyracks.api.io.IODeviceHandle; |
| import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable; |
| import edu.uci.ics.hyracks.dataflow.common.data.marshalling.IntegerSerializerDeserializer; |
| import edu.uci.ics.hyracks.storage.am.common.AbstractIndexLifecycleTest; |
| import edu.uci.ics.hyracks.storage.am.common.CheckTuple; |
| import edu.uci.ics.hyracks.storage.am.common.IIndexTestContext; |
| import edu.uci.ics.hyracks.storage.am.common.TreeIndexTestUtils; |
| import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory; |
| import edu.uci.ics.hyracks.storage.am.lsm.rtree.impls.LSMRTreeWithAntiMatterTuples; |
| import edu.uci.ics.hyracks.storage.am.lsm.rtree.util.LSMRTreeTestHarness; |
| import edu.uci.ics.hyracks.storage.am.lsm.rtree.util.LSMRTreeWithAntiMatterTuplesTestContext; |
| import edu.uci.ics.hyracks.storage.am.rtree.RTreeTestUtils; |
| import edu.uci.ics.hyracks.storage.am.rtree.frames.RTreePolicyType; |
| import edu.uci.ics.hyracks.storage.am.rtree.util.RTreeUtils; |
| |
| public class LSMRTreeWithAntiMatterTuplesLifecycleTest extends AbstractIndexLifecycleTest { |
| |
| @SuppressWarnings("rawtypes") |
| private final ISerializerDeserializer[] fieldSerdes = { IntegerSerializerDeserializer.INSTANCE, |
| IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, |
| IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE }; |
| private final IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils |
| .createPrimitiveValueProviderFactories(4, IntegerPointable.FACTORY); |
| private final int numKeys = 4; |
| |
| private final LSMRTreeTestHarness harness = new LSMRTreeTestHarness(); |
| private final TreeIndexTestUtils titu = new RTreeTestUtils(); |
| |
| @SuppressWarnings("rawtypes") |
| private IIndexTestContext<? extends CheckTuple> testCtx; |
| |
| @Override |
| protected boolean persistentStateExists() throws Exception { |
| // make sure all of the directories exist |
| for (IODeviceHandle handle : harness.getIOManager().getIODevices()) { |
| if (!new FileReference(handle, harness.getFileReference().getFile().getPath()).getFile().exists()) { |
| return false; |
| } |
| } |
| return true; |
| } |
| |
| @Override |
| protected boolean isEmptyIndex() throws Exception { |
| return ((LSMRTreeWithAntiMatterTuples) index).isEmptyIndex(); |
| } |
| |
| @Override |
| public void setup() throws Exception { |
| harness.setUp(); |
| testCtx = LSMRTreeWithAntiMatterTuplesTestContext.create(harness.getVirtualBufferCache(), |
| harness.getIOManager(), harness.getFileReference(), harness.getDiskBufferCache(), |
| harness.getDiskFileMapProvider(), fieldSerdes, valueProviderFactories, numKeys, RTreePolicyType.RTREE, |
| harness.getMergePolicy(), harness.getOperationTracker(), harness.getIOScheduler(), |
| harness.getIOOperationCallbackProvider(), harness.getIODeviceId()); |
| index = testCtx.getIndex(); |
| } |
| |
| @Override |
| public void tearDown() throws Exception { |
| try { |
| index.deactivate(); |
| } catch (Exception e) { |
| } finally { |
| index.destroy(); |
| } |
| harness.tearDown(); |
| } |
| |
| @Override |
| protected void performInsertions() throws Exception { |
| titu.insertIntTuples(testCtx, 10, harness.getRandom()); |
| } |
| |
| @Override |
| protected void checkInsertions() throws Exception { |
| titu.checkScan(testCtx); |
| } |
| |
| @Override |
| protected void clearCheckableInsertions() throws Exception { |
| testCtx.getCheckTuples().clear(); |
| } |
| } |