StarTreeUtils { public static List<StarTreeQuery> filterQueries(StarTreeConfig config, List<StarTreeQuery> queries, Map<String, List<String>> filter) { List<StarTreeQuery> filteredQueries = new ArrayList<StarTreeQuery>(queries.size()); for (StarTreeQuery query : queries) { boolean matches = true; for (Map.Entry<String, List<String>> entry : filter.entrySet()) { String dimensionName = entry.getKey(); String dimensionValue = query.getDimensionKey().getDimensionValue(config.getDimensions(), dimensionName); if (!entry.getValue().contains(StarTreeConstants.ALL) && !entry.getValue().contains(dimensionValue)) { matches = false; break; } } if (matches) { filteredQueries.add(query); } } return filteredQueries; }  static int getPartitionId(UUID nodeId, int numPartitions); static List<StarTreeQuery> filterQueries(StarTreeConfig config,
                                                  List<StarTreeQuery> queries,
                                                  Map<String, List<String>> filter); static List<StarTreeQuery> expandQueries(StarTree starTree,
                                                  StarTreeQuery baseQuery); static int printNode(PrintWriter printWriter, StarTreeNode node,
      int level); static void traverseAndGetLeafNodes(Collection<StarTreeNode> leafNodes,
      StarTreeNode node); static Map<String, Map<Integer, String>> toReverseIndex(
      Map<String, Map<String, Integer>> forwardIndex); static String toDimensionString(StarTreeRecord record,
      List<DimensionSpec> dimensionSpecs); static String[] convertToStringValue(
      Map<String, Map<Integer, String>> reverseForwardIndex, int[] leafRecord,
      List<String> dimensionNames); static int getDepth(StarTreeNode root);  }
@Test public void testFilterQueries() throws Exception { StarTreeConfig config = new StarTreeConfig.Builder() .setCollection("dummy") .setSplit(new SplitSpec(4, null)) .setMetrics(Arrays.asList(new MetricSpec("M", MetricType.INT))) .setDimensions(Arrays.asList(new DimensionSpec("A"), new DimensionSpec("B"), new DimensionSpec("C"))) .setRecordStoreFactoryClass(StarTreeRecordStoreFactoryLogBufferImpl.class.getCanonicalName()) .build(); StarTree starTree = new StarTreeImpl(config); starTree.open(); for (int i = 0; i < 100; i++) { MetricTimeSeries ts = new MetricTimeSeries(metricSchema); ts.set(i, "M", 1); StarTreeRecordImpl.Builder builder = new StarTreeRecordImpl.Builder(); builder.setDimensionKey(getDimensionKey("A" + (i % 2), "B" + (i % 4), "C" + (i % 8))); builder.setMetricTimeSeries(ts); starTree.add(builder.build(config)); } StarTreeQuery baseQuery = new StarTreeQueryImpl.Builder() .setDimensionKey(getDimensionKey(StarTreeConstants.ALL, StarTreeConstants.STAR, StarTreeConstants.STAR)) .build(config); List<StarTreeQuery> queries = StarTreeUtils.expandQueries(starTree, baseQuery); Assert.assertEquals(queries.size(), 3); Map<String, List<String>> filter = new HashMap<String, List<String>>(); filter.put("A", Arrays.asList("A0")); List<StarTreeQuery> filteredQueries = StarTreeUtils.filterQueries(config, queries, filter); Assert.assertEquals(filteredQueries.size(), 1); Assert.assertEquals(filteredQueries.get(0).getDimensionKey().getDimensionValue(config.getDimensions(), "A"), "A0"); starTree.close(); }