• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / datasketches-java / #306

30 Apr 2024 10:01PM UTC coverage: 97.645% (-0.5%) from 98.139%
#306

push

web-flow
Merge pull request #555 from apache/fix_pom_xml_header

Fix pom xml header

26865 of 27513 relevant lines covered (97.64%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/src/main/java/org/apache/datasketches/fdt/Group.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.datasketches.fdt;
21

22
/**
23
 * Defines a Group from a Frequent Distinct Tuple query. This class is called internally during
24
 * post processing and is not intended to be called by the user.
25
 * @author Lee Rhodes
26
 */
27
public class Group implements Comparable<Group> {
28
  private int count = 0;
1✔
29
  private double est = 0;
1✔
30
  private double ub = 0;
1✔
31
  private double lb = 0;
1✔
32
  private double fraction = 0;
1✔
33
  private double rse = 0;
1✔
34
  private String priKey = null;
1✔
35
  private final static String fmt =
36
      "%,12d" + "%,15.2f" + "%,15.2f" + "%,15.2f" + "%12.6f" + "%12.6f" + " %s";
37
  private final static String hfmt =
38
      "%12s"  + "%15s"    + "%15s"    + "%15s"    + "%12s"   + "%12s"   + " %s";
39

40
  /**
41
   * Construct an empty Group
42
   */
43
  public Group() { }
1✔
44

45
  /**
46
   * Specifies the parameters to be listed as columns
47
   * @param priKey the primary key of the FDT sketch
48
   * @param count the number of retained rows associated with this group
49
   * @param estimate the estimate of the original population associated with this group
50
   * @param ub the upper bound of the estimate
51
   * @param lb the lower bound of the estimate
52
   * @param fraction the fraction of all retained rows of the sketch associated with this group
53
   * @param rse the estimated Relative Standard Error for this group.
54
   * @return return this
55
   */
56
  public Group init(final String priKey, final int count, final double estimate, final double ub,
57
      final double lb, final double fraction, final double rse) {
58
    this.count = count;
1✔
59
    est = estimate;
1✔
60
    this.ub = ub;
1✔
61
    this.lb = lb;
1✔
62
    this.fraction = fraction;
1✔
63
    this.rse = rse;
1✔
64
    this.priKey = priKey;
1✔
65
    return this;
1✔
66
  }
67

68
  /**
69
   * @return priKey of type T
70
   */
71
  public String getPrimaryKey() { return priKey; }
1✔
72

73
  /**
74
   * @return the count
75
   */
76
  public int getCount() { return count; }
1✔
77

78
  /**
79
   * @return the estimate
80
   */
81
  public double getEstimate() { return est; }
1✔
82

83
  /**
84
   * @return the upper bound
85
   */
86
  public double getUpperBound() { return ub; }
1✔
87

88
  /**
89
   * @return the lower bound
90
   */
91
  public double getLowerBound() { return lb; }
1✔
92

93
  /**
94
   * @return the fraction for this group
95
   */
96
  public double getFraction() { return fraction; }
1✔
97

98
  /**
99
   * @return the RSE
100
   */
101
  public double getRse() { return rse; }
1✔
102

103
  /**
104
   * @return the descriptive header
105
   */
106
  public String getHeader() {
107
    return String.format(hfmt,"Count", "Est", "UB", "LB", "Fraction", "RSE", "PriKey");
1✔
108
  }
109

110
  @Override
111
  public String toString() {
112
    return String.format(fmt, count, est, ub, lb, fraction, rse, priKey);
1✔
113
  }
114

115
  /**
116
   * @param that The Group to compare to
117
   */
118
  @Override
119
  public int compareTo(final Group that) {
120
    return that.count - count; //decreasing
1✔
121
  }
122

123
  @Override
124
  public boolean equals(final Object that) {
125
    if (this == that) { return true; }
×
126
    if (!(that instanceof Group)) { return false; }
×
127
    return ((Group)that).count == count;
×
128
  }
129

130
  @Override
131
  public int hashCode() {
132
    return Integer.MAX_VALUE - count; //MAX_VALUE is a Double Mersenne Prime = 2^31 - 1 = M_M_5
×
133
  }
134

135
}
136

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc