/// <summary>
 /// Appends a new packet of buffered deletes to the stream,
 /// setting its generation:
 /// </summary>
 public virtual long Push(FrozenBufferedUpdates packet)
 {
     lock (this)
     {
         /*
          * The insert operation must be atomic. If we let threads increment the gen
          * and push the packet afterwards we risk that packets are out of order.
          * With DWPT this is possible if two or more flushes are racing for pushing
          * updates. If the pushed packets get our of order would loose documents
          * since deletes are applied to the wrong segments.
          */
         packet.DelGen = nextGen++;
         Debug.Assert(packet.Any());
         Debug.Assert(CheckDeleteStats());
         Debug.Assert(packet.DelGen < nextGen);
         Debug.Assert(updates.Count == 0 || updates[updates.Count - 1].DelGen < packet.DelGen, "Delete packets must be in order");
         updates.Add(packet);
         numTerms.AddAndGet(packet.numTermDeletes);
         bytesUsed.AddAndGet(packet.bytesUsed);
         if (infoStream.IsEnabled("BD"))
         {
             infoStream.Message("BD", "push deletes " + packet + " delGen=" + packet.DelGen + " packetCount=" + updates.Count + " totBytesUsed=" + bytesUsed.Get());
         }
         Debug.Assert(CheckDeleteStats());
         return(packet.DelGen);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Removes an existing file in the directory. </summary>
 /// <exception cref="IOException"> if the file does not exist </exception>
 public override void DeleteFile(string name)
 {
     EnsureOpen();
     if (m_fileMap.TryRemove(name, out RAMFile file) && file != null)
     {
         file.directory = null;
         m_sizeInBytes.AddAndGet(-file.m_sizeInBytes);
     }
     else
     {
         throw new FileNotFoundException(name);
     }
 }
Exemplo n.º 3
0
 public virtual void AddQuery(Query query, int docIDUpto)
 {
     queries.TryGetValue(query, out int?prev);
     queries[query] = docIDUpto;
     // increment bytes used only if the query wasn't added so far.
     if (prev == null)
     {
         bytesUsed.AddAndGet(BYTES_PER_DEL_QUERY);
     }
 }
Exemplo n.º 4
0
        internal virtual void AddQuery(Query query, int docIDUpto) // LUCENENET specific - Made internal rather than public, since this class is intended to be internal but couldn't be because it is exposed through a public API
        {
            bool prevExists = queries.TryGetValue(query, out _);

            queries[query] = docIDUpto;
            // increment bytes used only if the query wasn't added so far.
            if (!prevExists)
            {
                bytesUsed.AddAndGet(BYTES_PER_DEL_QUERY);
            }
        }
Exemplo n.º 5
0
 public override void Run()
 {
     try
     {
         long totHits   = 0;
         long totSearch = 0;
         long stopAt    = Environment.TickCount + outerInstance.RUN_TIME_MSEC;
         while (Environment.TickCount < stopAt && !failed)
         {
             s.Search(new TermQuery(new Term("body", "aaa")), col);
             totHits += col.TotalHits;
             s.Search(new TermQuery(new Term("body", "bbb")), col);
             totHits += col.TotalHits;
             totSearch++;
         }
         Assert.IsTrue(totSearch > 0 && totHits > 0);
         netSearch.AddAndGet(totSearch);
     }
     catch (Exception exc)
     {
         failed.Value = (true);
         throw new Exception(exc.Message, exc);
     }
 }
Exemplo n.º 6
0
 public override void Run()
 {
     try
     {
         long totHits   = 0;
         long totSearch = 0;
         long stopAt    = (J2N.Time.NanoTime() / J2N.Time.MillisecondsPerNanosecond) + outerInstance.RUN_TIME_MSEC; // LUCENENET: Use NanoTime() rather than CurrentTimeMilliseconds() for more accurate/reliable results
         while (J2N.Time.NanoTime() / J2N.Time.MillisecondsPerNanosecond < stopAt && !failed)                       // LUCENENET: Use NanoTime() rather than CurrentTimeMilliseconds() for more accurate/reliable results
         {
             s.Search(new TermQuery(new Term("body", "aaa")), col);
             totHits += col.TotalHits;
             s.Search(new TermQuery(new Term("body", "bbb")), col);
             totHits += col.TotalHits;
             totSearch++;
         }
         Assert.IsTrue(totSearch > 0 && totHits > 0);
         netSearch.AddAndGet(totSearch);
     }
     catch (Exception exc) when(exc.IsException())
     {
         failed.Value = (true);
         throw RuntimeException.Create(exc);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// NOTE: This was loadVarIntsField() in Lucene.
        /// </summary>
        private NumericDocValues LoadVarInt32sField(/*FieldInfo field, // LUCENENET: Never read */ IndexInput input)
        {
            CodecUtil.CheckHeader(input, Lucene40DocValuesFormat.VAR_INTS_CODEC_NAME, Lucene40DocValuesFormat.VAR_INTS_VERSION_START, Lucene40DocValuesFormat.VAR_INTS_VERSION_CURRENT);
            var header = (sbyte)input.ReadByte();

            if (header == Lucene40DocValuesFormat.VAR_INTS_FIXED_64)
            {
                int maxDoc = state.SegmentInfo.DocCount;
                var values = new long[maxDoc];
                for (int i = 0; i < values.Length; i++)
                {
                    values[i] = input.ReadInt64();
                }
                ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(values));
                return(new NumericDocValuesAnonymousClass(values));
            }
            else if (header == Lucene40DocValuesFormat.VAR_INTS_PACKED)
            {
                long minValue              = input.ReadInt64();
                long defaultValue          = input.ReadInt64();
                PackedInt32s.Reader reader = PackedInt32s.GetReader(input);
                ramBytesUsed.AddAndGet(reader.RamBytesUsed());
                return(new NumericDocValuesAnonymousClass2(minValue, defaultValue, reader));
            }
            else
            {
                throw new CorruptIndexException("invalid VAR_INTS header byte: " + header + " (resource=" + input + ")");
            }
        }
Exemplo n.º 8
0
 public override long AddAndGet(long delta)
 {
     return(count.AddAndGet(delta));
 }