示例#1
0
 protected internal override object Compress()
 {
     current[0] = 0;
     compressedSet.SetParam(current_base, current_b, BATCH_SIZE, current_ex_count);
     baseList.Add(current_base);
     return(compressedSet.CompressAlt(current));
 }
示例#2
0
            internal P4DDocIdSetIterator(P4DDocIdSet parent)
            {
                ADDRESS_BITS = (int)(Math.Log(parent.BATCH_SIZE) / Math.Log(2));
                size         = parent.Size();
                blobSize     = parent.blob.Size();

                localCompressedSet.SetParam(0, DEFAULT_B, parent.BATCH_SIZE, parent.BATCH_OVER);
                this.parent = parent;
            }
示例#3
0
        public override bool Find(int val)
        {
            long time = System.Environment.TickCount;
            int local = 0;

            if (Size() == 0)
            {
                return false;
            }


            if (val > lastAdded || val < baseList.Get(0)) //Short Circuit case where its not in the set at all
            {
                //System.out.println("Time to perform BinarySearch for:"+val+":"+(System.nanoTime() - time));
                return false;
            }
            else if (val >= current_base) // We are in the set
            {

                int i = 0;
                for (i = 0; i < current_size; i++)
                {
                    local += current[i];

                    if (local > val)
                    {
                        break;
                    }
                }

                if (i == current_size)
                {
                    return local == val;
                }
                else
                {
                    return (local - current[i] == val);
                }
            }
            else // We are in the compressed space
            {
                if (baseList.Size() == 0)
                {
                    return false;
                }

                int blobIndex = BinarySearchForNearest(val, 0, blob.Size() - 1);

                local = baseList.Get(blobIndex);
                long[] @ref = blob.Get(blobIndex);
                P4DSetNoBase localCompressedSet = new P4DSetNoBase();
                localCompressedSet.SetParam(0, DEFAULT_B, BATCH_SIZE, BATCH_OVER);
                localCompressedSet.UpdateParams(@ref);

                int i = 0;

                for (i = 0; i < BATCH_SIZE; i++)
                {
                    local += localCompressedSet.Get(@ref, i);

                    if (local > val)
                    {
                        break;
                    }

                }
                if (i == BATCH_SIZE)
                {
                    return local == val;
                }
                else
                {
                    return (local - localCompressedSet.Get(@ref, i)) == val;
                }
            }
        }
示例#4
0
        public override bool Find(int val)
        {
            long time  = System.Environment.TickCount;
            int  local = 0;

            if (Size() == 0)
            {
                return(false);
            }


            if (val > lastAdded || val < baseList.Get(0)) //Short Circuit case where its not in the set at all
            {
                //System.out.println("Time to perform BinarySearch for:"+val+":"+(System.nanoTime() - time));
                return(false);
            }
            else if (val >= current_base) // We are in the set
            {
                int i = 0;
                for (i = 0; i < current_size; i++)
                {
                    local += current[i];

                    if (local > val)
                    {
                        break;
                    }
                }

                if (i == current_size)
                {
                    return(local == val);
                }
                else
                {
                    return(local - current[i] == val);
                }
            }
            else // We are in the compressed space
            {
                if (baseList.Size() == 0)
                {
                    return(false);
                }

                int blobIndex = BinarySearchForNearest(val, 0, blob.Size() - 1);

                local = baseList.Get(blobIndex);
                long[]       @ref = blob.Get(blobIndex);
                P4DSetNoBase localCompressedSet = new P4DSetNoBase();
                localCompressedSet.SetParam(0, DEFAULT_B, BATCH_SIZE, BATCH_OVER);
                localCompressedSet.UpdateParams(@ref);

                int i = 0;

                for (i = 0; i < BATCH_SIZE; i++)
                {
                    local += localCompressedSet.Get(@ref, i);

                    if (local > val)
                    {
                        break;
                    }
                }
                if (i == BATCH_SIZE)
                {
                    return(local == val);
                }
                else
                {
                    return((local - localCompressedSet.Get(@ref, i)) == val);
                }
            }
        }