impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dimitris Tsirogiannis (Code Review)" <>
Subject [Impala-ASF-CR] [PREVIEW] Use native allocation while building catalog updates
Date Tue, 05 Sep 2017 22:01:33 GMT
Dimitris Tsirogiannis has posted comments on this change.

Change subject: [PREVIEW] Use native allocation while building catalog updates

Patch Set 1:

File be/src/catalog/

PS1, Line 106: RETURN_IF_ERROR(DeserializeThriftMsg(jni_env, result_bytes, &nbuffer));
What happens if DeserializeThriftMsg returns a non-ok status? Who will release the allocated

PS1, Line 108: uint32_t len = static_cast<uint32_t>(nbuffer.buffer_len);
Isn't buffer_len i64? What will happen if the cast fails?

PS1, Line 110: buf
Interestingly, DeserializeThriftMsg() casts the const away of the first param (buf). The comment
in this function still says that it is treated as a const even though the const is casted
away but let's make sure we check the implementation to ensure nothing bad happens to buf
after that call.

PS1, Line 111: desrialize
nit: deserialize (typo)

PS1, Line 113: free(buf);
> I used free after checking that the unsafe.freeMemory() also calls the same
Yes, I think we need to place it safe here. If the implementation changes in some later Java
version, we may run into issues.
File common/thrift/JniCatalog.thrift:

PS1, Line 596: native byte buffer
In the context of reading this thrift file, I don't think it is clear what "native byte buffer"
is. Maybe say at the beginning that it represents a buffer allocated by the JVM using native
memory (unsafe).
File fe/src/main/java/org/apache/impala/service/

Line 137:    * Gets all catalog objects
Please expand the comment. We're adding some non-trivial behavior here.
File fe/src/main/java/org/apache/impala/thrift/

Line 1: package org.apache.impala.thrift;
Apache header?

PS1, Line 26: @SuppressWarnings("restriction")

PS1, Line 27: class
nit: make it final (do you plan to extend it?)

PS1, Line 33:   private static final long BUFFER_DOUBLING_RESIZE_LIMIT = 1 * 1024 * 1024 *
1024; /* 1GB */
nit: long line

PS1, Line 38: length
length (in bytes)

PS1, Line 39: protected
why protected?

PS1, Line 48: public NativeByteArrayOutputStream() {
            :     this(BUFFER_INITIAL_SIZE_DEFAULT);
            :   }
single line?

PS1, Line 57: // Unsafe#allocateMemory() can handle negative inputs.
Why do I need to know about this here? Maybe remove.

PS1, Line 94: if (bufferLen_ >= BUFFER_DOUBLING_RESIZE_LIMIT) {
            :         newBufferSize = bufferLen_ + BUFFER_RESIZE_INCREMENTS;
            :       } else {
            :         newBufferSize = bufferLen_ << 1;
            :       }
How do you guarantee that newBufferSize > bytesWritten_ + len?
E.g. bufferLen_ = 128MB, len = 1GB. Isn't bufferLen_ going to be 256MB although you need 1128MB?
Am I missing something?
File fe/src/main/java/org/apache/impala/thrift/

PS1, Line 31: native by array
nit: "native by array"?

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I383684effa9524734ce3c6c0fb7ed37de0e15782
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Bharath Vissapragada <>
Gerrit-Reviewer: Alex Behm <>
Gerrit-Reviewer: Bharath Vissapragada <>
Gerrit-Reviewer: Dimitris Tsirogiannis <>
Gerrit-Reviewer: Mostafa Mokhtar <>
Gerrit-Reviewer: Tim Armstrong <>
Gerrit-HasComments: Yes

View raw message