Search in sources :

Example 1 with SqlRowImpl

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);
    }
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) SqlRow(com.hazelcast.sql.SqlRow) SqlRowImpl(com.hazelcast.sql.impl.SqlRowImpl) ArrayList(java.util.ArrayList) Data(com.hazelcast.internal.serialization.Data) SqlRowMetadata(com.hazelcast.sql.SqlRowMetadata) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) SqlColumnMetadata(com.hazelcast.sql.SqlColumnMetadata) SqlPage(com.hazelcast.sql.impl.client.SqlPage)

Example 2 with SqlRowImpl

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);
        }
    }
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) SqlRowImpl(com.hazelcast.sql.impl.SqlRowImpl) SqlResult(com.hazelcast.sql.SqlResult) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with SqlRowImpl

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());
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) SqlRowImpl(com.hazelcast.sql.impl.SqlRowImpl) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

SqlRowImpl (com.hazelcast.sql.impl.SqlRowImpl)3 SqlRow (com.hazelcast.sql.SqlRow)2 JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 Data (com.hazelcast.internal.serialization.Data)1 SqlColumnMetadata (com.hazelcast.sql.SqlColumnMetadata)1 SqlResult (com.hazelcast.sql.SqlResult)1 SqlRowMetadata (com.hazelcast.sql.SqlRowMetadata)1 SqlPage (com.hazelcast.sql.impl.client.SqlPage)1 ArrayList (java.util.ArrayList)1