public DependencySet executePlanFragment(Long txn_id,
Map<Integer, List<VoltTable>> dependencies,
int fragmentId,
ParameterSet params,
PartitionExecutor.SystemProcedureExecutionContext context) {
DependencySet result = null;
switch (fragmentId) {
// ----------------------------------------------------------------------------
// COLLECT DATA
// ----------------------------------------------------------------------------
case DISTRIBUTE_ID: {
VoltTable vt = new VoltTable(ACCESS_HISTORY);
AntiCacheManagerProfiler profiler = hstore_site.getAntiCacheManager().getDebugContext().getProfiler(this.partitionId);
assert(profiler != null);
TimestampType timestamp = new TimestampType();
for (AccessHistory eah : profiler.evictedaccess_history) {
String procName = catalogContext.getProcedureById(eah.procId).getName();
Object row[] = {
timestamp,
this.hstore_site.getSiteId(),
this.hstore_site.getSiteName(),
this.partitionId,
eah.txnId,
eah.startTimestamp,
procName,
eah.numBlocks,
eah.numTables,
eah.numTuples,
};
vt.addRow(row);
} // FOR
result = new DependencySet(DISTRIBUTE_ID, vt);
if (debug.val)
LOG.info(String.format("%s - Sending back result for partition %d",
hstore_site.getTransaction(txn_id), this.executor.getPartitionId()));
break;
}
// ----------------------------------------------------------------------------
// AGGREGATE RESULTS
// ----------------------------------------------------------------------------
case AGGREGATE_ID: {
List<VoltTable> siteResults = dependencies.get(DISTRIBUTE_ID);
if (siteResults == null || siteResults.isEmpty()) {
String msg = "Missing site results";
throw new ServerFaultException(msg, txn_id);
}
Pair<Integer, SortDirectionType> sortCol = Pair.of(3, SortDirectionType.ASC);
@SuppressWarnings("unchecked")
VoltTable vt = VoltTableUtil.sort(VoltTableUtil.union(siteResults), sortCol);
result = new DependencySet(AGGREGATE_ID, vt);
break;
}
default:
String msg = "Unexpected sysproc fragmentId '" + fragmentId + "'";
throw new ServerFaultException(msg, txn_id);