use of com.hazelcast.sql.impl.SqlRowImpl 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.SqlRowImpl in project hazelcast by hazelcast.
the class SqlNoDeserializationTest method testMember.
@Test
public void testMember() {
try (SqlResult res = instance().getSql().execute(SQL)) {
for (SqlRow row : res) {
SqlRowImpl row0 = (SqlRowImpl) row;
row0.getObjectRaw(0);
row0.getObjectRaw(1);
checkFailure(row, true);
checkFailure(row, false);
}
}
}
use of com.hazelcast.sql.impl.SqlRowImpl 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