@Override public boolean evaluate(OResult currentRecord, OCommandContext ctx) { return expression.execute(currentRecord, ctx) == null; }
@Override public boolean evaluate(OIdentifiable currentRecord, OCommandContext ctx) { Object leftValue = left.execute(currentRecord, ctx); if (leftValue == null || !(leftValue instanceof String)) { return false; } Object rightValue = right.execute(currentRecord, ctx); if (rightValue == null || !(rightValue instanceof String)) { return false; } return ((String) leftValue).indexOf((String) rightValue) > -1; }
@Override public boolean evaluate(OResult currentRecord, OCommandContext ctx) { Object leftValue = left.execute(currentRecord, ctx); if (leftValue == null || !(leftValue instanceof String)) { return false; } Object rightValue = right.execute(currentRecord, ctx); if (rightValue == null || !(rightValue instanceof String)) { return false; } return ((String) leftValue).indexOf((String) rightValue) > -1; }
@Override protected void onAfterParsing(Map<String, Object> params, OExpression[] args, OCommandContext ctx, Object rightValue) { OExpression number = args[2]; Number parsedNumber = (Number) number.execute((OIdentifiable) null, ctx); params.put("distance", parsedNumber.doubleValue()); }
/** * tests if current expression involves an indexed funciton AND that function can also be executed without using the index * * @param target the query target * @param context the execution context * * @return true if current expression involves an indexed function AND that function can be used on this target, false otherwise */ public boolean canExecuteIndexedFunctionWithoutIndex(OFromClause target, OCommandContext context) { return left.canExecuteIndexedFunctionWithoutIndex(target, context, operator, right.execute((OResult) null, context)); }
public Object execute(OResult iCurrentRecord, OCommandContext ctx) { List<Object> result = new ArrayList<Object>(); for (OExpression exp : expressions) { result.add(convert(exp.execute(iCurrentRecord, ctx))); } return result; }
@Override public void apply(OResult next, OCommandContext ctx) { List<Object> paramValues = new ArrayList<>(); for (OExpression expr : params) { paramValues.add(expr.execute(next, ctx)); } aggregateFunction.execute(next, null, null, paramValues.toArray(), ctx); } }
public Map<String, Object> toMap(OIdentifiable source, OCommandContext ctx) { Map<String, Object> doc = new HashMap<String, Object>(); for (OJsonItem item : items) { String name = item.getLeftValue(); if (name == null) { continue; } Object value = item.right.execute(source, ctx); doc.put(name, value); } return doc; }
/** * tests if current expression involves an indexed function AND that function can be used on this target * * @param target the query target * @param context the execution context * * @return true if current expression involves an indexed function AND that function can be used on this target, false otherwise */ public boolean allowsIndexedFunctionExecutionOnTarget(OFromClause target, OCommandContext context) { return left.allowsIndexedFunctionExecutionOnTarget(target, context, operator, right.execute((OResult) null, context)); }
@Override public Object execute(OIdentifiable iCurrentRecord, OCommandContext ctx) { if (expression != null) { return expression.execute(iCurrentRecord, ctx); } if (statement != null) { throw new UnsupportedOperationException("Execution of select in parentheses is not supported"); } return super.execute(iCurrentRecord, ctx); }
protected void init(OCommandContext ctx) { if (!this.inited) { Object val = source.execute(new OResultInternal(), ctx); this.iterator = OMultiValue.getMultiValueIterator(val); this.inited = true; } }
public Object execute(OIdentifiable iCurrentRecord, OCommandContext ctx) { Object result; if (all) { result = iCurrentRecord; } else { result = expression.execute(iCurrentRecord, ctx); } if (nestedProjection != null) { result = nestedProjection.apply(expression, result, ctx); } return convert(result); }
private void calculate(OCommandContext ctx) { if (executed) { return; } Object value = expression.execute((OResult) null, ctx); ctx.setVariable(varname.getStringValue(), value); executed = true; }
private ODocument toDocument(OResult source, OCommandContext ctx, String className){ ODocument retDoc = new ODocument(className); for (OJsonItem item : items) { String name = item.getLeftValue(); if (name == null || ODocumentHelper.getReservedAttributes().contains(name.toLowerCase(Locale.ENGLISH))) { continue; } Object value = item.right.execute(source, ctx); retDoc.field(name, value); } return retDoc; }
private boolean evaluateAny(OResult currentRecord, OCommandContext ctx) { for (String s : currentRecord.getPropertyNames()) { Object leftVal = currentRecord.getProperty(s); Object rightVal = right.execute(currentRecord, ctx); //TODO collate if (operator.execute(leftVal, rightVal)) { return true; } } return false; }
@Override public OResult next() { OResultInternal result = (OResultInternal) source.next(); Object value = expression.execute(result, ctx); result.setMetadata(varname.getStringValue(), value); return result; }
@Override protected OLuceneFullTextIndex searchForIndex(OFromClause target, OCommandContext ctx, OExpression... args) { List<String> fieldNames = (List<String>) args[0].execute((OIdentifiable) null, ctx); OFromItem item = target.getItem(); String className = item.getIdentifier().getStringValue(); return searchForIndex(className, ctx, fieldNames); }
private void processBinaryCondition() { OIndexDefinition definition = index.getDefinition(); OBinaryCompareOperator operator = ((OBinaryCondition) condition).getOperator(); OExpression left = ((OBinaryCondition) condition).getLeft(); if (!left.toString().equalsIgnoreCase("key")) { throw new OCommandExecutionException("search for index for " + condition + " is not supported yet"); } Object rightValue = ((OBinaryCondition) condition).getRight().execute((OResult) null, ctx); cursor = createCursor(operator, definition, rightValue, ctx); }
private OLuceneFullTextIndex searchForIndex(String className, OCommandContext ctx, OExpression... args) { String indexName = (String) args[0].execute((OIdentifiable) null, ctx); OIndex<?> index = ctx.getDatabase().getMetadata().getIndexManager().getClassIndex(className, indexName); if (index != null && index.getInternal() instanceof OLuceneFullTextIndex) { return (OLuceneFullTextIndex) index; } return null; }
private void processBinaryCondition() { OIndexDefinition definition = index.getDefinition(); OBinaryCompareOperator operator = ((OBinaryCondition) condition).getOperator(); OExpression left = ((OBinaryCondition) condition).getLeft(); if (!left.toString().equalsIgnoreCase("key")) { throw new OCommandExecutionException("search for index for " + condition + " is not supported yet"); } Object rightValue = ((OBinaryCondition) condition).getRight().execute((OResult) null, ctx); cursor = createCursor(operator, definition, rightValue, ctx); if (cursor != null) { fetchNextEntry(); } }