Example #1
0
 public void ReplaceValues(ReplaceValuesCtx ctx)
 {
     if (_rootNode == null)
     {
         return;
     }
     ctx._transactionId = TransactionId;
     _rootNode          = _rootNode.ReplaceValues(ctx);
 }
Example #2
0
        public IBTreeNode ReplaceValues(ReplaceValuesCtx ctx)
        {
            var result   = this;
            var children = _children;
            var i        = 0;

            if (ctx._restartKey != null)
            {
                for (; i < _keys.Length; i++)
                {
                    var compRes = BitArrayManipulation.CompareByteArray(_keys[i], 0, _keys[i].Length, ctx._restartKey, 0, ctx._restartKey.Length);
                    if (compRes > 0)
                    {
                        break;
                    }
                }
            }
            for (; i < children.Length; i++)
            {
                var child    = children[i];
                var newChild = child.ReplaceValues(ctx);
                if (newChild != child)
                {
                    if (result.TransactionId != ctx._transactionId)
                    {
                        var newKeys = new byte[_keys.Length][];
                        Array.Copy(_keys, newKeys, newKeys.Length);
                        var newChildren = new IBTreeNode[_children.Length];
                        Array.Copy(_children, newChildren, newChildren.Length);
                        var newPairCounts = new long[_pairCounts.Length];
                        Array.Copy(_pairCounts, newPairCounts, newPairCounts.Length);
                        result   = new BTreeBranch(ctx._transactionId, newKeys, newChildren, newPairCounts);
                        children = newChildren;
                    }
                    children[i] = newChild;
                }
                if (ctx._interrupt)
                {
                    break;
                }
                ctx._restartKey = null;
                var now = DateTime.UtcNow;
                if (i < _keys.Length && (now > ctx._iterationTimeOut || ctx._cancellation.IsCancellationRequested))
                {
                    ctx._interrupt  = true;
                    ctx._restartKey = _keys[i];
                    break;
                }
            }
            return(result);
        }
Example #3
0
        public IBTreeNode ReplaceValues(ReplaceValuesCtx ctx)
        {
            var result    = this;
            var keyvalues = _keyvalues;
            var map       = ctx._newPositionMap;

            for (var i = 0; i < keyvalues.Length; i++)
            {
                ref var ii = ref keyvalues[i];
                if (map.TryGetValue(((ulong)ii.ValueFileId << 32) | ii.ValueOfs, out var newOffset))
                {
                    if (result.TransactionId != ctx._transactionId)
                    {
                        var newKeyValues = new BTreeLeafMember[keyvalues.Length];
                        Array.Copy(keyvalues, newKeyValues, newKeyValues.Length);
                        result    = new BTreeLeaf(ctx._transactionId, newKeyValues);
                        keyvalues = newKeyValues;
                    }
                    keyvalues[i].ValueFileId = ctx._valueFileId;
                    keyvalues[i].ValueOfs    = newOffset;
                }
            }
Example #4
0
 IBTreeNode IBTreeNode.ReplaceValues(ReplaceValuesCtx ctx)
 {
     throw new InvalidOperationException();
 }