internal static void SetSuccessor(PageCursor cursor, long successorId, long stableGeneration, long unstableGeneration) { cursor.Offset = BytePosSuccessor; long result = GenerationSafePointerPair.Write(cursor, successorId, stableGeneration, unstableGeneration); GenerationSafePointerPair.AssertSuccess(result); }
internal static void SetLeftSibling(PageCursor cursor, long leftSiblingId, long stableGeneration, long unstableGeneration) { cursor.Offset = BytePosLeftsibling; long result = GenerationSafePointerPair.Write(cursor, leftSiblingId, stableGeneration, unstableGeneration); GenerationSafePointerPair.AssertSuccess(result); }
/// <summary> /// Checks a read pointer for success/failure and throws appropriate exception with failure information /// if failure. Must be called after a consistent read from page cache (after <seealso cref="PageCursor.shouldRetry()"/>. /// </summary> /// <param name="result"> result from <seealso cref="GenerationSafePointerPair.FLAG_READ"/> or /// <seealso cref="GenerationSafePointerPair.write(PageCursor, long, long, long)"/>. </param> /// <param name="allowNoNode"> If <seealso cref="TreeNode.NO_NODE_FLAG"/> is allowed as pointer value. </param> internal static void CheckPointer(long result, bool allowNoNode) { GenerationSafePointerPair.AssertSuccess(result); if (allowNoNode && !TreeNode.IsNode(result)) { return; } if (result < IdSpace.MIN_TREE_NODE_ID) { throw new TreeInconsistencyException("Pointer to id " + result + " not allowed. Minimum node id allowed is " + IdSpace.MIN_TREE_NODE_ID); } }
/* PageCorruption */ public static PageCorruption <KEY, VALUE> Crashed <KEY, VALUE>(GBPTreePointerType gbpTreePointerType) { return((pageCursor, layout, node, treeState) => { int offset = gbpTreePointerType.Offset(node); long stableGeneration = treeState.stableGeneration(); long unstableGeneration = treeState.unstableGeneration(); long crashGeneration = crashGeneration(treeState); pageCursor.Offset = offset; long pointer = pointer(GenerationSafePointerPair.Read(pageCursor, stableGeneration, unstableGeneration, NO_GENERATION_TARGET)); OverwriteGSPP(pageCursor, offset, crashGeneration, pointer); }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWrite() public virtual void ShouldWrite() { // GIVEN _cursor.Offset = SLOT_A_OFFSET; long preStatePointerA = StateA.materialize(_cursor, POINTER_A); _cursor.Offset = _slotBOffset; long preStatePointerB = StateB.materialize(_cursor, POINTER_B); // WHEN _cursor.Offset = GSPP_OFFSET; long written = GenerationSafePointerPair.Write(_cursor, WRITTEN_POINTER, STABLE_GENERATION, UNSTABLE_GENERATION); // THEN ExpectedWriteOutcome.verifyWrite(_cursor, written, StateA, StateB, preStatePointerA, preStatePointerB); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRead() public virtual void ShouldRead() { // GIVEN _cursor.Offset = SLOT_A_OFFSET; long preStatePointerA = StateA.materialize(_cursor, POINTER_A); _cursor.Offset = _slotBOffset; long preStatePointerB = StateB.materialize(_cursor, POINTER_B); // WHEN _cursor.Offset = GSPP_OFFSET; GenerationKeeper generationKeeper = new GenerationKeeper(); long result = GenerationSafePointerPair.Read(_cursor, STABLE_GENERATION, UNSTABLE_GENERATION, generationKeeper); // THEN ExpectedReadOutcome.verifyRead(_cursor, result, StateA, StateB, preStatePointerA, preStatePointerB, generationKeeper.Generation); }
private void AssertKeysAndChildren(long stable, long unstable, params long[] keysAndChildren) { KEY actualKey = _layout.newKey(); int pos; for (int i = 0; i < keysAndChildren.Length; i++) { pos = i / 2; if (i % 2 == 0) { assertEquals(keysAndChildren[i], GenerationSafePointerPair.Pointer(_node.childAt(Cursor, pos, stable, unstable))); } else { KEY expectedKey = Key(keysAndChildren[i]); _node.keyAt(Cursor, actualKey, pos, INTERNAL); assertEquals(0, _layout.Compare(expectedKey, actualKey)); } } }
private static void AssertFailure(long result, long readOrWrite, int generationComparison, sbyte pointerStateA, sbyte pointerStateB) { assertFalse(GenerationSafePointerPair.IsSuccess(result)); // Raw failure bits assertEquals(readOrWrite, result & READ_OR_WRITE_MASK); if (generationComparison != EXPECTED_GENERATION_DISREGARD) { assertEquals(GenerationComparisonBits(generationComparison), result & GENERATION_COMPARISON_MASK); } assertEquals(pointerStateA, pointerStateFromResult(result, SHIFT_STATE_A)); assertEquals(pointerStateB, pointerStateFromResult(result, SHIFT_STATE_B)); // Failure description string failureDescription = failureDescription(result); assertThat(failureDescription, containsString(isRead(result) ? "READ" : "WRITE")); if (generationComparison != EXPECTED_GENERATION_DISREGARD) { assertThat(failureDescription, containsString(GenerationComparisonName(generationComparison))); } assertThat(failureDescription, containsString(pointerStateName(pointerStateA))); assertThat(failureDescription, containsString(pointerStateName(pointerStateB))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void checkChildShouldThrowOnReadFailure() internal virtual void CheckChildShouldThrowOnReadFailure() { long result = GenerationSafePointerPair.Read(_cursor, 0, 1, NO_GENERATION_TARGET); assertThrows(typeof(TreeInconsistencyException), () => PointerChecking.checkPointer(result, false)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void goTo(org.neo4j.io.pagecache.PageCursor cursor, String messageOnError, long nodeId) throws java.io.IOException internal static void GoTo(PageCursor cursor, string messageOnError, long nodeId) { PageCursorUtil.GoTo(cursor, messageOnError, GenerationSafePointerPair.Pointer(nodeId)); }
internal static bool IsNode(long node) { return(GenerationSafePointerPair.Pointer(node) != NO_NODE_FLAG); }
internal static void WriteChild(PageCursor cursor, long child, long stableGeneration, long unstableGeneration) { long write = GenerationSafePointerPair.Write(cursor, child, stableGeneration, unstableGeneration); GenerationSafePointerPair.AssertSuccess(write); }
private static string StateToString(long generation, long readPointer, long pointer, sbyte stateA) { return(format("generation=%d, readPointer=%d, pointer=%d, state=%s", generation, readPointer, pointer, GenerationSafePointerPair.PointerStateName(stateA))); }