Search in sources :

Example 6 with MapIndexScanMetadata

use of com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata in project hazelcast by hazelcast.

the class MapIndexScanPTest method test_pointLookup_hashed.

// We also don't test full hash index scan, because such plan aren't allowed to be created.
@Test
public void test_pointLookup_hashed() {
    List<JetSqlRow> expected = new ArrayList<>();
    for (int i = count; i > 0; i--) {
        map.put(i, new Person("value-" + i, i));
    }
    expected.add(jetRow((5), "value-5", 5));
    IndexConfig indexConfig = new IndexConfig(IndexType.HASH, "age").setName(randomName());
    map.addIndex(indexConfig);
    IndexFilter filter = new IndexEqualsFilter(intValue(5));
    MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, -1, false);
    TestSupport.verifyProcessor(adaptSupplier(MapIndexScanP.readMapIndexSupplier(metadata))).hazelcastInstance(instance()).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).outputChecker(LENIENT_SAME_ITEMS_IN_ORDER).disableSnapshots().disableProgressAssertion().expectOutput(expected);
}
Also used : IndexEqualsFilter(com.hazelcast.sql.impl.exec.scan.index.IndexEqualsFilter) IndexConfig(com.hazelcast.config.IndexConfig) ArrayList(java.util.ArrayList) MapIndexScanMetadata(com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) IndexFilter(com.hazelcast.sql.impl.exec.scan.index.IndexFilter) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with MapIndexScanMetadata

use of com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata in project hazelcast by hazelcast.

the class MapIndexScanPTest method test_whenFilterExistsWithoutSpecificProjection_sorted.

@Test
public void test_whenFilterExistsWithoutSpecificProjection_sorted() {
    List<JetSqlRow> expected = new ArrayList<>();
    for (int i = count; i > 0; i--) {
        map.put(i, new Person("value-" + i, i));
        if (i > count / 2) {
            expected.add(jetRow((count - i + 1), "value-" + (count - i + 1), (count - i + 1)));
        }
    }
    IndexConfig indexConfig = new IndexConfig(IndexType.SORTED, "age").setName(randomName());
    map.addIndex(indexConfig);
    IndexFilter filter = new IndexRangeFilter(intValue(0), true, intValue(count / 2), true);
    MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, 2, false);
    TestSupport.verifyProcessor(adaptSupplier(MapIndexScanP.readMapIndexSupplier(metadata))).hazelcastInstance(instance()).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).outputChecker(LENIENT_SAME_ITEMS_IN_ORDER).disableSnapshots().disableProgressAssertion().expectOutput(expected);
}
Also used : IndexRangeFilter(com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter) IndexConfig(com.hazelcast.config.IndexConfig) ArrayList(java.util.ArrayList) MapIndexScanMetadata(com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) IndexFilter(com.hazelcast.sql.impl.exec.scan.index.IndexFilter) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with MapIndexScanMetadata

use of com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata in project hazelcast by hazelcast.

the class JetSqlSerializerHook method createFactory.

@SuppressWarnings("unchecked")
@Override
public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
    constructors[JSON_QUERY] = arg -> new JsonQueryFunction();
    constructors[JSON_PARSE] = arg -> new JsonParseFunction();
    constructors[JSON_VALUE] = arg -> new JsonValueFunction<>();
    constructors[JSON_OBJECT] = arg -> new JsonObjectFunction();
    constructors[JSON_ARRAY] = arg -> new JsonArrayFunction();
    constructors[MAP_INDEX_SCAN_METADATA] = arg -> new MapIndexScanMetadata();
    constructors[ROW_PROJECTOR_PROCESSOR_SUPPLIER] = arg -> new RowProjectorProcessorSupplier();
    constructors[KV_ROW_PROJECTOR_SUPPLIER] = arg -> new KvRowProjector.Supplier();
    constructors[ROOT_RESULT_CONSUMER_SINK_SUPPLIER] = arg -> new RootResultConsumerSink.Supplier();
    constructors[SQL_ROW_COMPARATOR] = arg -> new ExpressionUtil.SqlRowComparator();
    constructors[FIELD_COLLATION] = arg -> new FieldCollation();
    constructors[ROW_GET_MAYBE_SERIALIZED_FN] = arg -> new AggregateAbstractPhysicalRule.RowGetMaybeSerializedFn();
    constructors[NULL_FUNCTION] = arg -> AggregateAbstractPhysicalRule.NullFunction.INSTANCE;
    constructors[ROW_GET_FN] = arg -> new AggregateAbstractPhysicalRule.RowGetFn();
    constructors[AGGREGATE_CREATE_SUPPLIER] = arg -> new AggregateAbstractPhysicalRule.AggregateCreateSupplier();
    constructors[AGGREGATE_ACCUMULATE_FUNCTION] = arg -> new AggregateAbstractPhysicalRule.AggregateAccumulateFunction();
    constructors[AGGREGATE_COMBINE_FUNCTION] = arg -> AggregateAbstractPhysicalRule.AggregateCombineFunction.INSTANCE;
    constructors[AGGREGATE_EXPORT_FINISH_FUNCTION] = arg -> AggregateAbstractPhysicalRule.AggregateExportFinishFunction.INSTANCE;
    constructors[AGGREGATE_SUM_SUPPLIER] = arg -> new AggregateAbstractPhysicalRule.AggregateSumSupplier();
    constructors[AGGREGATE_AVG_SUPPLIER] = arg -> new AggregateAbstractPhysicalRule.AggregateAvgSupplier();
    constructors[AGGREGATE_COUNT_SUPPLIER] = arg -> new AggregateAbstractPhysicalRule.AggregateCountSupplier();
    return new ArrayDataSerializableFactory(constructors);
}
Also used : KvRowProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector) AggregateAbstractPhysicalRule(com.hazelcast.jet.sql.impl.opt.physical.AggregateAbstractPhysicalRule) JsonParseFunction(com.hazelcast.jet.sql.impl.expression.json.JsonParseFunction) FieldCollation(com.hazelcast.jet.sql.impl.opt.FieldCollation) JsonObjectFunction(com.hazelcast.jet.sql.impl.expression.json.JsonObjectFunction) RowProjectorProcessorSupplier(com.hazelcast.jet.sql.impl.connector.map.RowProjectorProcessorSupplier) ConstructorFunction(com.hazelcast.internal.util.ConstructorFunction) JsonArrayFunction(com.hazelcast.jet.sql.impl.expression.json.JsonArrayFunction) MapIndexScanMetadata(com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata) RootResultConsumerSink(com.hazelcast.jet.sql.impl.processors.RootResultConsumerSink) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) JsonQueryFunction(com.hazelcast.jet.sql.impl.expression.json.JsonQueryFunction)

Aggregations

MapIndexScanMetadata (com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata)8 IndexConfig (com.hazelcast.config.IndexConfig)6 JobConfig (com.hazelcast.jet.config.JobConfig)6 IndexFilter (com.hazelcast.sql.impl.exec.scan.index.IndexFilter)6 JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 IndexRangeFilter (com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter)5 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 ConstructorFunction (com.hazelcast.internal.util.ConstructorFunction)1 Vertex (com.hazelcast.jet.core.Vertex)1 KvRowProjector (com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector)1 RowProjectorProcessorSupplier (com.hazelcast.jet.sql.impl.connector.map.RowProjectorProcessorSupplier)1 JsonArrayFunction (com.hazelcast.jet.sql.impl.expression.json.JsonArrayFunction)1 JsonObjectFunction (com.hazelcast.jet.sql.impl.expression.json.JsonObjectFunction)1 JsonParseFunction (com.hazelcast.jet.sql.impl.expression.json.JsonParseFunction)1 JsonQueryFunction (com.hazelcast.jet.sql.impl.expression.json.JsonQueryFunction)1 FieldCollation (com.hazelcast.jet.sql.impl.opt.FieldCollation)1