public class PackedMemoryCloneIndex extends AbstractCloneIndex
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 and Description |
---|
PackedMemoryCloneIndex() |
PackedMemoryCloneIndex(int hashBytes,
int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
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.
|
public PackedMemoryCloneIndex()
public PackedMemoryCloneIndex(int hashBytes, int initialCapacity)
hashBytes
- size of hash in bytesinitialCapacity
- the initial capacitypublic 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)
Copyright © 2009-2012 SonarSource. All Rights Reserved.