本文整理汇总了Java中org.apache.cassandra.cql3.ColumnSpecification类的典型用法代码示例。如果您正苦于以下问题:Java ColumnSpecification类的具体用法?Java ColumnSpecification怎么用?Java ColumnSpecification使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnSpecification类属于org.apache.cassandra.cql3包,在下文中一共展示了ColumnSpecification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAssignment
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public final AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
{
// We should ignore the fact that the receiver type is frozen in our comparison as functions do not support
// frozen types for return type
AbstractType<?> returnType = returnType();
if (receiver.type.isFreezable() && !receiver.type.isMultiCell())
returnType = returnType.freeze();
if (receiver.type.equals(returnType))
return AssignmentTestable.TestResult.EXACT_MATCH;
if (receiver.type.isValueCompatibleWith(returnType))
return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
}
示例2: testAssignment
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public final AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
{
// We should ignore the fact that the output type is frozen in our comparison as functions do not support
// frozen types for arguments
AbstractType<?> receiverType = receiver.type;
if (isFreezable() && !isMultiCell())
receiverType = receiverType.freeze();
if (isReversed())
receiverType = ReversedType.getInstance(receiverType);
if (equals(receiverType))
return AssignmentTestable.TestResult.EXACT_MATCH;
if (receiverType.isValueCompatibleWith(this))
return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
}
示例3: validateTypes
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
private static void validateTypes(String keyspace, Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver) throws InvalidRequestException
{
if (!receiver.type.isValueCompatibleWith(fun.returnType()))
throw new InvalidRequestException(String.format("Type error: cannot assign result of function %s (type %s) to %s (type %s)", fun.name(), fun.returnType().asCQL3Type(), receiver, receiver.type.asCQL3Type()));
if (providedArgs.size() != fun.argsType().size())
throw new InvalidRequestException(String.format("Invalid number of arguments in call to function %s: %d required but %d provided", fun.name(), fun.argsType().size(), providedArgs.size()));
for (int i = 0; i < providedArgs.size(); i++)
{
AssignementTestable 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(receiver, fun, i);
if (!provided.isAssignableTo(keyspace, expected))
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()));
}
}
示例4: isValidType
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
private static boolean isValidType(String keyspace, Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver) throws InvalidRequestException
{
if (!receiver.type.isValueCompatibleWith(fun.returnType()))
return false;
if (providedArgs.size() != fun.argsType().size())
return false;
for (int i = 0; i < providedArgs.size(); i++)
{
AssignementTestable 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(receiver, fun, i);
if (!provided.isAssignableTo(keyspace, expected))
return false;
}
return true;
}
示例5: validateTypes
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
private static void validateTypes(Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver) throws InvalidRequestException
{
if (!receiver.type.asCQL3Type().equals(fun.returnType().asCQL3Type()))
throw new InvalidRequestException(String.format("Type error: cannot assign result of function %s (type %s) to %s (type %s)", fun.name(), fun.returnType().asCQL3Type(), receiver, receiver.type.asCQL3Type()));
if (providedArgs.size() != fun.argsType().size())
throw new InvalidRequestException(String.format("Invalid number of arguments in call to function %s: %d required but %d provided", fun.name(), fun.argsType().size(), providedArgs.size()));
for (int i = 0; i < providedArgs.size(); i++)
{
AssignementTestable 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(receiver, fun, i);
if (!provided.isAssignableTo(expected))
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()));
}
}
示例6: isValidType
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
private static boolean isValidType(Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver)
{
if (!receiver.type.asCQL3Type().equals(fun.returnType().asCQL3Type()))
return false;
if (providedArgs.size() != fun.argsType().size())
return false;
for (int i = 0; i < providedArgs.size(); i++)
{
AssignementTestable 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(receiver, fun, i);
if (!provided.isAssignableTo(expected))
return false;
}
return true;
}
示例7: testAssignment
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public final AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
{
// We should ignore the fact that the output type is frozen in our comparison as functions do not support
// frozen types for arguments
AbstractType<?> receiverType = receiver.type;
if (getType().isFrozenCollection())
receiverType = receiverType.freeze();
if (getType().isReversed())
receiverType = ReversedType.getInstance(receiverType);
if (receiverType.equals(getType()))
return AssignmentTestable.TestResult.EXACT_MATCH;
if (receiverType.isValueCompatibleWith(getType()))
return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
}
示例8: testAssignment
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public final AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
{
// We should ignore the fact that the receiver type is frozen in our comparison as functions do not support
// frozen types for return type
AbstractType<?> returnType = returnType();
if (receiver.type.isFrozenCollection())
returnType = returnType.freeze();
if (receiver.type.equals(returnType))
return AssignmentTestable.TestResult.EXACT_MATCH;
if (receiver.type.isValueCompatibleWith(returnType))
return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
}
示例9: prepare
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public Term prepare(ColumnSpecification receiver) throws InvalidRequestException
{
Function fun = Functions.get(functionName, terms, receiver);
List<Term> parameters = new ArrayList<Term>(terms.size());
boolean allTerminal = true;
for (int i = 0; i < terms.size(); i++)
{
Term t = terms.get(i).prepare(Functions.makeArgSpec(receiver, fun, i));
if (t instanceof NonTerminal)
allTerminal = false;
parameters.add(t);
}
// If all parameters are terminal and the function is pure, we can
// evaluate it now, otherwise we'd have to wait execution time
return allTerminal && fun.isPure()
? makeTerminal(fun, execute(fun, parameters))
: new FunctionCall(fun, parameters);
}
示例10: validateTypes
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
private static void validateTypes(String keyspace, Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver) throws InvalidRequestException
{
if (!receiver.type.asCQL3Type().equals(fun.returnType().asCQL3Type()))
throw new InvalidRequestException(String.format("Type error: cannot assign result of function %s (type %s) to %s (type %s)", fun.name(), fun.returnType().asCQL3Type(), receiver, receiver.type.asCQL3Type()));
if (providedArgs.size() != fun.argsType().size())
throw new InvalidRequestException(String.format("Invalid number of arguments in call to function %s: %d required but %d provided", fun.name(), fun.argsType().size(), providedArgs.size()));
for (int i = 0; i < providedArgs.size(); i++)
{
AssignementTestable 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(receiver, fun, i);
if (!provided.isAssignableTo(keyspace, expected))
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()));
}
}
示例11: isValidType
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
private static boolean isValidType(String keyspace, Function fun, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver) throws InvalidRequestException
{
if (!receiver.type.asCQL3Type().equals(fun.returnType().asCQL3Type()))
return false;
if (providedArgs.size() != fun.argsType().size())
return false;
for (int i = 0; i < providedArgs.size(); i++)
{
AssignementTestable 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(receiver, fun, i);
if (!provided.isAssignableTo(keyspace, expected))
return false;
}
return true;
}
示例12: makeArgSpec
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public static ColumnSpecification makeArgSpec(ColumnSpecification receiver, Function fun, int i)
{
return new ColumnSpecification(receiver.ksName,
receiver.cfName,
new ColumnIdentifier("arg" + i + "(" + fun.name() + ")", true),
fun.argsType().get(i));
}
示例13: get
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public static Function get(String keyspace, String name, List<? extends AssignementTestable> providedArgs, ColumnSpecification receiver) throws InvalidRequestException
{
List<Function.Factory> factories = declared.get(name.toLowerCase());
if (factories.isEmpty())
throw new InvalidRequestException(String.format("Unknown CQL3 function %s called", name));
// Fast path if there is not choice
if (factories.size() == 1)
{
Function fun = factories.get(0).create(receiver.ksName, receiver.cfName);
validateTypes(keyspace, fun, providedArgs, receiver);
return fun;
}
Function candidate = null;
for (Function.Factory factory : factories)
{
Function toTest = factory.create(receiver.ksName, receiver.cfName);
if (!isValidType(keyspace, toTest, providedArgs, receiver))
continue;
if (candidate == null)
candidate = toTest;
else
throw new InvalidRequestException(String.format("Ambiguous call to function %s (can match both type signature %s and %s): use type casts to disambiguate", name, signature(candidate), signature(toTest)));
}
if (candidate == null)
throw new InvalidRequestException(String.format("Invalid call to function %s, none of its type signature matches (known type signatures: %s)", name, signatures(factories, receiver)));
return candidate;
}
示例14: signatures
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
private static String signatures(List<Function.Factory> factories, ColumnSpecification receiver)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < factories.size(); i++)
{
if (i > 0) sb.append(", ");
sb.append(signature(factories.get(i).create(receiver.ksName, receiver.cfName)));
}
return sb.toString();
}
示例15: toThriftPreparedResult
import org.apache.cassandra.cql3.ColumnSpecification; //导入依赖的package包/类
public CqlPreparedResult toThriftPreparedResult()
{
List<String> namesString = new ArrayList<String>(metadata.names.size());
List<String> typesString = new ArrayList<String>(metadata.names.size());
for (ColumnSpecification name : metadata.names)
{
namesString.add(name.toString());
typesString.add(name.type.toString());
}
return new CqlPreparedResult(thriftStatementId, metadata.names.size()).setVariable_types(typesString).setVariable_names(namesString);
}