Search in sources :

Example 36 with ColumnIdentifier

use of org.apache.cassandra.cql3.ColumnIdentifier in project cassandra by apache.

the class AbstractPendingAntiCompactionTest method setup.

@Before
public void setup() {
    ks = "ks_" + System.currentTimeMillis();
    cfm = CreateTableStatement.parse(String.format("CREATE TABLE %s.%s (k INT PRIMARY KEY, v INT)", ks, tbl), ks).build();
    Indexes.Builder indexes = Indexes.builder();
    indexes.add(IndexMetadata.fromIndexTargets(Collections.singletonList(new IndexTarget(new ColumnIdentifier("v", true), IndexTarget.Type.VALUES)), tbl2 + "_idx", IndexMetadata.Kind.COMPOSITES, Collections.emptyMap()));
    TableMetadata cfm2 = CreateTableStatement.parse(String.format("CREATE TABLE %s.%s (k INT PRIMARY KEY, v INT)", ks, tbl2), ks).indexes(indexes.build()).build();
    SchemaLoader.createKeyspace(ks, KeyspaceParams.simple(1), cfm, cfm2);
    cfs = Schema.instance.getColumnFamilyStoreInstance(cfm.id);
    cfs2 = Schema.instance.getColumnFamilyStoreInstance(cfm2.id);
}
Also used : TableMetadata(org.apache.cassandra.schema.TableMetadata) IndexTarget(org.apache.cassandra.cql3.statements.schema.IndexTarget) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier) Indexes(org.apache.cassandra.schema.Indexes) Before(org.junit.Before)

Example 37 with ColumnIdentifier

use of org.apache.cassandra.cql3.ColumnIdentifier in project cassandra by apache.

the class Util method makeSomePagingState.

public static PagingState makeSomePagingState(ProtocolVersion protocolVersion, int remainingInPartition) {
    TableMetadata metadata = TableMetadata.builder("ks", "tbl").addPartitionKeyColumn("k", AsciiType.instance).addClusteringColumn("c1", AsciiType.instance).addClusteringColumn("c2", Int32Type.instance).addRegularColumn("myCol", AsciiType.instance).build();
    ByteBuffer pk = ByteBufferUtil.bytes("someKey");
    ColumnMetadata def = metadata.getColumn(new ColumnIdentifier("myCol", false));
    Clustering<?> c = Clustering.make(ByteBufferUtil.bytes("c1"), ByteBufferUtil.bytes(42));
    Row row = BTreeRow.singleCellRow(c, BufferCell.live(def, 0, ByteBufferUtil.EMPTY_BYTE_BUFFER));
    PagingState.RowMark mark = PagingState.RowMark.create(metadata, row, protocolVersion);
    return new PagingState(pk, mark, 10, remainingInPartition);
}
Also used : TableMetadata(org.apache.cassandra.schema.TableMetadata) ColumnMetadata(org.apache.cassandra.schema.ColumnMetadata) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier) ByteBuffer(java.nio.ByteBuffer) PagingState(org.apache.cassandra.service.pager.PagingState)

Example 38 with ColumnIdentifier

use of org.apache.cassandra.cql3.ColumnIdentifier in project cassandra by apache.

the class SchemaLoader method compositeIndexCFMD.

public static TableMetadata.Builder compositeIndexCFMD(String ksName, String cfName, boolean withRegularIndex, boolean withStaticIndex) throws ConfigurationException {
    // the withIndex flag exists to allow tests index creation
    // on existing columns
    TableMetadata.Builder builder = TableMetadata.builder(ksName, cfName).addPartitionKeyColumn("key", AsciiType.instance).addClusteringColumn("c1", AsciiType.instance).addRegularColumn("birthdate", LongType.instance).addRegularColumn("notbirthdate", LongType.instance).addStaticColumn("static", LongType.instance).compression(getCompressionParameters());
    Indexes.Builder indexes = Indexes.builder();
    if (withRegularIndex) {
        indexes.add(IndexMetadata.fromIndexTargets(Collections.singletonList(new IndexTarget(new ColumnIdentifier("birthdate", true), IndexTarget.Type.VALUES)), cfName + "_birthdate_key_index", IndexMetadata.Kind.COMPOSITES, Collections.EMPTY_MAP));
    }
    if (withStaticIndex) {
        indexes.add(IndexMetadata.fromIndexTargets(Collections.singletonList(new IndexTarget(new ColumnIdentifier("static", true), IndexTarget.Type.VALUES)), cfName + "_static_index", IndexMetadata.Kind.COMPOSITES, Collections.EMPTY_MAP));
    }
    return builder.indexes(indexes.build());
}
Also used : IndexTarget(org.apache.cassandra.cql3.statements.schema.IndexTarget) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier)

Example 39 with ColumnIdentifier

use of org.apache.cassandra.cql3.ColumnIdentifier in project cassandra by apache.

the class SchemaLoader method customIndexCFMD.

public static TableMetadata.Builder customIndexCFMD(String ksName, String cfName) {
    TableMetadata.Builder builder = TableMetadata.builder(ksName, cfName).addPartitionKeyColumn("key", AsciiType.instance).addClusteringColumn("c1", AsciiType.instance).addRegularColumn("value", LongType.instance).compression(getCompressionParameters());
    IndexMetadata index = IndexMetadata.fromIndexTargets(Collections.singletonList(new IndexTarget(new ColumnIdentifier("value", true), IndexTarget.Type.VALUES)), cfName + "_value_index", IndexMetadata.Kind.CUSTOM, Collections.singletonMap(IndexTarget.CUSTOM_INDEX_OPTION_NAME, StubIndex.class.getName()));
    builder.indexes(Indexes.of(index));
    return builder;
}
Also used : IndexTarget(org.apache.cassandra.cql3.statements.schema.IndexTarget) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier)

Example 40 with ColumnIdentifier

use of org.apache.cassandra.cql3.ColumnIdentifier in project cassandra by apache.

the class BurnTestUtil method generateRows.

public static ResultMessage.Rows generateRows(int idx, SizeCaps sizeCaps) {
    Random rnd = new Random(idx);
    List<ColumnSpecification> columns = new ArrayList<>();
    for (int i = 0; i < sizeCaps.columnCountCap; i++) {
        columns.add(new ColumnSpecification("ks", "cf", new ColumnIdentifier(bytes(rnd, 5, 10), BytesType.instance), BytesType.instance));
    }
    List<List<ByteBuffer>> rows = new ArrayList<>();
    int count = rnd.nextInt(sizeCaps.rowsCountCap);
    for (int i = 0; i < count; i++) {
        List<ByteBuffer> row = new ArrayList<>();
        for (int j = 0; j < sizeCaps.columnCountCap; j++) row.add(bytes(rnd, sizeCaps.valueMinSize, sizeCaps.valueMaxSize));
        rows.add(row);
    }
    ResultSet resultSet = new ResultSet(new ResultSet.ResultMetadata(columns), rows);
    return new ResultMessage.Rows(resultSet);
}
Also used : ColumnSpecification(org.apache.cassandra.cql3.ColumnSpecification) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Random(java.util.Random) ResultSet(org.apache.cassandra.cql3.ResultSet) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)43 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)26 Test (org.junit.Test)15 TableMetadata (org.apache.cassandra.schema.TableMetadata)14 Row (org.apache.cassandra.db.rows.Row)10 ByteBuffer (java.nio.ByteBuffer)9 IndexTarget (org.apache.cassandra.cql3.statements.schema.IndexTarget)8 java.util (java.util)4 ArrayList (java.util.ArrayList)4 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)4 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)4 PartitionUpdate (org.apache.cassandra.db.partitions.PartitionUpdate)4 RowIterator (org.apache.cassandra.db.rows.RowIterator)4 ClientState (org.apache.cassandra.service.ClientState)4 Iterables (com.google.common.collect.Iterables)3 StatementRestrictions (org.apache.cassandra.cql3.restrictions.StatementRestrictions)3 UnfilteredRowIterator (org.apache.cassandra.db.rows.UnfilteredRowIterator)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables.transform (com.google.common.collect.Iterables.transform)2 Lists (com.google.common.collect.Lists)2