当前位置: 首页>>代码示例>>Java>>正文


Java ColumnInterpreter.compare方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.coprocessor.ColumnInterpreter.compare方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnInterpreter.compare方法的具体用法?Java ColumnInterpreter.compare怎么用?Java ColumnInterpreter.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.coprocessor.ColumnInterpreter的用法示例。


在下文中一共展示了ColumnInterpreter.compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compute

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
@Override
public <T, S, P extends Message, Q extends Message, R extends Message> Map<Long, T> compute(
        Map results, Cell kv, ColumnInterpreter<T, S, P, Q, R> ci, byte[] columnFamily, long timestamp,
        List<TimeRange> timeRanges) throws IOException {
    Map<Long, T> minimums = results;
    ColumnInterpreter<T, S, P, Q, R> columnInterpreter = ci;
    T temp;
    T min;
    for (TimeRange t : timeRanges) {
        if (t.withinTimeRange(timestamp)) {
            long minTimestamp = t.getMin();
            if (minimums.containsKey(minTimestamp)) {
                min = minimums.get(minTimestamp);
            } else min = null;
            temp = ci.getValue(columnFamily, CellUtil.cloneQualifier(kv), kv);
            min = (min == null || (temp != null && ci.compare(temp, min) < 0)) ? temp : min;
            minimums.put(minTimestamp, min);
        }
    }
    return minimums;
}
 
开发者ID:juwi,项目名称:HBase-TAggregator,代码行数:22,代码来源:Min.java

示例2: compute

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
@Override
public <T, S, P extends Message, Q extends Message, R extends Message> Map<Long, T> compute(
        Map results, Cell kv, ColumnInterpreter<T, S, P, Q, R> ci, byte[] columnFamily, long timestamp,
        List<TimeRange> timeRanges) throws IOException {
    Map<Long, T> maximums = results;
    ColumnInterpreter<T, S, P, Q, R> columnInterpreter = ci;
    T temp;
    T max;
    for (TimeRange t : timeRanges) {
        if (t.withinTimeRange(timestamp)) {
            long minTimestamp = t.getMin();
            if (maximums.containsKey(minTimestamp)) {
                max = maximums.get(minTimestamp);
            } else max = null;
            temp = columnInterpreter.getValue(columnFamily, CellUtil.cloneQualifier(kv), kv);
            max = (max == null || (temp != null && ci.compare(temp, max) > 0)) ? temp : max;
            maximums.put(minTimestamp, max);
        }
    }
    return maximums;
}
 
开发者ID:juwi,项目名称:HBase-TAggregator,代码行数:22,代码来源:Max.java

示例3: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 * @param table
 * @param ci
 * @param scan
 * @return max val &lt;&gt;
 * @throws Throwable
 *           The caller is supposed to handle the exception as they are thrown
 *           &amp; propagated to it.
 */
public <R, S, P extends Message, Q extends Message, T extends Message>
R max(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci,
    final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
  class MaxCallBack implements Batch.Callback<R> {
    R max = null;

    R getMax() {
      return max;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
    }
  }
  MaxCallBack aMaxCallBack = new MaxCallBack();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, R>() {
        @Override
        public R call(AggregateService instance) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<AggregateResponse> rpcCallback =
              new BlockingRpcCallback<AggregateResponse>();
          instance.getMax(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          if (response.getFirstPartCount() > 0) {
            ByteString b = response.getFirstPart(0);
            Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
            return ci.getCellValueFromProto(q);
          }
          return null;
        }
      }, aMaxCallBack);
  return aMaxCallBack.getMax();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:52,代码来源:AggregationClient.java

示例4: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 *
 * @param table
 * @param ci
 * @param scan
 * @return max val <R>
 * @throws Throwable The caller is supposed to handle the exception as they are thrown
 *                   & propagated to it.
 */
public <R, S, P extends Message, Q extends Message, T extends Message> R max(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci, final Scan scan) throws Throwable {
    final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
    class MaxCallBack implements Batch.Callback<R> {
        R max = null;

        R getMax() {
            return max;
        }

        @Override
        public synchronized void update(byte[] region, byte[] row, R result) {
            max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
        }
    }
    MaxCallBack aMaxCallBack = new MaxCallBack();
    table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
            new Batch.Call<AggregateService, R>() {
                @Override
                public R call(AggregateService instance) throws IOException {
                    ServerRpcController controller = new ServerRpcController();
                    BlockingRpcCallback<AggregateResponse> rpcCallback =
                            new BlockingRpcCallback<AggregateResponse>();
                    instance.getMax(controller, requestArg, rpcCallback);
                    AggregateResponse response = rpcCallback.get();
                    if (controller.failedOnException()) {
                        throw controller.getFailedOn();
                    }
                    if (response.getFirstPartCount() > 0) {
                        ByteString b = response.getFirstPart(0);
                        Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
                        return ci.getCellValueFromProto(q);
                    }
                    return null;
                }
            }, aMaxCallBack);
    return aMaxCallBack.getMax();
}
 
开发者ID:enableiot,项目名称:iotanalytics-gearpump-rule-engine,代码行数:50,代码来源:CustomAggregationClient.java

示例5: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 * @param tableName
 * @param ci
 * @param scan
 * @return max val <R>
 * @throws Throwable
 *           The caller is supposed to handle the exception as they are thrown
 *           & propagated to it.
 */
public <R, S> R max(final byte[] tableName, final ColumnInterpreter<R, S> ci,
    final Scan scan) throws Throwable {
  validateParameters(scan);
  class MaxCallBack implements Batch.Callback<R> {
    R max = null;

    R getMax() {
      return max;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
    }
  }
  MaxCallBack aMaxCallBack = new MaxCallBack();
  HTable table = null;
  try {
    table = new HTable(conf, tableName);
    table.coprocessorExec(AggregateProtocol.class, scan.getStartRow(),
        scan.getStopRow(), new Batch.Call<AggregateProtocol, R>() {
          @Override
          public R call(AggregateProtocol instance) throws IOException {
            return instance.getMax(ci, scan);
          }
        }, aMaxCallBack);
  } finally {
    if (table != null) {
      table.close();
    }
  }
  return aMaxCallBack.getMax();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:46,代码来源:AggregationClient.java

示例6: min

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the minimum value of a column for a given column family for the
 * given range. In case qualifier is null, a min of all values for the given
 * family is returned.
 * @param tableName
 * @param ci
 * @param scan
 * @return min val <R>
 * @throws Throwable
 */
public <R, S> R min(final byte[] tableName, final ColumnInterpreter<R, S> ci,
    final Scan scan) throws Throwable {
  validateParameters(scan);
  class MinCallBack implements Batch.Callback<R> {

    private R min = null;

    public R getMinimum() {
      return min;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      min = (min == null || (result != null && ci.compare(result, min) < 0)) ? result : min;
    }
  }
  MinCallBack minCallBack = new MinCallBack();
  HTable table = null;
  try {
    table = new HTable(conf, tableName);
    table.coprocessorExec(AggregateProtocol.class, scan.getStartRow(),
        scan.getStopRow(), new Batch.Call<AggregateProtocol, R>() {

          @Override
          public R call(AggregateProtocol instance) throws IOException {
            return instance.getMin(ci, scan);
          }
        }, minCallBack);
  } finally {
    if (table != null) {
      table.close();
    }
  }
  log.debug("Min fom all regions is: " + minCallBack.getMinimum());
  return minCallBack.getMinimum();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:47,代码来源:AggregationClient.java

示例7: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 * @param table
 * @param ci
 * @param scan
 * @return max val <R>
 * @throws Throwable
 *           The caller is supposed to handle the exception as they are thrown
 *           & propagated to it.
 */
public <R, S, P extends Message, Q extends Message, T extends Message>
R max(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci,
    final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
  class MaxCallBack implements Batch.Callback<R> {
    R max = null;

    R getMax() {
      return max;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
    }
  }
  MaxCallBack aMaxCallBack = new MaxCallBack();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, R>() {
        @Override
        public R call(AggregateService instance) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<AggregateResponse> rpcCallback =
              new BlockingRpcCallback<AggregateResponse>();
          instance.getMax(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          if (response.getFirstPartCount() > 0) {
            ByteString b = response.getFirstPart(0);
            Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
            return ci.getCellValueFromProto(q);
          }
          return null;
        }
      }, aMaxCallBack);
  return aMaxCallBack.getMax();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:52,代码来源:AggregationClient.java

示例8: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 * @param table
 * @param ci
 * @param scan
 * @return max val <R>
 * @throws Throwable
 *           The caller is supposed to handle the exception as they are thrown
 *           & propagated to it.
 */
public <R, S, P extends Message, Q extends Message, T extends Message> 
R max(final HTable table, final ColumnInterpreter<R, S, P, Q, T> ci,
    final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
  class MaxCallBack implements Batch.Callback<R> {
    R max = null;

    R getMax() {
      return max;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
    }
  }
  MaxCallBack aMaxCallBack = new MaxCallBack();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, R>() {
        @Override
        public R call(AggregateService instance) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<AggregateResponse> rpcCallback = 
              new BlockingRpcCallback<AggregateResponse>();
          instance.getMax(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          if (response.getFirstPartCount() > 0) {
            ByteString b = response.getFirstPart(0);
            Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
            return ci.getCellValueFromProto(q);
          }
          return null;
        }
      }, aMaxCallBack);
  return aMaxCallBack.getMax();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:52,代码来源:AggregationClient.java

示例9: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 * @param table
 * @param ci
 * @param scan
 * @return max val &lt;&gt;
 * @throws Throwable
 *           The caller is supposed to handle the exception as they are thrown
 *           &amp; propagated to it.
 */
public <R, S, P extends Message, Q extends Message, T extends Message>
R max(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci,
    final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
  class MaxCallBack implements Batch.Callback<R> {
    R max = null;

    R getMax() {
      return max;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
    }
  }
  MaxCallBack aMaxCallBack = new MaxCallBack();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, R>() {
        @Override
        public R call(AggregateService instance) throws IOException {
          RpcController controller = new AggregationClientRpcController();
          CoprocessorRpcUtils.BlockingRpcCallback<AggregateResponse> rpcCallback =
              new CoprocessorRpcUtils.BlockingRpcCallback<>();
          instance.getMax(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failed()) {
            throw new IOException(controller.errorText());
          }
          if (response.getFirstPartCount() > 0) {
            ByteString b = response.getFirstPart(0);
            Q q = getParsedGenericInstance(ci.getClass(), 3, b);
            return ci.getCellValueFromProto(q);
          }
          return null;
        }
      }, aMaxCallBack);
  return aMaxCallBack.getMax();
}
 
开发者ID:apache,项目名称:hbase,代码行数:52,代码来源:AggregationClient.java

示例10: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
public static <R, S, P extends Message, Q extends Message, T extends Message> CompletableFuture<R>
    max(AsyncTable<?> table, ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) {
  CompletableFuture<R> future = new CompletableFuture<>();
  AggregateRequest req;
  try {
    req = validateArgAndGetPB(scan, ci, false);
  } catch (IOException e) {
    future.completeExceptionally(e);
    return future;
  }
  AbstractAggregationCallback<R> callback = new AbstractAggregationCallback<R>(future) {

    private R max;

    @Override
    protected void aggregate(RegionInfo region, AggregateResponse resp) throws IOException {
      if (resp.getFirstPartCount() > 0) {
        R result = getCellValueFromProto(ci, resp, 0);
        if (max == null || (result != null && ci.compare(max, result) < 0)) {
          max = result;
        }
      }
    }

    @Override
    protected R getFinalResult() {
      return max;
    }
  };
  table
      .<AggregateService, AggregateResponse> coprocessorService(AggregateService::newStub,
        (stub, controller, rpcCallback) -> stub.getMax(controller, req, rpcCallback), callback)
      .fromRow(nullToEmpty(scan.getStartRow()), scan.includeStartRow())
      .toRow(nullToEmpty(scan.getStopRow()), scan.includeStopRow()).execute();
  return future;
}
 
开发者ID:apache,项目名称:hbase,代码行数:37,代码来源:AsyncAggregationClient.java

示例11: min

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
public static <R, S, P extends Message, Q extends Message, T extends Message> CompletableFuture<R>
    min(AsyncTable<?> table, ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) {
  CompletableFuture<R> future = new CompletableFuture<>();
  AggregateRequest req;
  try {
    req = validateArgAndGetPB(scan, ci, false);
  } catch (IOException e) {
    future.completeExceptionally(e);
    return future;
  }
  AbstractAggregationCallback<R> callback = new AbstractAggregationCallback<R>(future) {

    private R min;

    @Override
    protected void aggregate(RegionInfo region, AggregateResponse resp) throws IOException {
      if (resp.getFirstPartCount() > 0) {
        R result = getCellValueFromProto(ci, resp, 0);
        if (min == null || (result != null && ci.compare(min, result) > 0)) {
          min = result;
        }
      }
    }

    @Override
    protected R getFinalResult() {
      return min;
    }
  };
  table
      .<AggregateService, AggregateResponse> coprocessorService(AggregateService::newStub,
        (stub, controller, rpcCallback) -> stub.getMin(controller, req, rpcCallback), callback)
      .fromRow(nullToEmpty(scan.getStartRow()), scan.includeStartRow())
      .toRow(nullToEmpty(scan.getStopRow()), scan.includeStopRow()).execute();
  return future;
}
 
开发者ID:apache,项目名称:hbase,代码行数:37,代码来源:AsyncAggregationClient.java

示例12: max

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the maximum value of a column for a given column family for the
 * given range. In case qualifier is null, a max of all values for the given
 * family is returned.
 * @param tableName
 * @param ci
 * @param scan
 * @return max val <R>
 * @throws Throwable
 *           The caller is supposed to handle the exception as they are thrown
 *           & propagated to it.
 */
public <R, S> R max(final byte[] tableName, final ColumnInterpreter<R, S> ci,
    final Scan scan) throws Throwable {
  validateParameters(scan);
  HTable table = new HTable(conf, tableName);

  class MaxCallBack implements Batch.Callback<R> {
    R max = null;

    R getMax() {
      return max;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      max = ci.compare(max, result) < 0 ? result : max;
    }
  }
  MaxCallBack aMaxCallBack = new MaxCallBack();
  table.coprocessorExec(AggregateProtocol.class, scan.getStartRow(), scan
      .getStopRow(), new Batch.Call<AggregateProtocol, R>() {
    @Override
    public R call(AggregateProtocol instance) throws IOException {
      return instance.getMax(ci, scan);
    }
  }, aMaxCallBack);
  return aMaxCallBack.getMax();
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:40,代码来源:AggregationClient.java

示例13: min

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the minimum value of a column for a given column family for the
 * given range. In case qualifier is null, a min of all values for the given
 * family is returned.
 * @param tableName
 * @param ci
 * @param scan
 * @return min val <R>
 * @throws Throwable
 */
public <R, S> R min(final byte[] tableName, final ColumnInterpreter<R, S> ci,
    final Scan scan) throws Throwable {
  validateParameters(scan);
  class MinCallBack implements Batch.Callback<R> {

    private R min = null;

    public R getMinimum() {
      return min;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      min = (min == null || ci.compare(result, min) < 0) ? result : min;
    }
  }
  HTable table = new HTable(conf, tableName);
  MinCallBack minCallBack = new MinCallBack();
  table.coprocessorExec(AggregateProtocol.class, scan.getStartRow(), scan
      .getStopRow(), new Batch.Call<AggregateProtocol, R>() {

    @Override
    public R call(AggregateProtocol instance) throws IOException {
      return instance.getMin(ci, scan);
    }
  }, minCallBack);
  log.debug("Min fom all regions is: " + minCallBack.getMinimum());
  return minCallBack.getMinimum();
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:40,代码来源:AggregationClient.java

示例14: min

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the minimum value of a column for a given column family for the
 * given range. In case qualifier is null, a min of all values for the given
 * family is returned.
 * @param table
 * @param ci
 * @param scan
 * @return min val &lt;R&gt;
 * @throws Throwable
 */
public <R, S, P extends Message, Q extends Message, T extends Message>
R min(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci,
    final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
  class MinCallBack implements Batch.Callback<R> {

    private R min = null;

    public R getMinimum() {
      return min;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      min = (min == null || (result != null && ci.compare(result, min) < 0)) ? result : min;
    }
  }
  MinCallBack minCallBack = new MinCallBack();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, R>() {

        @Override
        public R call(AggregateService instance) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<AggregateResponse> rpcCallback =
              new BlockingRpcCallback<AggregateResponse>();
          instance.getMin(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          if (response.getFirstPartCount() > 0) {
            ByteString b = response.getFirstPart(0);
            Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
            return ci.getCellValueFromProto(q);
          }
          return null;
        }
      }, minCallBack);
  log.debug("Min fom all regions is: " + minCallBack.getMinimum());
  return minCallBack.getMinimum();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:AggregationClient.java

示例15: min

import org.apache.hadoop.hbase.coprocessor.ColumnInterpreter; //导入方法依赖的package包/类
/**
 * It gives the minimum value of a column for a given column family for the
 * given range. In case qualifier is null, a min of all values for the given
 * family is returned.
 * @param table
 * @param ci
 * @param scan
 * @return min val <R>
 * @throws Throwable
 */
public <R, S, P extends Message, Q extends Message, T extends Message>
R min(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci,
    final Scan scan) throws Throwable {
  final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
  class MinCallBack implements Batch.Callback<R> {

    private R min = null;

    public R getMinimum() {
      return min;
    }

    @Override
    public synchronized void update(byte[] region, byte[] row, R result) {
      min = (min == null || (result != null && ci.compare(result, min) < 0)) ? result : min;
    }
  }
  MinCallBack minCallBack = new MinCallBack();
  table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
      new Batch.Call<AggregateService, R>() {

        @Override
        public R call(AggregateService instance) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<AggregateResponse> rpcCallback =
              new BlockingRpcCallback<AggregateResponse>();
          instance.getMin(controller, requestArg, rpcCallback);
          AggregateResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          if (response.getFirstPartCount() > 0) {
            ByteString b = response.getFirstPart(0);
            Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
            return ci.getCellValueFromProto(q);
          }
          return null;
        }
      }, minCallBack);
  log.debug("Min fom all regions is: " + minCallBack.getMinimum());
  return minCallBack.getMinimum();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:53,代码来源:AggregationClient.java


注:本文中的org.apache.hadoop.hbase.coprocessor.ColumnInterpreter.compare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。