leerho commented on code in PR #684: URL: https://github.com/apache/datasketches-java/pull/684#discussion_r2288813612
########## src/main/java/org/apache/datasketches/quantiles/DoublesSketch.java: ########## @@ -151,29 +151,59 @@ public static DoublesSketch heapify(final MemorySegment srcSeg) { } /** - * Wrap this sketch around the given updatable MemorySegment image of a DoublesSketch, compact or updatable. + * Wrap this sketch around the given MemorySegment image of a compact, read-only DoublesSketch. * - * @param srcSeg the given MemorySegment image of a DoublesSketch that may have data - * @return a sketch that wraps the given srcSeg in read-only mode. + * @param srcSeg the given MemorySegment image of a compact, read-only DoublesSketch. + * @return a compact, read-only sketch that wraps the given MemorySegment. */ public static DoublesSketch wrap(final MemorySegment srcSeg) { + if (!checkIsMemorySegmentCompact(srcSeg)) { + throw new SketchesArgumentException("MemorySegment sketch image must be in compact form."); Review Comment: The larger context here is that moving from datasketches-java 8.0.0 to datasketches-java 9.0.0 is a major rewrite of the entire library and there will be some unavoidable breaking changes as a result. This is one of them. The library's dependency on datasketches-memory has been entirely removed and that code has been migrated to the new Java FMM in Java 25. Such a major change was not practical to do without a few breaking changes. However, what is actually going on here is the previous wrap(...) method that accepted both compact and updatable MemorySegments has been split into two methods: a wrap(...) for compact segments and a writableWrap(...) for updatable segments, which is actually much clearer than the previous wrap(...) method, which was ambiguous. Also, splitting this into two wrap(...) and writableWrap(...) methods matches the same API protocol used in other sketches in the library. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@datasketches.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@datasketches.apache.org For additional commands, e-mail: dev-h...@datasketches.apache.org