spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gatorsmile <>
Subject [GitHub] spark pull request: [SPARK-12030] Fix Platform.copyMemory to handl...
Date Wed, 02 Dec 2015 02:44:09 GMT
Github user gatorsmile commented on a diff in the pull request:
    --- Diff: unsafe/src/main/java/org/apache/spark/unsafe/ ---
    @@ -107,12 +107,27 @@ public static void freeMemory(long address) {
       public static void copyMemory(
         Object src, long srcOffset, Object dst, long dstOffset, long length) {
    -    while (length > 0) {
    -      long size = Math.min(length, UNSAFE_COPY_THRESHOLD);
    -      _UNSAFE.copyMemory(src, srcOffset, dst, dstOffset, size);
    -      length -= size;
    -      srcOffset += size;
    -      dstOffset += size;
    +    // Check if dstOffset is before or after srcOffset to determine if we should copy
    +    // forward or backwards. This is necessary in case src and dst overlap.
    +    if (dstOffset < srcOffset) {
    --- End diff --
    I still have a question. Both `dstOffset` and `srcOffset` are offsets. They are not absolute
    Based on the code changes, I do not understand how it works. Could anybody give me a hint?
Thank you! 

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message