You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2016/10/04 20:01:58 UTC
[28/46] lucenenet git commit: Renamed
Facet.Taxonomy.WriterCache.CompactLabelToOrdinal.MemoryUsage,
Cl2oTaxonomyWriterCache.MemoryUsage and CollisionMap.MemoryUsage back to their
original name (GetMemoryUsage()) because these are intensive operations.
Renamed Facet.Taxonomy.WriterCache.CompactLabelToOrdinal.MemoryUsage, Cl2oTaxonomyWriterCache.MemoryUsage and CollisionMap.MemoryUsage back to their original name (GetMemoryUsage()) because these are intensive operations.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/cb8d47f2
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/cb8d47f2
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/cb8d47f2
Branch: refs/heads/master
Commit: cb8d47f280b1b459c9b56401d447da0f70564338
Parents: 56bf502
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sun Sep 25 15:40:35 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Mon Oct 3 23:31:41 2016 +0700
----------------------------------------------------------------------
.../WriterCache/Cl2oTaxonomyWriterCache.cs | 7 +--
.../Taxonomy/WriterCache/CollisionMap.cs | 19 ++++-----
.../WriterCache/CompactLabelToOrdinal.cs | 45 +++++++++-----------
3 files changed, 31 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cb8d47f2/src/Lucene.Net.Facet/Taxonomy/WriterCache/Cl2oTaxonomyWriterCache.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/Cl2oTaxonomyWriterCache.cs b/src/Lucene.Net.Facet/Taxonomy/WriterCache/Cl2oTaxonomyWriterCache.cs
index ba9da33..6cbff1f 100644
--- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/Cl2oTaxonomyWriterCache.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/Cl2oTaxonomyWriterCache.cs
@@ -107,12 +107,9 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
/// <summary>
/// Returns the number of bytes in memory used by this object. </summary>
- public virtual int MemoryUsage
+ public virtual int GetMemoryUsage()
{
- get
- {
- return cache == null ? 0 : cache.MemoryUsage;
- }
+ return cache == null ? 0 : cache.GetMemoryUsage();
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cb8d47f2/src/Lucene.Net.Facet/Taxonomy/WriterCache/CollisionMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/CollisionMap.cs b/src/Lucene.Net.Facet/Taxonomy/WriterCache/CollisionMap.cs
index fd47cd9..1b2767b 100644
--- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/CollisionMap.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/CollisionMap.cs
@@ -198,27 +198,24 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
/// <summary>
/// Returns an estimate of the memory usage of this CollisionMap. </summary>
/// <returns> The approximate number of bytes used by this structure. </returns>
- internal virtual int MemoryUsage
+ internal virtual int GetMemoryUsage()
{
- get
+ int memoryUsage = 0;
+ if (this.entries != null)
{
- int memoryUsage = 0;
- if (this.entries != null)
+ foreach (Entry e in this.entries)
{
- foreach (Entry e in this.entries)
+ if (e != null)
{
- if (e != null)
+ memoryUsage += (4 * 4);
+ for (Entry ee = e.next; ee != null; ee = ee.next)
{
memoryUsage += (4 * 4);
- for (Entry ee = e.next; ee != null; ee = ee.next)
- {
- memoryUsage += (4 * 4);
- }
}
}
}
- return memoryUsage;
}
+ return memoryUsage;
}
private class EntryIterator : IEnumerator<Entry>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cb8d47f2/src/Lucene.Net.Facet/Taxonomy/WriterCache/CompactLabelToOrdinal.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/CompactLabelToOrdinal.cs b/src/Lucene.Net.Facet/Taxonomy/WriterCache/CompactLabelToOrdinal.cs
index 0ea1122..94a9e38 100644
--- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/CompactLabelToOrdinal.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/CompactLabelToOrdinal.cs
@@ -356,35 +356,32 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
/// this package. Memory is consumed mainly by three structures: the hash arrays,
/// label repository and collision map.
/// </summary>
- internal virtual int MemoryUsage
+ internal virtual int GetMemoryUsage()
{
- get
+ int memoryUsage = 0;
+ if (this.hashArrays != null)
{
- int memoryUsage = 0;
- if (this.hashArrays != null)
+ // HashArray capacity is instance-specific.
+ foreach (HashArray ha in this.hashArrays)
{
- // HashArray capacity is instance-specific.
- foreach (HashArray ha in this.hashArrays)
- {
- // Each has 2 capacity-length arrays of ints.
- memoryUsage += (ha.capacity * 2 * 4) + 4;
- }
- }
- if (this.labelRepository != null)
- {
- // All blocks are the same size.
- int blockSize = this.labelRepository.blockSize;
- // Each block has room for blockSize UTF-16 chars.
- int actualBlockSize = (blockSize * 2) + 4;
- memoryUsage += this.labelRepository.blocks.Count * actualBlockSize;
- memoryUsage += 8; // Two int values for array as a whole.
- }
- if (this.collisionMap != null)
- {
- memoryUsage += this.collisionMap.MemoryUsage;
+ // Each has 2 capacity-length arrays of ints.
+ memoryUsage += (ha.capacity * 2 * 4) + 4;
}
- return memoryUsage;
}
+ if (this.labelRepository != null)
+ {
+ // All blocks are the same size.
+ int blockSize = this.labelRepository.blockSize;
+ // Each block has room for blockSize UTF-16 chars.
+ int actualBlockSize = (blockSize * 2) + 4;
+ memoryUsage += this.labelRepository.blocks.Count * actualBlockSize;
+ memoryUsage += 8; // Two int values for array as a whole.
+ }
+ if (this.collisionMap != null)
+ {
+ memoryUsage += this.collisionMap.GetMemoryUsage();
+ }
+ return memoryUsage;
}
/// <summary>