Search in sources :

Example 6 with NodeStateEntry

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

the class NodeStateEntryWriterTest method childOrderNotWritten.

@Test
public void childOrderNotWritten() {
    NodeStateEntryWriter nw = new NodeStateEntryWriter(blobStore);
    NodeBuilder b1 = EMPTY_NODE.builder();
    b1.setProperty("foo", "bar");
    b1.setProperty(":childOrder", "bar");
    b1.setProperty(":hidden", "bar");
    NodeStateEntry e1 = new NodeStateEntry(b1.getNodeState(), "/a");
    String line = nw.toString(e1);
    NodeStateEntryReader nr = new NodeStateEntryReader(blobStore);
    NodeStateEntry r1 = nr.read(line);
    assertTrue(r1.getNodeState().hasProperty(":hidden"));
    assertFalse(r1.getNodeState().hasProperty(":childOrder"));
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 7 with NodeStateEntry

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

the class NodeStateEntryWriterTest method multipleEntries.

@Test
public void multipleEntries() {
    NodeStateEntryWriter nw = new NodeStateEntryWriter(blobStore);
    NodeBuilder b1 = EMPTY_NODE.builder();
    b1.setProperty("foo", "bar");
    NodeBuilder b2 = EMPTY_NODE.builder();
    b2.setProperty("foo2", "bar2");
    NodeStateEntry e1 = new NodeStateEntry(b1.getNodeState(), "/a");
    NodeStateEntry e2 = new NodeStateEntry(b2.getNodeState(), "/a");
    String line1 = nw.toString(e1);
    String line2 = nw.toString(e2);
    NodeStateEntryReader nr = new NodeStateEntryReader(blobStore);
    assertEquals(e1, nr.read(line1));
    assertEquals(e2, nr.read(line2));
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 8 with NodeStateEntry

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

the class NodeStateEntryWriterTest method pathElements_root.

@Test
public void pathElements_root() {
    NodeStateEntryWriter nw = new NodeStateEntryWriter(blobStore);
    NodeBuilder b1 = EMPTY_NODE.builder();
    b1.setProperty("foo", "bar");
    NodeStateEntry e1 = new NodeStateEntry(b1.getNodeState(), "/");
    String json = nw.asJson(e1.getNodeState());
    List<String> pathElements = copyOf(elements(e1.getPath()));
    String line = nw.toString(pathElements, json);
    NodeStateEntryReader nr = new NodeStateEntryReader(blobStore);
    NodeStateEntry r1 = nr.read(line);
    assertTrue(r1.getNodeState().hasProperty("foo"));
    assertEquals("/", r1.getPath());
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 9 with NodeStateEntry

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

the class NodeStateEntryWriterTest method pathElements.

@Test
public void pathElements() {
    NodeStateEntryWriter nw = new NodeStateEntryWriter(blobStore);
    NodeBuilder b1 = EMPTY_NODE.builder();
    b1.setProperty("foo", "bar");
    NodeStateEntry e1 = new NodeStateEntry(b1.getNodeState(), "/a/b/c/d");
    String json = nw.asJson(e1.getNodeState());
    List<String> pathElements = copyOf(elements(e1.getPath()));
    String line = nw.toString(pathElements, json);
    NodeStateEntryReader nr = new NodeStateEntryReader(blobStore);
    NodeStateEntry r1 = nr.read(line);
    assertTrue(r1.getNodeState().hasProperty("foo"));
    assertEquals("/a/b/c/d", r1.getPath());
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 10 with NodeStateEntry

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

the class StoreAndSortStrategy method writeToStore.

private File writeToStore(File dir, String fileName) throws IOException {
    entryCount = 0;
    File file = new File(dir, fileName);
    Stopwatch sw = Stopwatch.createStarted();
    try (BufferedWriter w = FlatFileStoreUtils.createWriter(file, compressionEnabled)) {
        for (NodeStateEntry e : nodeStates) {
            String line = entryWriter.toString(e);
            w.append(line);
            w.newLine();
            textSize += line.length() + LINE_SEP_LENGTH;
            entryCount++;
        }
    }
    String sizeStr = compressionEnabled ? String.format("compressed/%s actual size", humanReadableByteCount(textSize)) : "";
    log.info("Dumped {} nodestates in json format in {} ({} {})", entryCount, sw, humanReadableByteCount(file.length()), sizeStr);
    return file;
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) Stopwatch(com.google.common.base.Stopwatch) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

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