internal readonly bool isSegmentPrivate; // set to true iff this frozen packet represents // a segment private deletes. in that case is should // only have Queries public FrozenBufferedUpdates(BufferedUpdates deletes, bool isSegmentPrivate) { this.isSegmentPrivate = isSegmentPrivate; if (Debugging.AssertsEnabled) { Debugging.Assert(!isSegmentPrivate || deletes.terms.Count == 0, "segment private package should only have del queries"); } Term[] termsArray = deletes.terms.Keys.ToArray(/*new Term[deletes.terms.Count]*/); termCount = termsArray.Length; ArrayUtil.TimSort(termsArray); PrefixCodedTerms.Builder builder = new PrefixCodedTerms.Builder(); foreach (Term term in termsArray) { builder.Add(term); } terms = builder.Finish(); queries = new Query[deletes.queries.Count]; queryLimits = new int[deletes.queries.Count]; int upto = 0; foreach (KeyValuePair <Query, int?> ent in deletes.queries) { queries[upto] = ent.Key; if (ent.Value.HasValue) { queryLimits[upto] = ent.Value.Value; } else { // LUCENENET NOTE: According to this: http://stackoverflow.com/a/13914344 // we are supposed to throw an exception in this case, rather than // silently fail. throw new NullReferenceException(); } upto++; } // TODO if a Term affects multiple fields, we could keep the updates key'd by Term // so that it maps to all fields it affects, sorted by their docUpto, and traverse // that Term only once, applying the update to all fields that still need to be // updated. IList <NumericDocValuesUpdate> allNumericUpdates = new List <NumericDocValuesUpdate>(); int numericUpdatesSize = 0; foreach (var numericUpdates in deletes.numericUpdates.Values) { foreach (NumericDocValuesUpdate update in numericUpdates.Values) { allNumericUpdates.Add(update); numericUpdatesSize += update.GetSizeInBytes(); } } numericDVUpdates = allNumericUpdates.ToArray(); // TODO if a Term affects multiple fields, we could keep the updates key'd by Term // so that it maps to all fields it affects, sorted by their docUpto, and traverse // that Term only once, applying the update to all fields that still need to be // updated. IList <BinaryDocValuesUpdate> allBinaryUpdates = new List <BinaryDocValuesUpdate>(); int binaryUpdatesSize = 0; foreach (var binaryUpdates in deletes.binaryUpdates.Values) { foreach (BinaryDocValuesUpdate update in binaryUpdates.Values) { allBinaryUpdates.Add(update); binaryUpdatesSize += update.GetSizeInBytes(); } } binaryDVUpdates = allBinaryUpdates.ToArray(); bytesUsed = (int)terms.GetSizeInBytes() + queries.Length * BYTES_PER_DEL_QUERY + numericUpdatesSize + numericDVUpdates.Length * RamUsageEstimator.NUM_BYTES_OBJECT_REF + binaryUpdatesSize + binaryDVUpdates.Length * RamUsageEstimator.NUM_BYTES_OBJECT_REF; numTermDeletes = deletes.numTermDeletes; }
internal FlushedSegment(SegmentCommitInfo segmentInfo, FieldInfos fieldInfos, BufferedUpdates segmentUpdates, IMutableBits liveDocs, int delCount) { this.segmentInfo = segmentInfo; this.fieldInfos = fieldInfos; this.segmentUpdates = segmentUpdates != null && segmentUpdates.Any() ? new FrozenBufferedUpdates(segmentUpdates, true) : null; this.liveDocs = liveDocs; this.delCount = delCount; }
internal override void Apply(BufferedUpdates bufferedUpdates, int docIDUpto) { bufferedUpdates.AddNumericUpdate((NumericDocValuesUpdate)item, docIDUpto); }
internal override void Apply(BufferedUpdates bufferedUpdates, int docIDUpto) { bufferedUpdates.AddBinaryUpdate((BinaryDocValuesUpdate)item, docIDUpto); }
internal override void Apply(BufferedUpdates bufferedDeletes, int docIDUpto) { bufferedDeletes.AddTerm((Term)item, docIDUpto); }
//internal static readonly AtomicReferenceFieldUpdater<Node, Node> NextUpdater = AtomicReferenceFieldUpdater.newUpdater(typeof(Node), typeof(Node), "next"); internal virtual void Apply(BufferedUpdates bufferedDeletes, int docIDUpto) { throw new InvalidOperationException("sentinel item must never be applied"); }
/// <summary> /// Constructor which takes segment suffix. /// </summary> /// <seealso cref="SegmentWriteState(InfoStream, Directory, SegmentInfo, FieldInfos, int, /// BufferedUpdates, IOContext)"/> public SegmentWriteState(InfoStream infoStream, Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, int termIndexInterval, BufferedUpdates segUpdates, IOContext context, string segmentSuffix) { this.InfoStream = infoStream; this.SegUpdates = segUpdates; this.Directory = directory; this.SegmentInfo = segmentInfo; this.FieldInfos = fieldInfos; this.TermIndexInterval = termIndexInterval; this.SegmentSuffix = segmentSuffix; this.Context = context; }
/// <summary> /// Sole constructor. </summary> public SegmentWriteState(InfoStream infoStream, Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, int termIndexInterval, BufferedUpdates segUpdates, IOContext context) : this(infoStream, directory, segmentInfo, fieldInfos, termIndexInterval, segUpdates, context, "") { }
//internal static readonly AtomicReferenceFieldUpdater<Node, Node> NextUpdater = AtomicReferenceFieldUpdater.newUpdater(typeof(Node), typeof(Node), "next"); internal virtual void Apply(BufferedUpdates bufferedDeletes, int docIDUpto) { throw IllegalStateException.Create("sentinel item must never be applied"); }