Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions core/src/main/java/org/apache/accumulo/core/data/LoadPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,28 @@ public byte[] getEndRow() {
public RangeType getRangeType() {
return rangeType;
}

@Override
public int hashCode() {
return Objects.hash(Arrays.hashCode(endRow), Arrays.hashCode(startRow), fileName, rangeType);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Destination other = (Destination) obj;
return Objects.equals(fileName, other.fileName) && rangeType == other.rangeType
&& Arrays.equals(endRow, other.endRow) && Arrays.equals(startRow, other.startRow);
}

}

private LoadPlan(List<Destination> destinations) {
Expand Down Expand Up @@ -509,4 +531,25 @@ public static LoadPlan compute(URI file, Map<String,String> properties,
return builder.build();
}
}

@Override
public int hashCode() {
return Objects.hash(destinations);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
LoadPlan other = (LoadPlan) obj;
return Objects.equals(destinations, other.destinations);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void testJson() {
builder.loadFileTo("f2.rf", RangeType.FILE, "004", "007");
builder.loadFileTo("f1.rf", RangeType.TABLE, "005", "006");
builder.loadFileTo("f3.rf", RangeType.TABLE, new byte[] {0, 1, 2, 3, 4, 5, 6}, null);
String json = builder.build().toJson();
LoadPlan actual = builder.build();

String b64003 = Base64.getUrlEncoder().encodeToString("003".getBytes(UTF_8));
String b64004 = Base64.getUrlEncoder().encodeToString("004".getBytes(UTF_8));
Expand All @@ -137,7 +137,8 @@ public void testJson() {
+ "','endRow':'" + b64006 + "','rangeType':'TABLE'},{'fileName':'f3.rf','startRow':'"
+ b64binary + "','endRow':null,'rangeType':'TABLE'}]}";

assertEquals(expected.replace("'", "\""), json);
LoadPlan expectedLoadPlan = LoadPlan.fromJson(expected);
assertEquals(expectedLoadPlan, actual);
}

@Test
Expand Down