use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class MapIndexScanPTest method test_fullScanDesc_sorted.
@Test
public void test_fullScanDesc_sorted() {
List<JetSqlRow> expected = new ArrayList<>();
for (int i = 0; i <= count; i++) {
map.put(i, new Person("value-" + i, i));
expected.add(jetRow((count - i), "value-" + (count - i), (count - i)));
}
IndexConfig indexConfig = new IndexConfig(IndexType.SORTED, "age").setName(randomName());
map.addIndex(indexConfig);
IndexFilter filter = new IndexRangeFilter(null, true, null, true);
MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, 2, true);
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);
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class TestAbstractSqlConnector method fullScanReader.
@Nonnull
@Override
public Vertex fullScanReader(@Nonnull DAG dag, @Nonnull Table table_, @Nullable Expression<Boolean> predicate, @Nonnull List<Expression<?>> projection, @Nullable FunctionEx<ExpressionEvalContext, EventTimePolicy<JetSqlRow>> eventTimePolicyProvider) {
TestTable table = (TestTable) table_;
List<Object[]> rows = table.rows;
boolean streaming = table.streaming;
FunctionEx<Context, TestDataGenerator> createContextFn = ctx -> {
ExpressionEvalContext evalContext = ExpressionEvalContext.from(ctx);
EventTimePolicy<JetSqlRow> eventTimePolicy = eventTimePolicyProvider == null ? EventTimePolicy.noEventTime() : eventTimePolicyProvider.apply(evalContext);
return new TestDataGenerator(rows, predicate, projection, evalContext, eventTimePolicy, streaming);
};
ProcessorMetaSupplier pms = createProcessorSupplier(createContextFn);
return dag.newUniqueVertex(table.toString(), pms);
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class TestAllTypesSqlConnector method fullScanReader.
@Nonnull
@Override
public Vertex fullScanReader(@Nonnull DAG dag, @Nonnull Table table, @Nullable Expression<Boolean> predicate, @Nonnull List<Expression<?>> projection, @Nullable FunctionEx<ExpressionEvalContext, EventTimePolicy<JetSqlRow>> eventTimePolicyProvider) {
if (eventTimePolicyProvider != null) {
throw QueryException.error("Ordering function are not supported for " + TYPE_NAME + " mappings");
}
BatchSource<JetSqlRow> source = SourceBuilder.batch("batch", ExpressionEvalContext::from).<JetSqlRow>fillBufferFn((ctx, buf) -> {
JetSqlRow row = ExpressionUtil.evaluate(predicate, projection, VALUES, ctx);
if (row != null) {
buf.add(row);
}
buf.close();
}).build();
ProcessorMetaSupplier pms = ((BatchSourceTransform<JetSqlRow>) source).metaSupplier;
return dag.newUniqueVertex(table.toString(), pms);
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class SqlPageCodecTest method check.
private void check(SqlColumnType type, List<Object> values, boolean last) {
SqlRowMetadata rowMetadata = new SqlRowMetadata(Collections.singletonList(new SqlColumnMetadata("a", type, true)));
List<SqlRow> rows = new ArrayList<>();
for (Object value : values) {
if (SqlPage.convertToData(type) && value != null) {
value = serializationService.toData(value);
}
rows.add(new SqlRowImpl(rowMetadata, new JetSqlRow(TEST_SS, new Object[] { value })));
}
SqlPage originalPage = SqlPage.fromRows(Collections.singletonList(type), rows, last, serializationService);
ClientMessage message = ClientMessage.createForEncode();
SqlPageCodec.encode(message, originalPage);
SqlPage restoredPage = SqlPageCodec.decode(message.frameIterator());
assertEquals(1, restoredPage.getColumnCount());
assertEquals(values.size(), restoredPage.getRowCount());
assertEquals(last, restoredPage.isLast());
assertEquals(1, restoredPage.getColumnTypes().size());
assertEquals(type, restoredPage.getColumnTypes().get(0));
for (int i = 0; i < values.size(); i++) {
Object value = values.get(i);
Object restoredValue = restoredPage.getColumnValueForClient(0, i);
if (restoredValue instanceof Data) {
assertTrue(SqlPage.convertToData(type));
restoredValue = serializationService.toObject(restoredValue);
}
assertEquals(value, restoredValue);
}
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class SqlMetadataTest method testRow.
@Test
public void testRow() {
SqlColumnMetadata column0Metadata = new SqlColumnMetadata("a", SqlColumnType.INTEGER, true);
SqlColumnMetadata column1Metadata = new SqlColumnMetadata("b", SqlColumnType.VARCHAR, true);
SqlRow row = new SqlRowImpl(new SqlRowMetadata(Arrays.asList(column0Metadata, column1Metadata)), new JetSqlRow(TEST_SS, new Object[] { 1, "2" }));
assertEquals("[a INTEGER=1, b VARCHAR=2]", row.toString());
}
Aggregations