Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-3708

Consider using DirectByteBuffers to pass serialized structs to frontend

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • Impala 2.6.0
    • None
    • Backend
    • None

    Description

      All of our JNI calls to the frontend use a byte[] to pass a serialized Thrift structure as an argument.

      This causes at least one copy too many as we have to populate the byte array:

        uint8_t* buffer = NULL;
        uint32_t size = 0;
        RETURN_IF_ERROR(serializer.Serialize<T>(msg, &size, &buffer));
      
        /// create jbyteArray given buffer
        *serialized_msg = env->NewByteArray(size);
        RETURN_ERROR_IF_EXC(env);
        if (*serialized_msg == NULL) return Status("couldn't construct jbyteArray");
        env->SetByteArrayRegion(*serialized_msg, 0, size, reinterpret_cast<jbyte*>(buffer));
      

      Instead, we should use a DirectByteBuffer to wrap the serialized buffer, which means we only have to pass the reference to the DBB around, rather than copy all the bytes into a Java object.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              henryr Henry Robinson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: