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 System.Int32.MaxValue doc/value entries"); } BytesRef val = (BytesRef)value; if (val == null) { val = BinaryDocValuesUpdate.MISSING; } // grow the structures to have room for more elements if (docs.Count == size) { docs = docs.Grow(size + 1); offsets = offsets.Grow(size + 1); lengths = lengths.Grow(size + 1); docsWithField = FixedBitSet.EnsureCapacity(docsWithField, (int)docs.Count); } 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 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 System.Int32.MaxValue 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.Count); 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; } }
public virtual void AddValue(int docID, BytesRef value) { if (docID < addedValues) { throw new ArgumentException("DocValuesField \"" + fieldInfo.Name + "\" appears more than once in this document (only one value is allowed per field)"); } if (value == null) { throw new ArgumentException("field=\"" + fieldInfo.Name + "\": null value not allowed"); } if (value.Length > MAX_LENGTH) { throw new ArgumentException("DocValuesField \"" + fieldInfo.Name + "\" is too large, must be <= " + MAX_LENGTH); } // Fill in any holes: while (addedValues < docID) { addedValues++; lengths.Add(0); } addedValues++; lengths.Add(value.Length); try { bytesOut.WriteBytes(value.Bytes, value.Offset, value.Length); } catch (IOException ioe) { // Should never happen! throw new Exception(ioe.ToString(), ioe); } docsWithField = FixedBitSet.EnsureCapacity(docsWithField, docID); docsWithField.Set(docID); UpdateBytesUsed(); }
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; } }
public virtual void AddValue(int docID, BytesRef value) { if (docID < addedValues) { throw new ArgumentOutOfRangeException(nameof(docID), "DocValuesField \"" + fieldInfo.Name + "\" appears more than once in this document (only one value is allowed per field)"); // LUCENENET specific - changed from IllegalArgumentException to ArgumentOutOfRangeException (.NET convention) } if (value is null) { throw new ArgumentNullException("field=\"" + fieldInfo.Name + "\": null value not allowed"); // LUCENENET specific - changed from IllegalArgumentException to ArgumentNullException (.NET convention) } if (value.Length > MAX_LENGTH) { throw new ArgumentException("DocValuesField \"" + fieldInfo.Name + "\" is too large, must be <= " + MAX_LENGTH); } // Fill in any holes: while (addedValues < docID) { addedValues++; lengths.Add(0); } addedValues++; lengths.Add(value.Length); try { bytesOut.WriteBytes(value.Bytes, value.Offset, value.Length); } catch (Exception ioe) when(ioe.IsIOException()) { // Should never happen! throw RuntimeException.Create(ioe); } docsWithField = FixedBitSet.EnsureCapacity(docsWithField, docID); docsWithField.Set(docID); UpdateBytesUsed(); }
private void Add(int doc, BytesRef value) // LUCENENET specific: Marked private instead of public and changed the value parameter type { // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (size == int.MaxValue) { throw IllegalStateException.Create("cannot support more than System.Int32.MaxValue doc/value entries"); } BytesRef val = value; if (val is null) { val = BinaryDocValuesUpdate.MISSING; } // grow the structures to have room for more elements if (docs.Count == size) { docs = docs.Grow(size + 1); offsets = offsets.Grow(size + 1); lengths = lengths.Grow(size + 1); docsWithField = FixedBitSet.EnsureCapacity(docsWithField, (int)docs.Count); } 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; }