Search in sources :

Example 71 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class OakSolrNodeStateConfigurationTest method setUp.

@Before
public void setUp() throws Exception {
    store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    NodeBuilder builder = store.getRoot().builder();
    builder.setProperty("a", 1).setProperty("b", 2).setProperty("c", 3);
    builder.setChildNode("x");
    builder.setChildNode("y");
    builder.setChildNode("z");
    builder.setChildNode("oak:index").setChildNode("solrIdx").setProperty("type", "solr").setProperty("rows", "100");
    store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Before(org.junit.Before)

Example 72 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrIndexLookupTest method collectPathOnSubNode.

@Test
public void collectPathOnSubNode() throws Exception {
    NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
    newSolrIndexDefinition(index, "l1", of("foo"));
    index = builder.child("a").child(INDEX_DEFINITIONS_NAME);
    newSolrIndexDefinition(index, "l2", of("foo"));
    index = builder.child("a").child("b").child(INDEX_DEFINITIONS_NAME);
    newSolrIndexDefinition(index, "l3", of("foo"));
    SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
    FilterImpl f = FilterImpl.newTestInstance();
    f.restrictPath("/a", Filter.PathRestriction.EXACT);
    assertEquals(of("/oak:index/l1", "/a/oak:index/l2"), lookup.collectIndexNodePaths(f));
    f.restrictPath("/a/b", Filter.PathRestriction.EXACT);
    assertEquals(of("/oak:index/l1", "/a/oak:index/l2", "/a/b/oak:index/l3"), lookup.collectIndexNodePaths(f));
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 73 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrIndexLookupTest method collectPathOnRootNode.

@Test
public void collectPathOnRootNode() throws Exception {
    NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
    newSolrIndexDefinition(index, "l1", of("foo"));
    newSolrIndexDefinition(index, "l2", of("foo"));
    SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
    FilterImpl f = FilterImpl.newTestInstance();
    f.restrictPath("/", Filter.PathRestriction.EXACT);
    assertEquals(of("/oak:index/l1", "/oak:index/l2"), lookup.collectIndexNodePaths(f));
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 74 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testPlanWithPropertyRestrictionsEnabledAndUsedProperty.

@Test
public void testPlanWithPropertyRestrictionsEnabledAndUsedProperty() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("usedProperties", Collections.singleton("name"), Type.STRINGS).setProperty("propertyRestrictions", true);
    nodeState = builder.getNodeState();
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
    filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(1, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 75 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexPlannerTest method nullPropertyCheck2.

@Test
public void nullPropertyCheck2() throws Exception {
    root = registerTestNodeType(builder).getNodeState();
    NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
    NodeBuilder rules = defn.child(INDEX_RULES);
    TestUtil.child(rules, "oak:TestNode/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "foo").setProperty(LuceneIndexConstants.PROP_NULL_CHECK_ENABLED, true).setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true);
    IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState().getChildNode("test"), "/foo");
    IndexNode node = createIndexNode(idxDefn);
    FilterImpl filter = createFilter(NT_TEST);
    filter.restrictProperty("foo", Operator.EQUAL, null);
    IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
    QueryIndex.IndexPlan plan = planner.getPlan();
    assertNotNull("For null checks plan should be returned with nullCheckEnabled", plan);
    IndexPlanner.PlanResult pr = (IndexPlanner.PlanResult) plan.getAttribute(LucenePropertyIndex.ATTR_PLAN_RESULT);
    assertNotNull(pr.getPropDefn(filter.getPropertyRestriction("foo")));
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1190 Test (org.junit.Test)849 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)338 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)96 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)82 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)80 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)77 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)75 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)73 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)69 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)64 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)61 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)43 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)40 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)38 Blob (org.apache.jackrabbit.oak.api.Blob)36 ArrayList (java.util.ArrayList)29 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)28 Nonnull (javax.annotation.Nonnull)26