@Test public void testMetricIndexesBuilderLongMetricsWildcard() { ArrayList<String> metricNames = new ArrayList<String>() {{ add("foo.bar.baz.qux.x.y"); }}; Map<String, Long> metricIndexMap = buildMetricIndexesSimilarToES(metricNames, "foo.bar.*"); Set<String> expectedIndexes = new HashSet<String>() {{ add("foo.bar.baz|1"); add("foo.bar.baz.qux|1"); }}; verifyMetricIndexes(metricIndexMap, expectedIndexes); }
public void add(String metricIndex, long docCount) { final String[] tokens = metricIndex.split(METRIC_TOKEN_SEPARATOR_REGEX); switch (tokens.length - baseLevel) { case 1: if (baseLevel > 0) { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.lastIndexOf("."))); } else { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.indexOf("."))); } addChildrenDocCount(metricNameBaseLevelMap, metricIndex.substring(0, metricIndex.lastIndexOf(".")), docCount); break; case 0: setActualDocCount(metricNameBaseLevelMap, metricIndex, docCount); break; default: break; } }
MetricIndexData { public void add(String metricIndex, long docCount) { final String[] tokens = metricIndex.split(METRIC_TOKEN_SEPARATOR_REGEX); switch (tokens.length - baseLevel) { case 1: if (baseLevel > 0) { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.lastIndexOf("."))); } else { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.indexOf("."))); } addChildrenDocCount(metricNameBaseLevelMap, metricIndex.substring(0, metricIndex.lastIndexOf(".")), docCount); break; case 0: setActualDocCount(metricNameBaseLevelMap, metricIndex, docCount); break; default: break; } } }
MetricIndexData { public void add(String metricIndex, long docCount) { final String[] tokens = metricIndex.split(METRIC_TOKEN_SEPARATOR_REGEX); switch (tokens.length - baseLevel) { case 1: if (baseLevel > 0) { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.lastIndexOf("."))); } else { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.indexOf("."))); } addChildrenDocCount(metricNameBaseLevelMap, metricIndex.substring(0, metricIndex.lastIndexOf(".")), docCount); break; case 0: setActualDocCount(metricNameBaseLevelMap, metricIndex, docCount); break; default: break; } } MetricIndexData(int baseLevel); }
MetricIndexData { public void add(String metricIndex, long docCount) { final String[] tokens = metricIndex.split(METRIC_TOKEN_SEPARATOR_REGEX); switch (tokens.length - baseLevel) { case 1: if (baseLevel > 0) { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.lastIndexOf("."))); } else { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.indexOf("."))); } addChildrenDocCount(metricNameBaseLevelMap, metricIndex.substring(0, metricIndex.lastIndexOf(".")), docCount); break; case 0: setActualDocCount(metricNameBaseLevelMap, metricIndex, docCount); break; default: break; } } MetricIndexData(int baseLevel); void add(String metricIndex, long docCount); Set<String> getMetricNamesWithNextLevel(); Set<String> getCompleteMetricNamesAtBaseLevel(); }
MetricIndexData { public void add(String metricIndex, long docCount) { final String[] tokens = metricIndex.split(METRIC_TOKEN_SEPARATOR_REGEX); switch (tokens.length - baseLevel) { case 1: if (baseLevel > 0) { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.lastIndexOf("."))); } else { metricNamesWithNextLevelSet.add(metricIndex.substring(0, metricIndex.indexOf("."))); } addChildrenDocCount(metricNameBaseLevelMap, metricIndex.substring(0, metricIndex.lastIndexOf(".")), docCount); break; case 0: setActualDocCount(metricNameBaseLevelMap, metricIndex, docCount); break; default: break; } } MetricIndexData(int baseLevel); void add(String metricIndex, long docCount); Set<String> getMetricNamesWithNextLevel(); Set<String> getCompleteMetricNamesAtBaseLevel();  }