Codota Logo
FunctionResolver.makeArgSpec
Code IndexAdd Codota to your IDE (free)

How to use
makeArgSpec
method
in
org.apache.cassandra.cql3.functions.FunctionResolver

Best Java code snippets using org.apache.cassandra.cql3.functions.FunctionResolver.makeArgSpec (Showing top 9 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: org.apache.cassandra/cassandra-all

private static AssignmentTestable.TestResult matchAguments(String keyspace,
                              Function fun,
                              List<? extends AssignmentTestable> providedArgs,
                              String receiverKs,
                              String receiverCf)
{
  if (providedArgs.size() != fun.argTypes().size())
    return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
  // It's an exact match if all are exact match, but is not assignable as soon as any is non assignable.
  AssignmentTestable.TestResult res = AssignmentTestable.TestResult.EXACT_MATCH;
  for (int i = 0; i < providedArgs.size(); i++)
  {
    AssignmentTestable provided = providedArgs.get(i);
    if (provided == null)
    {
      res = AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
      continue;
    }
    ColumnSpecification expected = makeArgSpec(receiverKs, receiverCf, fun, i);
    AssignmentTestable.TestResult argRes = provided.testAssignment(keyspace, expected);
    if (argRes == AssignmentTestable.TestResult.NOT_ASSIGNABLE)
      return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
    if (argRes == AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE)
      res = AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
  }
  return res;
}
origin: jsevellec/cassandra-unit

private static AssignmentTestable.TestResult matchAguments(String keyspace,
                              Function fun,
                              List<? extends AssignmentTestable> providedArgs,
                              String receiverKs,
                              String receiverCf)
{
  if (providedArgs.size() != fun.argTypes().size())
    return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
  // It's an exact match if all are exact match, but is not assignable as soon as any is non assignable.
  AssignmentTestable.TestResult res = AssignmentTestable.TestResult.EXACT_MATCH;
  for (int i = 0; i < providedArgs.size(); i++)
  {
    AssignmentTestable provided = providedArgs.get(i);
    if (provided == null)
    {
      res = AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
      continue;
    }
    ColumnSpecification expected = makeArgSpec(receiverKs, receiverCf, fun, i);
    AssignmentTestable.TestResult argRes = provided.testAssignment(keyspace, expected);
    if (argRes == AssignmentTestable.TestResult.NOT_ASSIGNABLE)
      return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
    if (argRes == AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE)
      res = AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
  }
  return res;
}
origin: com.strapdata.cassandra/cassandra-all

private static AssignmentTestable.TestResult matchAguments(String keyspace,
                              Function fun,
                              List<? extends AssignmentTestable> providedArgs,
                              String receiverKs,
                              String receiverCf)
{
  if (providedArgs.size() != fun.argTypes().size())
    return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
  // It's an exact match if all are exact match, but is not assignable as soon as any is non assignable.
  AssignmentTestable.TestResult res = AssignmentTestable.TestResult.EXACT_MATCH;
  for (int i = 0; i < providedArgs.size(); i++)
  {
    AssignmentTestable provided = providedArgs.get(i);
    if (provided == null)
    {
      res = AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
      continue;
    }
    ColumnSpecification expected = makeArgSpec(receiverKs, receiverCf, fun, i);
    AssignmentTestable.TestResult argRes = provided.testAssignment(keyspace, expected);
    if (argRes == AssignmentTestable.TestResult.NOT_ASSIGNABLE)
      return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
    if (argRes == AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE)
      res = AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
  }
  return res;
}
origin: org.apache.cassandra/cassandra-all

private static void validateTypes(String keyspace,
                 Function fun,
                 List<? extends AssignmentTestable> providedArgs,
                 String receiverKs,
                 String receiverCf)
throws InvalidRequestException
{
  if (providedArgs.size() != fun.argTypes().size())
    throw new InvalidRequestException(String.format("Invalid number of arguments in call to function %s: %d required but %d provided", fun.name(), fun.argTypes().size(), providedArgs.size()));
  for (int i = 0; i < providedArgs.size(); i++)
  {
    AssignmentTestable provided = providedArgs.get(i);
    // If the concrete argument is a bind variables, it can have any type.
    // We'll validate the actually provided value at execution time.
    if (provided == null)
      continue;
    ColumnSpecification expected = makeArgSpec(receiverKs, receiverCf, fun, i);
    if (!provided.testAssignment(keyspace, expected).isAssignable())
      throw new InvalidRequestException(String.format("Type error: %s cannot be passed as argument %d of function %s of type %s", provided, i, fun.name(), expected.type.asCQL3Type()));
  }
}
origin: jsevellec/cassandra-unit

private static void validateTypes(String keyspace,
                 Function fun,
                 List<? extends AssignmentTestable> providedArgs,
                 String receiverKs,
                 String receiverCf)
throws InvalidRequestException
{
  if (providedArgs.size() != fun.argTypes().size())
    throw new InvalidRequestException(String.format("Invalid number of arguments in call to function %s: %d required but %d provided", fun.name(), fun.argTypes().size(), providedArgs.size()));
  for (int i = 0; i < providedArgs.size(); i++)
  {
    AssignmentTestable provided = providedArgs.get(i);
    // If the concrete argument is a bind variables, it can have any type.
    // We'll validate the actually provided value at execution time.
    if (provided == null)
      continue;
    ColumnSpecification expected = makeArgSpec(receiverKs, receiverCf, fun, i);
    if (!provided.testAssignment(keyspace, expected).isAssignable())
      throw new InvalidRequestException(String.format("Type error: %s cannot be passed as argument %d of function %s of type %s", provided, i, fun.name(), expected.type.asCQL3Type()));
  }
}
origin: com.strapdata.cassandra/cassandra-all

private static void validateTypes(String keyspace,
                 Function fun,
                 List<? extends AssignmentTestable> providedArgs,
                 String receiverKs,
                 String receiverCf)
throws InvalidRequestException
{
  if (providedArgs.size() != fun.argTypes().size())
    throw new InvalidRequestException(String.format("Invalid number of arguments in call to function %s: %d required but %d provided", fun.name(), fun.argTypes().size(), providedArgs.size()));
  for (int i = 0; i < providedArgs.size(); i++)
  {
    AssignmentTestable provided = providedArgs.get(i);
    // If the concrete argument is a bind variables, it can have any type.
    // We'll validate the actually provided value at execution time.
    if (provided == null)
      continue;
    ColumnSpecification expected = makeArgSpec(receiverKs, receiverCf, fun, i);
    if (!provided.testAssignment(keyspace, expected).isAssignable())
      throw new InvalidRequestException(String.format("Type error: %s cannot be passed as argument %d of function %s of type %s", provided, i, fun.name(), expected.type.asCQL3Type()));
  }
}
origin: jsevellec/cassandra-unit

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);
}
origin: org.apache.cassandra/cassandra-all

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);
}
origin: com.strapdata.cassandra/cassandra-all

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);
}
org.apache.cassandra.cql3.functionsFunctionResolvermakeArgSpec

Popular methods of FunctionResolver

  • format
  • get
  • matchAguments
  • validateTypes

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • putExtra (Intent)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • MessageFormat (java.text)
    MessageFormat provides a means to produce concatenated messages in language-neutral way. Use this to
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now