Skip to content

Commit 2a6774f

Browse files
committed
Changes responding to Copilot issues.
1 parent 8841d5a commit 2a6774f

3 files changed

Lines changed: 19 additions & 20 deletions

File tree

src/main/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void reset() {
217217
//Restricted overrides
218218

219219
@Override
220-
HeapUpdateDoublesSketch getSketchAndReset() {
220+
UpdateDoublesSketch getSketchAndReset() {
221221
final HeapUpdateDoublesSketch skCopy = heapify(this);
222222
reset();
223223
return skCopy;

src/main/java/org/apache/datasketches/quantiles/DirectUpdateDoublesSketchR.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ public boolean isSameResource(final MemorySegment that) {
130130

131131
@Override
132132
public void reset() {
133-
throw new SketchesReadOnlyException("Call to reset() on read-only buffer");
133+
throw new SketchesReadOnlyException("Call to reset() on read-only sketch");
134134
}
135135

136136
@Override
137137
public void update(final double dataItem) {
138-
throw new SketchesReadOnlyException("Call to update() on read-only buffer");
138+
throw new SketchesReadOnlyException("Call to update() on read-only sketch");
139139
}
140140

141141
//Restricted overrides
@@ -147,8 +147,10 @@ int getBaseBufferCount() {
147147
}
148148

149149
@Override
150-
int getCombinedBufferItemCapacity() {
151-
return Math.max(0, (int)seg_.byteSize() - COMBINED_BUFFER) / 8;
150+
long getBitPattern() {
151+
final int k = getK();
152+
final long n = getN();
153+
return ClassicUtil.computeBitPattern(k, n);
152154
}
153155

154156
@Override
@@ -159,15 +161,12 @@ int getCombinedBufferItemCapacity() {
159161
final int itemCap = ClassicUtil.computeCombinedBufferItemCapacity(k, n);
160162
final double[] combinedBuffer = new double[itemCap];
161163
MemorySegment.copy(seg_, JAVA_DOUBLE_UNALIGNED, COMBINED_BUFFER, combinedBuffer, 0, itemCap);
162-
163164
return combinedBuffer;
164165
}
165166

166167
@Override
167-
long getBitPattern() {
168-
final int k = getK();
169-
final long n = getN();
170-
return ClassicUtil.computeBitPattern(k, n);
168+
int getCombinedBufferItemCapacity() {
169+
return Math.max(0, (int)seg_.byteSize() - COMBINED_BUFFER) / 8;
171170
}
172171

173172
@Override
@@ -177,19 +176,24 @@ MemorySegment getMemorySegment() {
177176

178177
@Override
179178
UpdateDoublesSketch getSketchAndReset() {
180-
throw new SketchesReadOnlyException("Call to getResultAndReset() on read-only sketch");
179+
throw new SketchesReadOnlyException("Call to getSketchAndReset() on read-only sketch");
180+
}
181+
182+
@Override
183+
double[] growCombinedBuffer(final int curCombBufItemCap, final int itemSpaceNeeded) {
184+
throw new SketchesReadOnlyException("Call to growCombinedBuffer() on read-only sketch");
181185
}
182186

183187
//Puts
184188

185189
@Override
186190
void putMinItem(final double minQuantile) {
187-
throw new SketchesReadOnlyException("Call to putMinQuantile() on read-only sketch");
191+
throw new SketchesReadOnlyException("Call to putMinItem() on read-only sketch");
188192
}
189193

190194
@Override
191195
void putMaxItem(final double maxQuantile) {
192-
throw new SketchesReadOnlyException("Call to putMaxQuantile() on read-only sketch");
196+
throw new SketchesReadOnlyException("Call to putMaxItem() on read-only sketch");
193197
}
194198

195199
@Override
@@ -209,12 +213,7 @@ void putBaseBufferCount(final int baseBufferCount) {
209213

210214
@Override
211215
void putBitPattern(final long bitPattern) {
212-
throw new SketchesReadOnlyException("Call to putBaseBufferCount() on read-only sketch");
213-
}
214-
215-
@Override
216-
double[] growCombinedBuffer(final int curCombBufItemCap, final int itemSpaceNeeded) {
217-
throw new SketchesReadOnlyException("Call to growCombinedBuffer() on read-only sketch");
216+
throw new SketchesReadOnlyException("Call to putBitPattern() on read-only sketch");
218217
}
219218

220219
//Checks

src/main/java/org/apache/datasketches/quantiles/ItemsUnion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public ItemsSketch<T> getResult() {
182182
*
183183
* @return the result of this Union operation and reset.
184184
*/
185-
public ItemsSketch<T> getResultAndReset() { //TODO
185+
public ItemsSketch<T> getResultAndReset() {
186186
if (gadget_ == null) { return null; } //Intentionally return null here for speed.
187187
return gadget_.getSketchAndReset();
188188
}

0 commit comments

Comments
 (0)