public boolean removeColumnDefinition(ColumnDefinition def) { assert !def.isPartitionKey(); boolean removed = columnMetadata.remove(def.name.bytes) != null; if (removed) partitionColumns = partitionColumns.without(def); return removed; }
public boolean removeColumnDefinition(ColumnDefinition def) { assert !def.isPartitionKey(); boolean removed = columnMetadata.remove(def.name.bytes) != null; if (removed) partitionColumns = partitionColumns.without(def); return removed; }
public boolean removeColumnDefinition(ColumnDefinition def) { assert !def.isPartitionKey(); boolean removed = columnMetadata.remove(def.name.bytes) != null; if (removed) partitionColumns = partitionColumns.without(def); return removed; }
private static boolean getColumnIdentifier(CFMetaData cfm, Set<ColumnIdentifier> basePK, boolean hasNonPKColumn, ColumnDefinition.Raw raw, List<ColumnIdentifier> columns, StatementRestrictions restrictions) { ColumnDefinition def = raw.prepare(cfm); boolean isPk = basePK.contains(def.name); if (!isPk && hasNonPKColumn) throw new InvalidRequestException(String.format("Cannot include more than one non-primary key column '%s' in materialized view primary key", def.name)); // We don't need to include the "IS NOT NULL" filter on a non-composite partition key // because we will never allow a single partition key to be NULL boolean isSinglePartitionKey = def.isPartitionKey() && cfm.partitionKeyColumns().size() == 1; if (!isSinglePartitionKey && !restrictions.isRestricted(def)) throw new InvalidRequestException(String.format("Primary key column '%s' is required to be filtered by 'IS NOT NULL'", def.name)); columns.add(def.name); return !isPk; } }
private void validatePartitionKey(DecoratedKey partitionKey) throws InvalidRequestException { assert indexedColumn.isPartitionKey(); validateIndexedValue(getIndexedValue(partitionKey.getKey(), null, null)); }
private void validatePartitionKey(DecoratedKey partitionKey) throws InvalidRequestException { assert indexedColumn.isPartitionKey(); validateIndexedValue(getIndexedValue(partitionKey.getKey(), null, null)); }
private void validatePartitionKey(DecoratedKey partitionKey) throws InvalidRequestException { assert indexedColumn.isPartitionKey(); validateIndexedValue(getIndexedValue(partitionKey.getKey(), null, null)); }
/** * Checks if this selection contains only static columns. * @return <code>true</code> if this selection contains only static columns, <code>false</code> otherwise; */ public boolean containsOnlyStaticColumns() { if (!containsStaticColumns()) return false; if (isWildcard()) return false; for (ColumnDefinition def : getColumns()) { if (!def.isPartitionKey() && !def.isStatic()) return false; } return true; }
/** * Checks if this selection contains only static columns. * @return <code>true</code> if this selection contains only static columns, <code>false</code> otherwise; */ public boolean containsOnlyStaticColumns() { if (!containsStaticColumns()) return false; if (isWildcard()) return false; for (ColumnDefinition def : getColumns()) { if (!def.isPartitionKey() && !def.isStatic()) return false; } return true; }
private void addRestriction(Restriction restriction) { ColumnDefinition def = restriction.getFirstColumn(); if (def.isPartitionKey()) partitionKeyRestrictions = partitionKeyRestrictions.mergeWith(restriction); else if (def.isClusteringColumn()) clusteringColumnsRestrictions = clusteringColumnsRestrictions.mergeWith(restriction); else nonPrimaryKeyRestrictions = nonPrimaryKeyRestrictions.addRestriction((SingleRestriction) restriction); }
/** * Checks if this selection contains only static columns. * @return <code>true</code> if this selection contains only static columns, <code>false</code> otherwise; */ public boolean containsOnlyStaticColumns() { if (!containsStaticColumns()) return false; if (isWildcard()) return false; for (ColumnDefinition def : getColumns()) { if (!def.isPartitionKey() && !def.isStatic()) return false; } return true; }
private void addRestriction(Restriction restriction) { ColumnDefinition def = restriction.getFirstColumn(); if (def.isPartitionKey()) partitionKeyRestrictions = partitionKeyRestrictions.mergeWith(restriction); else if (def.isClusteringColumn()) clusteringColumnsRestrictions = clusteringColumnsRestrictions.mergeWith(restriction); else nonPrimaryKeyRestrictions = nonPrimaryKeyRestrictions.addRestriction((SingleRestriction) restriction); }
private void addRestriction(Restriction restriction) { ColumnDefinition def = restriction.getFirstColumn(); if (def.isPartitionKey()) partitionKeyRestrictions = partitionKeyRestrictions.mergeWith(restriction); else if (def.isClusteringColumn()) clusteringColumnsRestrictions = clusteringColumnsRestrictions.mergeWith(restriction); else nonPrimaryKeyRestrictions = nonPrimaryKeyRestrictions.addRestriction((SingleRestriction) restriction); }
private static void validateDistinctSelection(CFMetaData cfm, Selection selection, StatementRestrictions restrictions) throws InvalidRequestException { checkFalse(restrictions.hasClusteringColumnsRestrictions() || (restrictions.hasNonPrimaryKeyRestrictions() && !restrictions.nonPKRestrictedColumns(true).stream().allMatch(ColumnDefinition::isStatic)), "SELECT DISTINCT with WHERE clause only supports restriction by partition key and/or static columns."); Collection<ColumnDefinition> requestedColumns = selection.getColumns(); for (ColumnDefinition def : requestedColumns) checkFalse(!def.isPartitionKey() && !def.isStatic(), "SELECT DISTINCT queries must only request partition key columns and/or static columns (not %s)", def.name); // If it's a key range, we require that all partition key columns are selected so we don't have to bother // with post-query grouping. if (!restrictions.isKeyRange()) return; for (ColumnDefinition def : cfm.partitionKeyColumns()) checkTrue(requestedColumns.contains(def), "SELECT DISTINCT queries must request all the partition key columns (missing %s)", def.name); }
/** * Returns true if all of the expressions within this filter that apply to the partition key are satisfied by * the given key, false otherwise. */ public boolean partitionKeyRestrictionsAreSatisfiedBy(DecoratedKey key, AbstractType<?> keyValidator) { for (Expression e : expressions) { if (!e.column.isPartitionKey()) continue; ByteBuffer value = keyValidator instanceof CompositeType ? ((CompositeType) keyValidator).split(key.getKey())[e.column.position()] : key.getKey(); if (!e.operator().isSatisfiedBy(e.column.type, value, e.value)) return false; } return true; }
/** * Returns true if all of the expressions within this filter that apply to the partition key are satisfied by * the given key, false otherwise. */ public boolean partitionKeyRestrictionsAreSatisfiedBy(DecoratedKey key, AbstractType<?> keyValidator) { for (Expression e : expressions) { if (!e.column.isPartitionKey()) continue; ByteBuffer value = keyValidator instanceof CompositeType ? ((CompositeType) keyValidator).split(key.getKey())[e.column.position()] : key.getKey(); if (!e.operator().isSatisfiedBy(e.column.type, value, e.value)) return false; } return true; }
/** * Returns true if all of the expressions within this filter that apply to the partition key are satisfied by * the given key, false otherwise. */ public boolean partitionKeyRestrictionsAreSatisfiedBy(DecoratedKey key, AbstractType<?> keyValidator) { for (Expression e : expressions) { if (!e.column.isPartitionKey()) continue; ByteBuffer value = keyValidator instanceof CompositeType ? ((CompositeType) keyValidator).split(key.getKey())[e.column.position()] : key.getKey(); if (!e.operator().isSatisfiedBy(e.column.type, value, e.value)) return false; } return true; }
public void insertRow(Row row) { if (row.isStatic() && !indexedColumn.isStatic() && !indexedColumn.isPartitionKey()) return; if (isPrimaryKeyIndex()) { indexPrimaryKey(row.clustering(), getPrimaryKeyIndexLiveness(row), row.deletion()); } else { if (indexedColumn.isComplex()) indexCells(row.clustering(), row.getComplexColumnData(indexedColumn)); else indexCell(row.clustering(), row.getCell(indexedColumn)); } }
public void insertRow(Row row) { if (row.isStatic() && !indexedColumn.isStatic() && !indexedColumn.isPartitionKey()) return; if (isPrimaryKeyIndex()) { indexPrimaryKey(row.clustering(), getPrimaryKeyIndexLiveness(row), row.deletion()); } else { if (indexedColumn.isComplex()) indexCells(row.clustering(), row.getComplexColumnData(indexedColumn)); else indexCell(row.clustering(), row.getCell(indexedColumn)); } }
public void insertRow(Row row) { if (row.isStatic() && !indexedColumn.isStatic() && !indexedColumn.isPartitionKey()) return; if (isPrimaryKeyIndex()) { indexPrimaryKey(row.clustering(), getPrimaryKeyIndexLiveness(row), row.deletion()); } else { if (indexedColumn.isComplex()) indexCells(row.clustering(), row.getComplexColumnData(indexedColumn)); else indexCell(row.clustering(), row.getCell(indexedColumn)); } }