Пример #1
0
        public void CheckKey_23()
        {
            if (insertCount != 0)
            {
                Prepare231();

                int prevArg1 = -1;
                int prevArg2 = -1;
                int prevArg3 = -1;

                for (int i = 0; i < insertCount; i++)
                {
                    int arg1 = insertList[3 * i];
                    int arg2 = insertList[3 * i + 1];
                    int arg3 = insertList[3 * i + 2];

                    if (arg2 == prevArg2 & arg3 == prevArg3 & arg1 != prevArg1)
                    {
                        throw Cols23KeyViolationException(arg1, arg2, arg3, prevArg1);
                    }

                    if (!Ints231.Contains23(deleteList, deleteCount, arg2, arg3) && table.Contains23(arg2, arg3))
                    {
                        throw Cols23KeyViolationException(arg1, arg2, arg3);
                    }

                    prevArg1 = arg1;
                    prevArg2 = arg2;
                    prevArg3 = arg3;
                }
            }
        }
Пример #2
0
        public bool Contains23(int surr2, int surr3)
        {
            Prepare231();

            if (Ints231.Contains23(insertList, insertCount, surr2, surr3))
            {
                return(true);
            }

            if (!table.Contains23(surr2, surr3))
            {
                return(false);
            }

            int idx = Ints231.IndexFirst23(deleteList, deleteCount, surr2, surr3);

            if (idx == -1)
            {
                return(true);
            }
            int count = Ints231.Count23(deleteList, deleteCount, surr2, surr3, idx);

            TernaryTable.Iter it = table.GetIter23(surr2, surr3);
            while (!it.Done())
            {
                // Tuples in the [idx, idx+count) range are sorted in any order, since two arguments are the same
                if (!Ints123.Contains1(deleteList, idx, count, it.Get1()))
                {
                    return(true);
                }
                it.Next();
            }

            return(false);
        }
Пример #3
0
 public void Prepare231()
 {
     if (deleteCount != 0 | insertCount != 0)
     {
         Debug.Assert(currOrd != Ord.ORD_312);
         if (currOrd != Ord.ORD_231)
         {
             Ints231.Sort(deleteList, deleteCount);
             Ints231.Sort(insertList, insertCount);
             currOrd = Ord.ORD_231;
         }
     }
 }
Пример #4
0
        public bool Contains13(int surr1, int surr3)
        {
            Prepare312();

            if (Ints312.Contains13(insertList, insertCount, surr1, surr3))
            {
                return(true);
            }

            if (!table.Contains13(surr1, surr3))
            {
                return(false);
            }

            int idx = Ints312.IndexFirst31(deleteList, deleteCount, surr3, surr1);

            if (idx == -1)
            {
                return(true);
            }
            int count = Ints312.Count13(deleteList, deleteCount, surr1, surr3, idx);

            TernaryTable.Iter it = table.GetIter13(surr1, surr3);
            while (!it.Done())
            {
                // Tuples in the [idx, idx+count) range are sorted in both 3/1/2
                // and 2/3/1 order, since the first and last argument are the same
                if (!Ints231.Contains2(deleteList, idx, count, it.Get1()))
                {
                    return(true);
                }
                it.Next();
            }

            return(false);
        }
Пример #5
0
        public bool Contains2(int surr2)
        {
            Prepare231();

            if (Ints231.Contains2(insertList, insertCount, surr2))
            {
                return(true);
            }

            if (!table.Contains2(surr2))
            {
                return(false);
            }

            int idx = Ints231.IndexFirst2(deleteList, deleteCount, surr2);

            if (idx == -1)
            {
                return(true);
            }
            int count = Ints231.Count2(deleteList, deleteCount, surr2, idx);

            TernaryTable.Iter it = table.GetIter2(surr2);
            while (!it.Done())
            {
                // Tuples in the [idx, idx+count) range are sorted in both 2/3/1
                // and 3/1/2 order, since the second argument is always the same
                if (!Ints312.Contains13(deleteList, idx, count, it.Get1(), it.Get2()))
                {
                    return(true);
                }
                it.Next();
            }

            return(false);
        }