Search in sources :

Example 16 with IPrimitiveValueProviderFactory

use of org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory in project asterixdb by apache.

the class AbstractRTreeTestDriver method rstartreeTwoDimensionsDouble.

@Test
public void rstartreeTwoDimensionsDouble() throws Exception {
    if (!testRstarPolicy) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Ignoring RTree " + getTestOpName() + " Test With Two Dimensions With Double Keys.");
        }
        return;
    }
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("RTree " + getTestOpName() + " Test With Two Dimensions With Double Keys.");
    }
    ISerializerDeserializer[] fieldSerdes = { DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE };
    int numKeys = 4;
    IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(numKeys, DoublePointable.FACTORY);
    // Range search, the rectangle bottom left coordinates are -1000.0,
    // -1000.0 and the top right coordinates are 1000.0, 1000.0
    ITupleReference key = TupleUtils.createDoubleTuple(-1000.0, -1000.0, 1000.0, 1000.0);
    runTest(fieldSerdes, valueProviderFactories, numKeys, key, RTreePolicyType.RSTARTREE);
}
Also used : IPrimitiveValueProviderFactory(org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) Test(org.junit.Test)

Example 17 with IPrimitiveValueProviderFactory

use of org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory in project asterixdb by apache.

the class AbstractRTreeTestDriver method rtreeFourDimensionsDouble.

@Test
public void rtreeFourDimensionsDouble() throws Exception {
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("RTree " + getTestOpName() + " Test With Four Dimensions With Double Keys.");
    }
    ISerializerDeserializer[] fieldSerdes = { DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE };
    int numKeys = 8;
    IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(numKeys, DoublePointable.FACTORY);
    // Range search, the rectangle bottom left coordinates are -1000.0,
    // -1000.0, -1000.0, -1000.0 and the top right coordinates are 1000.0,
    // 1000.0, 1000.0, 1000.0
    ITupleReference key = TupleUtils.createDoubleTuple(-1000.0, -1000.0, -1000.0, -1000.0, 1000.0, 1000.0, 1000.0, 1000.0);
    runTest(fieldSerdes, valueProviderFactories, numKeys, key, RTreePolicyType.RTREE);
}
Also used : IPrimitiveValueProviderFactory(org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) Test(org.junit.Test)

Example 18 with IPrimitiveValueProviderFactory

use of org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory in project asterixdb by apache.

the class AbstractRTreeMultiThreadTest method rtreeTwoDimensionsInt.

@Test
public void rtreeTwoDimensionsInt() throws InterruptedException, HyracksDataException {
    ISerializerDeserializer[] fieldSerdes = { IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE };
    int numKeys = 4;
    IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(numKeys, IntegerPointable.FACTORY);
    String dataMsg = "Two Dimensions Of Integer Values";
    for (TestWorkloadConf conf : workloadConfs) {
        runTest(fieldSerdes, valueProviderFactories, numKeys, RTreePolicyType.RTREE, REGULAR_NUM_THREADS, conf, dataMsg);
        runTest(fieldSerdes, valueProviderFactories, numKeys, RTreePolicyType.RTREE, EXCESSIVE_NUM_THREADS, conf, dataMsg);
    }
}
Also used : TestWorkloadConf(org.apache.hyracks.storage.am.common.TestWorkloadConf) IPrimitiveValueProviderFactory(org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) Test(org.junit.Test)

Example 19 with IPrimitiveValueProviderFactory

use of org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory in project asterixdb by apache.

the class AbstractRTreeMultiThreadTest method rstartreeTwoDimensionsDouble.

@Test
public void rstartreeTwoDimensionsDouble() throws Exception {
    if (!testRstarPolicy) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Ignoring RTree Multithread Test With Two Dimensions With Double Keys.");
        }
        return;
    }
    ISerializerDeserializer[] fieldSerdes = { DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE, DoubleSerializerDeserializer.INSTANCE };
    int numKeys = 4;
    IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(numKeys, DoublePointable.FACTORY);
    String dataMsg = "Two Dimensions Of Double Values";
    for (TestWorkloadConf conf : workloadConfs) {
        runTest(fieldSerdes, valueProviderFactories, numKeys, RTreePolicyType.RSTARTREE, REGULAR_NUM_THREADS, conf, dataMsg);
        runTest(fieldSerdes, valueProviderFactories, numKeys, RTreePolicyType.RSTARTREE, EXCESSIVE_NUM_THREADS, conf, dataMsg);
    }
}
Also used : TestWorkloadConf(org.apache.hyracks.storage.am.common.TestWorkloadConf) IPrimitiveValueProviderFactory(org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) Test(org.junit.Test)

Example 20 with IPrimitiveValueProviderFactory

use of org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory in project asterixdb by apache.

the class AbstractLSMRTreeExamplesTest method additionalFilteringingExample.

/**
     * Test the LSM component filters.
     */
@Test
public void additionalFilteringingExample() throws Exception {
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Testing LSMRTree or LSMRTreeWithAntiMatterTuples component filters.");
    }
    // Declare fields.
    int fieldCount = 6;
    ITypeTraits[] typeTraits = new ITypeTraits[fieldCount];
    typeTraits[0] = IntegerPointable.TYPE_TRAITS;
    typeTraits[1] = IntegerPointable.TYPE_TRAITS;
    typeTraits[2] = IntegerPointable.TYPE_TRAITS;
    typeTraits[3] = IntegerPointable.TYPE_TRAITS;
    typeTraits[4] = IntegerPointable.TYPE_TRAITS;
    typeTraits[5] = IntegerPointable.TYPE_TRAITS;
    // Declare field serdes.
    ISerializerDeserializer[] fieldSerdes = { IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE };
    // Declare RTree keys.
    int rtreeKeyFieldCount = 4;
    IBinaryComparatorFactory[] rtreeCmpFactories = new IBinaryComparatorFactory[rtreeKeyFieldCount];
    rtreeCmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
    rtreeCmpFactories[1] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
    rtreeCmpFactories[2] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
    rtreeCmpFactories[3] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
    // Declare BTree keys, this will only be used for LSMRTree
    int btreeKeyFieldCount;
    IBinaryComparatorFactory[] btreeCmpFactories;
    int[] btreeFields = null;
    if (rTreeType == RTreeType.LSMRTREE) {
        //Parameters look different for LSM RTREE from LSM RTREE WITH ANTI MATTER TUPLES
        btreeKeyFieldCount = 1;
        btreeCmpFactories = new IBinaryComparatorFactory[btreeKeyFieldCount];
        btreeCmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
        btreeFields = new int[btreeKeyFieldCount];
        for (int i = 0; i < btreeKeyFieldCount; i++) {
            btreeFields[i] = rtreeKeyFieldCount + i;
        }
    } else {
        btreeKeyFieldCount = 6;
        btreeCmpFactories = new IBinaryComparatorFactory[btreeKeyFieldCount];
        btreeCmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
        btreeCmpFactories[1] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
        btreeCmpFactories[2] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
        btreeCmpFactories[3] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
        btreeCmpFactories[4] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
        btreeCmpFactories[5] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
    }
    // create value providers
    IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(rtreeCmpFactories.length, IntegerPointable.FACTORY);
    int[] rtreeFields = { 0, 1, 2, 3, 4 };
    ITypeTraits[] filterTypeTraits = { IntegerPointable.TYPE_TRAITS };
    IBinaryComparatorFactory[] filterCmpFactories = { PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY) };
    int[] filterFields = { 5 };
    ITreeIndex treeIndex = createTreeIndex(typeTraits, rtreeCmpFactories, btreeCmpFactories, valueProviderFactories, RTreePolicyType.RTREE, rtreeFields, btreeFields, filterTypeTraits, filterCmpFactories, filterFields);
    treeIndex.create();
    treeIndex.activate();
    long start = System.currentTimeMillis();
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Inserting into tree...");
    }
    ArrayTupleBuilder tb = new ArrayTupleBuilder(fieldCount);
    ArrayTupleReference tuple = new ArrayTupleReference();
    IIndexAccessor indexAccessor = treeIndex.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
    int numInserts = 10000;
    for (int i = 0; i < numInserts; i++) {
        int p1x = rnd.nextInt();
        int p1y = rnd.nextInt();
        int p2x = rnd.nextInt();
        int p2y = rnd.nextInt();
        int pk = 5;
        int filter = i;
        TupleUtils.createIntegerTuple(tb, tuple, Math.min(p1x, p2x), Math.min(p1y, p2y), Math.max(p1x, p2x), Math.max(p1y, p2y), pk, filter);
        try {
            indexAccessor.insert(tuple);
        } catch (HyracksDataException e) {
            if (e.getErrorCode() != ErrorCode.DUPLICATE_KEY) {
                throw e;
            }
        }
    }
    long end = System.currentTimeMillis();
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info(numInserts + " inserts in " + (end - start) + "ms");
    }
    scan(indexAccessor, fieldSerdes);
    diskOrderScan(indexAccessor, fieldSerdes);
    // Build key.
    ArrayTupleBuilder keyTb = new ArrayTupleBuilder(rtreeKeyFieldCount);
    ArrayTupleReference key = new ArrayTupleReference();
    TupleUtils.createIntegerTuple(keyTb, key, -1000, -1000, 1000, 1000);
    // Build min filter key.
    ArrayTupleBuilder minFilterTb = new ArrayTupleBuilder(filterFields.length);
    ArrayTupleReference minTuple = new ArrayTupleReference();
    TupleUtils.createIntegerTuple(minFilterTb, minTuple, 400);
    // Build max filter key.
    ArrayTupleBuilder maxFilterTb = new ArrayTupleBuilder(filterFields.length);
    ArrayTupleReference maxTuple = new ArrayTupleReference();
    TupleUtils.createIntegerTuple(maxFilterTb, maxTuple, 500);
    rangeSearch(rtreeCmpFactories, indexAccessor, fieldSerdes, key, minTuple, maxTuple);
    treeIndex.deactivate();
    treeIndex.destroy();
}
Also used : ITypeTraits(org.apache.hyracks.api.dataflow.value.ITypeTraits) IPrimitiveValueProviderFactory(org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory) ArrayTupleReference(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference) IBinaryComparatorFactory(org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory) ArrayTupleBuilder(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) IIndexAccessor(org.apache.hyracks.storage.common.IIndexAccessor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ITreeIndex(org.apache.hyracks.storage.am.common.api.ITreeIndex) AbstractRTreeExamplesTest(org.apache.hyracks.storage.am.rtree.AbstractRTreeExamplesTest) Test(org.junit.Test)

Aggregations

IPrimitiveValueProviderFactory (org.apache.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory)22 Test (org.junit.Test)20 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)19 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)10 ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)10 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)8 ArrayTupleReference (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference)8 ITreeIndex (org.apache.hyracks.storage.am.common.api.ITreeIndex)7 IIndexAccessor (org.apache.hyracks.storage.common.IIndexAccessor)7 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)6 TestWorkloadConf (org.apache.hyracks.storage.am.common.TestWorkloadConf)6 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)5 UTF8StringSerializerDeserializer (org.apache.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AsterixVirtualBufferCacheProvider (org.apache.asterix.common.context.AsterixVirtualBufferCacheProvider)1 IStorageComponentProvider (org.apache.asterix.common.context.IStorageComponentProvider)1 CompilationException (org.apache.asterix.common.exceptions.CompilationException)1 ATypeTag (org.apache.asterix.om.types.ATypeTag)1 IAType (org.apache.asterix.om.types.IAType)1