private static List<AbstractType<?>> makeClusteringTypes(CFMetaData metadata) { // This is the types that will be used when serializing the clustering in the paging state. We can't really use the actual clustering // types however because we can't guarantee that there won't be a schema change between when we send the paging state and get it back, // and said schema change could theoretically change one of the clustering types from a fixed width type to a non-fixed one // (say timestamp -> blob). So we simply use a list of BytesTypes (for both reading and writting), which may be slightly inefficient // for fixed-width types, but avoid any risk during schema changes. int size = metadata.clusteringColumns().size(); List<AbstractType<?>> l = new ArrayList<>(size); for (int i = 0; i < size; i++) l.add(BytesType.instance); return l; }
private static List<AbstractType<?>> makeClusteringTypes(CFMetaData metadata) { // This is the types that will be used when serializing the clustering in the paging state. We can't really use the actual clustering // types however because we can't guarantee that there won't be a schema change between when we send the paging state and get it back, // and said schema change could theoretically change one of the clustering types from a fixed width type to a non-fixed one // (say timestamp -> blob). So we simply use a list of BytesTypes (for both reading and writting), which may be slightly inefficient // for fixed-width types, but avoid any risk during schema changes. int size = metadata.clusteringColumns().size(); List<AbstractType<?>> l = new ArrayList<>(size); for (int i = 0; i < size; i++) l.add(BytesType.instance); return l; }
protected void appendOrderByToCQLString(CFMetaData metadata, StringBuilder sb) { if (reversed) { sb.append(" ORDER BY ("); int i = 0; for (ColumnDefinition column : metadata.clusteringColumns()) sb.append(i++ == 0 ? "" : ", ").append(column.name).append(column.type instanceof ReversedType ? " ASC" : " DESC"); sb.append(')'); } }
protected void appendOrderByToCQLString(CFMetaData metadata, StringBuilder sb) { if (reversed) { sb.append(" ORDER BY ("); int i = 0; for (ColumnDefinition column : metadata.clusteringColumns()) sb.append(i++ == 0 ? "" : ", ").append(column.name).append(column.type instanceof ReversedType ? " ASC" : " DESC"); sb.append(')'); } }
private static List<ColumnDefinition> getClusteringColumns(CFMetaData metadata) { List<ColumnDefinition> cds = new ArrayList<>(metadata.clusteringColumns().size()); if (!metadata.isStaticCompactTable()) for (ColumnDefinition cd : metadata.clusteringColumns()) cds.add(cd); return cds; }
private static List<ColumnDefinition> getClusteringColumns(CFMetaData metadata) { List<ColumnDefinition> cds = new ArrayList<>(metadata.clusteringColumns().size()); if (!metadata.isStaticCompactTable()) for (ColumnDefinition cd : metadata.clusteringColumns()) cds.add(cd); return cds; }
/** * Checks if some clustering columns are not restricted. * @return <code>true</code> if some clustering columns are not restricted, <code>false</code> otherwise. */ private boolean hasUnrestrictedClusteringColumns() { return cfm.clusteringColumns().size() != clusteringColumnsRestrictions.size(); }
public boolean updatesRegularRows() { // We're updating regular rows if all the clustering columns are provided. // Note that the only case where we're allowed not to provide clustering // columns is if we set some static columns, and in that case no clustering // columns should be given. So in practice, it's enough to check if we have // either the table has no clustering or if it has at least one of them set. return cfm.clusteringColumns().isEmpty() || restrictions.hasClusteringColumnsRestrictions(); }
/** * Checks if some clustering columns are not restricted. * @return <code>true</code> if some clustering columns are not restricted, <code>false</code> otherwise. */ private boolean hasUnrestrictedClusteringColumns() { return cfm.clusteringColumns().size() != clusteringColumnsRestrictions.size(); }
/** * Checks if some clustering columns are not restricted. * @return <code>true</code> if some clustering columns are not restricted, <code>false</code> otherwise. */ private boolean hasUnrestrictedClusteringColumns() { return cfm.clusteringColumns().size() != clusteringColumnsRestrictions.size(); }
/** * Returns the clustering columns that are not restricted. * @return the clustering columns that are not restricted. */ private Collection<ColumnIdentifier> getUnrestrictedClusteringColumns() { List<ColumnDefinition> missingClusteringColumns = new ArrayList<>(cfm.clusteringColumns()); missingClusteringColumns.removeAll(new LinkedList<>(clusteringColumnsRestrictions.getColumnDefs())); return ColumnDefinition.toIdentifiers(missingClusteringColumns); }
public SelectStatement(CFMetaData cfm, int boundTerms, Parameters parameters, Selection selection, Term limit) { this.cfm = cfm; this.boundTerms = boundTerms; this.selection = selection; this.keyRestrictions = new Restriction[cfm.partitionKeyColumns().size()]; this.columnRestrictions = new Restriction[cfm.clusteringColumns().size()]; this.parameters = parameters; this.limit = limit; // Now gather a few info on whether we should bother with static columns or not for this statement initStaticColumnsInfo(); }
public default String toCQLString(CFMetaData metadata) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < size(); i++) { ColumnDefinition c = metadata.clusteringColumns().get(i); sb.append(i == 0 ? "" : ", ").append(c.type.getString(get(i))); } return sb.toString(); }
public default String toString(CFMetaData metadata) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < size(); i++) { ColumnDefinition c = metadata.clusteringColumns().get(i); sb.append(i == 0 ? "" : ", ").append(c.name).append('=').append(get(i) == null ? "null" : c.type.getString(get(i))); } return sb.toString(); }
public default String toCQLString(CFMetaData metadata) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < size(); i++) { ColumnDefinition c = metadata.clusteringColumns().get(i); sb.append(i == 0 ? "" : ", ").append(c.type.getString(get(i))); } return sb.toString(); }
public default String toString(CFMetaData metadata) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < size(); i++) { ColumnDefinition c = metadata.clusteringColumns().get(i); sb.append(i == 0 ? "" : ", ").append(c.name).append('=').append(get(i) == null ? "null" : c.type.getString(get(i))); } return sb.toString(); }
public CFMetaData.Builder addIndexClusteringColumns(CFMetaData.Builder builder, CFMetaData baseMetadata, ColumnDefinition columnDef) { for (ColumnDefinition def : baseMetadata.clusteringColumns()) builder.addClusteringColumn(def.name, def.type); // collection key builder.addClusteringColumn("cell_path", ((CollectionType)columnDef.type).nameComparator()); return builder; } };
public CFMetaData.Builder addIndexClusteringColumns(CFMetaData.Builder builder, CFMetaData baseMetadata, ColumnDefinition columnDef) { for (ColumnDefinition def : baseMetadata.clusteringColumns()) builder.addClusteringColumn(def.name, def.type); // collection key builder.addClusteringColumn("cell_path", ((CollectionType)columnDef.type).nameComparator()); return builder; } };
protected Composite makeIndexColumnPrefix(ByteBuffer rowKey, Composite cellName) { int count = 1 + baseCfs.metadata.clusteringColumns().size(); CBuilder builder = getIndexComparator().builder(); builder.add(rowKey); for (int i = 0; i < Math.min(cellName.size(), count - 1); i++) builder.add(cellName.get(i)); return builder.build(); }
public IndexEntry decodeEntry(DecoratedKey indexedValue, Row indexEntry) { int ckCount = baseCfs.metadata.clusteringColumns().size(); Clustering clustering = indexEntry.clustering(); CBuilder builder = CBuilder.create(baseCfs.getComparator()); for (int i = 0; i < ckCount; i++) builder.add(clustering.get(i + 1)); return new IndexEntry(indexedValue, clustering, indexEntry.primaryKeyLivenessInfo().timestamp(), clustering.get(0), builder.build()); }