private void handleFetchFromTarger(OSelectExecutionPlan result, OCommandContext ctx, boolean profilingEnabled) { OFromItem target = this.target == null ? null : this.target.getItem(); if (target == null) { handleNoTarget(result, ctx, profilingEnabled); } else if (target.getIdentifier() != null) { handleClassAsTarget(result, this.target, ctx, profilingEnabled); } else if (target.getCluster() != null) { handleClustersAsTarget(result, Collections.singletonList(target.getCluster()), ctx, profilingEnabled); } else if (target.getClusterList() != null) { handleClustersAsTarget(result, target.getClusterList().toListOfClusters(), ctx, profilingEnabled); } else if (target.getStatement() != null) { handleSubqueryAsTarget(result, target.getStatement(), ctx, profilingEnabled); } else if (target.getFunctionCall() != null) { // handleFunctionCallAsTarget(result, target.getFunctionCall(), ctx);//TODO throw new OCommandExecutionException("function call as target is not supported yet"); } else if (target.getInputParam() != null) { handleInputParamAsTarget(result, target.getInputParam(), ctx, profilingEnabled); } else if (target.getIndex() != null) { handleIndexAsTarget(result, target.getIndex(), ctx, profilingEnabled); } else if (target.getMetadata() != null) { handleMetadataAsTarget(result, target.getMetadata(), ctx, profilingEnabled); } else if (target.getRids() != null && target.getRids().size() > 0) { handleRidsAsTarget(result, target.getRids(), ctx, profilingEnabled); } else { throw new UnsupportedOperationException(); } }
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; }
public OFromClause copy() { OFromClause result= new OFromClause(-1); result.item = item.copy(); return result; }
public void deserialize(OResult fromResult) { item = new OFromItem(-1); item.deserialize(fromResult.getProperty("item")); }
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; }
ODatabase db = ctx.getDatabase(); OFromItem item = info.target.getItem(); if (item.getRids() != null && item.getRids().size() > 0) { if (item.getRids().size() == 1) { OInteger cluster = item.getRids().get(0).getCluster(); result.add(db.getClusterNameById(cluster.getValue().intValue())); } else { for (ORid rid : item.getRids()) { OInteger cluster = rid.getCluster(); result.add(db.getClusterNameById(cluster.getValue().intValue())); } else if (item.getInputParams() != null && item.getInputParams().size() > 0) { if (((ODatabaseInternal) ctx.getDatabase()).isSharded()) { throw new UnsupportedOperationException("Sharded query with input parameter as a target is not supported yet"); } else if (item.getCluster() != null) { String name = item.getCluster().getClusterName(); if (name == null) { name = db.getClusterNameById(item.getCluster().getClusterNumber()); } else if (item.getClusterList() != null) { for (OCluster cluster : item.getClusterList().toListOfClusters()) { String name = cluster.getClusterName(); if (name == null) { } else if (item.getIndex() != null) { String indexName = item.getIndex().getIndexName(); OIndex<?> idx = db.getMetadata().getIndexManager().getIndex(indexName); if (idx == null) {
@Override protected OLuceneFullTextIndex searchForIndex(OFromClause target, OCommandContext ctx, OExpression... args) { OFromItem item = target.getItem(); String className = item.getIdentifier().getStringValue(); return searchForIndex(ctx, className); }
if (statement.getTarget().getItem().getIdentifier() != null) { this.className = statement.getTarget().getItem().getIdentifier().getStringValue(); if (db.getClass(className) == null) { throw new OCommandExecutionException("Class " + className + " not found in the schema: " + query); } else if (statement.getTarget().getItem().getRids() != null) { this.rids = statement.getTarget().getItem().getRids().stream() .map(x -> x.toRecordId(new OResultInternal(), new OBasicCommandContext())).collect(Collectors.toList());
public ODeleteExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { ODeleteExecutionPlan result = new ODeleteExecutionPlan(ctx); if (leftExpression != null || rightExpression != null) { handleGlobalLet(result, new OIdentifier("$__ORIENT_DELETE_EDGE_fromV"), leftExpression, ctx, enableProfiling); handleGlobalLet(result, new OIdentifier("$__ORIENT_DELETE_EDGE_toV"), rightExpression, ctx, enableProfiling); handleFetchFromTo(result, ctx, "$__ORIENT_DELETE_EDGE_fromV", "$__ORIENT_DELETE_EDGE_toV", className, targetClusterName, enableProfiling); handleWhere(result, ctx, whereClause, enableProfiling); } else if (whereClause != null) { OFromClause fromClause = new OFromClause(-1); OFromItem item = new OFromItem(-1); if (className == null) { item.setIdentifier(new OIdentifier("E")); } else { item.setIdentifier(className); } fromClause.setItem(item); handleTarget(result, ctx, fromClause, this.whereClause, enableProfiling); } else { handleTargetClass(result, ctx, className, enableProfiling); handleTargetCluster(result, ctx, targetClusterName, enableProfiling); handleTargetRids(result, ctx, rids, enableProfiling); } handleLimit(result, ctx, this.limit, enableProfiling); handleCastToEdge(result, ctx, enableProfiling); handleDelete(result, ctx, enableProfiling); handleReturn(result, ctx, enableProfiling); return result; }
final public OFromItem FromItem() throws ParseException { OFromItem jjtn000 = new OFromItem(JJTFROMITEM); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1));jjtn000.rids = new java.util.ArrayList(); jjtn000.inputParams = new java.util.ArrayList(); ORid lastRid; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0));
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; }
private boolean handleHardwiredCountOnIndex(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { OIndexIdentifier targetIndex = info.target == null ? null : info.target.getItem().getIndex(); if (targetIndex == null) { return false; } if (info.distinct || info.expand) { return false; } if (info.preAggregateProjection != null) { return false; } if (!isCountStar(info)) { return false; } if (!isMinimalQuery(info)) { return false; } result.chain(new CountFromIndexStep(targetIndex, info.projection.getAllAliases().iterator().next(), ctx, profilingEnabled)); return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OFromClause that = (OFromClause) o; if (item != null ? !item.equals(that.item) : that.item != null) return false; return true; }
@Override protected OLuceneFullTextIndex searchForIndex(OFromClause target, OCommandContext ctx, OExpression... args) { OFromItem item = target.getItem(); OIdentifier identifier = item.getIdentifier(); return searchForIndex(identifier.getStringValue(), ctx, args); }
private void validateStatement(OSelectStatement statement) { if (statement.getProjection() != null) { if (statement.getProjection().getItems().size() > 1) { throw new OCommandExecutionException("Projections cannot be used in live query " + statement); } else if (statement.getProjection().getItems().get(0).isAll()) { throw new OCommandExecutionException("Projections cannot be used in live query " + statement); } } if (statement.getTarget().getItem().getIdentifier() == null && statement.getTarget().getItem().getRids() == null) { throw new OCommandExecutionException("Live queries can only be executed against a Class or on RIDs" + statement); } if (statement.getOrderBy() != null) { throw new OCommandExecutionException("Live queries do not support ORDER BY " + statement); } if (statement.getGroupBy() != null) { throw new OCommandExecutionException("Live queries do not support GROUP BY " + statement); } if (statement.getSkip() != null || statement.getLimit() != null) { throw new OCommandExecutionException("Live queries do not support SKIP/LIMIT " + statement); } }
for (OBinaryCondition cond : indexedFunctConditions) { OFromClause from = new OFromClause(-1); OFromItem item = new OFromItem(-1); from.item = item; from.item.setIdentifier(new OIdentifier(oClass.getName())); long newCount = cond.estimateIndexed(from, ctx); if (newCount < conditionEstimation) {
public OFromItem copy() { OFromItem result = new OFromItem(-1); if (rids != null) { result.rids = rids.stream().map(r -> r.copy()).collect(Collectors.toList()); } if (inputParams != null) { result.inputParams = inputParams.stream().map(r -> r.copy()).collect(Collectors.toList()); } result.cluster = cluster == null ? null : cluster.copy(); result.clusterList = clusterList == null ? null : clusterList.copy(); result.index = index == null ? null : index.copy(); result.metadata = metadata == null ? null : metadata.copy(); result.statement = statement == null ? null : statement.copy(); result.inputParam = inputParam == null ? null : inputParam.copy(); result.identifier = identifier == null ? null : identifier.copy(); result.functionCall = functionCall == null ? null : functionCall.copy(); result.modifier = modifier == null ? null : modifier.copy(); return result; }
public ODeleteExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { ODeleteExecutionPlan result = new ODeleteExecutionPlan(ctx); if (handleIndexAsTarget(result, fromClause.getItem().getIndex(), whereClause, ctx)) { if (limit != null) { throw new OCommandExecutionException("Cannot apply a LIMIT on a delete from index"); } if (returnBefore) { throw new OCommandExecutionException("Cannot apply a RETURN BEFORE on a delete from index"); } } else { handleTarget(result, ctx, this.fromClause, this.whereClause, enableProfiling); handleLimit(result, ctx, this.limit, enableProfiling); } handleCastToVertex(result, ctx, enableProfiling); handleDelete(result, ctx, enableProfiling); handleReturn(result, ctx, this.returnBefore, enableProfiling); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OMoveVertexStatement that = (OMoveVertexStatement) o; if (!source.equals(that.source)) return false; if (targetCluster != null ? !targetCluster.equals(that.targetCluster) : that.targetCluster != null) return false; if (targetClass != null ? !targetClass.equals(that.targetClass) : that.targetClass != null) return false; if (updateOperations != null ? !updateOperations.equals(that.updateOperations) : that.updateOperations != null) return false; return batch != null ? batch.equals(that.batch) : that.batch == null; }
if (target == null) { handleNoTarget(shardedPlan.getValue(), ctx, profilingEnabled); } else if (target.getIdentifier() != null) { Set<String> filterClusters = info.serverToClusters.get(shardedPlan.getKey()); } else if (target.getCluster() != null) { handleClustersAsTarget(shardedPlan.getValue(), info, Collections.singletonList(target.getCluster()), ctx, profilingEnabled); } else if (target.getClusterList() != null) { List<OCluster> allClusters = target.getClusterList().toListOfClusters(); List<OCluster> clustersForShard = new ArrayList<>(); for (OCluster cluster : allClusters) { } else if (target.getStatement() != null) { handleSubqueryAsTarget(shardedPlan.getValue(), target.getStatement(), ctx, profilingEnabled); } else if (target.getFunctionCall() != null) { } else if (target.getInputParam() != null) { handleInputParamAsTarget(shardedPlan.getValue(), info.serverToClusters.get(shardedPlan.getKey()), info, target.getInputParam(), ctx, profilingEnabled); } else if (target.getInputParams() != null && target.getInputParams().size() > 0) { List<OInternalExecutionPlan> plans = new ArrayList<>(); for (OInputParameter param : target.getInputParams()) { OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); handleInputParamAsTarget(subPlan, info.serverToClusters.get(shardedPlan.getKey()), info, param, ctx, profilingEnabled); } else if (target.getIndex() != null) { handleIndexAsTarget(shardedPlan.getValue(), info, target.getIndex(), null, ctx, profilingEnabled); if (info.serverToClusters.size() > 1) { shardedPlan.getValue()