// This file is part of OpenTSDB.
// Copyright (C) 2010-2012  The OpenTSDB Authors.
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or (at your
// option) any later version.  This program is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
// General Public License for more details.  You should have received a copy
// of the GNU Lesser General Public License along with this program.  If not,
// see <http://www.gnu.org/licenses/>.
package net.opentsdb.core;

import java.util.Arrays;

/** Helper functions to deal with the row key. */
final class RowKey {

  private RowKey() {
    // Can't create instances of this utility class.
  }

  /**
   * Extracts the name of the metric ID contained in a row key.
   * @param tsdb The TSDB to use.
   * @param row The actual row key.
   * @return The name of the metric.
   */
  static String metricName(final TSDB tsdb, final byte[] row) {
    final byte[] id = Arrays.copyOfRange(row, 0, tsdb.metrics.width());
    return tsdb.metrics.getName(id);
  }

}

@@ -796,16 +796,56 @@
 rrays;%0A%0A
+import com.stumbleupon.async.Deferred;%0A%0A
 /** Help
@@ -1230,24 +1230,525 @@
 te%5B%5D row) %7B%0A
+    try %7B%0A      return metricNameAsync(tsdb, row).joinUninterruptibly();%0A    %7D catch (RuntimeException e) %7B%0A      throw e;%0A    %7D catch (Exception e) %7B%0A      throw new RuntimeException(%22Should never be here%22, e);%0A    %7D%0A  %7D%0A%0A  /**%0A   * Extracts the name of the metric ID contained in a row key.%0A   * @param tsdb The TSDB to use.%0A   * @param row The actual row key.%0A   * @return The name of the metric.%0A   * @since 1.2%0A   */%0A  static Deferred%3CString%3E metricNameAsync(final TSDB tsdb, final byte%5B%5D row) %7B%0A
     final by
@@ -1838,16 +1838,21 @@
 .getName
+Async
 (id);%0A  
@@ -1853,11 +1853,10 @@
 d);%0A  %7D%0A
-%0A
 %7D%0A

Add RowKey.metricNameAsync() to fetch the metric name asynchronously from a row key