• 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

83.33
/src/main/java/org/apache/datasketches/quantilescommon/GenericSortedViewIterator.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.quantilescommon;
21

22
import static org.apache.datasketches.quantilescommon.QuantileSearchCriteria.INCLUSIVE;
23

24
/**
25
 * Iterator over quantile sketches of generic type.
26
 * @param <T> The generic item class type
27
 */
28
public class GenericSortedViewIterator<T> extends SortedViewIterator {
29
  private final T[] quantiles;
30

31
  /**
32
   * Constructor
33
   * @param quantiles the given array of quantiles
34
   * @param cumWeights the array of cumulative weights, corresponding to the array of quantiles,
35
   * starting with the value one and the end value must equal N, the total number of items input to the sketch.
36
   */
37
  public GenericSortedViewIterator(final T[] quantiles, final long[] cumWeights) {
38
    super(cumWeights);
1✔
39
    this.quantiles = quantiles; //SpotBugs EI_EXPOSE_REP2 suppressed by FindBugsExcludeFilter
1✔
40
  }
1✔
41

42
  /**
43
   * Gets the quantile at the current index
44
   * This is equivalent to <i>getQuantile(INCLUSIVE)</i>.
45
   *
46
   * <p>Don't call this before calling next() for the first time or after getting false from next().</p>
47
   *
48
   * @return the quantile at the current index.
49
   */
50
  public T getQuantile() {
51
    return quantiles[index];
1✔
52
  }
53

54
  /**
55
   * Gets the quantile at the current index (or previous index)
56
   * based on the chosen search criterion.
57
   *
58
   * <p>Don't call this before calling next() for the first time or after getting false from next().</p>
59
   *
60
   * @param searchCrit if INCLUSIVE, includes the quantile at the current index.
61
   * Otherwise, returns the quantile of the previous index.
62
   *
63
   * @return the quantile at the current index (or previous index)
64
   * based on the chosen search criterion. If the chosen search criterion is <i>EXCLUSIVE</i> and
65
   * the current index is at zero, this will return <i>null</i>.
66
   */
67
  public T getQuantile(final QuantileSearchCriteria searchCrit) {
68
    if (searchCrit == INCLUSIVE) { return quantiles[index]; }
1✔
69
    return (index == 0) ? null : quantiles[index - 1];
×
70
  }
71
}
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