PropertyIndexStats extends AnnotatedStandardMBean implements PropertyIndexStatsMBean { @Override public CompositeData getStatsForSpecificIndex(String path, int maxValueCount, int maxDepth, int maxPathCount) throws OpenDataException { NodeState idx = NodeStateUtils.getNode(store.getRoot(), path); return getStatsForIndex(path, idx, maxValueCount, maxDepth, maxPathCount); } PropertyIndexStats(); @Override TabularData getStatsForAllIndexes(String path, int maxValueCount, int maxDepth, int maxPathCount); @Override CompositeData getStatsForSpecificIndex(String path, int maxValueCount, int maxDepth, int maxPathCount);  }
@Test public void statsForSpecificIndex() throws Exception{ prepareStore(); NodeBuilder builder = store.getRoot().builder(); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, false, ImmutableSet.of("foo"), null); setProperty(builder, "/a/b/c", "foo", "x"); setProperty(builder, "/a/e/c/d", "foo", "y"); store.merge(builder, HOOK, CommitInfo.EMPTY); CompositeData cd = mbean.getStatsForSpecificIndex("/oak:index/foo", 5, 2, 100); assertEquals(2L, cd.get("valueCount")); assertArray(cd, "values", asList("x", "y")); assertArray(cd, "paths", asList("/a/b", "/a/e")); cd = mbean.getStatsForSpecificIndex("/oak:index/foo", 5, 3, 100); assertArray(cd, "paths", asList("/a/b/c", "/a/e/c")); cd = mbean.getStatsForSpecificIndex("/oak:index/foo", 5, 5, 100); assertArray(cd, "paths", asList("/a/b/c", "/a/e/c/d")); }
@Test public void statsForSpecificIndexWithPathLimit() throws Exception{ prepareStore(); NodeBuilder builder = store.getRoot().builder(); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, false, ImmutableSet.of("foo"), null); for (int i = 0; i < 10; i++) { setProperty(builder, "/a/b/c/d" + i, "foo", "x"); } store.merge(builder, HOOK, CommitInfo.EMPTY); CompositeData cd = mbean.getStatsForSpecificIndex("/oak:index/foo", 5, 7, 3); assertEquals(1L, cd.get("valueCount")); assertArray(cd, "values", asList("x")); assertArray(cd, "paths", asList("/a/b/c")); }