Search in sources :

Example 26 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class KvProjectorTest method test_project.

@Test
public void test_project() {
    KvProjector projector = new KvProjector(new QueryPath[] { QueryPath.KEY_PATH, QueryPath.VALUE_PATH }, new QueryDataType[] { QueryDataType.INT, QueryDataType.INT }, new MultiplyingTarget(), new MultiplyingTarget(), false);
    Entry<Object, Object> entry = projector.project(new JetSqlRow(TEST_SS, new Object[] { 1, 2 }));
    assertThat(entry.getKey()).isEqualTo(2);
    assertThat(entry.getValue()).isEqualTo(4);
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class KvRowProjectorTest method when_filteredByPredicate_then_returnsNull.

@Test
@SuppressWarnings("unchecked")
public void when_filteredByPredicate_then_returnsNull() {
    KvRowProjector projector = new KvRowProjector(new QueryPath[] { QueryPath.KEY_PATH, QueryPath.VALUE_PATH }, new QueryDataType[] { INT, INT }, new IdentityTarget(), new IdentityTarget(), (Expression<Boolean>) ConstantExpression.create(Boolean.FALSE, BOOLEAN), emptyList(), mock(ExpressionEvalContext.class));
    JetSqlRow row = projector.project(1, 8);
    assertThat(row).isNull();
}
Also used : ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class KvRowProjectorTest method test_project.

@Test
public void test_project() {
    KvRowProjector projector = new KvRowProjector(new QueryPath[] { QueryPath.KEY_PATH, QueryPath.VALUE_PATH }, new QueryDataType[] { INT, INT }, new IdentityTarget(), new IdentityTarget(), null, asList(MultiplyFunction.create(ColumnExpression.create(0, INT), ConstantExpression.create(2, INT), INT), DivideFunction.create(ColumnExpression.create(1, INT), ConstantExpression.create(2, INT), INT)), mock(ExpressionEvalContext.class));
    JetSqlRow row = projector.project(1, 8);
    assertThat(row.getValues()).isEqualTo(new Object[] { 2, 4 });
}
Also used : ExpressionEvalContext(com.hazelcast.sql.impl.expression.ExpressionEvalContext) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class KvProjectorTest method test_projectAllowNulls.

@Test
public void test_projectAllowNulls() {
    KvProjector projector = new KvProjector(new QueryPath[] { QueryPath.KEY_PATH, QueryPath.VALUE_PATH }, new QueryDataType[] { QueryDataType.INT, QueryDataType.INT }, new NullTarget(), new NullTarget(), false);
    Entry<Object, Object> entry = projector.project(new JetSqlRow(TEST_SS, new Object[] { 1, 2 }));
    assertThat(entry.getKey()).isNull();
    assertThat(entry.getValue()).isNull();
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 30 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow 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)

Aggregations

JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)50 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)16 QuickTest (com.hazelcast.test.annotation.QuickTest)16 Test (org.junit.Test)16 ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)15 ArrayList (java.util.ArrayList)14 Vertex (com.hazelcast.jet.core.Vertex)13 List (java.util.List)9 IndexConfig (com.hazelcast.config.IndexConfig)8 JobConfig (com.hazelcast.jet.config.JobConfig)8 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)8 NodeEngine (com.hazelcast.spi.impl.NodeEngine)8 Expression (com.hazelcast.sql.impl.expression.Expression)8 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)8 FunctionEx (com.hazelcast.function.FunctionEx)7 QueryParameterMetadata (com.hazelcast.sql.impl.QueryParameterMetadata)7 DAG (com.hazelcast.jet.core.DAG)6 ObjectArrayKey (com.hazelcast.jet.sql.impl.ObjectArrayKey)6 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)5 Traverser (com.hazelcast.jet.Traverser)5