drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-4134) Incorporate remaining patches from DRILL-1942 Allocator refactor
Date Tue, 01 Dec 2015 17:37:11 GMT

    [ https://issues.apache.org/jira/browse/DRILL-4134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15034149#comment-15034149
] 

ASF GitHub Bot commented on DRILL-4134:
---------------------------------------

Github user julienledem commented on a diff in the pull request:

    https://github.com/apache/drill/pull/283#discussion_r46310317
  
    --- Diff: exec/memory/base/src/main/java/io/netty/buffer/DrillBuf.java ---
    @@ -733,17 +790,98 @@ public byte getByte(int index) {
         return PlatformDependent.getByte(addr(index));
       }
     
    -  public static DrillBuf getEmpty(BufferAllocator allocator, Accountor a) {
    -    return new DrillBuf(allocator, a);
    +  @Override
    +  public void close() {
    +    release();
       }
     
    -  public boolean isRootBuffer() {
    -    return rootBuffer;
    +  /**
    +   * Returns the possible memory consumed by this DrillBuf in the worse case scenario.
(not shared, connected to larger
    +   * underlying buffer of allocated memory)
    +   *
    +   * @return Size in bytes.
    +   */
    +  public int getPossibleMemoryConsumed() {
    +    return ledger.getSize();
       }
     
    -  @Override
    -  public void close() {
    -    release();
    +  /**
    +   * Return that is Accounted for by this buffer (and its potentially shared siblings
within the context of the
    +   * associated allocator).
    +   *
    +   * @return Size in bytes.
    +   */
    +  public int getActualMemoryConsumed() {
    +    return ledger.getAccountedSize();
    +  }
    +
    +  private final static int LOG_BYTES_PER_ROW = 10;
    +  /**
    +   * Log this buffer's byte contents in the form of a hex dump.
    +   *
    +   * @param logger where to log to
    +   * @param start the starting byte index
    +   * @param length how many bytes to log
    +   */
    +  public void logBytes(final Logger logger, 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>");
    +        }
    +      }
    +      sb.append('\n');
    +    }
    +    logger.trace(sb.toString());
    +  }
    +
    +  /**
    +   * Get the integer id assigned to this DrillBuf for debugging purposes.
    +   *
    +   * @return integer id
    +   */
    +  public long getId() {
    +    return id;
    +  }
    +
    +  /**
    +   * Log this buffer's history.
    +   *
    +   * @param logger the logger to use
    +   */
    +  public void logHistory(final Logger logger) {
    +    if (historicalLog == null) {
    +      logger.warn("DrillBuf[{}] historicalLog not available", id);
    +    } else {
    +      historicalLog.logHistory(logger);
    +    }
    +  }
    +
    +  public String toVerboseString() {
    +    if (isEmpty) {
    +      return toString();
    +    }
    +
    +    StringBuilder sb = new StringBuilder();
    +    ledger.print(sb, 0, Verbosity.LOG_WITH_STACKTRACE);
    +    return sb.toString();
    +  }
    +
    +  public void print(StringBuilder sb, int indent, Verbosity verbosity) {
    +    BaseAllocator.indent(sb, indent).append(toString());
    +
    +    if (BaseAllocator.DEBUG && !isEmpty && verbosity.includeHistoricalLog)
{
    +      sb.append("\n");
    +      historicalLog.buildHistory(sb, indent + 1, verbosity.includeStackTraces);
    +    }
       }
    --- End diff --
    
    logBytes() logHistory() toVerboseString() and print() have various level of details about
what they do in their name.
    Possibly make print private?


> Incorporate remaining patches from DRILL-1942 Allocator refactor
> ----------------------------------------------------------------
>
>                 Key: DRILL-4134
>                 URL: https://issues.apache.org/jira/browse/DRILL-4134
>             Project: Apache Drill
>          Issue Type: Sub-task
>          Components: Execution - Flow
>            Reporter: Jacques Nadeau
>            Assignee: Jacques Nadeau
>             Fix For: 1.4.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message