org.sonar.duplications.block
Class BlockChunker

java.lang.Object
  extended by 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.


Constructor Summary
BlockChunker(int blockSize)
           
 
Method Summary
 List<Block> chunk(String resourceId, List<Statement> statements)
           
 int getBlockSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockChunker

public BlockChunker(int blockSize)
Method Detail

chunk

public List<Block> chunk(String resourceId,
                         List<Statement> statements)

getBlockSize

public int getBlockSize()


Copyright © 2009-2012 SonarSource. All Rights Reserved.