Skip to content

Commit 469be94

Browse files
authored
Merge pull request #2778 from sepinf-inc/#2777_FixPhotoDNA
Fix PhotoDNALookup to correctly map PhotoDNAItem's (#2777)
2 parents 86a68ec + d3aed50 commit 469be94

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

iped-engine/src/main/java/iped/engine/hashdb/PhotoDnaTree.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ public PhotoDnaTree(PhotoDnaItem[] items) {
2727
childs = new int[maxLen];
2828
Arrays.fill(starts, -1);
2929

30-
split(0, items.length, len++);
30+
len = 1;
31+
split(0, items.length, 0);
3132

3233
rays = Arrays.copyOf(rays, len);
3334
starts = Arrays.copyOf(starts, len);
3435
ends = Arrays.copyOf(ends, len);
3536
childs = Arrays.copyOf(childs, len);
3637
photoDnaArr = new byte[items[0].getBytes().length][items.length];
3738
hashId = new int[items.length];
38-
Map<Integer, Integer> posToId = new HashMap<Integer, Integer>();
39+
Map<PhotoDnaItem, Integer> itemToPos = new HashMap<PhotoDnaItem, Integer>();
3940
for (int i = 0; i < items.length; i++) {
4041
PhotoDnaItem item = items[i];
41-
int id = hashId[i] = item.getHashId();
42-
posToId.put(id, i);
42+
hashId[i] = item.getHashId();
43+
itemToPos.put(item, i);
4344
byte[] b = item.getBytes();
4445
for (int j = 0; j < b.length; j++) {
4546
photoDnaArr[j][i] = b[j];
@@ -49,7 +50,7 @@ public PhotoDnaTree(PhotoDnaItem[] items) {
4950
for (int i = 0; i < len; i++) {
5051
PhotoDnaItem item = centerItems[i];
5152
if (item != null) {
52-
centers[i] = posToId.get(item.getHashId());
53+
centers[i] = itemToPos.get(item);
5354
}
5455
}
5556
this.items = null;

iped-engine/src/main/java/iped/engine/task/PhotoDNALookup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class PhotoDNALookup extends AbstractTask {
6060
private static HashDBDataSource hashDBDataSource;
6161

6262
// Magic number used as the first bytes of cache file
63-
private static final int magic = 0x20250826;
63+
private static final int magic = 0x20260126;
6464

6565
private PhotoDNALookupConfig pdnaLookupConfig;
6666

0 commit comments

Comments
 (0)