@Override public long count(Filter filter, NodeState root, NodeState indexMeta, Set<String> values, int max) { return strategy.count(filter, root, indexMeta, values, max); }
@Override public long count(NodeState root, NodeState indexMeta, Set<String> values, int max) { return strategy.count(root, indexMeta, values, max); }
@Override public long count(Filter filter, NodeState root, NodeState indexMeta, Set<String> values, int max) { return strategy.count(filter, root, indexMeta, values, max); }
@Override public long count(NodeState root, NodeState indexMeta, Set<String> values, int max) { return strategy.count(root, indexMeta, values, max); }
@Override public long count(Filter filter, NodeState root, NodeState indexMeta, Set<String> values, int max) { return strategy.count(filter, root, indexMeta, values, max); }
@Override public long count(NodeState root, NodeState indexMeta, Set<String> values, int max) { return strategy.count(root, indexMeta, values, max); }
private static boolean hasReferences(IndexStoreStrategy refStore, NodeState root, NodeState definition, String name, String key) { return definition.hasChildNode(name) && refStore.count(root, definition, of(key), 1) > 0; }
private static boolean hasReferences(IndexStoreStrategy refStore, NodeState root, NodeState definition, String name, String key) { return definition.hasChildNode(name) && refStore.count(root, definition, of(key), 1) > 0; }
private static boolean hasReferences(IndexStoreStrategy refStore, NodeState root, NodeState definition, String name, String key) { return definition.hasChildNode(name) && refStore.count(root, definition, of(key), 1) > 0; }
/** * From a set of keys, get the first that has multiple entries, if any. * * @param keys the keys * @param indexMeta the index configuration * @return the first duplicate, or null if none was found */ private String getFirstDuplicate(Set<String> keys, NodeState indexMeta) { for (String key : keys) { long count = 0; for (IndexStoreStrategy s : getStrategies(true)) { count += s.count(root, indexMeta, singleton(key), 2); if (count > 1) { Iterator<String> it = s.query(null, null, indexMeta, singleton(key)).iterator(); if (it.hasNext()) { return key + ": " + it.next(); } return key; } } } return null; }
/** * From a set of keys, get the first that has multiple entries, if any. * * @param keys the keys * @param indexMeta the index configuration * @return the first duplicate, or null if none was found */ private String getFirstDuplicate(Set<String> keys, NodeState indexMeta) { for (String key : keys) { long count = 0; for (IndexStoreStrategy s : getStrategies(true)) { count += s.count(root, indexMeta, singleton(key), 2); if (count > 1) { Iterator<String> it = s.query(null, null, indexMeta, singleton(key)).iterator(); if (it.hasNext()) { return key + ": " + it.next(); } return key; } } } return null; }
/** * From a set of keys, get the first that has multiple entries, if any. * * @param keys the keys * @param indexMeta the index configuration * @return the first duplicate, or null if none was found */ private String getFirstDuplicate(Set<String> keys, NodeState indexMeta) { for (String key : keys) { long count = 0; for (IndexStoreStrategy s : getStrategies(true)) { count += s.count(root, indexMeta, singleton(key), 2); if (count > 1) { Iterator<String> it = s.query(null, null, indexMeta, singleton(key)).iterator(); if (it.hasNext()) { return key + ": " + it.next(); } return key; } } } return null; }
public double getCost(Filter filter, String propertyName, PropertyValue value) { NodeState indexMeta = getIndexNode(root, propertyName, filter); if (indexMeta == null) { return Double.POSITIVE_INFINITY; } Set<IndexStoreStrategy> strategies = getStrategies(indexMeta); ValuePattern pattern = new ValuePattern(indexMeta); double cost = strategies.isEmpty() ? MAX_COST : COST_OVERHEAD; for (IndexStoreStrategy s : strategies) { cost += s.count(filter, root, indexMeta, encode(value, pattern), MAX_COST); } return cost; }
public double getCost(Filter filter, String propertyName, PropertyValue value) { NodeState indexMeta = getIndexNode(root, propertyName, filter); if (indexMeta == null) { return Double.POSITIVE_INFINITY; } Set<IndexStoreStrategy> strategies = getStrategies(indexMeta); ValuePattern pattern = new ValuePattern(indexMeta); double cost = strategies.isEmpty() ? MAX_COST : COST_OVERHEAD; for (IndexStoreStrategy s : strategies) { cost += s.count(filter, root, indexMeta, encode(value, pattern), MAX_COST); } return cost; }
public double getCost(Filter filter, String propertyName, PropertyValue value) { NodeState indexMeta = getIndexNode(root, propertyName, filter); if (indexMeta == null) { return Double.POSITIVE_INFINITY; } Set<IndexStoreStrategy> strategies = getStrategies(indexMeta); ValuePattern pattern = new ValuePattern(indexMeta); double cost = strategies.isEmpty() ? MAX_COST : COST_OVERHEAD; for (IndexStoreStrategy s : strategies) { cost += s.count(filter, root, indexMeta, encode(value, pattern), MAX_COST); } return cost; }
@Test public void testUnique() throws CommitFailedException { IndexStoreStrategy store = new ContentMirrorStoreStrategy(); NodeState root = EMPTY_NODE; NodeBuilder indexMeta = root.builder(); Supplier<NodeBuilder> index = memoize(() -> indexMeta.child(INDEX_CONTENT_NODE_NAME)); store.update(index, "a", null, null, EMPTY, KEY); store.update(index, "b", null, null, EMPTY, KEY); Assert.assertTrue( "ContentMirrorStoreStrategy should guarantee uniqueness on insert", store.count(root, indexMeta.getNodeState(), Collections.singleton("key"), 2) > 1); }
double cost = strategies.isEmpty() ? MAX_COST : 0; for (IndexStoreStrategy strategy : strategies) { cost += strategy.count(filter, root, definition, values, MAX_COST);
approxNodeCount, store.count(root, indexMeta.getNodeState(), null, maxTraversal)); approxKeyCount, store.count(root, indexMeta.getNodeState(), KEY, maxTraversal)); Assert.assertEquals( "Entry count not used even when present for is-not-null query", entryCount, store.count(root, indexMeta.getNodeState(), null, maxTraversal)); entryCount > store.count(root, indexMeta.getNodeState(), KEY, maxTraversal)); entryCount > store.count(root, indexMeta.getNodeState(), KEY, maxTraversal)); Assert.assertEquals( "Entry count not used even when present for is-not-null query", 0, store.count(root, indexMeta.getNodeState(), null, maxTraversal));
double cost = strategies.isEmpty() ? MAX_COST : 0; for (IndexStoreStrategy strategy : strategies) { cost += strategy.count(filter, root, definition, values, MAX_COST);
"Approximate count not used for is-not-null query", approxNodeCount, store.count(filter, root, indexMeta.getNodeState(), null, maxTraversal)); "Approximate count not used for key=value query", approxKeyCount, store.count(filter, root, indexMeta.getNodeState(), KEY, maxTraversal)); entryCount, filteredNodeFactor * store.count(filter, root, indexMeta.getNodeState(), null, maxTraversal)); "Rough key count not considered for key=value query", entryCount > filteredNodeFactor * store.count(filter, root, indexMeta.getNodeState(), KEY, maxTraversal)); "Key count not considered for key=value query", entryCount > filteredNodeFactor * store.count(filter, root, indexMeta.getNodeState(), KEY, maxTraversal));