Examples of BatchedUpdateCommand


Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

                batchSize = i;
              } else {
                ensureValue(insert, 2, callCount);
              }
            } else if ( command instanceof BatchedUpdateCommand ){
                BatchedUpdateCommand bu = (BatchedUpdateCommand)command;
                List<Command> batch = bu.getUpdateCommands();
 
                batchSize = batch.size();
                assertEquals("Unexpected batch on call " + callCount, expectedBatchSize, batchSize); //$NON-NLS-1$
            } else {
                fail("Unexpected command type"); //$NON-NLS-1$
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

    public static BatchedUpdateCommand helpExample() {
        List updates = new ArrayList();
        updates.add(TestInsertImpl.helpExample("a.b")); //$NON-NLS-1$
        updates.add(TestUpdateImpl.helpExample());
        updates.add(TestDeleteImpl.helpExample());
        return new BatchedUpdateCommand(updates);
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

                                  IDGenerator idGenerator,
                                  QueryMetadataInterface metadata,
                                  CapabilitiesFinder capFinder,
                                  AnalysisRecord analysisRecord, CommandContext context)
    throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
        BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand)command;
        List childPlans = new ArrayList(batchedUpdateCommand.getUpdateCommands().size());
        List updateCommands = batchedUpdateCommand.getUpdateCommands();
        int numCommands = updateCommands.size();
        List<VariableContext> allContexts = batchedUpdateCommand.getVariableContexts();
        List<VariableContext> planContexts = null;
        if (allContexts != null) {
          planContexts = new ArrayList<VariableContext>(allContexts.size());
        }
        for (int commandIndex = 0; commandIndex < numCommands; commandIndex++) {
            // Potentially the first command of a batch
            Command updateCommand = (Command)updateCommands.get(commandIndex);
            boolean commandWasBatched = false;
            // If this command can be placed in a batch
            if (isEligibleForBatching(updateCommand, metadata)) {
                // Get the model ID. Subsequent and contiguous commands that update a group in this model are candidates for this batch
                Object batchModelID = metadata.getModelID(getUpdatedGroup(updateCommand).getMetadataID());
                String modelName = metadata.getFullName(batchModelID);
                SourceCapabilities caps = capFinder.findCapabilities(modelName);
                // Only attempt batching if the source supports batching
                if (caps.supportsCapability(Capability.BATCHED_UPDATES)) {
                    // Start a new batch
                    List<Command> batch = new ArrayList<Command>();
                    List<VariableContext> contexts = new ArrayList<VariableContext>();
                    List<Boolean> shouldEvaluate = new ArrayList<Boolean>();
                    // This is the first command in a potential batch, so add it to the batch
                    batch.add(updateCommand);
                    if (allContexts != null) {
                      contexts.add(allContexts.get(commandIndex));
                      shouldEvaluate.add(Boolean.TRUE);
                    } else {
                      shouldEvaluate.add(EvaluatableVisitor.needsProcessingEvaluation(updateCommand));
                    }
                    // Find out if there are other commands called on the same physical model
                    // immediately and contiguously after this one
                    batchLoop: for (int batchIndex = commandIndex+1; batchIndex < numCommands; batchIndex++) {
                        Command batchingCandidate = (Command)updateCommands.get(batchIndex);
                        // If this command updates the same model, and is eligible for batching, add it to the batch
                        if (canBeAddedToBatch(batchingCandidate, batchModelID, metadata, capFinder)) {
                            batch.add(batchingCandidate);
                            if (allContexts != null) {
                              contexts.add(allContexts.get(batchIndex));
                              shouldEvaluate.add(Boolean.TRUE);
                            } else {
                              shouldEvaluate.add(EvaluatableVisitor.needsProcessingEvaluation(batchingCandidate));
                            }
                        } else { // Otherwise, stop batching at this point. The next command may well be the start of a new batch
                            break batchLoop;
                        }
                    }
                    // If two or more contiguous commands made on the same model were found, then batch them
                    if (batch.size() > 1) {
                        ProjectNode projectNode = new ProjectNode(((IntegerID)idGenerator.create()).getValue());
                        // Create a BatchedUpdateNode that creates a batched request for the connector
                        BatchedUpdateNode batchNode = new BatchedUpdateNode(((IntegerID)idGenerator.create()).getValue(),
                                                                            batch, contexts, shouldEvaluate,
                                                                            modelName);
                        List symbols = batchedUpdateCommand.getProjectedSymbols();
                        projectNode.setSelectSymbols(symbols);
                        projectNode.setElements(symbols);
                       
                        batchNode.setElements(symbols);
                       
                        projectNode.addChild(batchNode);
                        // Add a new RelationalPlan that represents the plan for this batch.
                        childPlans.add(new RelationalPlan(projectNode));
                        if (planContexts != null) {
                          planContexts.add(new VariableContext());
                      }
                        // Skip those commands that were added to this batch
                        commandIndex += batch.size() - 1;
                        commandWasBatched = true;
                    }
                }
            }
            if (!commandWasBatched) { // If the command wasn't batched, just add the plan for this command to the list of plans
              Command cmd = (Command)batchedUpdateCommand.getUpdateCommands().get(commandIndex);
              ProcessorPlan plan = cmd.getProcessorPlan();
              if (plan == null) {
                plan = QueryOptimizer.optimizePlan(cmd, metadata, idGenerator, capFinder, analysisRecord, context);
              }
                childPlans.add(plan);
                if (allContexts != null) {
                  planContexts.add(allContexts.get(commandIndex));
                }
            }
        }
        return new BatchedUpdatePlan(childPlans, batchedUpdateCommand.getUpdateCommands().size(), planContexts);
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

              if (RelationalNodeUtil.isUpdate(command)) {
                long ts = System.currentTimeMillis();
                checkForUpdates(results, command, dtm.getEventDistributor(), commandIndex, ts);
              } else if (command instanceof BatchedUpdateCommand) {
                long ts = System.currentTimeMillis();
                BatchedUpdateCommand bac = (BatchedUpdateCommand)command;
                for (Command uc : bac.getUpdateCommands()) {
                  checkForUpdates(results, uc, dtm.getEventDistributor(), commandIndex++, ts);
                }
              }
            }
          } catch (TranslatorException e) {
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

        List<Command> batchedUpdates = new ArrayList<Command>(info.getUnionBranches().size() + 1);
        for (UpdateInfo branchInfo : info.getUnionBranches()) {
          batchedUpdates.add(rewriteInherentUpdate((Update)update.clone(), branchInfo));
        }
        batchedUpdates.add(0, rewriteInherentUpdate(update, info));
        return new BatchedUpdateCommand(batchedUpdates);
      }
      return rewriteInherentUpdate(update, info);
    }
   
    if (commandType == Command.TYPE_UPDATE && variables != null) {
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

        List<Command> batchedUpdates = new ArrayList<Command>(info.getUnionBranches().size() + 1);
        for (UpdateInfo branchInfo : info.getUnionBranches()) {
          batchedUpdates.add(rewriteInherentDelete((Delete)delete.clone(), branchInfo));
        }
        batchedUpdates.add(0, rewriteInherentDelete(delete, info));
        return new BatchedUpdateCommand(batchedUpdates);
      }
      return rewriteInherentDelete(delete, info);
    }
    // Rewrite criteria
    Criteria crit = delete.getCriteria();
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

public class BatchedUpdateResolver implements CommandResolver {
   
    public void resolveCommand(Command command, TempMetadataAdapter metadata, boolean resolveNullLiterals)
        throws QueryMetadataException, QueryResolverException, TeiidComponentException {

        BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand) command;
       
        for (Command subCommand : batchedUpdateCommand.getUpdateCommands()) {
            QueryResolver.setChildMetadata(subCommand, command);
            QueryResolver.resolveCommand(subCommand, metadata.getMetadata());
        }
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

        String update2 = "update pm2.g1 set e1 =1"; //$NON-NLS-1$
       
        List commands = new ArrayList();
        commands.add(QueryParser.getQueryParser().parseCommand(update1));
        commands.add(QueryParser.getQueryParser().parseCommand(update2));
        BatchedUpdateCommand command = new BatchedUpdateCommand(commands);
       
        helpResolve(command);
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

                    insert = new Insert( intoGroup,
                                                 intoElements,
                                                 convertValuesToConstants(currentBatch.getTuple(rowNum), intoElements));
                    rows.add( insert );
                }
                registerRequest(new BatchedUpdateCommand( rows ));
                break;
            case SINGLE:
                batchSize = 1;
                // Register insert command against source
                // Defect 16036 - submit a new INSERT command to the DataManager.
View Full Code Here

Examples of org.teiid.query.sql.lang.BatchedUpdateCommand

            } else {
                unexecutedCommands.add(Integer.valueOf(i));
            }
        }
        if (!commandsToExecute.isEmpty()) {
            BatchedUpdateCommand command = new BatchedUpdateCommand(commandsToExecute);
            tupleSource = getDataManager().registerRequest(getContext(), command, modelName, null, getID(), -1);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.