firstKS = parsed.keyspace(); firstCF = parsed.columnFamily(); haveMultipleCFs = !firstKS.equals(parsed.keyspace()) || !firstCF.equals(parsed.columnFamily()); statements.add(parsed.prepare(boundNames, clientState));
/** * Returns the column conditions. * * @param metadata the column family meta data * @param boundNames the bound names * @return the column conditions. */ private Conditions prepareConditions(CFMetaData metadata, VariableSpecifications boundNames) { // To have both 'IF EXISTS'/'IF NOT EXISTS' and some other conditions doesn't make sense. // So far this is enforced by the parser, but let's assert it for sanity if ever the parse changes. if (ifExists) { assert conditions.isEmpty(); assert !ifNotExists; return Conditions.IF_EXISTS_CONDITION; } if (ifNotExists) { assert conditions.isEmpty(); assert !ifExists; return Conditions.IF_NOT_EXISTS_CONDITION; } if (conditions.isEmpty()) return Conditions.EMPTY_CONDITION; return prepareColumnConditions(metadata, boundNames); }
public ModificationStatement prepare(VariableSpecifications boundNames) throws InvalidRequestException CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace(), columnFamily()); Attributes preparedAttributes = attrs.prepare(keyspace(), columnFamily()); preparedAttributes.collectMarkerSpecification(boundNames); ModificationStatement stmt = prepareInternal(metadata, boundNames, preparedAttributes); throw new InvalidRequestException(String.format("Unknown identifier %s", id)); ColumnCondition condition = entry.right.prepare(keyspace(), def); condition.collectMarkerSpecification(boundNames);
/** * Returns the column conditions. * * @param metadata the column family meta data * @param boundNames the bound names * @return the column conditions. */ private Conditions prepareConditions(CFMetaData metadata, VariableSpecifications boundNames) { // To have both 'IF EXISTS'/'IF NOT EXISTS' and some other conditions doesn't make sense. // So far this is enforced by the parser, but let's assert it for sanity if ever the parse changes. if (ifExists) { assert conditions.isEmpty(); assert !ifNotExists; return Conditions.IF_EXISTS_CONDITION; } if (ifNotExists) { assert conditions.isEmpty(); assert !ifExists; return Conditions.IF_NOT_EXISTS_CONDITION; } if (conditions.isEmpty()) return Conditions.EMPTY_CONDITION; return prepareColumnConditions(metadata, boundNames); }
firstKS = parsed.keyspace(); firstCF = parsed.columnFamily(); haveMultipleCFs = !firstKS.equals(parsed.keyspace()) || !firstCF.equals(parsed.columnFamily()); statements.add(parsed.prepare(boundNames, clientState));
firstKS = parsed.keyspace(); firstCF = parsed.columnFamily(); haveMultipleCFs = !firstKS.equals(parsed.keyspace()) || !firstCF.equals(parsed.columnFamily()); statements.add(parsed.prepare(boundNames, clientState));
/** * Returns the column conditions. * * @param metadata the column family meta data * @param boundNames the bound names * @return the column conditions. */ private ColumnConditions prepareColumnConditions(CFMetaData metadata, VariableSpecifications boundNames) { checkNull(attrs.timestamp, "Cannot provide custom timestamp for conditional updates"); ColumnConditions.Builder builder = ColumnConditions.newBuilder(); for (Pair<ColumnDefinition.Raw, ColumnCondition.Raw> entry : conditions) { ColumnDefinition def = entry.left.prepare(metadata); ColumnCondition condition = entry.right.prepare(keyspace(), def, metadata); condition.collectMarkerSpecification(boundNames); checkFalse(def.isPrimaryKeyColumn(), "PRIMARY KEY column '%s' cannot have IF conditions", def.name); builder.add(condition); } return builder.build(); }
/** * Returns the column conditions. * * @param metadata the column family meta data * @param boundNames the bound names * @return the column conditions. */ private Conditions prepareConditions(CFMetaData metadata, VariableSpecifications boundNames) { // To have both 'IF EXISTS'/'IF NOT EXISTS' and some other conditions doesn't make sense. // So far this is enforced by the parser, but let's assert it for sanity if ever the parse changes. if (ifExists) { assert conditions.isEmpty(); assert !ifNotExists; return Conditions.IF_EXISTS_CONDITION; } if (ifNotExists) { assert conditions.isEmpty(); assert !ifExists; return Conditions.IF_NOT_EXISTS_CONDITION; } if (conditions.isEmpty()) return Conditions.EMPTY_CONDITION; return prepareColumnConditions(metadata, boundNames); }
/** * Returns the column conditions. * * @param metadata the column family meta data * @param boundNames the bound names * @return the column conditions. */ private ColumnConditions prepareColumnConditions(CFMetaData metadata, VariableSpecifications boundNames) { checkNull(attrs.timestamp, "Cannot provide custom timestamp for conditional updates"); ColumnConditions.Builder builder = ColumnConditions.newBuilder(); for (Pair<ColumnDefinition.Raw, ColumnCondition.Raw> entry : conditions) { ColumnDefinition def = entry.left.prepare(metadata); ColumnCondition condition = entry.right.prepare(keyspace(), def, metadata); condition.collectMarkerSpecification(boundNames); checkFalse(def.isPrimaryKeyColumn(), "PRIMARY KEY column '%s' cannot have IF conditions", def.name); builder.add(condition); } return builder.build(); }
/** * Prepares insert statement for writing data to SSTable * * @return prepared Insert statement and it's bound names */ private Pair<UpdateStatement, List<ColumnSpecification>> prepareInsert() { ParsedStatement.Prepared cqlStatement = insertStatement.prepare(ClientState.forInternalCalls()); UpdateStatement insert = (UpdateStatement) cqlStatement.statement; insert.validate(ClientState.forInternalCalls()); if (insert.hasConditions()) throw new IllegalArgumentException("Conditional statements are not supported"); if (insert.isCounter()) throw new IllegalArgumentException("Counter update statements are not supported"); if (cqlStatement.boundNames.isEmpty()) throw new IllegalArgumentException("Provided insert statement has no bind variables"); return Pair.create(insert, cqlStatement.boundNames); } }
/** * Returns the column conditions. * * @param metadata the column family meta data * @param boundNames the bound names * @return the column conditions. */ private ColumnConditions prepareColumnConditions(CFMetaData metadata, VariableSpecifications boundNames) { checkNull(attrs.timestamp, "Cannot provide custom timestamp for conditional updates"); ColumnConditions.Builder builder = ColumnConditions.newBuilder(); for (Pair<ColumnDefinition.Raw, ColumnCondition.Raw> entry : conditions) { ColumnDefinition def = entry.left.prepare(metadata); ColumnCondition condition = entry.right.prepare(keyspace(), def, metadata); condition.collectMarkerSpecification(boundNames); checkFalse(def.isPrimaryKeyColumn(), "PRIMARY KEY column '%s' cannot have IF conditions", def.name); builder.add(condition); } return builder.build(); }
/** * Prepares insert statement for writing data to SSTable * * @return prepared Insert statement and it's bound names */ private Pair<UpdateStatement, List<ColumnSpecification>> prepareInsert() { ParsedStatement.Prepared cqlStatement = insertStatement.prepare(ClientState.forInternalCalls()); UpdateStatement insert = (UpdateStatement) cqlStatement.statement; insert.validate(ClientState.forInternalCalls()); if (insert.hasConditions()) throw new IllegalArgumentException("Conditional statements are not supported"); if (insert.isCounter()) throw new IllegalArgumentException("Counter update statements are not supported"); if (cqlStatement.boundNames.isEmpty()) throw new IllegalArgumentException("Provided insert statement has no bind variables"); return Pair.create(insert, cqlStatement.boundNames); } }
/** * Prepares insert statement for writing data to SSTable * * @return prepared Insert statement and it's bound names */ private Pair<UpdateStatement, List<ColumnSpecification>> prepareInsert() { ParsedStatement.Prepared cqlStatement = insertStatement.prepare(ClientState.forInternalCalls()); UpdateStatement insert = (UpdateStatement) cqlStatement.statement; insert.validate(ClientState.forInternalCalls()); if (insert.hasConditions()) throw new IllegalArgumentException("Conditional statements are not supported"); if (insert.isCounter()) throw new IllegalArgumentException("Counter update statements are not supported"); if (cqlStatement.boundNames.isEmpty()) throw new IllegalArgumentException("Provided insert statement has no bind variables"); return Pair.create(insert, cqlStatement.boundNames); } }
@Override public void prepareKeyspace(ClientState state) throws InvalidRequestException { for (ModificationStatement.Parsed statement : parsedStatements) statement.prepareKeyspace(state); }
public ParsedStatement.Prepared prepare() throws InvalidRequestException { VariableSpecifications boundNames = getBoundVariables(); List<ModificationStatement> statements = new ArrayList<>(parsedStatements.size()); for (ModificationStatement.Parsed parsed : parsedStatements) statements.add(parsed.prepare(boundNames)); Attributes prepAttrs = attrs.prepare("[batch]", "[batch]"); prepAttrs.collectMarkerSpecification(boundNames); BatchStatement batchStatement = new BatchStatement(boundNames.size(), type, statements, prepAttrs); batchStatement.validate(); return new ParsedStatement.Prepared(batchStatement, boundNames); } }
@Override public void prepareKeyspace(ClientState state) throws InvalidRequestException { for (ModificationStatement.Parsed statement : parsedStatements) statement.prepareKeyspace(state); }
public ParsedStatement.Prepared prepare(ClientState clientState) { VariableSpecifications boundNames = getBoundVariables(); ModificationStatement statement = prepare(boundNames, clientState); return new ParsedStatement.Prepared(statement, boundNames, boundNames.getPartitionKeyBindIndexes(statement.cfm)); }
public ParsedStatement.Prepared prepare(ClientState clientState) { VariableSpecifications boundNames = getBoundVariables(); ModificationStatement statement = prepare(boundNames, clientState); return new ParsedStatement.Prepared(statement, boundNames, boundNames.getPartitionKeyBindIndexes(statement.cfm)); }
@Override public void prepareKeyspace(ClientState state) throws InvalidRequestException { for (ModificationStatement.Parsed statement : parsedStatements) statement.prepareKeyspace(state); }
public ModificationStatement prepare(VariableSpecifications boundNames, ClientState clientState) { CFMetaData metadata = ThriftValidation.validateColumnFamilyWithCompactMode(keyspace(), columnFamily(), clientState.isNoCompactMode()); Attributes preparedAttributes = attrs.prepare(keyspace(), columnFamily()); preparedAttributes.collectMarkerSpecification(boundNames); Conditions preparedConditions = prepareConditions(metadata, boundNames); return prepareInternal(metadata, boundNames, preparedConditions, preparedAttributes); }