StarTreeImpl implements StarTree { @Override public MetricTimeSeries getTimeSeries(StarTreeQuery query) { StarTreeNode node = find(root, query); if (node == null) { throw new IllegalArgumentException("No star tree node for query " + query); } return node.getRecordStore().getTimeSeries(query); } StarTreeImpl(StarTreeConfig config);  StarTreeImpl(StarTreeConfig config, File dataDir);  StarTreeImpl(StarTreeConfig config, File dataDir, StarTreeNode root); @Override StarTreeNode getRoot(); @Override StarTreeConfig getConfig(); @Override StarTreeRecordStoreFactory getRecordStoreFactory(); @Override void open(); @Override MetricTimeSeries getTimeSeries(StarTreeQuery query); @Override void add(StarTreeRecord record); @Override void close(); @Override Set<String> getDimensionValues(String dimensionName,
      Map<String, Collection<String>> fixedDimensions); void getDimensionValues(StarTreeNode node, String dimensionName,
      Map<String, Collection<String>> fixedDimensions, Set<String> collector); @Override StarTreeNode find(StarTreeQuery query); @Override Collection<StarTreeNode> findAll(StarTreeQuery query); @Override StarTreeStats getStats(); @Override void eachLeaf(StarTreeCallback callback); @Override void clear(); void getStats(StarTreeNode node, StarTreeStats stats); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testQuery() throws Exception { StarTreeQueryImpl.Builder queryBuilder = new StarTreeQueryImpl.Builder(); queryBuilder.setTimeRange(new TimeRange(0L, 100L)); queryBuilder.setDimensionKey(getDimensionKey("*", "*", "*")); MetricTimeSeries result = starTree.getTimeSeries(queryBuilder.build(config)); Assert.assertEquals(result.getMetricSums()[0].intValue(), 100 + 1); queryBuilder.setDimensionKey(getDimensionKey("A0", "*", "*")); result = starTree.getTimeSeries(queryBuilder.build(config)); Assert.assertEquals(result.getMetricSums()[0].intValue(), 50); queryBuilder.setDimensionKey(getDimensionKey("*", "B0", "*")); result = starTree.getTimeSeries(queryBuilder.build(config)); Assert.assertEquals(result.getMetricSums()[0].intValue(), 25); queryBuilder.setDimensionKey(getDimensionKey("AX", "BX", "CX")); result = starTree.getTimeSeries(queryBuilder.build(config)); Assert.assertEquals(result.getMetricSums()[0].intValue(), 1); }
@Test public void testTimeRangeQuery() throws Exception { StarTreeQueryImpl.Builder queryBuilder = new StarTreeQueryImpl.Builder(); queryBuilder.setDimensionKey(getDimensionKey("*", "*", "*")); queryBuilder.setTimeRange(new TimeRange(0L, 49L)); MetricTimeSeries result = starTree.getTimeSeries(queryBuilder.build(config)); Assert.assertEquals(result.getMetricSums()[0].intValue(), 50 + 1); }