use of org.voltdb.DependencyPair in project voltdb by VoltDB.
the class LoadMultipartitionTable method executePlanFragment.
@SuppressWarnings("deprecation")
@Override
public DependencyPair executePlanFragment(Map<Integer, List<VoltTable>> dependencies, long fragmentId, ParameterSet params, SystemProcedureExecutionContext context) {
// Return a single long for modified rowcount
VoltTable result = new VoltTable(new VoltTable.ColumnInfo("", VoltType.BIGINT));
if (fragmentId == SysProcFragmentId.PF_distribute) {
assert context.getCluster().getTypeName() != null;
assert context.getDatabase().getTypeName() != null;
assert params != null;
assert params.toArray() != null;
assert params.toArray()[0] != null;
assert params.toArray()[1] != null;
String tableName = (String) params.toArray()[0];
VoltTable toInsert = (VoltTable) params.toArray()[1];
// add the partition id
long currentPartition = context.getPartitionId();
result.addRow(currentPartition);
try {
// voltLoadTable is void. Assume success or exception.
DeprecatedProcedureAPIAccess.voltLoadTable(this, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), tableName, toInsert, false, false);
// return the number of rows inserted
result.addRow(toInsert.getRowCount());
} catch (VoltAbortException e) {
// must continue and reply with dependency.
e.printStackTrace();
// report -1 rows inserted, though this might be false
result.addRow(-1);
}
return new DependencyPair.TableDependencyPair(DEP_distribute, result);
} else if (fragmentId == SysProcFragmentId.PF_aggregate) {
long[] modifiedTuples = new long[context.getNumberOfPartitions()];
List<VoltTable> deps = dependencies.get(DEP_distribute);
assert (deps.size() > 0);
// go through all the deps and find one mod tuple count per partition
for (VoltTable t : deps) {
t.advanceRow();
int partitionId = (int) t.getLong(0);
t.advanceRow();
long rowsModified = t.getLong(0);
if (modifiedTuples[partitionId] == 0) {
modifiedTuples[partitionId] = rowsModified;
} else {
if (modifiedTuples[partitionId] != rowsModified)
throw new RuntimeException("@LoadMultipartitionTable received different tuple mod counts from two replicas.");
}
}
// sum up all the modified rows from all partitions
long rowsModified = 0;
for (long l : modifiedTuples) rowsModified += l;
result.addRow(rowsModified);
return new DependencyPair.TableDependencyPair(DEP_aggregate, result);
}
// must handle every dependency id.
assert (false);
return null;
}
use of org.voltdb.DependencyPair in project voltdb by VoltDB.
the class ValidatePartitioning method executePlanFragment.
@Override
public DependencyPair executePlanFragment(Map<Integer, List<VoltTable>> dependencies, long fragmentId, ParameterSet params, final SystemProcedureExecutionContext context) {
if (fragmentId == SysProcFragmentId.PF_validatePartitioning) {
final VoltTable results = constructPartitioningResultsTable();
List<Integer> tableIds = new ArrayList<Integer>();
List<String> tableNames = new ArrayList<String>();
for (Table t : CatalogUtil.getNormalTables(context.getDatabase(), false)) {
tableIds.add(t.getRelativeIndex());
tableNames.add(t.getTypeName());
}
long[] mispartitionedCounts = context.getSiteProcedureConnection().validatePartitioning(Longs.toArray(tableIds), (Integer) params.toArray()[0], (byte[]) params.toArray()[1]);
for (int ii = 0; ii < tableNames.size(); ii++) {
results.addRow(context.getHostId(), CoreUtils.getSiteIdFromHSId(context.getSiteId()), context.getPartitionId(), tableNames.get(ii), mispartitionedCounts[ii]);
}
return new DependencyPair.TableDependencyPair(DEP_validatePartitioning, results);
} else if (fragmentId == SysProcFragmentId.PF_validatePartitioningResults) {
assert (dependencies.size() > 0);
final VoltTable results = VoltTableUtil.unionTables(dependencies.get(DEP_validatePartitioning));
return new DependencyPair.TableDependencyPair(DEP_validatePartitioningResults, results);
} else if (fragmentId == SysProcFragmentId.PF_matchesHashinator) {
final VoltTable matchesHashinator = constructHashinatorMatchesTable();
byte[] configBytes = (byte[]) params.toArray()[1];
if (configBytes == null) {
configBytes = LegacyHashinator.getConfigureBytes(0);
}
final long givenConfigurationSignature = TheHashinator.computeConfigurationSignature(configBytes);
matchesHashinator.addRow(context.getHostId(), CoreUtils.getSiteIdFromHSId(context.getSiteId()), context.getPartitionId(), givenConfigurationSignature == TheHashinator.getConfigurationSignature() ? (byte) 1 : (byte) 0);
return new DependencyPair.TableDependencyPair(DEP_matchesHashinator, matchesHashinator);
} else if (fragmentId == SysProcFragmentId.PF_matchesHashinatorResults) {
assert (dependencies.size() > 0);
final VoltTable results = VoltTableUtil.unionTables(dependencies.get(DEP_matchesHashinator));
return new DependencyPair.TableDependencyPair(DEP_matchesHashinatorResults, results);
}
assert (false);
return null;
}
Aggregations