@Override public void handleResult(ResultContext<? extends LineHashesWithUuidDto> resultContext) { LineHashesWithUuidDto lineHashesDto = resultContext.getResultObject(); if (lineHashesDto.getPath() == null) { return; } int removeFileIndex = removedFilesIndexes.get(lineHashesDto.getUuid()); ScoreMatrix.ScoreFile removedFile = removedFiles[removeFileIndex]; int lowerBound = (int) Math.floor(removedFile.getLineCount() * LOWER_BOUND_RATIO); int upperBound = (int) Math.ceil(removedFile.getLineCount() * UPPER_BOUND_RATIO); for (int newFileIndex = 0; newFileIndex < newFiles.length; newFileIndex++) { ScoreMatrix.ScoreFile newFile = newFiles[newFileIndex]; if (newFile.getLineCount() >= upperBound) { continue; } if (newFile.getLineCount() <= lowerBound) { break; } File fileInDb = new FileImpl(lineHashesDto.getPath(), lineHashesDto.getLineHashes()); File unmatchedFile = newFileSourcesByKey.get(newFile.getFileUuid()); int score = fileSimilarity.score(fileInDb, unmatchedFile); scoreMatrix[removeFileIndex][newFileIndex] = score; if (score > maxScore) { maxScore = score; } } }
private static void verifyLinesHashes(LineHashesWithKeyDtoHandler handler, ComponentDto file, FileSourceDto fileSource) { LineHashesWithUuidDto dto = handler.getByUuid(file.uuid()).get(); assertThat(dto.getPath()).isEqualTo(file.path()); assertThat(dto.getRawLineHashes()).isEqualTo(fileSource.getRawLineHashes()); assertThat(dto.getLineHashes()).isEqualTo(fileSource.getLineHashes()); }