Search in sources :

Example 11 with JetSqlRow

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

the class CreateDagVisitor method onAccumulateByKey.

public Vertex onAccumulateByKey(AggregateAccumulateByKeyPhysicalRel rel) {
    FunctionEx<JetSqlRow, ?> groupKeyFn = rel.groupKeyFn();
    AggregateOperation<?, JetSqlRow> aggregateOperation = rel.aggrOp();
    Vertex vertex = dag.newUniqueVertex("AccumulateByKey", Processors.accumulateByKeyP(singletonList(groupKeyFn), aggregateOperation));
    connectInput(rel.getInput(), vertex, edge -> edge.partitioned(groupKeyFn));
    return vertex;
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Example 12 with JetSqlRow

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

the class CreateDagVisitor method onAggregate.

public Vertex onAggregate(AggregatePhysicalRel rel) {
    AggregateOperation<?, JetSqlRow> aggregateOperation = rel.aggrOp();
    Vertex vertex = dag.newUniqueVertex("Aggregate", ProcessorMetaSupplier.forceTotalParallelismOne(ProcessorSupplier.of(Processors.aggregateP(aggregateOperation)), localMemberAddress));
    connectInput(rel.getInput(), vertex, edge -> edge.distributeTo(localMemberAddress).allToOne(""));
    return vertex;
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Example 13 with JetSqlRow

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

the class ProjectorTest method test_project.

@Test
public void test_project() {
    Projector projector = new Projector(new QueryPath[] { QueryPath.create("this.field") }, new QueryDataType[] { QueryDataType.BIGINT }, new MultiplyingTarget(), singletonList(CastExpression.create(ColumnExpression.create(0, QueryDataType.INT), QueryDataType.BIGINT)), mock(ExpressionEvalContext.class));
    Object value = projector.project(new JetSqlRow(TEST_SS, new Object[] { 1 }));
    assertThat(value).isEqualTo(2L);
}
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 14 with JetSqlRow

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

the class KvRowProjectorTest method test_project_onlyDataKeyAndValueIsProvided.

@Test
public void test_project_onlyDataKeyAndValueIsProvided() {
    InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    KvRowProjector projector = new KvRowProjector(new QueryPath[] { QueryPath.KEY_PATH, QueryPath.VALUE_PATH }, new QueryDataType[] { INT, INT }, new GenericQueryTarget(serializationService, null, true), new GenericQueryTarget(serializationService, null, false), null, asList(MultiplyFunction.create(ColumnExpression.create(0, INT), ConstantExpression.create(2, INT), INT), DivideFunction.create(ColumnExpression.create(1, INT), ConstantExpression.create(2, INT), INT)), SqlTestSupport.createExpressionEvalContext());
    JetSqlRow row = projector.project(serializationService.toData(1), serializationService.toData(8));
    assertThat(row).isEqualTo(jetRow(2, 4));
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) GenericQueryTarget(com.hazelcast.sql.impl.extract.GenericQueryTarget) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 15 with JetSqlRow

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

the class RowProjectorTest method when_filteredByPredicate_then_returnsNull.

@Test
@SuppressWarnings("unchecked")
public void when_filteredByPredicate_then_returnsNull() {
    RowProjector projector = new RowProjector(new String[] { "target" }, new QueryDataType[] { INT }, new IdentityTarget(), (Expression<Boolean>) ConstantExpression.create(Boolean.FALSE, BOOLEAN), emptyList(), mock(ExpressionEvalContext.class));
    JetSqlRow row = projector.project(1);
    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)

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