Exemplo n.º 1
0
        /// <summary>
        /// Adds answer to the query node.
        /// </summary>
        /// <param name="answer">Answer to be added.</param>
        /// <returns><c>true</c> if answer was added (it was new), <c>false</c> otherwise.</returns>
        internal bool AddAnswer(NpletTree answer)
        {
            if (!_availableAnswerIndex.Add(answer))
                return false;

            _availableAnswers.Add(answer);
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds nplets satisfiing the query.
        /// </summary>
        /// <param name="query">The asked query.</param>
        /// <returns>The satisfiing nplets.</returns>
        internal IEnumerable<NpletTree> Find(NpletTree query)
        {
            var rootQueryNode = CreateQueryNode(query);
            var rootReader = CreateReader(rootQueryNode);

            var queriesToExpand = new Queue<NpletQueryNode>();
            queriesToExpand.Enqueue(rootQueryNode);

            _activeProducers.Clear();
            while (queriesToExpand.Count > 0 || _activeProducers.Count > 0)
            {
                //firstly we will expand newest dependencies
                expandQueries(queriesToExpand);

                //secondly we produce new answers
                produceAnswers();

                while (rootReader.HasNewAnswer)
                {
                    yield return rootReader.GetNextAnswer();
                }
            }
        }
Exemplo n.º 3
0
 internal NpletQueryNode(NpletTree query)
 {
     Query = query;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Finds triplets according to given wildcard.
 /// Including the inference.
 /// </summary>
 /// <param name="nplet">The wildcard for search.</param>
 /// <returns>Found nplets.</returns>
 public IEnumerable<NpletTree> Find(NpletTree nplet)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Fetches known nplets in form matching the query.
 /// </summary>
 /// <param name="query">Query used for matching of the nplets.</param>
 /// <returns>The nplets</returns>
 internal IEnumerable<NpletTree> Fetch(NpletTree query)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates query node for given nplet.
 /// </summary>
 /// <param name="nplet">The nplet.</param>
 /// <returns>The query node.</returns>
 internal NpletQueryNode CreateQueryNode(NpletTree nplet)
 {
     return new NpletQueryNode(nplet);
 }