for (int i = 0; i < batchSize; i++) {
stmtCounters[i] = ts.updateStatementCounter(batchStmts[i].getStatement());
} // FOR
if (ts.hasPrefetchQueries()) {
PartitionSet stmtPartitions[] = plan.getStatementPartitions();
PrefetchState prefetchState = ts.getPrefetchState();
QueryTracker queryTracker = prefetchState.getExecQueryTracker();
assert(prefetchState != null);
for (int i = 0; i < batchSize; i++) {
// We always have to update the query tracker regardless of whether
// the query was prefetched or not. This is so that we can ensure
// that we execute the queries in the right order.
Statement stmt = batchStmts[i].getStatement();
stmtCounters[i] = queryTracker.addQuery(stmt, stmtPartitions[i], batchParams[i]);
} // FOR
// FIXME PrefetchQueryUtil.checkSQLStmtBatch(this, ts, plan, batchSize, batchStmts, batchParams);
} // PREFETCH
VoltTable results[] = null;
// FAST-PATH: Single-partition + Local
// If the BatchPlan only has WorkFragments that are for this partition, then
// we can use the fast-path executeLocalPlan() method
if (plan.isSingledPartitionedAndLocal()) {
if (trace.val)
LOG.trace(String.format("%s - Sending %s directly to the ExecutionEngine at partition %d",
ts, plan.getClass().getSimpleName(), this.partitionId));
// If this the finalTask flag is set to true, and we're only executing queries at this
// partition, then we need to notify the other partitions that we're done with them.
if (hstore_conf.site.exec_early_prepare &&
finalTask == true &&
ts.isPredictSinglePartition() == false &&
ts.isSysProc() == false &&
ts.allowEarlyPrepare() == true) {
tmp_fragmentsPerPartition.clearValues();
tmp_fragmentsPerPartition.put(this.partitionId, batchSize);
DonePartitionsNotification notify = this.computeDonePartitions(ts, null, tmp_fragmentsPerPartition, finalTask);
if (notify != null && notify.hasSitesToNotify()) {
this.notifyDonePartitions(ts, notify);
}
}
// Execute the queries right away.
results = this.executeLocalPlan(ts, plan, batchParams);
}
// DISTRIBUTED EXECUTION
// Otherwise, we need to generate WorkFragments and then send the messages out
// to our remote partitions using the HStoreCoordinator
else {
List<WorkFragment.Builder> partitionFragments = new ArrayList<WorkFragment.Builder>();
plan.getWorkFragmentsBuilders(ts.getTransactionId(), stmtCounters, partitionFragments);
if (debug.val)
LOG.debug(String.format("%s - Using dispatchWorkFragments to execute %d %ss",
ts, partitionFragments.size(), WorkFragment.class.getSimpleName()));
if (needs_profiling) {
int remote_cnt = 0;
PartitionSet stmtPartitions[] = plan.getStatementPartitions();
for (int i = 0; i < batchSize; i++) {
if (stmtPartitions[i].get() != ts.getBasePartition()) remote_cnt++;
if (trace.val)
LOG.trace(String.format("%s - [%02d] stmt:%s / partitions:%s",
ts, i, batchStmts[i].getStatement().getName(), stmtPartitions[i]));