boolean fastCombine = false; // FIXME
// Now update our catalog information
int id = getNextFragmentId(db, readonly, fastAggregate, fastCombine);
String planFragmentName = Integer.toString(id);
PlanFragment planFragment = null;
if (_singleSited) {
planFragment = catalogStmt.getFragments().add(planFragmentName);
catalogStmt.setHas_singlesited(true);
if (trace.val)
LOG.trace(String.format("%s SP PLAN FRAGMENT: %s", catalogStmt.fullName(), planFragment));
} else {
planFragment = catalogStmt.getMs_fragments().add(planFragmentName);
catalogStmt.setHas_multisited(true);
if (trace.val)
LOG.trace(String.format("%s DTXN PLAN FRAGMENT: %s", catalogStmt.fullName(), planFragment));
}
// mark a fragment as non-transactional if it never touches a persistent table
planFragment.setNontransactional(!fragmentReferencesPersistentTable(fragment.planGraph));
planFragment.setReadonly(readonly);
planFragment.setHasdependencies(fragment.hasDependencies);
planFragment.setMultipartition(fragment.multiPartition);
planFragment.setId(id);
String json = null;
try {
JSONObject jobj = new JSONObject(node_list.toJSONString());
json = jobj.toString(4);
} catch (JSONException e2) {
throw new RuntimeException(e2);
}
// TODO: can't re-enable this until the EE accepts PlanColumn GUIDs
// instead of column names because the deserialization is done without
// any connection to the child nodes - required to map the PlanColumn's
// GUID to the child's column name.
// verify the plan serializes and deserializes correctly.
// assert(node_list.testJSONSerialization(db));
// output the plan to disk for debugging
PrintStream plansOut = BuildDirectoryUtils.getDebugOutputPrintStream(
"statement-winner-plans", name + "-" + String.valueOf(i++) + ".txt");
plansOut.println(json);
plansOut.close();
//
// We then stick a serialized version of PlanNodeTree into a PlanFragment
//
try {
FastSerializer fs = new FastSerializer(false, false); // C++ needs little-endian
fs.write(json.getBytes());
String hexString = fs.getHexEncodedBytes();
planFragment.setPlannodetree(hexString);
} catch (Exception e) {
e.printStackTrace();
throw compiler.new VoltCompilerException(e.getMessage());
}
}