Search in sources :

Example 6 with ColumnSpec

use of com.datastax.oss.protocol.internal.response.result.ColumnSpec in project java-driver by datastax.

the class Conversions method toColumnDefinitions.

public static ColumnDefinitions toColumnDefinitions(RowsMetadata metadata, InternalDriverContext context) {
    ColumnDefinition[] values = new ColumnDefinition[metadata.columnSpecs.size()];
    int i = 0;
    for (ColumnSpec columnSpec : metadata.columnSpecs) {
        values[i++] = new DefaultColumnDefinition(columnSpec, context);
    }
    return DefaultColumnDefinitions.valueOf(ImmutableList.copyOf(values));
}
Also used : ColumnSpec(com.datastax.oss.protocol.internal.response.result.ColumnSpec) ColumnDefinition(com.datastax.oss.driver.api.core.cql.ColumnDefinition)

Example 7 with ColumnSpec

use of com.datastax.oss.protocol.internal.response.result.ColumnSpec in project java-driver by datastax.

the class DseTestFixtures method singleDseRow.

// Returns a single row, with a single "message" column with the value "hello, world"
public static Rows singleDseRow() {
    DseRowsMetadata metadata = new DseRowsMetadata(ImmutableList.of(new ColumnSpec("ks", "table", "message", 0, RawType.PRIMITIVES.get(ProtocolConstants.DataType.VARCHAR))), null, new int[] {}, null, 1, true);
    Queue<List<ByteBuffer>> data = new ArrayDeque<>();
    data.add(ImmutableList.of(Bytes.fromHexString("0x68656C6C6F2C20776F726C64")));
    return new DefaultRows(metadata, data);
}
Also used : ColumnSpec(com.datastax.oss.protocol.internal.response.result.ColumnSpec) DefaultRows(com.datastax.oss.protocol.internal.response.result.DefaultRows) ImmutableList(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList) List(java.util.List) DseRowsMetadata(com.datastax.dse.protocol.internal.response.result.DseRowsMetadata) ArrayDeque(java.util.ArrayDeque)

Example 8 with ColumnSpec

use of com.datastax.oss.protocol.internal.response.result.ColumnSpec in project java-driver by datastax.

the class ReprepareOnUpTest method preparedIdRows.

private Rows preparedIdRows(char... values) {
    ColumnSpec preparedIdSpec = new ColumnSpec("system", "prepared_statements", "prepared_id", 0, RawType.PRIMITIVES.get(ProtocolConstants.DataType.BLOB));
    RowsMetadata rowsMetadata = new RowsMetadata(ImmutableList.of(preparedIdSpec), null, null, null);
    Queue<List<ByteBuffer>> data = new ArrayDeque<>();
    for (char value : values) {
        data.add(ImmutableList.of(Bytes.fromHexString("0x0" + value)));
    }
    return new DefaultRows(rowsMetadata, data);
}
Also used : RowsMetadata(com.datastax.oss.protocol.internal.response.result.RowsMetadata) ColumnSpec(com.datastax.oss.protocol.internal.response.result.ColumnSpec) DefaultRows(com.datastax.oss.protocol.internal.response.result.DefaultRows) ImmutableList(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList) List(java.util.List) ArrayDeque(java.util.ArrayDeque)

Example 9 with ColumnSpec

use of com.datastax.oss.protocol.internal.response.result.ColumnSpec in project java-driver by datastax.

the class TestResponses method clusterNameResponse.

/**
 * The response to the query run by each connection to check if the cluster name matches.
 */
public static Rows clusterNameResponse(String actualClusterName) {
    ColumnSpec colSpec = new ColumnSpec("system", "local", "cluster_name", 0, RawType.PRIMITIVES.get(ProtocolConstants.DataType.VARCHAR));
    RowsMetadata metadata = new RowsMetadata(ImmutableList.of(colSpec), null, null, null);
    Queue<List<ByteBuffer>> data = Lists.newLinkedList();
    data.add(Lists.newArrayList(ByteBuffer.wrap(actualClusterName.getBytes(Charsets.UTF_8))));
    return new DefaultRows(metadata, data);
}
Also used : RowsMetadata(com.datastax.oss.protocol.internal.response.result.RowsMetadata) ColumnSpec(com.datastax.oss.protocol.internal.response.result.ColumnSpec) DefaultRows(com.datastax.oss.protocol.internal.response.result.DefaultRows) ImmutableList(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList) List(java.util.List)

Example 10 with ColumnSpec

use of com.datastax.oss.protocol.internal.response.result.ColumnSpec in project java-driver by datastax.

the class RequestLogFormatterTest method mockPreparedStatement.

private PreparedStatement mockPreparedStatement(String query, Map<String, DataType> variables) {
    ImmutableList.Builder<ColumnDefinition> definitions = ImmutableList.builder();
    int i = 0;
    for (Map.Entry<String, DataType> entry : variables.entrySet()) {
        definitions.add(new DefaultColumnDefinition(new ColumnSpec("test", "foo", entry.getKey(), i, RawType.PRIMITIVES.get(entry.getValue().getProtocolCode())), context));
    }
    return new DefaultPreparedStatement(Bytes.fromHexString("0x"), query, DefaultColumnDefinitions.valueOf(definitions.build()), Collections.emptyList(), null, null, null, Collections.emptyMap(), null, null, null, null, null, Collections.emptyMap(), null, null, null, Integer.MIN_VALUE, null, null, false, context.getCodecRegistry(), context.getProtocolVersion());
}
Also used : DefaultPreparedStatement(com.datastax.oss.driver.internal.core.cql.DefaultPreparedStatement) ColumnSpec(com.datastax.oss.protocol.internal.response.result.ColumnSpec) ImmutableList(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList) DefaultColumnDefinition(com.datastax.oss.driver.internal.core.cql.DefaultColumnDefinition) DataType(com.datastax.oss.driver.api.core.type.DataType) ImmutableMap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap) Map(java.util.Map) DefaultColumnDefinition(com.datastax.oss.driver.internal.core.cql.DefaultColumnDefinition) ColumnDefinition(com.datastax.oss.driver.api.core.cql.ColumnDefinition)

Aggregations

ColumnSpec (com.datastax.oss.protocol.internal.response.result.ColumnSpec)10 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)8 DefaultRows (com.datastax.oss.protocol.internal.response.result.DefaultRows)7 List (java.util.List)7 ArrayDeque (java.util.ArrayDeque)6 DseRowsMetadata (com.datastax.dse.protocol.internal.response.result.DseRowsMetadata)4 RowsMetadata (com.datastax.oss.protocol.internal.response.result.RowsMetadata)4 ColumnDefinition (com.datastax.oss.driver.api.core.cql.ColumnDefinition)2 DefaultRemoteTraverser (org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser)2 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 DetachedVertex (org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex)2 DataType (com.datastax.oss.driver.api.core.type.DataType)1 DefaultColumnDefinition (com.datastax.oss.driver.internal.core.cql.DefaultColumnDefinition)1 DefaultPreparedStatement (com.datastax.oss.driver.internal.core.cql.DefaultPreparedStatement)1 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)1 Prepared (com.datastax.oss.protocol.internal.response.result.Prepared)1 Map (java.util.Map)1