Skip to content

Commit

Permalink
Add option to summarize counts for DiscoveryLogic
Browse files Browse the repository at this point in the history
Add the query parameter sum.counts that, when specified for the
DiscoveryLogic, will results in counts being summed up across the
specified time range, rather than returning counts per day.

Closes #2222
  • Loading branch information
lbschanno committed Mar 8, 2024
1 parent 048ebec commit eeeec50
Show file tree
Hide file tree
Showing 6 changed files with 799 additions and 440 deletions.
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();
}
}

0 comments on commit eeeec50

Please sign in to comment.