Ejemplo n.º 1
0
            internal virtual void Detect(SameGroupDetector sameGroupDetector, long i)
            {
                long dataIndexA = outerInstance.trackerCache.Get(i);
                long dataIndexB = outerInstance.trackerCache.Get(i + 1);

                if (dataIndexA == [email protected]_Fields.ID_NOT_FOUND || dataIndexB == [email protected]_Fields.ID_NOT_FOUND)
                {
                    sameGroupDetector.Reset();
                    return;
                }

                long eIdA = ClearCollision(outerInstance.dataCache.Get(dataIndexA));
                long eIdB = ClearCollision(outerInstance.dataCache.Get(dataIndexB));

                if (eIdA == GAP_VALUE || eIdB == GAP_VALUE)
                {
                    sameGroupDetector.Reset();
                    return;
                }

                switch (unsignedDifference(eIdA, eIdB))
                {
                case GT:
                    throw new System.InvalidOperationException("Unsorted data, a > b Failure:[" + i + "] " + eIdA.ToString("x") + " > " + eIdB.ToString("x") + " | " + outerInstance.radixOf(eIdA) + ":" + outerInstance.radixOf(eIdB));

                case EQ:
                    // Here we have two equal encoded values. First let's check if they are in the same id space.
                    long collision = sameGroupDetector.CollisionWithinSameGroup(dataIndexA, outerInstance.groupOf(dataIndexA), dataIndexB, outerInstance.groupOf(dataIndexB));

                    if (dataIndexA > dataIndexB)
                    {
                        // Swap so that lower tracker index means lower data index. TODO Why do we do this?
                        outerInstance.trackerCache.Swap(i, i + 1);
                    }

                    if (collision != [email protected]_Fields.ID_NOT_FOUND)
                    {
                        if (outerInstance.markAsCollision(collision))
                        {
                            NumberOfCollisions++;
                        }
                        if (outerInstance.markAsCollision(dataIndexB))
                        {
                            NumberOfCollisions++;
                        }
                    }
                    break;

                default:
                    sameGroupDetector.Reset();
                    break;
                }
            }
Ejemplo n.º 2
0
            public override void Run()
            {
                SameGroupDetector sameGroupDetector = new SameGroupDetector();

                // In all chunks except the last this chunk also takes care of the detection in the seam,
                // but for the last one there's no seam at the end.
                long end = Last ? ToExclusive - 1 : ToExclusive;

                for (long i = FromInclusive; i < end; i++)
                {
                    Detect(sameGroupDetector, i);
                    if (++LocalProgress == 1000)
                    {
                        Progress.add(LocalProgress);
                        LocalProgress = 0;
                    }
                }
                Progress.add(LocalProgress);
            }