Search in sources :

Example 1 with NodeStateEntry

use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.

the class TraverseWithSortStrategy method writeToSortedFiles.

private void writeToSortedFiles() throws IOException {
    Stopwatch w = Stopwatch.createStarted();
    for (NodeStateEntry e : nodeStates) {
        entryCount++;
        addEntry(e);
    }
    // Save the last batch
    sortAndSaveBatch();
    // Free up the batch
    entryBatch.clear();
    entryBatch.trimToSize();
    log.info("Dumped {} nodestates in json format in {}", entryCount, w);
    log.info("Created {} sorted files of size {} to merge", sortedFiles.size(), humanReadableByteCount(sizeOf(sortedFiles)));
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) Stopwatch(com.google.common.base.Stopwatch)

Example 2 with NodeStateEntry

use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.

the class FlatFileStoreIteratorTest method comodificationException.

// OAK-7284
@Test
public void comodificationException() {
    Set<String> preferred = ImmutableSet.of("j:c");
    CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/j:c", "/a/j:c/j:c", "/a/b"));
    FlatFileStoreIterator fitr = new FlatFileStoreIterator(citr.iterator(), preferred);
    NodeStateEntry a = fitr.next();
    assertEquals("/a", a.getPath());
    NodeState aNS = a.getNodeState();
    // fake aggregate rule like "j:c/*"
    for (ChildNodeEntry cne : aNS.getChildNodeEntries()) {
        NodeState childNS = cne.getNodeState();
        // read preferred names for aggregation sub-tree nodes
        for (String prefName : preferred) {
            childNS.getChildNode(prefName);
        }
    }
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) Test(org.junit.Test)

Example 3 with NodeStateEntry

use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.

the class FlatFileStoreIteratorTest method invalidOrderAccess.

@Test
public void invalidOrderAccess() {
    Set<String> preferred = ImmutableSet.of("jcr:content");
    CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/jcr:content/metadata", "/a/d", "/e"));
    FlatFileStoreIterator fitr = new FlatFileStoreIterator(citr.iterator(), preferred);
    NodeStateEntry a = fitr.next();
    assertEquals("/a", a.getPath());
    NodeState ns1 = a.getNodeState().getChildNode("jcr:content");
    NodeStateEntry nse1 = fitr.next();
    assertEquals("/a/jcr:content", nse1.getPath());
    assertEquals(1, nse1.getNodeState().getChildNodeCount(100));
    // Now move past /a/jcr:content
    NodeStateEntry nse2 = fitr.next();
    assertEquals("/a/jcr:content/metadata", nse2.getPath());
    try {
        // Now access from /a/jcr:content node should fail
        ns1.getChildNodeCount(100);
        fail("Access should have failed");
    } catch (IllegalStateException ignore) {
    }
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Example 4 with NodeStateEntry

use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.

the class FlatFileStoreIteratorTest method getChildNodeLimitedByNonPreferred.

// OAK-7285
@Test
public void getChildNodeLimitedByNonPreferred() {
    // have more than 1 preferred names
    Set<String> preferred = ImmutableSet.of("j:c", "md");
    CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/b", "/a/c"));
    FlatFileStoreIterator fitr = new FlatFileStoreIterator(citr.iterator(), preferred);
    NodeStateEntry a = fitr.next();
    assertEquals("/a", a.getPath());
    NodeState aNS = a.getNodeState();
    aNS.getChildNode("j:c");
    // Don't read whole tree to conclude that "j:c" doesn't exist (reading /a/b should imply that it doesn't exist)
    assertEquals(1, fitr.getBufferSize());
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Example 5 with NodeStateEntry

use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.

the class FlatFileStoreIteratorTest method simpleTraversal.

@Test
public void simpleTraversal() {
    Set<String> preferred = ImmutableSet.of("jcr:content");
    CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/jcr:content/metadata", "/a/d", "/e"));
    FlatFileStoreIterator fitr = new FlatFileStoreIterator(citr.iterator(), preferred);
    NodeStateEntry a = fitr.next();
    assertEquals("/a", a.getPath());
    NodeState ns1 = a.getNodeState().getChildNode("jcr:content");
    assertEquals("/a/jcr:content", ns1.getString("path"));
    assertEquals(1, fitr.getBufferSize());
    NodeState ns2 = ns1.getChildNode("metadata");
    assertEquals("/a/jcr:content/metadata", ns2.getString("path"));
    assertEquals(2, fitr.getBufferSize());
    NodeStateEntry nse1 = fitr.next();
    assertEquals("/a/jcr:content", nse1.getPath());
    NodeStateEntry nse2 = fitr.next();
    assertEquals("/a/jcr:content/metadata", nse2.getPath());
    NodeStateEntry nse3 = fitr.next();
    assertEquals("/a/d", nse3.getPath());
    assertEquals(0, nse3.getNodeState().getChildNodeCount(100));
    NodeStateEntry nse4 = fitr.next();
    assertEquals("/e", nse4.getPath());
    assertEquals(0, nse4.getNodeState().getChildNodeCount(100));
    assertFalse(fitr.hasNext());
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Aggregations

NodeStateEntry (org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry)17 Test (org.junit.Test)13 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)6 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)6 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 Stopwatch (com.google.common.base.Stopwatch)2 AbstractIterator (com.google.common.collect.AbstractIterator)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 TestUtils.createList (org.apache.jackrabbit.oak.index.indexer.document.flatfile.TestUtils.createList)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1