@@ -228,14 +228,61 @@ else if (serVer == 2) {
228228 "Corrupted: Serialization Version " + serVer + " not recognized." );
229229 }
230230
231+ /**
232+ * Wrap takes the sketch image in the given Memory and refers to it directly.
233+ * There is no data copying onto the java heap.
234+ * The wrap operation enables fast read-only merging and access to all the public read-only API.
235+ *
236+ * <p>Only "Direct" Serialization Version 3 (i.e, OpenSource) sketches that have
237+ * been explicitly stored as direct sketches can be wrapped.
238+ * Wrapping earlier serial version sketches will result in a heapify operation.
239+ * These early versions were never designed to "wrap".</p>
240+ *
241+ * <p>Wrapping any subclass of this class that is empty or contains only a single item will
242+ * result in heapified forms of empty and single item sketch respectively.
243+ * This is actually faster and consumes less overall memory.</p>
244+ *
245+ * <p>This method checks if the DEFAULT_UPDATE_SEED was used to create the source Memory image.
246+ * Note that SerialVersion 1 sketches cannot be checked as they don't have a seedHash field,
247+ * so the resulting heapified CompactSketch will be given the hash of DEFAULT_UPDATE_SEED.</p>
248+ *
249+ * @param bytes a byte array image of a Sketch that was created using the DEFAULT_UPDATE_SEED.
250+ * <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
251+ *
252+ * @return a CompactSketch backed by the given Memory except as above.
253+ */
231254 public static CompactSketch wrap (final byte [] bytes ) {
232255 return wrap (bytes , ThetaUtil .DEFAULT_UPDATE_SEED , false );
233256 }
234-
257+
258+ /**
259+ * Wrap takes the sketch image in the given Memory and refers to it directly.
260+ * There is no data copying onto the java heap.
261+ * The wrap operation enables fast read-only merging and access to all the public read-only API.
262+ *
263+ * <p>Only "Direct" Serialization Version 3 (i.e, OpenSource) sketches that have
264+ * been explicitly stored as direct sketches can be wrapped.
265+ * Wrapping earlier serial version sketches will result in a heapify operation.
266+ * These early versions were never designed to "wrap".</p>
267+ *
268+ * <p>Wrapping any subclass of this class that is empty or contains only a single item will
269+ * result in heapified forms of empty and single item sketch respectively.
270+ * This is actually faster and consumes less overall memory.</p>
271+ *
272+ * <p>This method checks if the given expectedSeed was used to create the source Memory image.
273+ * Note that SerialVersion 1 sketches cannot be checked as they don't have a seedHash field,
274+ * so the resulting heapified CompactSketch will be given the hash of the expectedSeed.</p>
275+ *
276+ * @param bytes a byte array image of a Sketch that was created using the given expectedSeed.
277+ * <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
278+ * @param expectedSeed the seed used to validate the given Memory image.
279+ * <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
280+ * @return a CompactSketch backed by the given Memory except as above.
281+ */
235282 public static CompactSketch wrap (final byte [] bytes , final long expectedSeed ) {
236283 return wrap (bytes , expectedSeed , true );
237284 }
238-
285+
239286 private static CompactSketch wrap (final byte [] bytes , final long seed , final boolean enforceSeed ) {
240287 final int serVer = bytes [PreambleUtil .SER_VER_BYTE ];
241288 final int familyId = bytes [PreambleUtil .FAMILY_BYTE ];
0 commit comments