当前位置: 首页>>代码示例>>Java>>正文


Java RamUsageEstimator类代码示例

本文整理汇总了Java中org.apache.lucene.util.RamUsageEstimator的典型用法代码示例。如果您正苦于以下问题:Java RamUsageEstimator类的具体用法?Java RamUsageEstimator怎么用?Java RamUsageEstimator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RamUsageEstimator类属于org.apache.lucene.util包,在下文中一共展示了RamUsageEstimator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CompositeBytesReference

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
public CompositeBytesReference(BytesReference... references) {
    this.references = Objects.requireNonNull(references, "references must not be null");
    this.offsets = new int[references.length];
    long ramBytesUsed = 0;
    int offset = 0;
    for (int i = 0; i < references.length; i++) {
        BytesReference reference = references[i];
        if (reference == null) {
            throw new IllegalArgumentException("references must not be null");
        }
        offsets[i] = offset; // we use the offsets to seek into the right BytesReference for random access and slicing
        offset += reference.length();
        ramBytesUsed += reference.ramBytesUsed();
    }
    this.ramBytesUsed = ramBytesUsed
        + (Integer.BYTES * offsets.length + RamUsageEstimator.NUM_BYTES_ARRAY_HEADER) // offsets
        + (references.length * RamUsageEstimator.NUM_BYTES_OBJECT_REF + RamUsageEstimator.NUM_BYTES_ARRAY_HEADER) // references
        + Integer.BYTES // length
        + Long.BYTES; // ramBytesUsed
    length = offset;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:CompositeBytesReference.java

示例2: resize

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newBytePage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigByteArray.java

示例3: resize

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newObjectPage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigObjectArray.java

示例4: resize

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newIntPage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigIntArray.java

示例5: resize

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newLongPage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigLongArray.java

示例6: loadIntField

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
private NumericDocValues loadIntField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.INTS_CODEC_NAME,
                               Lucene40DocValuesFormat.INTS_VERSION_START,
                               Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 4) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final int values[] = new int[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readInt();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例7: loadLongField

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
private NumericDocValues loadLongField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.INTS_CODEC_NAME,
                               Lucene40DocValuesFormat.INTS_VERSION_START,
                               Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 8) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final long values[] = new long[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readLong();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例8: loadFloatField

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
private NumericDocValues loadFloatField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.FLOATS_CODEC_NAME,
                               Lucene40DocValuesFormat.FLOATS_VERSION_START,
                               Lucene40DocValuesFormat.FLOATS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 4) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final int values[] = new int[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readInt();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例9: getIntervalInstance

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
/** returns an address instance for prefix-compressed binary values. */
private MonotonicBlockPackedReader getIntervalInstance(IndexInput data, FieldInfo field, BinaryEntry bytes) throws IOException {
  final MonotonicBlockPackedReader addresses;
  final long interval = bytes.addressInterval;
  synchronized (addressInstances) {
    MonotonicBlockPackedReader addrInstance = addressInstances.get(field.number);
    if (addrInstance == null) {
      data.seek(bytes.addressesOffset);
      final long size;
      if (bytes.count % interval == 0) {
        size = bytes.count / interval;
      } else {
        size = 1L + bytes.count / interval;
      }
      addrInstance = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, size, false);
      addressInstances.put(field.number, addrInstance);
      ramBytesUsed.addAndGet(addrInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT);
    }
    addresses = addrInstance;
  }
  return addresses;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:Lucene49DocValuesProducer.java

示例10: writeOperations

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
/**
 * Writes all operations in the given iterable to the given output stream including the size of the array
 * use {@link #readOperations(StreamInput)} to read it back.
 */
public static void writeOperations(StreamOutput outStream, List<Operation> toWrite) throws IOException {
    final ReleasableBytesStreamOutput out = new ReleasableBytesStreamOutput(BigArrays.NON_RECYCLING_INSTANCE);
    try {
        outStream.writeInt(toWrite.size());
        final BufferedChecksumStreamOutput checksumStreamOutput = new BufferedChecksumStreamOutput(out);
        for (Operation op : toWrite) {
            out.reset();
            final long start = out.position();
            out.skip(RamUsageEstimator.NUM_BYTES_INT);
            writeOperationNoSize(checksumStreamOutput, op);
            long end = out.position();
            int operationSize = (int) (out.position() - RamUsageEstimator.NUM_BYTES_INT - start);
            out.seek(start);
            out.writeInt(operationSize);
            out.seek(end);
            ReleasablePagedBytesReference bytes = out.bytes();
            bytes.writeTo(outStream);
        }
    } finally {
        Releasables.close(out.bytes());
    }

}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:Translog.java

示例11: addOneValue

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
private void addOneValue(BytesRef value) {
  int termID = hash.add(value);
  if (termID < 0) {
    termID = -termID-1;
  } else {
    // reserve additional space for each unique value:
    // 1. when indexing, when hash is 50% full, rehash() suddenly needs 2*size ints.
    //    TODO: can this same OOM happen in THPF?
    // 2. when flushing, we need 1 int per value (slot in the ordMap).
    iwBytesUsed.addAndGet(2 * RamUsageEstimator.NUM_BYTES_INT);
  }
  
  if (currentUpto == currentValues.length) {
    currentValues = ArrayUtil.grow(currentValues, currentValues.length+1);
    // reserve additional space for max # values per-doc
    // when flushing, we need an int[] to sort the mapped-ords within the doc
    iwBytesUsed.addAndGet((currentValues.length - currentUpto) * 2 * RamUsageEstimator.NUM_BYTES_INT);
  }
  
  currentValues[currentUpto] = termID;
  currentUpto++;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:SortedSetDocValuesWriter.java

示例12: saveState

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
/**
 * Saves the existing attribute states
 */
private void saveState() {
  // otherwise, we have delimiters, save state
  savedStartOffset = offsetAttribute.startOffset();
  savedEndOffset = offsetAttribute.endOffset();
  // if length by start + end offsets doesn't match the term text then assume this is a synonym and don't adjust the offsets.
  hasIllegalOffsets = (savedEndOffset - savedStartOffset != termAttribute.length());
  savedType = typeAttribute.type();

  if (savedBuffer.length < termAttribute.length()) {
    savedBuffer = new char[ArrayUtil.oversize(termAttribute.length(), RamUsageEstimator.NUM_BYTES_CHAR)];
  }

  System.arraycopy(termAttribute.buffer(), 0, savedBuffer, 0, termAttribute.length());
  iterator.text = savedBuffer;

  hasSavedState = true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:WordDelimiterFilter.java

示例13: ramBytesUsed

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
private long ramBytesUsed(Arc<T>[] arcs) {
  long size = 0;
  if (arcs != null) {
    size += RamUsageEstimator.shallowSizeOf(arcs);
    for (Arc<T> arc : arcs) {
      if (arc != null) {
        size += ARC_SHALLOW_RAM_BYTES_USED;
        if (arc.output != null && arc.output != outputs.getNoOutput()) {
          size += outputs.ramBytesUsed(arc.output);
        }
        if (arc.nextFinalOutput != null && arc.nextFinalOutput != outputs.getNoOutput()) {
          size += outputs.ramBytesUsed(arc.nextFinalOutput);
        }
      }
    }
  }
  return size;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:FST.java

示例14: ramBytesUsed

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
@Override
public long ramBytesUsed() {
  return RamUsageEstimator.alignObjectSize(
      RamUsageEstimator.NUM_BYTES_OBJECT_HEADER
      + 2 * RamUsageEstimator.NUM_BYTES_INT     // valueCount,bitsPerValue
      + RamUsageEstimator.NUM_BYTES_OBJECT_REF) // blocks ref
      + RamUsageEstimator.sizeOf(blocks);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:Packed8ThreeBlocks.java

示例15: getGeoPointValues

import org.apache.lucene.util.RamUsageEstimator; //导入依赖的package包/类
@Override
public MultiGeoPointValues getGeoPointValues() {
    return new MultiGeoPointValues() {
        GeoPoint[] points = new GeoPoint[0];
        private int count = 0;

        @Override
        public void setDocument(int docId) {
            values.setDocument(docId);
            count = values.count();
            if (count > points.length) {
                final int previousLength = points.length;
                points = Arrays.copyOf(points, ArrayUtil.oversize(count, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
                for (int i = previousLength; i < points.length; ++i) {
                    points[i] = new GeoPoint(Double.NaN, Double.NaN);
                }
            }
            long encoded;
            for (int i=0; i<count; ++i) {
                encoded = values.valueAt(i);
                points[i].reset(GeoEncodingUtils.decodeLatitude((int)(encoded >>> 32)), GeoEncodingUtils.decodeLongitude((int)encoded));
            }
        }

        @Override
        public int count() {
            return count;
        }

        @Override
        public GeoPoint valueAt(int index) {
            return points[index];
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:LatLonPointDVAtomicFieldData.java


注:本文中的org.apache.lucene.util.RamUsageEstimator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。