Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-22838

Avoid unnecessary copying of data

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 2.2.1
    • None
    • Spark Core
    • None

    Description

      If we read data from FileChannel to HeapByteBuffer, there is a need to copy the data from the off-heap to the on-heap, you can see the follow code:
      ```java
      static int read(FileDescriptor var0, ByteBuffer var1, long var2, NativeDispatcher var4) throws IOException {
      if(var1.isReadOnly())

      { throw new IllegalArgumentException("Read-only buffer"); }

      else if(var1 instanceof DirectBuffer)

      { return readIntoNativeBuffer(var0, var1, var2, var4); }

      else {
      ByteBuffer var5 = Util.getTemporaryDirectBuffer(var1.remaining());

      int var7;
      try {
      int var6 = readIntoNativeBuffer(var0, var5, var2, var4);
      var5.flip();
      if(var6 > 0)

      { var1.put(var5); }

      var7 = var6;
      } finally

      { Util.offerFirstTemporaryDirectBuffer(var5); }

      return var7;
      }
      }
      ```

      Attachments

        Activity

          People

            Unassigned Unassigned
            coneyliu Xianyang Liu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: