Beispiel #1
0
 @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());
 }
Beispiel #2
0
  @Test
  public void testMaxQuery() {

    BrokerRequest brokerRequest = getMaxQuery();

    QuerySource querySource = new QuerySource();
    querySource.setTableName("midas");
    brokerRequest.setQuerySource(querySource);
    InstanceRequest instanceRequest = new InstanceRequest(0, brokerRequest);
    instanceRequest.setSearchSegments(new ArrayList<String>());
    for (IndexSegment segment : _indexSegmentList) {
      instanceRequest.getSearchSegments().add(segment.getSegmentName());
    }
    try {
      DataTable instanceResponse = _queryExecutor.processQuery(instanceRequest);
      LOGGER.info("InstanceResponse is " + instanceResponse.getDouble(0, 0));
      Assert.assertEquals(instanceResponse.getDouble(0, 0), 200000.0);

      LOGGER.info(
          "Time used for instanceResponse is " + instanceResponse.getMetadata().get("timeUsedMs"));
    } catch (Exception e) {
      e.printStackTrace();
      // Should never happen
      Assert.assertEquals(true, false);
    }
  }