Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to summarize counts for DiscoveryLogic #2298

Open
wants to merge 10 commits into
base: integration
Choose a base branch
from
Expand Up @@ -3,14 +3,16 @@
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Comparator;
import java.util.Map;
import java.util.Objects;
import java.util.StringJoiner;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.hadoop.io.MapWritable;
import org.apache.hadoop.io.VLongWritable;
import org.apache.hadoop.io.WritableComparable;

import com.google.common.base.Objects;

public class DiscoveredThing implements WritableComparable<DiscoveredThing> {
private String term, field, type, date, columnVisibility;
private final VLongWritable count;
Expand Down Expand Up @@ -83,6 +85,7 @@ public void readFields(DataInput in) throws IOException {

@Override
public int compareTo(DiscoveredThing o) {

CompareToBuilder cmp = new CompareToBuilder();
if (o == null) {
return 1;
Expand All @@ -93,28 +96,34 @@ public int compareTo(DiscoveredThing o) {
cmp.append(getDate(), o.getDate());
cmp.append(getColumnVisibility(), o.getColumnVisibility());
cmp.append(getCount(), o.getCount());
cmp.append(getCountsByColumnVisibility(), o.getCountsByColumnVisibility());
return cmp.toComparison();
}
}

@Override
public boolean equals(Object o) {
if (!(o instanceof DiscoveredThing))
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
DiscoveredThing other = (DiscoveredThing) o;
return Objects.equal(getTerm(), other.getTerm()) && Objects.equal(getField(), other.getField()) && Objects.equal(getType(), other.getType())
&& Objects.equal(getDate(), other.getDate()) && Objects.equal(getColumnVisibility(), other.getColumnVisibility())
&& Objects.equal(getCount(), other.getCount());
}
DiscoveredThing that = (DiscoveredThing) o;
return Objects.equals(term, that.term) && Objects.equals(field, that.field) && Objects.equals(type, that.type) && Objects.equals(date, that.date)
&& Objects.equals(columnVisibility, that.columnVisibility) && Objects.equals(count, that.count)
&& Objects.equals(countsByColumnVisibility, that.countsByColumnVisibility);
}

@Override
public int hashCode() {
return Objects.hashCode(getTerm(), getField(), getType(), getDate(), getColumnVisibility(), getCount());
return Objects.hash(term, field, type, date, columnVisibility, count, countsByColumnVisibility);
}

@Override
public String toString() {
return "DiscoveredThing [term=" + term + ", field=" + field + ", type=" + type + ", date=" + date + ", columnVisibility=" + columnVisibility
+ ", count=" + count + "]";
return new StringJoiner(", ", DiscoveredThing.class.getSimpleName() + "[", "]").add("term='" + term + "'").add("field='" + field + "'")
.add("type='" + type + "'").add("date='" + date + "'").add("columnVisibility='" + columnVisibility + "'").add("count=" + count)
.add("countsByColumnVisibility=" + countsByColumnVisibility).toString();
}
}