Skip to content

Commit 3e4eae0

Browse files
committed
Correcting javadocs
1 parent b2aa63c commit 3e4eae0

5 files changed

Lines changed: 66 additions & 18 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static void checkDirectSegCapacity(final int k, final long n, final long segCapB
250250
/**
251251
* Checks a sketch's serial version and flags to see if the sketch can be wrapped as a
252252
* DirectCompactDoubleSketch. Throws an exception if the sketch is neither empty nor compact
253-
* and ordered, unles the sketch uses serialization version 2.
253+
* and ordered, unless the sketch uses serialization version 2.
254254
* @param serVer the serialization version
255255
* @param flags Flags from the sketch to evaluate
256256
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static void checkDirectSegCapacity(final int k, final long n, final long segCapB
384384
static void checkCompact(final int serVer, final int flags) {
385385
final boolean compact = (serVer == 2) || ((flags & COMPACT_FLAG_MASK) > 0);
386386
if (compact) {
387-
throw new SketchesArgumentException("Compact MemorySegment is not supported for Wrap Instance.");
387+
throw new SketchesArgumentException("MemorySegment is in compact form and is not supported for this writableWrap Instance.");
388388
}
389389
}
390390

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

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,29 +151,59 @@ public static DoublesSketch heapify(final MemorySegment srcSeg) {
151151
}
152152

153153
/**
154-
* Wrap this sketch around the given updatable MemorySegment image of a DoublesSketch, compact or updatable.
154+
* Wrap this sketch around the given MemorySegment image of a compact, read-only DoublesSketch.
155155
*
156-
* @param srcSeg the given MemorySegment image of a DoublesSketch that may have data
157-
* @return a sketch that wraps the given srcSeg in read-only mode.
156+
* @param srcSeg the given MemorySegment image of a compact, read-only DoublesSketch.
157+
* @return a compact, read-only sketch that wraps the given MemorySegment.
158158
*/
159159
public static DoublesSketch wrap(final MemorySegment srcSeg) {
160+
if (!checkIsMemorySegmentCompact(srcSeg)) {
161+
throw new SketchesArgumentException("MemorySegment sketch image must be in compact form.");
162+
}
163+
return DirectCompactDoublesSketch.wrapInstance(srcSeg);
164+
}
165+
166+
/**
167+
* Wrap this sketch around the given MemorySegment image of an updatable DoublesSketch.
168+
*
169+
* <p>The given MemorySegment must be writable and it must contain a <i>UpdateDoublesSketch</i>.
170+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
171+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
172+
*
173+
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
174+
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
175+
* return a new MemorySegment on the heap.</p>
176+
*
177+
* @param srcSeg the given MemorySegment image of an <i>UpdateDoublesSketch</i>.
178+
* @return an updatable sketch that wraps the given MemorySegment.
179+
*/
180+
public static DoublesSketch writableWrap(final MemorySegment srcSeg) {
160181
if (checkIsMemorySegmentCompact(srcSeg)) {
161-
return DirectCompactDoublesSketch.wrapInstance(srcSeg);
182+
throw new SketchesArgumentException("MemorySegment sketch image must be in updatable form.");
162183
}
163184
return DirectUpdateDoublesSketch.wrapInstance(srcSeg, null);
164185
}
165186

166187
/**
167-
* Wrap this sketch around the given updatable MemorySegment image of a DoublesSketch, compact or updatable.
188+
* Wrap this sketch around the given MemorySegment image of an updatable DoublesSketch.
189+
*
190+
* <p>The given MemorySegment must be writable and it must contain a <i>UpdateDoublesSketch</i>.
191+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
192+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
193+
*
194+
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
195+
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
196+
* return a new MemorySegment on the heap. It is up to the user to optionally extend this interface if more flexible
197+
* handling of requests for more capacity is required.</p>
168198
*
169-
* @param srcSeg the given MemorySegment image of a DoublesSketch that may have data.
199+
* @param srcSeg the given MemorySegment image of a DoublesSketch.
170200
* @param mSegReq the MemorySegmentRequest used if the given MemorySegment needs to expand.
171201
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
172-
* @return a sketch that wraps the given srcSeg in read-only mode.
202+
* @return a sketch that wraps the given MemorySegment.
173203
*/
174-
public static DoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
204+
public static DoublesSketch writableWrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
175205
if (checkIsMemorySegmentCompact(srcSeg)) {
176-
return DirectCompactDoublesSketch.wrapInstance(srcSeg);
206+
throw new SketchesArgumentException("MemorySegment sketch image must be in updatable form.");
177207
}
178208
return DirectUpdateDoublesSketch.wrapInstance(srcSeg, mSegReq);
179209
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void union(final DoublesSketch sketchIn) {
138138
@Override
139139
public void union(final MemorySegment seg) {
140140
Objects.requireNonNull(seg);
141-
gadget_ = updateLogic(maxK_, gadget_, DoublesSketch.wrap(seg, null));
141+
gadget_ = updateLogic(maxK_, gadget_, DoublesSketch.writableWrap(seg, null));
142142
gadget_.doublesSV = null;
143143
}
144144

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,40 @@ public abstract class UpdateDoublesSketch extends DoublesSketch {
3434
}
3535

3636
/**
37-
* Wrap this sketch around the given MemorySegment image of an UpdateDoublesSketch.
37+
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch.
3838
*
39-
* @param srcSeg the given MemorySegment image of an UpdateDoublesSketch and must not be null.
40-
* @return a sketch that wraps the given srcSeg
39+
* <p>The given MemorySegment must be writable and it must contain a <i>UpdateDoublesSketch</i>.
40+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
41+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
42+
*
43+
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
44+
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
45+
* return a new MemorySegment on the heap.</p>
46+
*
47+
* @param srcSeg a MemorySegment that contains sketch data.
48+
* @return an instance of this sketch that wraps the given MemorySegment.
4149
*/
4250
public static UpdateDoublesSketch wrap(final MemorySegment srcSeg) {
4351
return DirectUpdateDoublesSketch.wrapInstance(srcSeg, null);
4452
}
4553

4654
/**
47-
* Wrap this sketch around the given MemorySegment image of an UpdateDoublesSketch.
55+
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including an
56+
* optional, user defined {@link MemorySegmentRequest MemorySegmentRequest}.
57+
*
58+
* <p>The given MemorySegment must be writable and it must contain a <i>UpdateDoublesSketch</i>.
59+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
60+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
61+
*
62+
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
63+
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
64+
* return a new MemorySegment on the heap. It is up to the user to optionally extend this interface if more flexible
65+
* handling of requests for more capacity is required.</p>
4866
*
49-
* @param srcSeg the given MemorySegment image of an UpdateDoublesSketch and must not be null.
67+
* @param srcSeg a MemorySegment that contains sketch data.
5068
* @param mSegReq the MemorySegmentRequest used if the given MemorySegment needs to expand.
5169
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
52-
* @return a sketch that wraps the given srcSeg
70+
* @return an instance of this sketch that wraps the given MemorySegment.
5371
*/
5472
public static UpdateDoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
5573
return DirectUpdateDoublesSketch.wrapInstance(srcSeg, mSegReq);

0 commit comments

Comments
 (0)