use of org.apache.cassandra.db.marshal.AbstractType in project cassandra by apache.
the class CassandraIndex method indexCfsMetadata.
/**
* Construct the TableMetadata for an index table, the clustering columns in the index table
* vary dependent on the kind of the indexed value.
* @param baseCfsMetadata
* @param indexMetadata
* @return
*/
public static TableMetadata indexCfsMetadata(TableMetadata baseCfsMetadata, IndexMetadata indexMetadata) {
Pair<ColumnMetadata, IndexTarget.Type> target = TargetParser.parse(baseCfsMetadata, indexMetadata);
CassandraIndexFunctions utils = getFunctions(indexMetadata, target);
ColumnMetadata indexedColumn = target.left;
AbstractType<?> indexedValueType = utils.getIndexedValueType(indexedColumn);
TableMetadata.Builder builder = TableMetadata.builder(baseCfsMetadata.keyspace, baseCfsMetadata.indexTableName(indexMetadata), baseCfsMetadata.id).kind(TableMetadata.Kind.INDEX).partitioner(new LocalPartitioner(indexedValueType)).addPartitionKeyColumn(indexedColumn.name, indexedColumn.type).addClusteringColumn("partition_key", baseCfsMetadata.partitioner.partitionOrdering());
// Adding clustering columns, which depends on the index type.
builder = utils.addIndexClusteringColumns(builder, baseCfsMetadata, indexedColumn);
return builder.build().updateIndexTableMetadata(baseCfsMetadata.params);
}
use of org.apache.cassandra.db.marshal.AbstractType in project cassandra by apache.
the class SecondaryIndexTest method assertIndexedCount.
private void assertIndexedCount(ColumnFamilyStore cfs, ByteBuffer col, Object val, int count) {
ColumnMetadata cdef = cfs.metadata().getColumn(col);
ReadCommand rc = Util.cmd(cfs).filterOn(cdef.name.toString(), Operator.EQ, ((AbstractType) cdef.cellValueType()).decompose(val)).build();
Index.Searcher searcher = rc.getIndex(cfs).searcherFor(rc);
if (count != 0)
assertNotNull(searcher);
try (ReadExecutionController executionController = rc.executionController();
PartitionIterator iter = UnfilteredPartitionIterators.filter(searcher.search(executionController), FBUtilities.nowInSeconds())) {
assertEquals(count, Util.size(iter));
}
}
use of org.apache.cassandra.db.marshal.AbstractType in project cassandra by apache.
the class SerializationHeader method toComponent.
public Component toComponent() {
Map<ByteBuffer, AbstractType<?>> staticColumns = new LinkedHashMap<>();
Map<ByteBuffer, AbstractType<?>> regularColumns = new LinkedHashMap<>();
for (ColumnMetadata column : columns.statics) staticColumns.put(column.name.bytes, column.type);
for (ColumnMetadata column : columns.regulars) regularColumns.put(column.name.bytes, column.type);
return new Component(keyType, clusteringTypes, staticColumns, regularColumns, stats);
}
use of org.apache.cassandra.db.marshal.AbstractType in project cassandra by apache.
the class SSTableHeaderFix method fixTypeInnerTuple.
private AbstractType<?> fixTypeInnerTuple(TupleType cHeader, TupleType cSchema, boolean droppedColumnMode) {
if (cHeader.size() != cSchema.size())
// different number of components - bummer...
return null;
List<AbstractType<?>> cHeaderFixed = new ArrayList<>(cHeader.size());
boolean anyChanged = false;
for (int i = 0; i < cHeader.size(); i++) {
AbstractType<?> cHeaderComp = cHeader.type(i);
AbstractType<?> cHeaderCompFixed = fixTypeInner(cHeaderComp, cSchema.type(i), droppedColumnMode);
if (cHeaderCompFixed == null)
// incompatible, bummer...
return null;
cHeaderFixed.add(cHeaderCompFixed);
anyChanged |= cHeaderComp != cHeaderCompFixed;
}
if (anyChanged || cSchema.isMultiCell() != cHeader.isMultiCell())
// TODO this should create a non-frozen tuple type for the sake of handling a dropped, non-frozen UDT
return new TupleType(cHeaderFixed);
return cHeader;
}
use of org.apache.cassandra.db.marshal.AbstractType in project cassandra by apache.
the class SSTableHeaderFix method validateColumns.
private Map<ByteBuffer, AbstractType<?>> validateColumns(Descriptor desc, TableMetadata tableMetadata, Map<ByteBuffer, AbstractType<?>> columns, ColumnMetadata.Kind kind) {
Map<ByteBuffer, AbstractType<?>> target = new LinkedHashMap<>();
for (Map.Entry<ByteBuffer, AbstractType<?>> nameAndType : columns.entrySet()) {
ByteBuffer name = nameAndType.getKey();
AbstractType<?> type = nameAndType.getValue();
AbstractType<?> fixedType = validateColumn(desc, tableMetadata, kind, name, type);
if (fixedType == null) {
error("sstable %s: contains column '%s' of type '%s', which could not be validated", desc, type, logColumnName(name));
// don't use a "null" type instance
fixedType = type;
}
target.put(name, fixedType);
}
return target;
}
Aggregations