use of org.apache.asterix.om.base.IAObject in project asterixdb by apache.
the class InvertedIndexAccessMethod method isContainsFuncSelectOptimizable.
private boolean isContainsFuncSelectOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) {
AsterixConstantValue strConstVal = (AsterixConstantValue) ((ConstantExpression) optFuncExpr.getConstantExpr(0)).getValue();
IAObject strObj = strConstVal.getObject();
ATypeTag typeTag = strObj.getType().getTypeTag();
if (!isContainsFuncCompatible(typeTag, index.getIndexType())) {
return false;
}
// Check that the constant search string has at least gramLength characters.
if (strObj.getType().getTypeTag() == ATypeTag.STRING) {
AString astr = (AString) strObj;
if (astr.getStringValue().length() >= index.getGramLength()) {
return true;
}
}
return false;
}
use of org.apache.asterix.om.base.IAObject in project asterixdb by apache.
the class InvertedIndexAccessMethod method isFullTextContainsFuncSelectOptimizable.
// Checks whether the given index is compatible with full-text search and
// the type of the constant search predicate is STRING, ARRAY, or MULTISET
private boolean isFullTextContainsFuncSelectOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) {
AsterixConstantValue strConstVal = (AsterixConstantValue) ((ConstantExpression) optFuncExpr.getConstantExpr(0)).getValue();
IAObject strObj = strConstVal.getObject();
ATypeTag typeTag = strObj.getType().getTypeTag();
return isFullTextContainsFuncCompatible(typeTag, index.getIndexType());
}
use of org.apache.asterix.om.base.IAObject in project asterixdb by apache.
the class PlanTranslationUtil method prepareMetaKeyAccessExpression.
public static void prepareMetaKeyAccessExpression(List<String> field, LogicalVariable resVar, List<Mutable<ILogicalExpression>> assignExpressions, List<LogicalVariable> vars, List<Mutable<ILogicalExpression>> varRefs, IVariableContext context) {
IAObject value = (field.size() > 1) ? new AOrderedList(field) : new AString(field.get(0));
ScalarFunctionCallExpression metaKeyFunction = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.META_KEY));
metaKeyFunction.getArguments().add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(resVar)));
metaKeyFunction.getArguments().add(new MutableObject<>(new ConstantExpression(new AsterixConstantValue(value))));
assignExpressions.add(new MutableObject<ILogicalExpression>(metaKeyFunction));
LogicalVariable v = context.newVar();
vars.add(v);
if (varRefs != null) {
varRefs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(v)));
}
}
use of org.apache.asterix.om.base.IAObject in project asterixdb by apache.
the class FieldAccessNestedResultType method getResultType.
@Override
protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException {
IAType firstArgType = strippedInputTypes[0];
if (firstArgType.getTypeTag() != ATypeTag.OBJECT) {
return BuiltinType.ANY;
}
AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
ILogicalExpression arg1 = funcExpr.getArguments().get(1).getValue();
if (arg1.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
return BuiltinType.ANY;
}
ConstantExpression ce = (ConstantExpression) arg1;
IAObject v = ((AsterixConstantValue) ce.getValue()).getObject();
List<String> fieldPath = new ArrayList<>();
if (v.getType().getTypeTag() == ATypeTag.ARRAY) {
for (int i = 0; i < ((AOrderedList) v).size(); i++) {
fieldPath.add(((AString) ((AOrderedList) v).getItem(i)).getStringValue());
}
} else {
fieldPath.add(((AString) v).getStringValue());
}
ARecordType recType = (ARecordType) firstArgType;
IAType fieldType = recType.getSubFieldType(fieldPath);
return fieldType == null ? BuiltinType.ANY : fieldType;
}
use of org.apache.asterix.om.base.IAObject in project asterixdb by apache.
the class NonTaggedDataFormat method getExpressionEvalSizeComputer.
@Override
public IExpressionEvalSizeComputer getExpressionEvalSizeComputer() {
return new IExpressionEvalSizeComputer() {
@Override
public int getEvalSize(ILogicalExpression expr, IVariableEvalSizeEnvironment env) throws AlgebricksException {
switch(expr.getExpressionTag()) {
case CONSTANT:
{
ConstantExpression c = (ConstantExpression) expr;
if (c == ConstantExpression.MISSING) {
return 1;
} else if (c == ConstantExpression.FALSE || c == ConstantExpression.TRUE) {
return 2;
} else {
AsterixConstantValue acv = (AsterixConstantValue) c.getValue();
IAObject o = acv.getObject();
switch(o.getType().getTypeTag()) {
case DOUBLE:
return 9;
case FLOAT:
return 5;
case BOOLEAN:
return 2;
case MISSING:
return 1;
case NULL:
return 1;
case TINYINT:
return 2;
case SMALLINT:
return 3;
case INTEGER:
return 5;
case BIGINT:
return 9;
default:
return -1;
}
}
}
case FUNCTION_CALL:
{
AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
if (f.getFunctionIdentifier().equals(BuiltinFunctions.TID)) {
return 5;
} else {
// TODO
return -1;
}
}
default:
{
// TODO
return -1;
}
}
}
};
}
Aggregations