public NumericDocValuesFieldUpdates(string field, int maxDoc)
     : base(field, Type_e.NUMERIC)
 {
     DocsWithField = new FixedBitSet(64);
     Docs = new PagedMutable(1, 1024, PackedInts.BitsRequired(maxDoc - 1), PackedInts.COMPACT);
     Values = new PagedGrowableWriter(1, 1024, 1, PackedInts.FAST);
     Size = 0;
 }
 public BinaryDocValuesFieldUpdates(string field, int maxDoc)
     : base(field, Type_e.BINARY)
 {
     DocsWithField = new FixedBitSet(64);
     Docs = new PagedMutable(1, 1024, PackedInts.BitsRequired(maxDoc - 1), PackedInts.COMPACT);
     Offsets = new PagedGrowableWriter(1, 1024, 1, PackedInts.FAST);
     Lengths = new PagedGrowableWriter(1, 1024, 1, PackedInts.FAST);
     Values = new BytesRef(16); // start small
     Size = 0;
 }
        public override void Add(int doc, object value)
        {
            // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation
            if (Size == int.MaxValue)
            {
                throw new InvalidOperationException("cannot support more than Integer.MAX_VALUE doc/value entries");
            }

            BytesRef val = (BytesRef)value;
            if (val == null)
            {
                val = BinaryDocValuesUpdate.MISSING;
            }

            // grow the structures to have room for more elements
            if (Docs.Size() == Size)
            {
                Docs = Docs.Grow(Size + 1);
                Offsets = Offsets.Grow(Size + 1);
                Lengths = Lengths.Grow(Size + 1);
                DocsWithField = FixedBitSet.EnsureCapacity(DocsWithField, (int)Docs.Size());
            }

            if (val != BinaryDocValuesUpdate.MISSING)
            {
                // only mark the document as having a value in that field if the value wasn't set to null (MISSING)
                DocsWithField.Set(Size);
            }

            Docs.Set(Size, doc);
            Offsets.Set(Size, Values.Length);
            Lengths.Set(Size, val.Length);
            Values.Append(val);
            ++Size;
        }
 public InPlaceMergeSorterAnonymousInnerClassHelper(BinaryDocValuesFieldUpdates outerInstance, PagedMutable docs, PagedGrowableWriter offsets, PagedGrowableWriter lengths, FixedBitSet docsWithField)
 {
     this.OuterInstance = outerInstance;
     this.Docs = docs;
     this.Offsets = offsets;
     this.Lengths = lengths;
     this.DocsWithField = docsWithField;
 }
 internal Iterator(int size, PagedGrowableWriter offsets, PagedGrowableWriter lengths, PagedMutable docs, BytesRef values, FixedBitSet docsWithField)
 {
     this.Offsets = offsets;
     this.Size = size;
     this.Lengths = lengths;
     this.Docs = docs;
     this.DocsWithField = docsWithField;
     Value_Renamed = (BytesRef)values.Clone();
 }
 public override void Merge(DocValuesFieldUpdates other)
 {
     BinaryDocValuesFieldUpdates otherUpdates = (BinaryDocValuesFieldUpdates)other;
     int newSize = Size + otherUpdates.Size;
     if (newSize > int.MaxValue)
     {
         throw new InvalidOperationException("cannot support more than Integer.MAX_VALUE doc/value entries; size=" + Size + " other.size=" + otherUpdates.Size);
     }
     Docs = Docs.Grow(newSize);
     Offsets = Offsets.Grow(newSize);
     Lengths = Lengths.Grow(newSize);
     DocsWithField = FixedBitSet.EnsureCapacity(DocsWithField, (int)Docs.Size());
     for (int i = 0; i < otherUpdates.Size; i++)
     {
         int doc = (int)otherUpdates.Docs.Get(i);
         if (otherUpdates.DocsWithField.Get(i))
         {
             DocsWithField.Set(Size);
         }
         Docs.Set(Size, doc);
         Offsets.Set(Size, Values.Length + otherUpdates.Offsets.Get(i)); // correct relative offset
         Lengths.Set(Size, otherUpdates.Lengths.Get(i));
         ++Size;
     }
     Values.Append(otherUpdates.Values);
 }
 public InPlaceMergeSorterAnonymousInnerClassHelper(NumericDocValuesFieldUpdates outerInstance, PagedMutable docs, PagedGrowableWriter values, FixedBitSet docsWithField)
 {
     this.OuterInstance = outerInstance;
     this.Docs = docs;
     this.Values = values;
     this.DocsWithField = docsWithField;
 }
 internal Iterator(int size, PagedGrowableWriter values, FixedBitSet docsWithField, PagedMutable docs)
 {
     this.Size = size;
     this.Values = values;
     this.DocsWithField = docsWithField;
     this.Docs = docs;
 }
 public override void Merge(DocValuesFieldUpdates other)
 {
     Debug.Assert(other is NumericDocValuesFieldUpdates);
     NumericDocValuesFieldUpdates otherUpdates = (NumericDocValuesFieldUpdates)other;
     if (Size + otherUpdates.Size > int.MaxValue)
     {
         throw new InvalidOperationException("cannot support more than Integer.MAX_VALUE doc/value entries; size=" + Size + " other.size=" + otherUpdates.Size);
     }
     Docs = Docs.Grow(Size + otherUpdates.Size);
     Values = Values.Grow(Size + otherUpdates.Size);
     DocsWithField = FixedBitSet.EnsureCapacity(DocsWithField, (int)Docs.Size());
     for (int i = 0; i < otherUpdates.Size; i++)
     {
         int doc = (int)otherUpdates.Docs.Get(i);
         if (otherUpdates.DocsWithField.Get(i))
         {
             DocsWithField.Set(Size);
         }
         Docs.Set(Size, doc);
         Values.Set(Size, otherUpdates.Values.Get(i));
         ++Size;
     }
 }