Example #1
0
 // Newly allocated stream IndexNode constructor
 public IndexNode(ServerProcess AProcess, Index AIndex, StreamID AStreamID, Stream AStream, IndexNodeType ANodeType)
 {
     FProcess  = AProcess;
     FIndex    = AIndex;
     FStreamID = AStreamID;
     FStream   = AStream;
     NodeType  = ANodeType;
     InternalInitialize();
 }
Example #2
0
        protected override Task ValidateAsync()
        {
            // Check if there is a <ValueNode> with non-empty body.
            IndexNodeType valueNode =
                _indexListItems.ValueNode?.Where(v => !string.IsNullOrWhiteSpace(v.Value))
                .FirstOrDefault();

            if (valueNode == null)
            {
                throw new InvalidOperationException("No valid <ValueNode> found.");
            }

            return(Task.CompletedTask);
        }
Example #3
0
        public override async Task <IList <IVariableInformation> > GetChildrenAsync(
            int from, int count)
        {
            await InitAsync();

            var result = new List <IVariableInformation>();

            if (_store.ValidationError != null)
            {
                result.Add(_store.ValidationError);
                return(result.GetRange(from, count));
            }

            var indexDic = new NatvisScope(_natvisScope);

            for (int index = from; index < from + count; index++)
            {
                IVariableInformation varInfo = await _store.GetOrEvaluateAsync(index, async i => {
                    indexDic.AddScopedName("$i", $"{i}U");
                    string displayName = $"[{i}]";

                    // From the list of all <ValueNode> children, filter all with non-empty body
                    // and return the first which Condition evaluates to true.
                    IndexNodeType valueNode =
                        await _indexListItems
                        .ValueNode?.Where(v => !string.IsNullOrWhiteSpace(v.Value))
                        .FirstOrDefaultAsync(v => _evaluator.EvaluateConditionAsync(
                                                 v.Condition, _variable, indexDic));

                    if (valueNode == null)
                    {
                        // For the current index $i, there is no <ValueNode> which passes the
                        // Condition check.
                        return(new ErrorVariableInformation(
                                   displayName, "<Error> No valid <ValueNode> found."));
                    }

                    return(await _evaluator.GetExpressionValueOrErrorAsync(
                               valueNode.Value, _variable, indexDic, displayName, "IndexListItems"));
                });

                result.Add(varInfo);
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Will return an IndexNode wrapper on a newly allocated IndexNode stream opened in exclusive mode
        /// it is the callers responsibility Dispose the returned IndexNode, closing and unlocking the stream
        /// </summary>
        private unsafe IndexNode AllocateNode(ServerProcess AProcess, IndexNodeType ANodeType)
        {
            // Allocate a new index node
            StreamID LStreamID = AProcess.StreamManager.Allocate();
            Stream   LStream   = AProcess.StreamManager.Open(LStreamID, LockMode.Shared);

            // Size it (HeaderSize + ((KeyLength + DataLength | sizeof(StreamID)) * Capacity | Fanout)
            if (ANodeType == IndexNodeType.Routing)
            {
                LStream.SetLength(checked (IndexNode.HeaderSize + ((KeyLength + sizeof(StreamID)) * Fanout)));
            }
            else
            {
                LStream.SetLength(checked (IndexNode.HeaderSize + ((KeyLength + DataLength) * Capacity)));
            }
            return(new IndexNode(AProcess, this, LStreamID, LStream, ANodeType));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="IndexingStrategy"/> class.
 /// </summary>
 /// <param name="unique">if <c>true</c>, indicates that the values in the index are unique.</param>
 /// <param name="pathType">sets the <seealso cref="IndexPathType"/> property of the index.</param>
 /// <param name="nodeType">indicates whether the node is an element, attribute, or metadata.</param>
 /// <param name="keyType">sets the types of query supported by the index.</param>
 /// <param name="indexValueSyntax">sets the intended datatype of the item being indexed.</param>
 public IndexingStrategy(
     bool unique, IndexPathType pathType,
     IndexNodeType nodeType, IndexKeyType keyType,
     XmlDatatype indexValueSyntax)
 {
 }