Search in sources :

Example 1 with BTreeManager

use of org.apache.jackrabbit.commons.flat.BTreeManager in project jackrabbit by apache.

the class ItemSequenceTest method testEmptyNodeSequence.

public void testEmptyNodeSequence() throws RepositoryException {
    Comparator<String> order = Rank.<String>comparableComparator();
    TreeManager treeManager = new BTreeManager(testNode, 5, 10, order, true);
    NodeSequence nodes = ItemSequence.createNodeSequence(treeManager, errorHandler);
    Iterator<Node> nodeIt = nodes.iterator();
    assertTrue(nodeIt.hasNext());
    assertTrue(treeManager.isRoot(nodeIt.next()));
    assertFalse(nodeIt.hasNext());
    checkTreeProperty(testNode, 5, 10, order);
    checkOrder(nodes, order);
    assertEmpty(nodes);
}
Also used : NodeSequence(org.apache.jackrabbit.commons.flat.NodeSequence) Node(javax.jcr.Node) TreeManager(org.apache.jackrabbit.commons.flat.TreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager)

Example 2 with BTreeManager

use of org.apache.jackrabbit.commons.flat.BTreeManager in project jackrabbit by apache.

the class ItemSequenceTest method testNodeSequence.

public void testNodeSequence() throws RepositoryException, IOException {
    Comparator<String> order = Rank.<String>comparableComparator();
    TreeManager treeManager = new BTreeManager(testNode, 5, 10, order, true);
    NodeSequence nodes = ItemSequence.createNodeSequence(treeManager, errorHandler);
    List<String> words = loadWords();
    Collections.shuffle(words);
    addAll(nodes, words);
    checkTreeProperty(testNode, 5, 10, order);
    checkOrder(nodes, order);
    Collections.shuffle(words);
    checkLookup(nodes, words);
    Collections.shuffle(words);
    List<String> toRemove = take(words.size() / 5, words);
    removeAll(nodes, toRemove);
    checkNotFound(nodes, toRemove);
    checkLookup(nodes, words);
    removeAll(nodes, words);
    assertEmpty(nodes);
}
Also used : NodeSequence(org.apache.jackrabbit.commons.flat.NodeSequence) TreeManager(org.apache.jackrabbit.commons.flat.TreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager)

Example 3 with BTreeManager

use of org.apache.jackrabbit.commons.flat.BTreeManager in project jackrabbit by apache.

the class ItemSequenceTest method testSingletonPropertySequence.

public void testSingletonPropertySequence() throws RepositoryException {
    Comparator<String> order = Rank.<String>comparableComparator();
    TreeManager treeManager = new BTreeManager(testNode, 2, 4, order, true);
    PropertySequence properties = ItemSequence.createPropertySequence(treeManager, errorHandler);
    ValueFactory vFactory = testNode.getSession().getValueFactory();
    properties.addProperty("key", vFactory.createValue("key_"));
    assertTrue(properties.hasItem("key"));
    Iterator<Property> propertyIt = properties.iterator();
    assertTrue(propertyIt.hasNext());
    assertEquals("key", propertyIt.next().getName());
    assertFalse(propertyIt.hasNext());
    properties.removeProperty("key");
    assertEmpty(properties);
}
Also used : PropertySequence(org.apache.jackrabbit.commons.flat.PropertySequence) TreeManager(org.apache.jackrabbit.commons.flat.TreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager) ValueFactory(javax.jcr.ValueFactory) Property(javax.jcr.Property) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager)

Example 4 with BTreeManager

use of org.apache.jackrabbit.commons.flat.BTreeManager in project jackrabbit by apache.

the class ItemSequenceTest method testSingletonNodeSequence.

public void testSingletonNodeSequence() throws RepositoryException {
    Comparator<String> order = Rank.<String>comparableComparator();
    TreeManager treeManager = new BTreeManager(testNode, 5, 10, order, true);
    NodeSequence nodes = ItemSequence.createNodeSequence(treeManager, errorHandler);
    nodes.addNode("key", NodeType.NT_UNSTRUCTURED);
    assertTrue(nodes.hasItem("key"));
    Iterator<Node> nodeIt = nodes.iterator();
    assertTrue(nodeIt.hasNext());
    assertEquals("key", nodeIt.next().getName());
    assertFalse(nodeIt.hasNext());
    checkTreeProperty(testNode, 5, 10, order);
    checkOrder(nodes, order);
    nodes.removeNode("key");
    assertEmpty(nodes);
}
Also used : NodeSequence(org.apache.jackrabbit.commons.flat.NodeSequence) Node(javax.jcr.Node) TreeManager(org.apache.jackrabbit.commons.flat.TreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager)

Example 5 with BTreeManager

use of org.apache.jackrabbit.commons.flat.BTreeManager in project jackrabbit by apache.

the class ItemSequenceTest method testPropertySequence.

public void testPropertySequence() throws RepositoryException, IOException {
    Comparator<String> order = Rank.<String>comparableComparator();
    TreeManager treeManager = new BTreeManager(testNode, 2, 4, order, true);
    PropertySequence properties = ItemSequence.createPropertySequence(treeManager, errorHandler);
    List<String> words = loadWords();
    Collections.shuffle(words);
    ValueFactory vFactory = testNode.getSession().getValueFactory();
    addAll(properties, words, vFactory);
    checkTreeProperty(testNode, 2, 4, order);
    Collections.shuffle(words);
    checkLookup(properties, words);
    Collections.shuffle(words);
    List<String> toRemove = take(words.size() / 5, words);
    removeAll(properties, toRemove);
    checkNotFound(properties, toRemove);
    checkLookup(properties, words);
    removeAll(properties, words);
    assertEmpty(properties);
}
Also used : PropertySequence(org.apache.jackrabbit.commons.flat.PropertySequence) TreeManager(org.apache.jackrabbit.commons.flat.TreeManager) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager) ValueFactory(javax.jcr.ValueFactory) BTreeManager(org.apache.jackrabbit.commons.flat.BTreeManager)

Aggregations

BTreeManager (org.apache.jackrabbit.commons.flat.BTreeManager)7 TreeManager (org.apache.jackrabbit.commons.flat.TreeManager)7 NodeSequence (org.apache.jackrabbit.commons.flat.NodeSequence)3 PropertySequence (org.apache.jackrabbit.commons.flat.PropertySequence)3 Node (javax.jcr.Node)2 Property (javax.jcr.Property)2 ValueFactory (javax.jcr.ValueFactory)2