Search in sources :

Example 11 with ResultSet

use of com.datastax.oss.driver.api.core.cql.ResultSet in project janusgraph by JanusGraph.

the class CQLResultSetKeyIteratorTest method testUneven.

@Test
public void testUneven() throws IOException {
    final Array<Tuple2<ByteBuffer, Array<Tuple2<ByteBuffer, ByteBuffer>>>> keysMap = generateRandomKeysMap();
    final ResultSet resultSet = generateMockedResultSet(keysMap);
    final CQLColValGetter getter = new CQLColValGetter(new EntryMetaData[0]);
    try (final CQLResultSetKeyIterator resultSetKeyIterator = new CQLResultSetKeyIterator(ALL_COLUMNS, getter, resultSet)) {
        final Iterator<Tuple2<ByteBuffer, Array<Tuple2<ByteBuffer, ByteBuffer>>>> iterator = keysMap.iterator();
        while (resultSetKeyIterator.hasNext()) {
            final StaticBuffer next = resultSetKeyIterator.next();
            try (final RecordIterator<Entry> entries = resultSetKeyIterator.getEntries()) {
                final Tuple2<ByteBuffer, Array<Tuple2<ByteBuffer, ByteBuffer>>> current = iterator.next();
                final ByteBuffer currentKey = current._1;
                final Array<Tuple2<ByteBuffer, ByteBuffer>> columnValues = current._2;
                final Iterator<Tuple2<ByteBuffer, ByteBuffer>> columnIterator = columnValues.iterator();
                while (entries.hasNext()) {
                    final Entry entry = entries.next();
                    final Tuple2<ByteBuffer, ByteBuffer> columnAndValue = columnIterator.next();
                    assertEquals(currentKey, next.asByteBuffer());
                    assertEquals(columnAndValue._1, entry.getColumn().asByteBuffer());
                    assertEquals(columnAndValue._2, entry.getValue().asByteBuffer());
                    assertEquals(columnIterator.hasNext(), entries.hasNext());
                }
            }
        }
    }
}
Also used : ByteBuffer(java.nio.ByteBuffer) Array(io.vavr.collection.Array) Entry(org.janusgraph.diskstorage.Entry) Tuple2(io.vavr.Tuple2) ResultSet(com.datastax.oss.driver.api.core.cql.ResultSet) StaticBuffer(org.janusgraph.diskstorage.StaticBuffer) Test(org.junit.jupiter.api.Test)

Aggregations

ResultSet (com.datastax.oss.driver.api.core.cql.ResultSet)11 Row (com.datastax.oss.driver.api.core.cql.Row)6 Test (org.junit.jupiter.api.Test)6 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)5 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)5 Tuple2 (io.vavr.Tuple2)4 Entry (org.janusgraph.diskstorage.Entry)4 Select (com.datastax.oss.driver.api.querybuilder.select.Select)3 Array (io.vavr.collection.Array)3 ByteBuffer (java.nio.ByteBuffer)3 Map (java.util.Map)3 Field (io.openmessaging.connector.api.data.Field)2 FieldType (io.openmessaging.connector.api.data.FieldType)2 Random (java.util.Random)2 ColumnParser (org.apache.rocketmq.connect.cassandra.schema.column.ColumnParser)2 Delete (com.datastax.oss.driver.api.querybuilder.delete.Delete)1 DeleteSelection (com.datastax.oss.driver.api.querybuilder.delete.DeleteSelection)1 InsertInto (com.datastax.oss.driver.api.querybuilder.insert.InsertInto)1 RegularInsert (com.datastax.oss.driver.api.querybuilder.insert.RegularInsert)1 Function1 (io.vavr.Function1)1