|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sonar.duplications.index.AbstractCloneIndex
org.sonar.duplications.index.PackedMemoryCloneIndex
public class PackedMemoryCloneIndex
Provides an index optimized by memory.
Each object in Java has an overhead - see
"HOWTO: Determine the size of a Java Object or Class".
So to optimize memory consumption, we use flat arrays, however this increases time of queries.
During usual detection of duplicates most time consuming method is a getByResourceId(String):
around 50% of time spent in this class and number of invocations of this method is 1% of total invocations,
however total time spent in this class less than 1 second for small projects and around 2 seconds for projects like JDK.
Note that this implementation currently does not support deletion, however it's possible to implement.
| Constructor Summary | |
|---|---|
PackedMemoryCloneIndex()
|
|
PackedMemoryCloneIndex(int hashBytes,
int initialCapacity)
|
|
| Method Summary | |
|---|---|
Collection<Block> |
getByResourceId(String resourceId)
Performs search of blocks for specified resource. |
Collection<Block> |
getBySequenceHash(ByteArray sequenceHash)
Performs search of blocks for specified hash value. |
void |
insert(Block block)
Adds specified block into index. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PackedMemoryCloneIndex()
public PackedMemoryCloneIndex(int hashBytes,
int initialCapacity)
hashBytes - size of hash in bytesinitialCapacity - the initial capacity| Method Detail |
|---|
public Collection<Block> getByResourceId(String resourceId)
Note that this implementation does not guarantee that blocks would be sorted by index.
public Collection<Block> getBySequenceHash(ByteArray sequenceHash)
public void insert(Block block)
Note that this implementation allows insertion of two blocks with same index for one resource.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||