public ByteBuffer bindAndGet(QueryOptions options) throws InvalidRequestException { List<ByteBuffer> buffers = new ArrayList<>(terms.size()); for (Term t : terms) { ByteBuffer functionArg = t.bindAndGet(options); RequestValidations.checkBindValueSet(functionArg, "Invalid unset value for argument in call to function %s", fun.name().name); buffers.add(functionArg); } return executeInternal(options.getProtocolVersion(), fun, buffers); }
public ByteBuffer bindAndGet(QueryOptions options) throws InvalidRequestException { List<ByteBuffer> buffers = new ArrayList<>(terms.size()); for (Term t : terms) { ByteBuffer functionArg = t.bindAndGet(options); RequestValidations.checkBindValueSet(functionArg, "Invalid unset value for argument in call to function %s", fun.name().name); buffers.add(functionArg); } return executeInternal(options.getProtocolVersion(), fun, buffers); }
public ByteBuffer bindAndGet(QueryOptions options) throws InvalidRequestException { List<ByteBuffer> buffers = new ArrayList<>(terms.size()); for (Term t : terms) { ByteBuffer functionArg = t.bindAndGet(options); RequestValidations.checkBindValueSet(functionArg, "Invalid unset value for argument in call to function %s", fun.name().name); buffers.add(functionArg); } return executeInternal(options.getProtocolVersion(), fun, buffers); }
public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException { maybeInit(protocolVersion); // final function is traced in UDFunction Tracing.trace("Executed UDA {}: {} call(s) to state function {} in {}\u03bcs", name(), stateFunctionCount, stateFunction.name(), stateFunctionDuration); if (finalFunction == null) return UDFunction.decompose(stateTypeCodec, protocolVersion, state); if (finalFunction instanceof UDFunction) { UDFunction udf = (UDFunction)finalFunction; Object result = udf.executeForAggregate(protocolVersion, state, Collections.emptyList()); return UDFunction.decompose(returnTypeCodec, protocolVersion, result); } throw new UnsupportedOperationException("UDAs only support UDFs"); }
public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException { maybeInit(protocolVersion); // final function is traced in UDFunction Tracing.trace("Executed UDA {}: {} call(s) to state function {} in {}\u03bcs", name(), stateFunctionCount, stateFunction.name(), stateFunctionDuration); if (finalFunction == null) return UDFunction.decompose(stateTypeCodec, protocolVersion, state); if (finalFunction instanceof UDFunction) { UDFunction udf = (UDFunction)finalFunction; Object result = udf.executeForAggregate(protocolVersion, state, Collections.emptyList()); return UDFunction.decompose(returnTypeCodec, protocolVersion, result); } throw new UnsupportedOperationException("UDAs only support UDFs"); }
public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException { maybeInit(protocolVersion); // final function is traced in UDFunction Tracing.trace("Executed UDA {}: {} call(s) to state function {} in {}\u03bcs", name(), stateFunctionCount, stateFunction.name(), stateFunctionDuration); if (finalFunction == null) return UDFunction.decompose(stateTypeCodec, protocolVersion, state); if (finalFunction instanceof UDFunction) { UDFunction udf = (UDFunction)finalFunction; Object result = udf.executeForAggregate(protocolVersion, state, Collections.emptyList()); return UDFunction.decompose(returnTypeCodec, protocolVersion, result); } throw new UnsupportedOperationException("UDAs only support UDFs"); }
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { Function fun = FunctionResolver.get(keyspace, name, terms, receiver.ksName, receiver.cfName, receiver.type); if (fun == null) throw new InvalidRequestException(String.format("Unknown function %s called", name)); if (fun.isAggregate()) throw new InvalidRequestException("Aggregation function are not supported in the where clause"); ScalarFunction scalarFun = (ScalarFunction) fun; // Functions.get() will complain if no function "name" type check with the provided arguments. // We still have to validate that the return type matches however if (!scalarFun.testAssignment(keyspace, receiver).isAssignable()) throw new InvalidRequestException(String.format("Type error: cannot assign result of function %s (type %s) to %s (type %s)", scalarFun.name(), scalarFun.returnType().asCQL3Type(), receiver.name, receiver.type.asCQL3Type())); if (fun.argTypes().size() != terms.size()) throw new InvalidRequestException(String.format("Incorrect number of arguments specified for function %s (expected %d, found %d)", fun, fun.argTypes().size(), terms.size())); List<Term> parameters = new ArrayList<>(terms.size()); for (int i = 0; i < terms.size(); i++) { Term t = terms.get(i).prepare(keyspace, FunctionResolver.makeArgSpec(receiver.ksName, receiver.cfName, scalarFun, i)); parameters.add(t); } return new FunctionCall(scalarFun, parameters); }
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { Function fun = FunctionResolver.get(keyspace, name, terms, receiver.ksName, receiver.cfName, receiver.type); if (fun == null) throw new InvalidRequestException(String.format("Unknown function %s called", name)); if (fun.isAggregate()) throw new InvalidRequestException("Aggregation function are not supported in the where clause"); ScalarFunction scalarFun = (ScalarFunction) fun; // Functions.get() will complain if no function "name" type check with the provided arguments. // We still have to validate that the return type matches however if (!scalarFun.testAssignment(keyspace, receiver).isAssignable()) throw new InvalidRequestException(String.format("Type error: cannot assign result of function %s (type %s) to %s (type %s)", scalarFun.name(), scalarFun.returnType().asCQL3Type(), receiver.name, receiver.type.asCQL3Type())); if (fun.argTypes().size() != terms.size()) throw new InvalidRequestException(String.format("Incorrect number of arguments specified for function %s (expected %d, found %d)", fun, fun.argTypes().size(), terms.size())); List<Term> parameters = new ArrayList<>(terms.size()); for (int i = 0; i < terms.size(); i++) { Term t = terms.get(i).prepare(keyspace, FunctionResolver.makeArgSpec(receiver.ksName, receiver.cfName, scalarFun, i)); parameters.add(t); } return new FunctionCall(scalarFun, parameters); }
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { Function fun = FunctionResolver.get(keyspace, name, terms, receiver.ksName, receiver.cfName, receiver.type); if (fun == null) throw new InvalidRequestException(String.format("Unknown function %s called", name)); if (fun.isAggregate()) throw new InvalidRequestException("Aggregation function are not supported in the where clause"); ScalarFunction scalarFun = (ScalarFunction) fun; // Functions.get() will complain if no function "name" type check with the provided arguments. // We still have to validate that the return type matches however if (!scalarFun.testAssignment(keyspace, receiver).isAssignable()) throw new InvalidRequestException(String.format("Type error: cannot assign result of function %s (type %s) to %s (type %s)", scalarFun.name(), scalarFun.returnType().asCQL3Type(), receiver.name, receiver.type.asCQL3Type())); if (fun.argTypes().size() != terms.size()) throw new InvalidRequestException(String.format("Incorrect number of arguments specified for function %s (expected %d, found %d)", fun, fun.argTypes().size(), terms.size())); List<Term> parameters = new ArrayList<>(terms.size()); for (int i = 0; i < terms.size(); i++) { Term t = terms.get(i).prepare(keyspace, FunctionResolver.makeArgSpec(receiver.ksName, receiver.cfName, scalarFun, i)); parameters.add(t); } return new FunctionCall(scalarFun, parameters); }
static void addAggregateToSchemaMutation(UDAggregate aggregate, Mutation.SimpleBuilder builder) { builder.update(Aggregates) .row(aggregate.name().name, functionArgumentsList(aggregate)) .add("return_type", aggregate.returnType().asCQL3Type().toString()) .add("state_func", aggregate.stateFunction().name().name) .add("state_type", aggregate.stateType().asCQL3Type().toString()) .add("final_func", aggregate.finalFunction() != null ? aggregate.finalFunction().name().name : null) .add("initcond", aggregate.initialCondition() != null // must use the frozen state type here, as 'null' for unfrozen collections may mean 'empty' ? aggregate.stateType().freeze().asCQL3Type().toCQLLiteral(aggregate.initialCondition(), ProtocolVersion.CURRENT) : null); }
static void addAggregateToSchemaMutation(UDAggregate aggregate, Mutation.SimpleBuilder builder) { builder.update(Aggregates) .row(aggregate.name().name, functionArgumentsList(aggregate)) .add("return_type", aggregate.returnType().asCQL3Type().toString()) .add("state_func", aggregate.stateFunction().name().name) .add("state_type", aggregate.stateType().asCQL3Type().toString()) .add("final_func", aggregate.finalFunction() != null ? aggregate.finalFunction().name().name : null) .add("initcond", aggregate.initialCondition() != null // must use the frozen state type here, as 'null' for unfrozen collections may mean 'empty' ? aggregate.stateType().freeze().asCQL3Type().toCQLLiteral(aggregate.initialCondition(), ProtocolVersion.CURRENT) : null); }
static void addAggregateToSchemaMutation(UDAggregate aggregate, Mutation.SimpleBuilder builder) { builder.update(Aggregates) .row(aggregate.name().name, functionArgumentsList(aggregate)) .add("return_type", aggregate.returnType().asCQL3Type().toString()) .add("state_func", aggregate.stateFunction().name().name) .add("state_type", aggregate.stateType().asCQL3Type().toString()) .add("final_func", aggregate.finalFunction() != null ? aggregate.finalFunction().name().name : null) .add("initcond", aggregate.initialCondition() != null // must use the frozen state type here, as 'null' for unfrozen collections may mean 'empty' ? aggregate.stateType().freeze().asCQL3Type().toCQLLiteral(aggregate.initialCondition(), ProtocolVersion.CURRENT) : null); }
throw new InvalidRequestException("State function " + stateFuncSig(stateFunction.name(), stateTypeRaw, argRawTypes) + " return type must be the same as the first argument type - check STYPE, argument and return types");
throw new InvalidRequestException("State function " + stateFuncSig(stateFunction.name(), stateTypeRaw, argRawTypes) + " return type must be the same as the first argument type - check STYPE, argument and return types");
throw new InvalidRequestException("State function " + stateFuncSig(stateFunction.name(), stateTypeRaw, argRawTypes) + " return type must be the same as the first argument type - check STYPE, argument and return types");