private void EnsureBounds(long endPoint)
            {
                // The number of bytes to expand by
                long toExpandBy = endPoint - end;

                // If we need to expand,
                if (toExpandBy > 0)
                {
                    long sizeDiff = toExpandBy;
                    // Go to the end position,
                    stack.SetupForPosition(key, Math.Max(start, end - 1));
                    // Did we find a leaf for this key?
                    if (!stack.CurrentLeafKey.Equals(key))
                    {
                        // No, so add empty nodes after to make up the space
                        stack.AddSpaceAfter(key, toExpandBy);
                    }
                    else
                    {
                        // Otherwise, try to expand the current leaf,
                        toExpandBy -= stack.ExpandLeaf(toExpandBy);
                        // And add nodes for the remaining
                        stack.AddSpaceAfter(key, toExpandBy);
                    }
                    end = endPoint;

                    // Update the state because this key changed the relative offset of
                    // the keys ahead of it.
                    UpdateLowestSizeChangedKey();
                }
            }
Example #2
0
            public long MoveToKeyStart()
            {
                transaction.CheckErrorState();

                try {
                    EnsureCorrectBounds();
                    CheckAccessSize(1);

                    stack.SetupForPosition(Key.Tail, start + p);
                    Key  curKey     = stack.CurrentLeafKey;
                    long startOfCur = transaction.AbsKeyEndPosition(transaction.PreviousKeyOrder(curKey)) - start;
                    p = startOfCur;
                    return(p);
                } catch (IOException e) {
                    throw transaction.HandleIOException(e);
                } catch (OutOfMemoryException e) {
                    throw transaction.HandleMemoryException(e);
                }
            }