@Test public void testInterSegmentAggregationPlanMakerAndRun() { PlanMaker instancePlanMaker = new InstancePlanMakerImplV2(); BrokerRequest brokerRequest = _brokerRequest.deepCopy(); ExecutorService executorService = Executors.newCachedThreadPool(new NamedThreadFactory("test-plan-maker")); Plan globalPlan = instancePlanMaker.makeInterSegmentPlan( makeSegMgrList(_indexSegmentList), brokerRequest, executorService, 150000); globalPlan.print(); globalPlan.execute(); DataTable instanceResponse = globalPlan.getInstanceResponse(); LOGGER.debug(Long.toString(instanceResponse.getLong(0, 0))); LOGGER.debug(Double.toString(instanceResponse.getDouble(0, 1))); LOGGER.debug(Double.toString(instanceResponse.getDouble(0, 2))); LOGGER.debug(Double.toString(instanceResponse.getDouble(0, 3))); LOGGER.debug(instanceResponse.getObject(0, 4).toString()); LOGGER.debug(instanceResponse.getObject(0, 5).toString()); LOGGER.debug(instanceResponse.getObject(0, 6).toString()); LOGGER.debug("Query time: {}", instanceResponse.getMetadata().get("timeUsedMs")); assertEquals(200001L * _indexSegmentList.size(), instanceResponse.getLong(0, 0)); assertEquals(20000100000.0 * _indexSegmentList.size(), instanceResponse.getDouble(0, 1)); assertEquals(200000.0, instanceResponse.getDouble(0, 2)); assertEquals(0.0, instanceResponse.getDouble(0, 3)); assertEquals(100000.0, Double.parseDouble(instanceResponse.getObject(0, 4).toString())); assertEquals(10, ((IntOpenHashSet) instanceResponse.getObject(0, 5)).size()); assertEquals(100, ((IntOpenHashSet) instanceResponse.getObject(0, 6)).size()); DefaultReduceService reduceService = new DefaultReduceService(); Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>(); instanceResponseMap.put(new ServerInstance("localhost:1111"), instanceResponse); BrokerResponseJSON brokerResponse = reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap); LOGGER.debug(brokerResponse.getAggregationResults().toString()); }
@Test public void testInterSegmentAggregationPlanMaker() { PlanMaker instancePlanMaker = new InstancePlanMakerImplV2(); BrokerRequest brokerRequest = _brokerRequest.deepCopy(); brokerRequest.setSelections(null); brokerRequest.setSelectionsIsSet(false); ExecutorService executorService = Executors.newCachedThreadPool(new NamedThreadFactory("test-plan-maker")); Plan globalPlan = instancePlanMaker.makeInterSegmentPlan( makeSegMgrList(_indexSegmentList), brokerRequest, executorService, 150000); globalPlan.print(); brokerRequest = setFilterQuery(brokerRequest); globalPlan = instancePlanMaker.makeInterSegmentPlan( makeSegMgrList(_indexSegmentList), brokerRequest, executorService, 150000); globalPlan.print(); }
@Test public void testInterSegmentSelectionPlanMaker() throws JSONException { PlanMaker instancePlanMaker = new InstancePlanMakerImplV2(); BrokerRequest brokerRequest = _brokerRequest.deepCopy(); brokerRequest.setAggregationsInfo(null); brokerRequest.setAggregationsInfoIsSet(false); brokerRequest.setSelections(getSelectionQuery()); brokerRequest.getSelections().setOffset(0); brokerRequest.getSelections().setSize(20); ExecutorService executorService = Executors.newCachedThreadPool(new NamedThreadFactory("test-plan-maker")); Plan globalPlan = instancePlanMaker.makeInterSegmentPlan( makeSegMgrList(_indexSegmentList), brokerRequest, executorService, 150000); globalPlan.print(); brokerRequest = setFilterQuery(brokerRequest); globalPlan = instancePlanMaker.makeInterSegmentPlan( makeSegMgrList(_indexSegmentList), brokerRequest, executorService, 150000); globalPlan.print(); globalPlan.execute(); DataTable instanceResponse = globalPlan.getInstanceResponse(); DefaultReduceService defaultReduceService = new DefaultReduceService(); Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>(); instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse); instanceResponseMap.put(new ServerInstance("localhost:1111"), instanceResponse); BrokerResponseJSON brokerResponse = defaultReduceService.reduceOnDataTable(brokerRequest, instanceResponseMap); LOGGER.debug(brokerResponse.getSelectionResults().toString()); LOGGER.debug("Time used: {}", brokerResponse.getTimeUsedMs()); LOGGER.debug(brokerResponse.toString()); JSONArray selectionResultsArray = brokerResponse.getSelectionResults().getJSONArray("results"); for (int j = 0; j < selectionResultsArray.length(); ++j) { LOGGER.debug(selectionResultsArray.getJSONArray(j).toString()); assertEquals(selectionResultsArray.getJSONArray(j).getInt(0), 1); assertEquals(selectionResultsArray.getJSONArray(j).getInt(1), 91); assertEquals(selectionResultsArray.getJSONArray(j).getInt(2) % 100, 91); } }