Java Code Examples for org.apache.lucene.util.RamUsageEstimator#shallowSizeOf()
The following examples show how to use
org.apache.lucene.util.RamUsageEstimator#shallowSizeOf() .
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: DirectPostingsFormat.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public long ramBytesUsed() { long sizeInBytes = BASE_RAM_BYTES_USED; sizeInBytes += ((termBytes!=null) ? RamUsageEstimator.sizeOf(termBytes) : 0); sizeInBytes += ((termOffsets!=null) ? RamUsageEstimator.sizeOf(termOffsets) : 0); sizeInBytes += ((skips!=null) ? RamUsageEstimator.sizeOf(skips) : 0); sizeInBytes += ((skipOffsets!=null) ? RamUsageEstimator.sizeOf(skipOffsets) : 0); sizeInBytes += ((sameCounts!=null) ? RamUsageEstimator.sizeOf(sameCounts) : 0); if(terms!=null) { sizeInBytes += RamUsageEstimator.shallowSizeOf(terms); for(TermAndSkip termAndSkip : terms) { sizeInBytes += (termAndSkip!=null) ? termAndSkip.ramBytesUsed() : 0; } } return sizeInBytes; }
Example 2
Source File: TernaryTreeNode.java From lucene-solr with Apache License 2.0 | 6 votes |
long sizeInBytes() { long mem = RamUsageEstimator.shallowSizeOf(this); if (loKid != null) { mem += loKid.sizeInBytes(); } if (eqKid != null) { mem += eqKid.sizeInBytes(); } if (hiKid != null) { mem += hiKid.sizeInBytes(); } if (token != null) { mem += RamUsageEstimator.shallowSizeOf(token) + RamUsageEstimator.NUM_BYTES_ARRAY_HEADER + Character.BYTES * token.length(); } mem += RamUsageEstimator.shallowSizeOf(val); return mem; }
Example 3
Source File: PerformanceEvaluationTask.java From junitperf with Apache License 2.0 | 5 votes |
@Override public void run() { long startTimeNs = System.nanoTime(); long startMeasurements = startTimeNs + warmUpNs; // 堆大小 long memoryKb = RamUsageEstimator.shallowSizeOf(testInstance); statisticsCalculator.setMemory(memoryKb); while (isContinue) { evaluateStatement(startMeasurements); } }
Example 4
Source File: DirectPostingsFormat.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { long sizeInBytes = BASE_RAM_BYTES_USED; sizeInBytes += (docIDs!=null)? RamUsageEstimator.sizeOf(docIDs) : 0; sizeInBytes += (freqs!=null)? RamUsageEstimator.sizeOf(freqs) : 0; if(positions != null) { sizeInBytes += RamUsageEstimator.shallowSizeOf(positions); for(int[] position : positions) { sizeInBytes += (position!=null) ? RamUsageEstimator.sizeOf(position) : 0; } } if (payloads != null) { sizeInBytes += RamUsageEstimator.shallowSizeOf(payloads); for(byte[][] payload : payloads) { if(payload != null) { sizeInBytes += RamUsageEstimator.shallowSizeOf(payload); for(byte[] pload : payload) { sizeInBytes += (pload!=null) ? RamUsageEstimator.sizeOf(pload) : 0; } } } } return sizeInBytes; }
Example 5
Source File: AnalyzingInfixSuggester.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { long mem = RamUsageEstimator.shallowSizeOf(this); try { if (searcherMgr != null) { SearcherManager mgr; IndexSearcher searcher; synchronized (searcherMgrLock) { mgr = searcherMgr; // acquire & release on same SearcherManager, via local reference searcher = mgr.acquire(); } try { for (LeafReaderContext context : searcher.getIndexReader().leaves()) { LeafReader reader = FilterLeafReader.unwrap(context.reader()); if (reader instanceof SegmentReader) { mem += ((SegmentReader) context.reader()).ramBytesUsed(); } } } finally { mgr.release(searcher); } } return mem; } catch (IOException ioe) { throw new RuntimeException(ioe); } }
Example 6
Source File: JaspellTernarySearchTrie.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { long mem = RamUsageEstimator.shallowSizeOf(this) + RamUsageEstimator.shallowSizeOf(relatives); // We don't need to add parent since our parent added itself: for (int i=1;i<4;i++) { TSTNode node = relatives[i]; if (node != null) { mem += node.ramBytesUsed(); } } return mem; }
Example 7
Source File: JaspellTernarySearchTrie.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { long mem = RamUsageEstimator.shallowSizeOf(this); final TSTNode root = getRoot(); if (root != null) { mem += root.ramBytesUsed(); } return mem; }
Example 8
Source File: FSTCompletionLookup.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { long mem = RamUsageEstimator.shallowSizeOf(this) + RamUsageEstimator.shallowSizeOf(normalCompletion) + RamUsageEstimator.shallowSizeOf(higherWeightsCompletion); if (normalCompletion != null) { mem += normalCompletion.getFST().ramBytesUsed(); } if (higherWeightsCompletion != null && (normalCompletion == null || normalCompletion.getFST() != higherWeightsCompletion.getFST())) { // the fst should be shared between the 2 completion instances, don't count it twice mem += higherWeightsCompletion.getFST().ramBytesUsed(); } return mem; }
Example 9
Source File: TSTLookup.java From lucene-solr with Apache License 2.0 | 5 votes |
/** Returns byte size of the underlying TST */ @Override public long ramBytesUsed() { long mem = RamUsageEstimator.shallowSizeOf(this); if (root != null) { mem += root.sizeInBytes(); } return mem; }
Example 10
Source File: CachedOrdinalsReader.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { long mem = RamUsageEstimator.shallowSizeOf(this) + RamUsageEstimator.sizeOf(offsets); if (offsets != ordinals) { mem += RamUsageEstimator.sizeOf(ordinals); } return mem; }
Example 11
Source File: DirectMonotonicReader.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { // Don't include meta, which should be accounted separately return BASE_RAM_BYTES_USED + RamUsageEstimator.shallowSizeOf(readers) + // Assume empty objects for the readers nonZeroBpvs * RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER); }
Example 12
Source File: PackedLongValues.java From lucene-solr with Apache License 2.0 | 5 votes |
Builder(int pageSize, float acceptableOverheadRatio) { pageShift = checkBlockSize(pageSize, MIN_PAGE_SIZE, MAX_PAGE_SIZE); pageMask = pageSize - 1; this.acceptableOverheadRatio = acceptableOverheadRatio; values = new PackedInts.Reader[INITIAL_PAGE_COUNT]; pending = new long[pageSize]; valuesOff = 0; pendingOff = 0; size = 0; ramBytesUsed = baseRamBytesUsed() + RamUsageEstimator.sizeOf(pending) + RamUsageEstimator.shallowSizeOf(values); }
Example 13
Source File: DeltaBaseTermStateSerializer.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * @return The estimated RAM usage of the given {@link TermState}. */ public static long ramBytesUsed(TermState termState) { return termState instanceof IntBlockTermState ? INT_BLOCK_TERM_STATE_RAM_USAGE : RamUsageEstimator.shallowSizeOf(termState); }
Example 14
Source File: PackedLongValues.java From lucene-solr with Apache License 2.0 | 4 votes |
void grow(int newBlockCount) { ramBytesUsed -= RamUsageEstimator.shallowSizeOf(values); values = ArrayUtil.growExact(values, newBlockCount); ramBytesUsed += RamUsageEstimator.shallowSizeOf(values); }
Example 15
Source File: IndexVersionValue.java From crate with Apache License 2.0 | 4 votes |
@Override public long ramBytesUsed() { return RAM_BYTES_USED + RamUsageEstimator.shallowSizeOf(translogLocation); }