private static int HTTP_REQUEST_MAXIMUM_LENGTH = 1900;
public static QueryUnit[] createJoinTasks(SubQuery subQuery)
throws IOException {
MasterPlan masterPlan = subQuery.getMasterPlan();
ExecutionBlock execBlock = subQuery.getBlock();
QueryMasterTask.QueryMasterTaskContext masterContext = subQuery.getContext();
AbstractStorageManager storageManager = subQuery.getStorageManager();
ScanNode[] scans = execBlock.getScanNodes();
Path tablePath;
Fragment [] fragments = new Fragment[2];
TableStat [] stats = new TableStat[2];
// initialize variables from the child operators
for (int i =0; i < 2; i++) {
TableDesc tableDesc = masterContext.getTableDescMap().get(scans[i].getCanonicalName());
if (tableDesc == null) { // if it is a real table stored on storage
// TODO - to be fixed (wrong directory)
ExecutionBlock [] childBlocks = new ExecutionBlock[2];
childBlocks[0] = masterPlan.getChild(execBlock.getId(), 0);
childBlocks[1] = masterPlan.getChild(execBlock.getId(), 1);
tablePath = storageManager.getTablePath(scans[i].getTableName());
stats[i] = masterContext.getSubQuery(childBlocks[i].getId()).getTableStat();
fragments[i] = new Fragment(scans[i].getCanonicalName(), tablePath,
CatalogUtil.newTableMeta(scans[i].getInSchema(), StoreType.CSV), 0, 0);
} else {
tablePath = tableDesc.getPath();
stats[i] = tableDesc.getMeta().getStat();
fragments[i] = storageManager.getSplits(scans[i].getCanonicalName(),
tableDesc.getMeta(), tablePath).get(0);
}
}
// Assigning either fragments or fetch urls to query units
QueryUnit [] tasks;
boolean leftSmall = execBlock.isBroadcastTable(scans[0].getCanonicalName());
boolean rightSmall = execBlock.isBroadcastTable(scans[1].getCanonicalName());
if (leftSmall && rightSmall) {
LOG.info("[Distributed Join Strategy] : Immediate Two Way Join on Single Machine");
tasks = new QueryUnit[1];
tasks[0] = new QueryUnit(QueryIdFactory.newQueryUnitId(subQuery.getId(), 0),
false, subQuery.getEventHandler());
tasks[0].setLogicalPlan(execBlock.getPlan());
tasks[0].setFragment(scans[0].getCanonicalName(), fragments[0]);
tasks[0].setFragment(scans[1].getCanonicalName(), fragments[1]);
} else if (leftSmall ^ rightSmall) {
LOG.info("[Distributed Join Strategy] : Broadcast Join");
int broadcastIdx = leftSmall ? 0 : 1;