private boolean hasTargetWithSortedRids(QueryPlanningInfo info) { if (info.target == null) { return false; } if (info.target.getItem() == null) { return false; } if (info.target.getItem().getIdentifier() != null) { return true; } else if (info.target.getItem().getCluster() != null) { return true; } else if (info.target.getItem().getClusterList() != null) { return true; } return false; }
private void handleSource(OUpdateExecutionPlan result, OCommandContext ctx, OFromItem source, boolean profilingEnabled) { OSelectStatement sourceStatement = new OSelectStatement(-1); sourceStatement.setTarget(new OFromClause(-1)); sourceStatement.getTarget().setItem(source); OSelectExecutionPlanner planner = new OSelectExecutionPlanner(sourceStatement); result.chain(new SubQueryStep(planner.createExecutionPlan(ctx, profilingEnabled, false), ctx, ctx, profilingEnabled)); } }
@Override public OStatement copy() { OTraverseStatement result = new OTraverseStatement(-1); result.projections = projections == null ? null : projections.stream().map(x -> x.copy()).collect(Collectors.toList()); result.target = target == null ? null : target.copy(); result.whileClause = whileClause == null ? null : whileClause.copy(); result.limit = limit == null ? null : limit.copy(); result.strategy = strategy; result.maxDepth = maxDepth == null ? null : maxDepth.copy(); return result; }
@Override public void deserialize(OResult fromResult) { try { OExecutionStepInternal.basicDeserialize(fromResult, this); functionCondition = new OBinaryCondition(-1); functionCondition.deserialize(fromResult.getProperty("functionCondition ")); queryTarget = new OFromClause(-1); queryTarget.deserialize(fromResult.getProperty("functionCondition ")); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException(""), e); } } }
final public OFromClause FromClause() throws ParseException { OFromClause jjtn000 = new OFromClause(JJTFROMCLAUSE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { jjtn000.item = FromItem(); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0));
OWhereClause where = aliasFilters.get(patternNode.alias); OSelectStatement select = new OSelectStatement(-1); select.setTarget(new OFromClause(-1)); select.getTarget().setItem(new OFromItem(-1)); if (clazz != null) { select.getTarget().getItem().setIdentifier(new OIdentifier(clazz)); } else if (cluster != null) { select.getTarget().getItem().setCluster(new OCluster(cluster)); } else if (rid != null) { select.getTarget().getItem().setRids(Collections.singletonList(rid));
@Override public int hashCode() { int result = fromClause != null ? fromClause.hashCode() : 0; result = 31 * result + (whereClause != null ? whereClause.hashCode() : 0); result = 31 * result + (returnBefore ? 1 : 0); result = 31 * result + (limit != null ? limit.hashCode() : 0); result = 31 * result + (unsafe ? 1 : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ODeleteStatement that = (ODeleteStatement) o; if (returnBefore != that.returnBefore) return false; if (unsafe != that.unsafe) return false; if (fromClause != null ? !fromClause.equals(that.fromClause) : that.fromClause != null) return false; if (whereClause != null ? !whereClause.equals(that.whereClause) : that.whereClause != null) return false; if (limit != null ? !limit.equals(that.limit) : that.limit != null) return false; return true; }
public OFromClause copy() { OFromClause result= new OFromClause(-1); result.item = item.copy(); return result; }
public boolean refersToParent() { if (projections != null && projections.stream().anyMatch(x -> x.refersToParent())) { return true; } if (this.target != null && this.target.refersToParent()) { return true; } if (this.whileClause != null && this.whileClause.refersToParent()) { return true; } return false; }
@Override public boolean executinPlanCanBeCached() { if (originalStatement == null) { setOriginalStatement(this.toString()); } if (this.target != null && !this.target.isCacheable()) { return false; } if (this.letClause != null && !this.letClause.isCacheable()) { return false; } if (projection != null && !this.projection.isCacheable()) { return false; } if (whereClause != null && !whereClause.isCacheable()) { return false; } return true; }
private OSelectStatement indexChainToStatement(OModifier modifier, OClass clazz, OExpression right, OCommandContext ctx) { OClass queryClass = clazz; OSelectStatement result = new OSelectStatement(-1); result.target = new OFromClause(-1); result.target.setItem(new OFromItem(-1)); result.target.getItem().identifier = new OIdentifier(queryClass.getName()); result.whereClause = new OWhereClause(-1); OBinaryCondition base = new OBinaryCondition(-1); result.whereClause.baseExpression = new ONotBlock(-1); ((ONotBlock) result.whereClause.baseExpression).sub = base; ((ONotBlock) result.whereClause.baseExpression).negate = false; base.left = new OExpression(-1); base.left.mathExpression = new OBaseExpression(-1); ((OBaseExpression) base.left.mathExpression).identifier = new OBaseIdentifier(modifier.suffix.identifier); ((OBaseExpression) base.left.mathExpression).modifier = modifier.next == null ? null : modifier.next.copy(); base.operator = new OEqualsCompareOperator(-1); base.right = right.copy(); return result; } }
public void deserialize(OResult fromResult) { if (fromResult.getProperty("target") != null) { target = new OFromClause(-1); target.deserialize(fromResult.getProperty("target"));
@Override public int hashCode() { int result = (from ? 1 : 0); result = 31 * result + (fromClause != null ? fromClause.hashCode() : 0); result = 31 * result + (whereClause != null ? whereClause.hashCode() : 0); result = 31 * result + (returnBefore ? 1 : 0); result = 31 * result + (limit != null ? limit.hashCode() : 0); result = 31 * result + (batch != null ? batch.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OTraverseStatement that = (OTraverseStatement) o; if (projections != null ? !projections.equals(that.projections) : that.projections != null) return false; if (target != null ? !target.equals(that.target) : that.target != null) return false; if (whileClause != null ? !whileClause.equals(that.whileClause) : that.whileClause != null) return false; if (limit != null ? !limit.equals(that.limit) : that.limit != null) return false; if (strategy != that.strategy) return false; if (maxDepth != null ? !maxDepth.equals(that.maxDepth) : that.maxDepth != null) return false; return true; }
private OSelectStatement buildSelectStatement(String className, OWhereClause oWhereClause) { OSelectStatement stm = new OSelectStatement(-1); stm.whereClause = oWhereClause; stm.target = new OFromClause(-1); stm.target.item = new OFromItem(-1); stm.target.item.identifier = new OIdentifier(className); return stm; }
@Override public boolean refersToParent() { //no FROM, if a subquery refers to parent it does not make sense, so that reference will be just ignored if (projection != null && projection.refersToParent()) { return true; } if(target!=null && target.refersToParent()){ return true; } if (whereClause != null && whereClause.refersToParent()) { return true; } if (groupBy != null && groupBy.refersToParent()) { return true; } if (orderBy != null && orderBy.refersToParent()) { return true; } if (letClause != null && letClause.refersToParent()) { return true; } return false; }
public void validate() throws OCommandSQLParsingException { // for(OTraverseProjectionItem projection:projections) { // // projection. validate(); // if (projection.isExpand() && groupBy != null) { // throw new OCommandSQLParsingException("expand() cannot be used together with GROUP BY"); // } // // } if (target.getItem().getStatement() != null) { target.getItem().getStatement().validate(); } }
private OSelectStatement createSelectStatement(String targetClass, String targetCluster, ORid targetRid, OWhereClause filter) { OSelectStatement prefetchStm = new OSelectStatement(-1); prefetchStm.setWhereClause(filter); OFromClause from = new OFromClause(-1); OFromItem fromItem = new OFromItem(-1); if (targetRid != null) { fromItem.setRids(Collections.singletonList(targetRid)); } else if (targetClass != null) { fromItem.setIdentifier(new OIdentifier(targetClass)); } else if (targetCluster != null) { fromItem.setCluster(new OCluster(targetCluster)); } from.setItem(fromItem); prefetchStm.setTarget(from); return prefetchStm; }
@Override public OUpdateStatement copy() { OUpdateStatement result = null; try { result = getClass().getConstructor(Integer.TYPE).newInstance(-1); } catch (Exception e) { throw new RuntimeException(e); } result.target = target == null ? null : target.copy(); result.operations = operations == null ? null : operations.stream().map(x -> x.copy()).collect(Collectors.toList()); result.upsert = upsert; result.returnBefore = returnBefore; result.returnAfter = returnAfter; result.returnProjection = returnProjection == null ? null : returnProjection.copy(); result.whereClause = whereClause == null ? null : whereClause.copy(); result.lockRecord = lockRecord; result.limit = limit == null ? null : limit.copy(); result.timeout = timeout == null ? null : timeout.copy(); return result; }