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);
}
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();
}
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 });
}
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();
}
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);
}
Aggregations