Java Code Examples for org.apache.lucene.util.Counter#addAndGet()

The following examples show how to use org.apache.lucene.util.Counter#addAndGet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MimetypeGroupingCollector.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void collect(int doc) throws IOException 
{
    if(sortedDocValues != null)
    {
        int ordinal = sortedDocValues.getOrd(doc);
        if(ordinal > -1)
        {
            String value = (String)schemaField.getType().toObject(schemaField, sortedDocValues.lookupOrd(ordinal));
            String group = doGroup ? mappings.get(value) : value;
            if(group == null)
            {
                group = value;
            }

            Counter counter = counters.get(group);
            if(counter == null)
            {
                counter = Counter.newCounter();
                counters.put(group, counter);
            }
            counter.addAndGet(1);
        }
    }


    leafDelegate.collect(doc);
}
 
Example 2
Source File: BinaryDocValuesWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.bytes = new PagedBytes(BLOCK_BITS);
  this.bytesOut = bytes.getDataOutput();
  this.lengths = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  this.iwBytesUsed = iwBytesUsed;
  this.docsWithField = new DocsWithFieldSet();
  this.bytesUsed = lengths.ramBytesUsed() + docsWithField.ramBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
 
Example 3
Source File: SortedSetDocValuesWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public SortedSetDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.iwBytesUsed = iwBytesUsed;
  hash = new BytesRefHash(
      new ByteBlockPool(
          new ByteBlockPool.DirectTrackingAllocator(iwBytesUsed)),
          BytesRefHash.DEFAULT_CAPACITY,
          new DirectBytesStartArray(BytesRefHash.DEFAULT_CAPACITY, iwBytesUsed));
  pending = PackedLongValues.packedBuilder(PackedInts.COMPACT);
  pendingCounts = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  docsWithField = new DocsWithFieldSet();
  bytesUsed = pending.ramBytesUsed() + pendingCounts.ramBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
 
Example 4
Source File: SortedDocValuesWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public SortedDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.iwBytesUsed = iwBytesUsed;
  hash = new BytesRefHash(
      new ByteBlockPool(
          new ByteBlockPool.DirectTrackingAllocator(iwBytesUsed)),
          BytesRefHash.DEFAULT_CAPACITY,
          new DirectBytesStartArray(BytesRefHash.DEFAULT_CAPACITY, iwBytesUsed));
  pending = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  docsWithField = new DocsWithFieldSet();
  bytesUsed = pending.ramBytesUsed() + docsWithField.ramBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
 
Example 5
Source File: NumericDocValuesWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public NumericDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  pending = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  docsWithField = new DocsWithFieldSet();
  bytesUsed = pending.ramBytesUsed() + docsWithField.ramBytesUsed();
  this.fieldInfo = fieldInfo;
  this.iwBytesUsed = iwBytesUsed;
  iwBytesUsed.addAndGet(bytesUsed);
}
 
Example 6
Source File: NormValuesWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public NormValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  docsWithField = new DocsWithFieldSet();
  pending = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  bytesUsed = pending.ramBytesUsed() + docsWithField.ramBytesUsed();
  this.fieldInfo = fieldInfo;
  this.iwBytesUsed = iwBytesUsed;
  iwBytesUsed.addAndGet(bytesUsed);
}
 
Example 7
Source File: SortedNumericDocValuesWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public SortedNumericDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.iwBytesUsed = iwBytesUsed;
  pending = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  pendingCounts = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  docsWithField = new DocsWithFieldSet();
  bytesUsed = pending.ramBytesUsed() + pendingCounts.ramBytesUsed() + docsWithField.ramBytesUsed() + RamUsageEstimator.sizeOf(currentValues);
  iwBytesUsed.addAndGet(bytesUsed);
}
 
Example 8
Source File: FieldUpdatesBuffer.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private FieldUpdatesBuffer(Counter bytesUsed, DocValuesUpdate initialValue, int docUpTo, boolean isNumeric) {
  this.bytesUsed = bytesUsed;
  this.bytesUsed.addAndGet(SELF_SHALLOW_SIZE);
  termValues = new BytesRefArray(bytesUsed);
  termValues.append(initialValue.term.bytes);
  fields = new String[] {initialValue.term.field};
  bytesUsed.addAndGet(sizeOfString(initialValue.term.field));
  docsUpTo = new int[] {docUpTo};
  if (initialValue.hasValue == false) {
    hasValues = new FixedBitSet(1);
    bytesUsed.addAndGet(hasValues.ramBytesUsed());
  }
  this.isNumeric = isNumeric;
  byteValues = isNumeric ? null : new BytesRefArray(bytesUsed);
}
 
Example 9
Source File: FieldUpdatesBuffer.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
FieldUpdatesBuffer(Counter bytesUsed, DocValuesUpdate.NumericDocValuesUpdate initialValue, int docUpTo) {
  this(bytesUsed, initialValue, docUpTo, true);
  if (initialValue.hasValue()) {
    numericValues = new long[] {initialValue.getValue()};
    maxNumeric = minNumeric = initialValue.getValue();
  } else {
    numericValues = new long[] {0};
  }
  bytesUsed.addAndGet(Long.BYTES);
}
 
Example 10
Source File: TranslogDeletionPolicy.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * releases a generation that was acquired by {@link #acquireTranslogGen(long)}
 */
private synchronized void releaseTranslogGen(long translogGen) {
    Counter current = translogRefCounts.get(translogGen);
    if (current == null || current.get() <= 0) {
        throw new IllegalArgumentException("translog gen [" + translogGen + "] wasn't acquired");
    }
    if (current.addAndGet(-1) == 0) {
        translogRefCounts.remove(translogGen);
    }
}