Search in sources :

Example 51 with MutableLong

use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.

the class SeekCursorTest method shouldCatchupRootWhenRootNodeHasTooNewGeneration.

@Test
public void shouldCatchupRootWhenRootNodeHasTooNewGeneration() throws Exception {
    // given
    long id = cursor.getCurrentPageId();
    long generation = node.generation(cursor);
    MutableBoolean triggered = new MutableBoolean(false);
    Supplier<Root> rootCatchup = () -> {
        triggered.setTrue();
        return new Root(id, generation);
    };
    // when
    try (SeekCursor<MutableLong, MutableLong> seek = new SeekCursor<>(cursor, node, from, to, layout, stableGeneration, unstableGeneration, generationSupplier, rootCatchup, generation - 1)) {
    // do nothing
    }
    // then
    assertTrue(triggered.getValue());
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) Test(org.junit.Test)

Example 52 with MutableLong

use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.

the class SeekCursorTest method mustStartReadingFromCorrectLeafWhenRangeStartWithKeyEqualToPrimKey.

@Test
public void mustStartReadingFromCorrectLeafWhenRangeStartWithKeyEqualToPrimKey() throws Exception {
    // given
    for (int i = 0; i < maxKeyCount + 1; i++) {
        insert(i);
    }
    MutableLong primKey = layout.newKey();
    node.keyAt(cursor, primKey, 0);
    long expectedNext = primKey.longValue();
    long rightChild = GenerationSafePointerPair.pointer(node.childAt(cursor, 1, stableGeneration, unstableGeneration));
    // when
    try (SeekCursor<MutableLong, MutableLong> seek = seekCursor(expectedNext, maxKeyCount + 1)) {
        assertEquals(rightChild, cursor.getCurrentPageId());
        while (seek.next()) {
            assertKeyAndValue(seek, expectedNext);
            expectedNext++;
        }
    }
    // then
    assertEquals(maxKeyCount + 1, expectedNext);
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) Test(org.junit.Test)

Example 53 with MutableLong

use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.

the class TreeNodeTest method shouldRemoveKey.

private void shouldRemoveKey() throws Exception {
    // GIVEN
    MutableLong key = layout.newKey();
    long firstKey = 10;
    key.setValue(firstKey);
    node.insertKeyAt(cursor, key, 0, 0);
    long otherKey = 19;
    key.setValue(otherKey);
    node.insertKeyAt(cursor, key, 1, 1);
    long thirdKey = 123;
    key.setValue(thirdKey);
    node.insertKeyAt(cursor, key, 2, 2);
    // WHEN
    node.removeKeyAt(cursor, 1, 3);
    // THEN
    assertEquals(firstKey, node.keyAt(cursor, key, 0).longValue());
    assertEquals(thirdKey, node.keyAt(cursor, key, 1).longValue());
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong)

Example 54 with MutableLong

use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.

the class TreeNodeTest method shouldSetAndGetValue.

@Test
public void shouldSetAndGetValue() throws Exception {
    // GIVEN
    node.initializeLeaf(cursor, STABLE_GENERATION, UNSTABLE_GENERATION);
    MutableLong value = layout.newKey();
    // WHEN
    long firstValue = 123456789;
    value.setValue(firstValue);
    node.insertValueAt(cursor, value, 0, 0);
    long otherValue = 987654321;
    value.setValue(otherValue);
    node.insertValueAt(cursor, value, 1, 1);
    // THEN
    assertEquals(firstValue, node.valueAt(cursor, value, 0).longValue());
    assertEquals(otherValue, node.valueAt(cursor, value, 1).longValue());
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) Test(org.junit.Test)

Example 55 with MutableLong

use of org.apache.commons.lang3.mutable.MutableLong in project neo4j by neo4j.

the class TreeNodeTest method shouldSetAndGetKey.

private void shouldSetAndGetKey() throws Exception {
    // GIVEN
    MutableLong key = layout.newKey();
    // WHEN
    long firstKey = 10;
    key.setValue(firstKey);
    node.insertKeyAt(cursor, key, 0, 0);
    long otherKey = 19;
    key.setValue(otherKey);
    node.insertKeyAt(cursor, key, 1, 1);
    // THEN
    assertEquals(firstKey, node.keyAt(cursor, key, 0).longValue());
    assertEquals(otherKey, node.keyAt(cursor, key, 1).longValue());
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong)

Aggregations

MutableLong (org.apache.commons.lang3.mutable.MutableLong)66 Test (org.junit.Test)45 IOException (java.io.IOException)11 Query (org.apache.apex.malhar.lib.appdata.schemas.Query)6 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)5 PageCache (org.neo4j.io.pagecache.PageCache)4 File (java.io.File)3 Map (java.util.Map)3 KeyedWindowedOperatorImpl (org.apache.apex.malhar.lib.window.impl.KeyedWindowedOperatorImpl)3 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)3 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 ConsoleOutputOperator (org.apache.apex.malhar.lib.io.ConsoleOutputOperator)2 SpillableComplexComponentImpl (org.apache.apex.malhar.lib.state.spillable.SpillableComplexComponentImpl)2 Tuple (org.apache.apex.malhar.lib.window.Tuple)2 WindowOption (org.apache.apex.malhar.lib.window.WindowOption)2 WindowState (org.apache.apex.malhar.lib.window.WindowState)2 SumLong (org.apache.apex.malhar.lib.window.accumulation.SumLong)2 WindowedOperatorImpl (org.apache.apex.malhar.lib.window.impl.WindowedOperatorImpl)2