Exemple #1
0
 /// <summary>
 /// Finds document IDs given a set of conditions.
 /// </summary>
 /// <param name="persistIndexLeaves"></param>
 /// <param name="conditions"></param>
 /// <param name="foundDocumentIds"></param>
 private void MatchDocuments(int nestedLevel, PersistIndexExtent persistIndexLeaves, IndexSelection indexSelection, HashSet <Guid> globallyFoundDocumentIds)
 {
     /*
      * HashSet<Guid> sessionFoundDocumentIds = new HashSet<Guid>();
      *
      * //TODO: This is broken, very broken.
      * // We have scenarios where we have ANDs/ORs and nested ANDs/ORs.
      * // We also have to support the same key being used in an OR (e.g. Color = 'BLACK' OR Color = 'Silver')
      *
      * foreach (var leaf in persistIndexLeaves.Leaves)
      * {
      *  Condition condition = conditions[conditionOrdinal];
      *
      *  if (condition.IsMatch(leaf.Key) == true)
      *  {
      *      if (conditions.Count == conditionOrdinal + 1)
      *      {
      *          //We have exausted all of our conditons, go ahead and skip to the document IDs.
      *          foreach (var documentId in leaf.Coalesce())
      *          {
      *              if (condition.ConditionType == ConditionType.None) //None means this is the first condition in a group.
      *              {
      *                  sessionFoundDocumentIds.Add(documentId);
      *              }
      *              else if (condition.ConditionType == ConditionType.And)
      *              {
      *                  if (globallyFoundDocumentIds.Contains(documentId))
      *                  {
      *                      sessionFoundDocumentIds.Add(documentId);
      *                  }
      *              }
      *              else if (condition.ConditionType == ConditionType.Or)
      *              {
      *                  sessionFoundDocumentIds.Add(documentId);
      *              }
      *              else
      *              {
      *                  throw new LeafSQLExceptionBase("Unsupported expression type.");
      *              }
      *
      *          }
      *      }
      *      else if (leaf.IsBottom) //This is the bottom of the index, where the doucment IDs are stored.
      *      {
      *          //We have matched all of the index attributes.
      *          foreach (var documentId in leaf.DocumentIDs)
      *          {
      *              if (condition.ConditionType == ConditionType.None) //None means this is the first condition in a group.
      *              {
      *                  sessionFoundDocumentIds.Add(documentId);
      *              }
      *              else if (condition.ConditionType == ConditionType.And)
      *              {
      *                  if (globallyFoundDocumentIds.Contains(documentId))
      *                  {
      *                      sessionFoundDocumentIds.Add(documentId);
      *                  }
      *              }
      *              else if (condition.ConditionType == ConditionType.Or)
      *              {
      *                  sessionFoundDocumentIds.Add(documentId);
      *              }
      *              else
      *              {
      *                  throw new LeafSQLExceptionBase("Unsupported expression type.");
      *              }
      *          }
      *      }
      *      else
      *      {
      *          //Match the next condition to the next lowest leaf level.
      *          MatchDocuments(nestedLevel++, leaf.Extent, indexSelection, globallyFoundDocumentIds);
      *          return;
      *      }
      *  }
      * }
      */
 }
Exemple #2
0
        /// <summary>
        /// Finds document IDs given a set of conditions.
        /// </summary>
        /// <param name="indexPageCatalog"></param>
        /// <param name="conditions"></param>
        /// <returns></returns>
        public HashSet <Guid> MatchDocuments(PersistIndexPageCatalog indexPageCatalog, IndexSelection indexSelection)
        {
            HashSet <Guid> globallyFoundDocumentIds = new HashSet <Guid>();

            MatchDocuments(0, indexPageCatalog.Leaves, indexSelection, globallyFoundDocumentIds);
            return(globallyFoundDocumentIds);
        }