Exemplo n.º 1
0
        public (IBPlusTreeNode, int) FindNodeForCondition(LeafCondition condition, bool first)
        {
            if (IsLeaf)
            {
                //CustomValueComparer comparer = Comparers.GetComparer(condition.Column.Type);

                // todo: if column not in index, fetch data
                if (first)
                {
                    for (int i = 0; i < Values.Count; i++)
                    {
                        CustomTuple tuple = new CustomTuple(DataRelation);
                        tuple.AddValueFor(condition.Column.Name, (int)Values[i].Value);

                        if (condition.SatisfiesCondition(tuple))
                        {
                            return(this, i);
                        }
                    }
                }
                else
                {
                    for (int i = Values.Count - 1; i >= 0; i--)
                    {
                        CustomTuple tuple = new CustomTuple(DataRelation);
                        tuple.AddValueFor(condition.Column.Name, (int)Values[i].Value);

                        if (condition.SatisfiesCondition(tuple))
                        {
                            return(this, i);
                        }
                    }
                }

                return(null, -1);
            }
            else
            {
                // todo: if GreaterThan, get right pointer
                Pointer target = GetTargetPointer((TKeyType)condition.Value);
                BPlusTreeNode <TKeyType> node = ReadNode(target);
                return(node.FindNodeForCondition(condition, first));
            }
        }
Exemplo n.º 2
0
 public (IBPlusTreeNode, int) FindLastNodeForCondition(LeafCondition condition)
 {
     return(FindNodeForCondition(condition, false));
 }
Exemplo n.º 3
0
 // todo: support AndCondition, OrCondition with 1 column (index column)
 public (IBPlusTreeNode, int) FindFirstNodeForCondition(LeafCondition condition)
 {
     return(FindNodeForCondition(condition, true));
 }