use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class TokenFct method getKeyTypes.
private static AbstractType[] getKeyTypes(TableMetadata metadata) {
AbstractType[] types = new AbstractType[metadata.partitionKeyColumns().size()];
int i = 0;
for (ColumnMetadata def : metadata.partitionKeyColumns()) types[i++] = def.type;
return types;
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class RestrictionSet method mergeRestrictions.
private TreeMap<ColumnMetadata, SingleRestriction> mergeRestrictions(TreeMap<ColumnMetadata, SingleRestriction> restrictions, SingleRestriction restriction) {
Collection<ColumnMetadata> columnDefs = restriction.getColumnDefs();
Set<SingleRestriction> existingRestrictions = getRestrictions(columnDefs);
if (existingRestrictions.isEmpty()) {
for (ColumnMetadata columnDef : columnDefs) restrictions.put(columnDef, restriction);
} else {
for (SingleRestriction existing : existingRestrictions) {
SingleRestriction newRestriction = mergeRestrictions(existing, restriction);
for (ColumnMetadata columnDef : columnDefs) restrictions.put(columnDef, newRestriction);
}
}
return restrictions;
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class AbstractClusteringIndexFilter method appendOrderByToCQLString.
protected void appendOrderByToCQLString(TableMetadata metadata, StringBuilder sb) {
if (reversed) {
sb.append(" ORDER BY (");
int i = 0;
for (ColumnMetadata column : metadata.clusteringColumns()) sb.append(i++ == 0 ? "" : ", ").append(column.name).append(column.type instanceof ReversedType ? " ASC" : " DESC");
sb.append(')');
}
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class UnfilteredSerializer method serializedRowBodySize.
private long serializedRowBodySize(Row row, SerializationHeader header, long previousUnfilteredSize, int version) {
long size = 0;
if (header.isForSSTable())
size += TypeSizes.sizeofUnsignedVInt(previousUnfilteredSize);
boolean isStatic = row.isStatic();
Columns headerColumns = header.columns(isStatic);
LivenessInfo pkLiveness = row.primaryKeyLivenessInfo();
Row.Deletion deletion = row.deletion();
boolean hasComplexDeletion = row.hasComplexDeletion();
boolean hasAllColumns = (row.size() == headerColumns.size());
if (!pkLiveness.isEmpty())
size += header.timestampSerializedSize(pkLiveness.timestamp());
if (pkLiveness.isExpiring()) {
size += header.ttlSerializedSize(pkLiveness.ttl());
size += header.localDeletionTimeSerializedSize(pkLiveness.localExpirationTime());
}
if (!deletion.isLive())
size += header.deletionTimeSerializedSize(deletion.time());
if (!hasAllColumns)
size += Columns.serializer.serializedSubsetSize(Collections2.transform(row, ColumnData::column), header.columns(isStatic));
SearchIterator<ColumnMetadata, ColumnMetadata> si = headerColumns.iterator();
for (ColumnData data : row) {
ColumnMetadata column = si.next(data.column());
assert column != null;
if (data.column.isSimple())
size += Cell.serializer.serializedSize((Cell) data, column, pkLiveness, header);
else
size += sizeOfComplexColumn((ComplexColumnData) data, column, hasComplexDeletion, pkLiveness, header);
}
return size;
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class ViewUpdateGenerator method computeLivenessInfoForEntry.
private LivenessInfo computeLivenessInfoForEntry(Row baseRow) {
// This may change, but is currently an enforced limitation
assert view.baseNonPKColumnsInViewPK.size() <= 1;
LivenessInfo baseLiveness = baseRow.primaryKeyLivenessInfo();
if (view.baseNonPKColumnsInViewPK.isEmpty()) {
int ttl = baseLiveness.ttl();
int expirationTime = baseLiveness.localExpirationTime();
for (Cell cell : baseRow.cells()) {
if (cell.ttl() > ttl) {
ttl = cell.ttl();
expirationTime = cell.localDeletionTime();
}
}
return ttl == baseLiveness.ttl() ? baseLiveness : LivenessInfo.withExpirationTime(baseLiveness.timestamp(), ttl, expirationTime);
}
ColumnMetadata baseColumn = view.baseNonPKColumnsInViewPK.get(0);
Cell cell = baseRow.getCell(baseColumn);
assert isLive(cell) : "We shouldn't have got there if the base row had no associated entry";
long timestamp = Math.max(baseLiveness.timestamp(), cell.timestamp());
return LivenessInfo.withExpirationTime(timestamp, cell.ttl(), cell.localDeletionTime());
}
Aggregations