Commit 604115ca authored by Panagiotis Papadakos's avatar Panagiotis Papadakos
Browse files

[DocInfoEssential & DocInfoFull] override equals and hashcode to use only the id

parent 0731d924
......@@ -54,10 +54,10 @@ public class DocInfoEssential {
LENGTH // for OkapiBM25 (Value should be integer)
}
private String id = ""; // the 40 byte id
private long offset = 0; // offset in documents file
protected String id = ""; // the 40 byte id
protected long offset = 0; // offset in documents file
// The size of the hashmap is only 3.... since up to now we have 3 properties to hold
private final Map<PROPERTY, Object> props = new HashMap<>(3);
protected final Map<PROPERTY, Object> props = new HashMap<>(3);
public DocInfoEssential(String id, long offset) {
this.id = id;
......@@ -93,4 +93,21 @@ public class DocInfoEssential {
return offset;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DocInfoEssential other = (DocInfoEssential) o;
return this.id == other.id;
}
@Override
public int hashCode() {
return id.hashCode();
}
}
......@@ -36,4 +36,21 @@ public class DocInfoFull extends DocInfoEssential {
super(id, offset);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DocInfoEssential other = (DocInfoEssential) o;
return this.id == other.id;
}
@Override
public int hashCode() {
return id.hashCode();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment