Package org.apache.jackrabbit.oak.plugins.index.property.strategy

Examples of org.apache.jackrabbit.oak.plugins.index.property.strategy.IndexStoreStrategy


            // check uniqueness constraints when leaving the root
            if (keysToCheckForUniqueness != null
                    && !keysToCheckForUniqueness.isEmpty()) {
                NodeState indexMeta = definition.getNodeState();
                IndexStoreStrategy s = getStrategy(true);
                for (String key : keysToCheckForUniqueness) {
                    if (s.count(indexMeta, singleton(key), 2) > 1) {
                        throw new CommitFailedException(
                                CONSTRAINT, 30,
                                "Uniqueness constraint violated for key " + key);
                    }
                }
View Full Code Here


            // check uniqueness constraints when leaving the root
            if (keysToCheckForUniqueness != null
                    && !keysToCheckForUniqueness.isEmpty()) {
                NodeState indexMeta = definition.getNodeState();
                IndexStoreStrategy s = getStrategy(true);
                for (String key : keysToCheckForUniqueness) {
                    if (s.count(indexMeta, singleton(key), 2) > 1) {
                        throw new CommitFailedException(
                                CONSTRAINT, 30,
                                "Uniqueness constraint violated for key " + key);
                    }
                }
View Full Code Here

            definition.child(INDEX_CONTENT_NODE_NAME);

            // check uniqueness constraints when leaving the root
            if (unique && !keysToCheckForUniqueness.isEmpty()) {
                NodeState indexMeta = definition.getNodeState();
                IndexStoreStrategy s = getStrategy(unique);
                for (String key : keysToCheckForUniqueness) {
                    if (s.count(indexMeta, singleton(key), 2) > 1) {
                        throw new CommitFailedException(
                                CONSTRAINT, 30,
                                "Uniqueness constraint violated for key " + key);
                    }
                }
View Full Code Here

            // check uniqueness constraints when leaving the root
            if (keysToCheckForUniqueness != null
                    && !keysToCheckForUniqueness.isEmpty()) {
                NodeState indexMeta = definition.getNodeState();
                IndexStoreStrategy s = getStrategy(true);
                for (String key : keysToCheckForUniqueness) {
                    if (s.count(indexMeta, singleton(key), 2) > 1) {
                        throw new CommitFailedException(
                                CONSTRAINT, 30,
                                "Uniqueness constraint violated for key " + key);
                    }
                }
View Full Code Here

     * property is considered dead weight and should be removed from the index</li>
     * </ul>
     */
    @Test
    public void testIndexPruning() throws Exception {
        IndexStoreStrategy store = new ContentMirrorStoreStrategy();

        NodeState root = EMPTY_NODE;
        NodeBuilder index = root.builder();

        store.insert(index, "key",
                Sets.newHashSet("/", "a/b/c", "a/b/d", "b", "d/e", "d/e/f"));
        checkPath(index, "key", "", true);
        checkPath(index, "key", "a/b/c", true);
        checkPath(index, "key", "a/b/d", true);
        checkPath(index, "key", "b", true);
        checkPath(index, "key", "d/e", true);
        checkPath(index, "key", "d/e/f", true);

        // remove the root key, removes just the "match" property, when the
        // index is not empty
        store.remove(index, "key", Sets.newHashSet("/"));
        checkPath(index, "key", "d/e/f", true);

        // removing intermediary path doesn't remove the entire subtree
        store.remove(index, "key", Sets.newHashSet("d/e"));
        checkPath(index, "key", "d/e/f", true);

        // removing intermediary path doesn't remove the entire subtree
        store.remove(index, "key", Sets.newHashSet("d/e/f"));
        checkNotPath(index, "key", "d");

        // brother segment removed
        store.remove(index, "key", Sets.newHashSet("a/b/d", "a/b"));
        checkPath(index, "key", "a/b/c", true);

        // reinsert root and remove everything else
        store.insert(index, "key", Sets.newHashSet("/"));
        store.remove(index, "key", Sets.newHashSet("d/e/f", "b", "a/b/c"));

        // remove the root key when the index is empty
        store.remove(index, "key", Sets.newHashSet("/"));
        Assert.assertEquals(0, index.getChildNodeCount());
    }
View Full Code Here

        Assert.assertFalse(check.hasChildNode(name));
    }

    @Test
    public void testUnique() throws CommitFailedException {
        IndexStoreStrategy store = new ContentMirrorStoreStrategy();
        NodeState root = EMPTY_NODE;
        NodeBuilder index = root.builder();
        store.insert(index, "key", Sets.newHashSet("a"));
        store.insert(index, "key", Sets.newHashSet("b"));
        Assert.assertTrue(
                "ContentMirrorStoreStrategy should guarantee uniqueness on insert",
                store.count(index.getNodeState(), Collections.singletonList("key"), 2) > 1);
    }
View Full Code Here

     *
     * @return the proper index strategy
     */
    @Override
    IndexStoreStrategy getStrategy(boolean unique) {
        IndexStoreStrategy store = ORDERED_MIRROR;
        if (!OrderedIndex.DEFAULT_DIRECTION.equals(getDirection())) {
            store = ORDERED_MIRROR_DESCENDING;
        }
        return store;
    }
View Full Code Here

     *
     * @return the proper index strategy
     */
    @Override
    IndexStoreStrategy getStrategy(boolean unique) {
        IndexStoreStrategy store = ORDERED_MIRROR;
        if (!OrderedIndex.DEFAULT_DIRECTION.equals(getDirection())) {
            store = ORDERED_MIRROR_DESCENDING;
        }
        return store;
    }
View Full Code Here

            // check uniqueness constraints when leaving the root
            if (keysToCheckForUniqueness != null
                    && !keysToCheckForUniqueness.isEmpty()) {
                NodeState indexMeta = definition.getNodeState();
                IndexStoreStrategy s = getStrategy(true);
                for (String key : keysToCheckForUniqueness) {
                    if (s.count(indexMeta, singleton(key), 2) > 1) {
                        throw new CommitFailedException(
                                CONSTRAINT, 30,
                                "Uniqueness constraint violated for key " + key);
                    }
                }
View Full Code Here

     *
     * @return the proper index strategy
     */
    @Override
    IndexStoreStrategy getStrategy(boolean unique) {
        IndexStoreStrategy store = ORDERED_MIRROR;
        if (!OrderedIndex.DEFAULT_DIRECTION.equals(getDirection())) {
            store = ORDERED_MIRROR_DESCENDING;
        }
        return store;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.index.property.strategy.IndexStoreStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.