/** * iterates over a class and its subclasses * * @param clusterIds the clusters * @param ctx the query context * @param ridOrder true to sort by RID asc, false to sort by RID desc, null for no sort. */ public FetchFromClustersExecutionStep(int[] clusterIds, OCommandContext ctx, Boolean ridOrder, boolean profilingEnabled) { super(ctx, profilingEnabled); if (Boolean.TRUE.equals(ridOrder)) { orderByRidAsc = true; } else if (Boolean.FALSE.equals(ridOrder)) { orderByRidDesc = true; } subSteps = new ArrayList<OExecutionStep>(); sortClusers(clusterIds); for (int i = 0; i < clusterIds.length; i++) { FetchFromClusterExecutionStep step = new FetchFromClusterExecutionStep(clusterIds[i], ctx, profilingEnabled); if (orderByRidAsc) { step.setOrder(FetchFromClusterExecutionStep.ORDER_ASC); } else if (orderByRidDesc) { step.setOrder(FetchFromClusterExecutionStep.ORDER_DESC); } subSteps.add(step); } }
@Override public String prettyPrint(int depth, int indent) { String result = OExecutionStepInternal.getIndent(depth, indent) + "+ FETCH FROM CLUSTER " + clusterId + " " + (ORDER_DESC.equals(order) ? "DESC" : "ASC"); if (profilingEnabled) { result += " (" + getCostFormatted() + ")"; } return result; }
@Override public OResultSet syncPull(OCommandContext ctx, int nRecords) throws OTimeoutException { getPrev().ifPresent(x -> x.syncPull(ctx, nRecords)); long begin = profilingEnabled ? System.nanoTime() : 0; try { if (iterator == null) { long minClusterPosition = calculateMinClusterPosition(); long maxClusterPosition = calculateMaxClusterPosition(); iterator = new ORecordIteratorCluster((ODatabaseDocumentInternal) ctx.getDatabase(), clusterId, minClusterPosition, maxClusterPosition); if (ORDER_DESC == order) {
@Override public OExecutionStep copy(OCommandContext ctx) { FetchFromClusterExecutionStep result = new FetchFromClusterExecutionStep(this.clusterId, this.queryPlanning == null ? null : this.queryPlanning.copy(), ctx, profilingEnabled); return result; } }
private void handleTargetCluster(ODeleteExecutionPlan result, OCommandContext ctx, OIdentifier targetClusterName, boolean profilingEnabled) { if (targetClusterName != null) { String name = targetClusterName.getStringValue(); int clusterId = ctx.getDatabase().getClusterIdByName(name); if (clusterId < 0) { throw new OCommandExecutionException("Cluster not found: " + name); } result.chain(new FetchFromClusterExecutionStep(clusterId, ctx, profilingEnabled)); } }
throw new OCommandExecutionException("Cluster " + cluster + " does not exist"); FetchFromClusterExecutionStep step = new FetchFromClusterExecutionStep(clusterId, ctx, profilingEnabled); if (Boolean.TRUE.equals(orderByRidAsc)) { step.setOrder(FetchFromClusterExecutionStep.ORDER_ASC); } else if (Boolean.FALSE.equals(orderByRidAsc)) { step.setOrder(FetchFromClusterExecutionStep.ORDER_DESC);
int clusterId = clusterIds[i]; if (clusterId > 0) { FetchFromClusterExecutionStep step = new FetchFromClusterExecutionStep(clusterId, planningInfo, ctx, profilingEnabled); if (orderByRidAsc) { step.setOrder(FetchFromClusterExecutionStep.ORDER_ASC); } else if (orderByRidDesc) { step.setOrder(FetchFromClusterExecutionStep.ORDER_DESC);
throw new OCommandExecutionException("Cluster " + cluster + " does not exist"); FetchFromClusterExecutionStep step = new FetchFromClusterExecutionStep(clusterId, ctx, profilingEnabled); if (Boolean.TRUE.equals(orderByRidAsc)) { step.setOrder(FetchFromClusterExecutionStep.ORDER_ASC); } else if (Boolean.FALSE.equals(orderByRidAsc)) { step.setOrder(FetchFromClusterExecutionStep.ORDER_DESC);