impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dimitris Tsirogiannis (Code Review)" <ger...@cloudera.org>
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:

(17 comments)

http://gerrit.cloudera.org:8080/#/c/7955/1/be/src/catalog/catalog.cc
File be/src/catalog/catalog.cc:

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
memory?


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.


http://gerrit.cloudera.org:8080/#/c/7955/1/common/thrift/JniCatalog.thrift
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).


http://gerrit.cloudera.org:8080/#/c/7955/1/fe/src/main/java/org/apache/impala/service/JniCatalog.java
File fe/src/main/java/org/apache/impala/service/JniCatalog.java:

Line 137:    * Gets all catalog objects
Please expand the comment. We're adding some non-trivial behavior here.


http://gerrit.cloudera.org:8080/#/c/7955/1/fe/src/main/java/org/apache/impala/thrift/NativeByteArrayOutputStream.java
File fe/src/main/java/org/apache/impala/thrift/NativeByteArrayOutputStream.java:

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


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


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?


http://gerrit.cloudera.org:8080/#/c/7955/1/fe/src/main/java/org/apache/impala/thrift/TNativeSerializer.java
File fe/src/main/java/org/apache/impala/thrift/TNativeSerializer.java:

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


-- 
To view, visit http://gerrit.cloudera.org:8080/7955
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I383684effa9524734ce3c6c0fb7ed37de0e15782
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Bharath Vissapragada <bharathv@cloudera.com>
Gerrit-Reviewer: Alex Behm <alex.behm@cloudera.com>
Gerrit-Reviewer: Bharath Vissapragada <bharathv@cloudera.com>
Gerrit-Reviewer: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Gerrit-Reviewer: Mostafa Mokhtar <mmokhtar@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <tarmstrong@cloudera.com>
Gerrit-HasComments: Yes

Mime
View raw message