org.sonar.duplications.block
Class BlockChunker
java.lang.Object
org.sonar.duplications.block.BlockChunker
public class BlockChunker
- extends Object
Creates blocks from statements, each block will contain specified number of statements (blockSize
) and 64-bits (8-bytes) hash value.
Hash value computed using
Rabin-Karp rolling hash :
s[0]*31^(blockSize-1) + s[1]*31^(blockSize-2) + ... + s[blockSize-1]
using long
arithmetic, where s[i]
is the hash code of String
(which is cached) for statement with number i.
Thus running time - O(N), where N - number of statements.
Implementation fully thread-safe.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BlockChunker
public BlockChunker(int blockSize)
chunk
public List<Block> chunk(String resourceId,
List<Statement> statements)
getBlockSize
public int getBlockSize()
Copyright © 2009-2011 SonarSource. All Rights Reserved.