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);
}
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);
}
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());
}
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;
}
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);
}
Aggregations