コード例 #1
0
ファイル: IndexManager.cs プロジェクト: NTDLS/LeafSQL
        private bool RemoveDocumentFromLeaves(ref PersistIndexExtent leaves, Guid documentId)
        {
            foreach (var leaf in leaves)
            {
                if (leaf.DocumentIDs != null && leaf.DocumentIDs.Count > 0)
                {
                    if (leaf.DocumentIDs.Remove(documentId))
                    {
                        return(true); //We found the document and removed it.
                    }
                }

                if (leaf.Extent != null && leaf.Extent.Count > 0)
                {
                    if (RemoveDocumentFromLeaves(ref leaf.Extent, documentId))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #2
0
ファイル: IndexManager.cs プロジェクト: NTDLS/LeafSQL
 /// <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;
      *      }
      *  }
      * }
      */
 }