Skip to content

Commit b2aa63c

Browse files
committed
Improved javadocs
1 parent 7477b36 commit b2aa63c

5 files changed

Lines changed: 34 additions & 49 deletions

File tree

src/main/java/org/apache/datasketches/kll/KllDirectCompactItemsSketch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final class KllDirectCompactItemsSketch<T> extends KllItemsSketch<T> {
6363
final Comparator<? super T> comparator,
6464
final ArrayOfItemsSerDe<T> serDe) {
6565
super(segVal.sketchStructure, comparator, serDe);
66-
seg = segVal.srcSeg;
66+
seg = segVal.srcSeg.asReadOnly();
6767
readOnly = true;
6868
levelsArr = segVal.levelsArr; //always converted to writable form.
6969
}

src/main/java/org/apache/datasketches/kll/KllDoublesSketch.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,14 @@ public static KllDoublesSketch heapify(final MemorySegment srcSeg) {
132132
/**
133133
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch.
134134
*
135-
* <p>If the given MemorySegment is writable and if the {@link KllSketch.SketchStructure SketchStructure} of the MemorySegment is
136-
* {@link #UPDATABLE UPDATABLE}, the sketch will be updated and managed totally within the MemorySegment. If the given source
137-
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.<br></p>
135+
* <p>The given MemorySegment must be writable and it must contain a <i>KllDoublesSketch</i> in updatable form.
136+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
137+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
138138
*
139139
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
140140
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
141141
* return a new MemorySegment on the heap.</p>
142142
*
143-
* <p>If the given MemorySegment is read-only or if the SketchStructure is not UPDATABLE, than the sketch can be read but not written to
144-
* independent of whether the MemorySegment was created on-heap or off-heap.</p>
145-
*
146143
* @param srcSeg a MemorySegment that contains sketch data.
147144
* @return an instance of this sketch that wraps the given MemorySegment.
148145
*/
@@ -153,23 +150,21 @@ public static KllDoublesSketch wrap(final MemorySegment srcSeg) {
153150
}
154151

155152
/**
156-
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including a user
157-
* defined {@link MemorySegmentRequest MemorySegmentRequest}.
153+
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including an
154+
* optional, user defined {@link MemorySegmentRequest MemorySegmentRequest}.
158155
*
159-
* <p>If the given MemorySegment is writable and if the {@link KllSketch.SketchStructure SketchStructure} of the MemorySegment is
160-
* {@link #UPDATABLE UPDATABLE}, the sketch will be updated and managed totally within the MemorySegment. If the given source
161-
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.<br></p>
156+
* <p>The given MemorySegment must be writable and it must contain a <i>KllDoublesSketch</i> in updatable form.
157+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
158+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
162159
*
163160
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
164161
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
165162
* return a new MemorySegment on the heap. It is up to the user to optionally extend this interface if more flexible
166163
* handling of requests for more capacity is required.</p>
167164
*
168-
* <p>If the given MemorySegment is read-only or if the SketchStructure is not UPDATABLE, than the sketch can be read,
169-
* but not written to, independent of whether the MemorySegment was created on-heap or off-heap.</p>
170-
*
171165
* @param srcSeg a MemorySegment that contains sketch data.
172-
* @param mSegReq the callback for the sketch to request a larger MemorySegment. It may be null.
166+
* @param mSegReq the MemorySegmentRequest used if the given MemorySegment needs to expand.
167+
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
173168
* @return an instance of this sketch that wraps the given MemorySegment.
174169
*/
175170
public static KllDoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {

src/main/java/org/apache/datasketches/kll/KllFloatsSketch.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,14 @@ public static KllFloatsSketch heapify(final MemorySegment srcSeg) {
132132
/**
133133
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch.
134134
*
135-
* <p>If the given MemorySegment is writable and if the {@link KllSketch.SketchStructure SketchStructure} of the MemorySegment is
136-
* {@link #UPDATABLE UPDATABLE}, the sketch will be updated and managed totally within the MemorySegment. If the given source
137-
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.<br></p>
135+
* <p>The given MemorySegment must be writable and it must contain a <i>KllFloatsSketch</i> in updatable form.
136+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
137+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
138138
*
139139
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
140140
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
141141
* return a new MemorySegment on the heap.</p>
142142
*
143-
* <p>If the given MemorySegment is read-only or if the SketchStructure is not UPDATABLE, than the sketch can be read but not written to
144-
* independent of whether the MemorySegment was created on-heap or off-heap.</p>
145-
*
146143
* @param srcSeg a MemorySegment that contains sketch data.
147144
* @return an instance of this sketch that wraps the given MemorySegment.
148145
*/
@@ -153,26 +150,24 @@ public static KllFloatsSketch wrap(final MemorySegment srcSeg) {
153150
}
154151

155152
/**
156-
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including a user
157-
* defined {@link MemorySegmentRequest MemorySegmentRequest}.
153+
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including an
154+
* optional, user defined {@link MemorySegmentRequest MemorySegmentRequest}.
158155
*
159-
* <p>If the given MemorySegment is writable and if the {@link KllSketch.SketchStructure SketchStructure} of the MemorySegment is
160-
* {@link #UPDATABLE UPDATABLE}, the sketch will be updated and managed totally within the MemorySegment. If the given source
161-
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.<br></p>
156+
* <p>The given MemorySegment must be writable and it must contain a <i>KllFloatsSketch</i> in updatable form.
157+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
158+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
162159
*
163160
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
164161
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
165162
* return a new MemorySegment on the heap. It is up to the user to optionally extend this interface if more flexible
166163
* handling of requests for more capacity is required.</p>
167164
*
168-
* <p>If the given MemorySegment is read-only or if the SketchStructure is not UPDATABLE, than the sketch can be read,
169-
* but not written to, independent of whether the MemorySegment was created on-heap or off-heap.</p>
170-
*
171165
* @param srcSeg a MemorySegment that contains sketch data.
172-
* @param mSegReq the callback for the sketch to request a larger MemorySegment. It may be null.
166+
* @param mSegReq the MemorySegmentRequest used if the given MemorySegment needs to expand.
167+
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
173168
* @return an instance of this sketch that wraps the given MemorySegment.
174169
*/
175-
public static KllFloatsSketch writableWrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
170+
public static KllFloatsSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
176171
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
177172
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, FLOATS_SKETCH);
178173
return new KllDirectFloatsSketch(srcSeg, segVal, mSegReq);

src/main/java/org/apache/datasketches/kll/KllItemsSketch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ public static <T> KllItemsSketch<T> heapify(
124124
* A reference to the MemorySegment is kept in the sketch and must remain in scope consistent
125125
* with the temporal scope of this sketch. The amount of data kept on the heap is very small.
126126
* All of the item data originally collected by the given MemorySegment sketch object remains in the
127-
* MemorySegment object
128-
* @param srcSeg the MemorySegment object that this sketch will wrap.
127+
* MemorySegment object.
128+
* @param srcSeg the MemorySegment object that this sketch will wrap. It will not be modified.
129129
* @param comparator to compare items
130130
* @param serDe Serializer / deserializer for items of type <i>T</i> and <i>T[]</i>.
131131
* @param <T> The sketch data type

src/main/java/org/apache/datasketches/kll/KllLongsSketch.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,14 @@ public static KllLongsSketch heapify(final MemorySegment srcSeg) {
132132
/**
133133
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch.
134134
*
135-
* <p>If the given MemorySegment is writable and if the {@link KllSketch.SketchStructure SketchStructure} of the MemorySegment is
136-
* {@link #UPDATABLE UPDATABLE}, the sketch will be updated and managed totally within the MemorySegment. If the given source
137-
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.<br></p>
135+
* <p>The given MemorySegment must be writable and it must contain a <i>KllLongsSketch</i> in updatable form.
136+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
137+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
138138
*
139139
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
140140
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
141141
* return a new MemorySegment on the heap.</p>
142142
*
143-
* <p>If the given MemorySegment is read-only or if the SketchStructure is not UPDATABLE, than the sketch can be read but not written to
144-
* independent of whether the MemorySegment was created on-heap or off-heap.</p>
145-
*
146143
* @param srcSeg a MemorySegment that contains sketch data.
147144
* @return an instance of this sketch that wraps the given MemorySegment.
148145
*/
@@ -153,23 +150,21 @@ public static KllLongsSketch wrap(final MemorySegment srcSeg) {
153150
}
154151

155152
/**
156-
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including a user
157-
* defined {@link MemorySegmentRequest MemorySegmentRequest}.
153+
* Wrap a sketch around the given source MemorySegment containing sketch data that originated from this sketch and including an
154+
* optional, user defined {@link MemorySegmentRequest MemorySegmentRequest}.
158155
*
159-
* <p>If the given MemorySegment is writable and if the {@link KllSketch.SketchStructure SketchStructure} of the MemorySegment is
160-
* {@link #UPDATABLE UPDATABLE}, the sketch will be updated and managed totally within the MemorySegment. If the given source
161-
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.<br></p>
156+
* <p>The given MemorySegment must be writable and it must contain a <i>KllLongsSketch</i> in updatable form.
157+
* The sketch will be updated and managed totally within the MemorySegment. If the given source
158+
* MemorySegment is created off-heap, then all the management of the sketch's internal data will be off-heap as well.</p>
162159
*
163160
* <p><b>NOTE:</b>If during updating of the sketch the sketch requires more capacity than the given size of the MemorySegment, the sketch
164161
* will request more capacity using the {@link MemorySegmentRequest MemorySegmentRequest} interface. The default of this interface will
165162
* return a new MemorySegment on the heap. It is up to the user to optionally extend this interface if more flexible
166163
* handling of requests for more capacity is required.</p>
167164
*
168-
* <p>If the given MemorySegment is read-only or if the SketchStructure is not UPDATABLE, than the sketch can be read,
169-
* but not written to, independent of whether the MemorySegment was created on-heap or off-heap.</p>
170-
*
171165
* @param srcSeg a MemorySegment that contains sketch data.
172-
* @param mSegReq the callback for the sketch to request a larger MemorySegment. It may be null.
166+
* @param mSegReq the MemorySegmentRequest used if the given MemorySegment needs to expand.
167+
* Otherwise, it can be null and the default MemorySegmentRequest will be used.
173168
* @return an instance of this sketch that wraps the given MemorySegment.
174169
*/
175170
public static KllLongsSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {

0 commit comments

Comments
 (0)