[
https://issues.apache.org/jira/browse/DRILL-6202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16424985#comment-16424985
]
ASF GitHub Bot commented on DRILL-6202:
---------------------------------------
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/1144#discussion_r179022090
--- Diff: exec/memory/base/src/main/java/io/netty/buffer/DrillBuf.java ---
@@ -777,23 +778,20 @@ public int getActualMemoryConsumed() {
* @return A hex dump in a String.
*/
public String toHexString(final int start, final int length) {
- final int roundedStart = (start / LOG_BYTES_PER_ROW) *
LOG_BYTES_PER_ROW;
-
- final StringBuilder sb = new StringBuilder("buffer byte dump\n");
- int index = roundedStart;
- for (int nLogged = 0; nLogged < length; nLogged += LOG_BYTES_PER_ROW) {
- sb.append(String.format(" [%05d-%05d]", index, index +
LOG_BYTES_PER_ROW - 1));
- for (int i = 0; i < LOG_BYTES_PER_ROW; ++i) {
- try {
- final byte b = getByte(index++);
- sb.append(String.format(" 0x%02x", b));
- } catch (IndexOutOfBoundsException ioob) {
- sb.append(" <ioob>");
- }
+ Preconditions.checkArgument(start >= 0);
+ final StringBuilder sb = new StringBuilder("buffer byte dump");
+ final int end = Math.min(length, this.length - start);
+ for (int i = 0; i < end; i++) {
+ if (i % LOG_BYTES_PER_ROW == 0) {
+ sb.append(String.format("%n [%05d-%05d]", i + start, Math.min(i +
LOG_BYTES_PER_ROW - 1, end - 1) + start));
}
- sb.append('\n');
+ byte b = _getByte(i + start);
+ sb.append(" 0x").append(HEX_CHAR[b >> 4]).append(HEX_CHAR[b & 0x0F]);
--- End diff --
Is this complexity needed relative to the original `format(" 0x02x", b)`
implementation? Is this code performance sensitive enough to justify the extra
complexity?
> Deprecate usage of IndexOutOfBoundsException to re-alloc vectors
> ----------------------------------------------------------------
>
> Key: DRILL-6202
> URL: https://issues.apache.org/jira/browse/DRILL-6202
> Project: Apache Drill
> Issue Type: Bug
> Reporter: Vlad Rozov
> Assignee: Vlad Rozov
> Priority: Major
> Fix For: 1.14.0
>
>
> As bounds checking may be enabled or disabled, using
> IndexOutOfBoundsException to resize vectors is unreliable. It works only when
> bounds checking is enabled.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)