- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
HBase Javadoc对于HTable.get(List)方法非常困惑。
作为返回参数文档,我们有以下语句:
如果重试后仍然有任何失败,
这些Gets的结果数组中将为null,
并且将引发异常。
我不理解“AND”:我们可以在返回的数组中有一个异常或null,不能像文档中所暗示的那样同时存在。
我从未听说过能够同时引发异常和返回某些内容的Java方法。
调用此方法时,我在代码中处理异常,但是我是否还需要担心结果数组中的空引用?
最佳答案
这里的文档具有误导性,因为此功能不会返回结果,并且在失败的情况下会同时引发错误。
我之所以对此进行挖掘,是因为我也感到困惑。
这是此函数的source code:
/** {@inheritDoc} */
@Override
public Result[] get(List<Get> gets) throws IOException {
LOG.trace("get(List<>)");
Preconditions.checkNotNull(gets);
if (gets.isEmpty()) {
return new Result[0];
} else if (gets.size() == 1) {
try {
return new Result[] {get(gets.get(0))};
} catch (IOException e) {
throw createRetriesExhaustedWithDetailsException(e, gets.get(0));
}
} else {
try (Scope scope = TRACER.spanBuilder("BigtableTable.get").startScopedSpan()) {
addBatchSizeAnnotation(gets);
return getBatchExecutor().batch(gets);
}
}
}
getBatchExecutor().batch(gets)
,该函数的定义如下:
public Result[] batch(List<? extends Row> actions) throws IOException {
try {
Object[] resultsOrErrors = new Object[actions.size()];
batchCallback(actions, resultsOrErrors, null);
// At this point we are guaranteed that the array only contains results,
// if it had any errors, batch would've thrown an exception
Result[] results = new Result[resultsOrErrors.length];
System.arraycopy(resultsOrErrors, 0, results, 0, results.length);
return results;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Encountered exception in batch(List<>).", e);
throw new IOException("Batch error", e);
}
}
At this point we are guaranteed that the array only contains results, if it had any errors, batch would've thrown an exception
batch
defined on Table
支持这种情况:
/** {@inheritDoc} */
@Override
public void batch(List<? extends Row> actions, Object[] results)
throws IOException, InterruptedException {
LOG.trace("batch(List<>, Object[])");
try (Scope scope = TRACER.spanBuilder("BigtableTable.batch").startScopedSpan()) {
addBatchSizeAnnotation(actions);
getBatchExecutor().batch(actions, results);
}
}
BatchExecutor
中的相应
definition:
public void batch(List<? extends Row> actions, @Nullable Object[] results)
throws IOException, InterruptedException {
batchCallback(actions, results, null);
}
public <R> void batchCallback(
List<? extends Row> actions, Object[] results, Batch.Callback<R> callback)
throws IOException, InterruptedException {
Preconditions.checkArgument(
results == null || results.length == actions.size(),
"Result array must have same dimensions as actions list.");
if (actions.isEmpty()) {
return;
}
if (results == null) {
results = new Object[actions.size()];
}
Timer.Context timerContext = batchTimer.time();
List<ApiFuture<?>> resultFutures = issueAsyncRowRequests(actions, results, callback);
// Don't want to throw an exception for failed futures, instead the place in results is
// set to null.
List<Throwable> problems = new ArrayList<>();
List<Row> problemActions = new ArrayList<>();
List<String> hosts = new ArrayList<>();
for (int i = 0; i < resultFutures.size(); i++) {
try {
resultFutures.get(i).get();
} catch (ExecutionException e) {
problemActions.add(actions.get(i));
problems.add(e.getCause());
hosts.add(options.getDataHost());
}
}
if (problems.size() > 0) {
throw new RetriesExhaustedWithDetailsException(problems, problemActions, hosts);
}
timerContext.close();
}
results
数组,结果输入时该数组将被填充。最后,如果该批处理中的任何项目失败,则将出现异常有关失败原因的详细信息,但仍然在
results
数组中填充了所有项目的结果。失败的项目将在该数组中为
null
,而其余项包含实际的
Result
。
关于java - HTable.get(List <Get>)是否可以在返回的数组中放入空引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15114141/
我正在开发 HBase 协处理器。每次我们想要向 HTable 添加新的协处理器时,我们都必须首先禁用它。 有没有办法动态加载它而不禁用它? 我们提出了使用类加载器加载协处理器并让加载器动态加载协处理
我正在使用 Nutch 1.8 从网站抓取数据。我现在正在为 Nutch 编写一个自定义插件来解析 HTML 并将数据保存到 HBase。通过教程我创建配置: Configuration conf =
有 Hbase 连接程序的示例 java 代码,这是著名的“HbaseTest”类示例,该示例在互联网上已经存在很长时间了。 我已经在我的服务器中编译了代码并且编译成功。当我运行 Java 类文件时,
我对 Hbase 和 Hadoop 很陌生。我对 MapReduce 概念感到困惑,我想知道 Mapreduce F/w 中的执行流程。我尝试在谷歌上搜索一种方法来从文件中读取数据并使用 Put 类使
一种方法是直接调用 HTable 构造函数,另一种方法是从 HConnection 调用 getTable 方法。第二个选项要求 HConnection 为“非托管”,这对我来说不是很好,因为我的进程
调用 HTable.get(List) 返回的 Result 数组的顺序是什么? ? 我的意思是,假设与输入列表的顺序相同是否正确? 最佳答案 结果数组中的顺序将与输入列表的顺序相同。与批处理方法一样
HBase Javadoc对于HTable.get(List)方法非常困惑。 作为返回参数文档,我们有以下语句: 如果重试后仍然有任何失败, 这些Gets的结果数组中将为null, 并且将引发异常。
我想为我的学期项目重新实现 s-box 的研究论文,但现在时间不够。我的部分是使用不同的 sbox 测试不同的 aes 模式(如 cbc、ecb、ctr、gcm)。我正在使用 openssl 库 1.
我有一个 MapReduce 作业,其输入来自 HTable。在 Java MapReduce 代码中,如何将作业输入格式设置为 HBase TableInputFormat ? 有没有类似JDBC连
我有一个 Scala spark 作业,它像这样从 HBase 读取数据: val hBaseRDD = sc.newAPIHadoopRDD(conf, classOf[TableInputForm
我可以用什么代替 HTable(config,tablename)? 此方法已弃用。在每个示例中,我都可以发现他们使用这个或另一个构造函数,这也已被弃用。 最佳答案 手动构造 HTable 对象已弃用
我想从 扫描 HTable 中的行hbase shell 其中列族(即 Tweet)具有特定值(即 user_id)。 现在我想找到 tweet:user_id 具有值 test1 的所有行因为此列具
我在弄清楚如何使用 emr-5.4.0 从 HTable 获取输入来执行简单的 MapReduce 作业时遇到了一些麻烦。 当我在 ERM 上运行时,由于超时而失败。(emr-5.3.0 也失败了)
我正在使用 CDH 5.4.2 并尝试创建 Hbase 表,代码片段如下: Configuration conf = HBaseConfiguration.create(new Config
情况是这样的:我们有一个安全的 (Kerberos) HBase 集群。我有一个在启动时创建 HTable 实例并卡在它上面的对象。它调用: UserGroupInformation.setConfi
我正在开发一个自定义加载函数,以便在 Dataproc 上使用 Pig 从 Bigtable 加载数据。我使用从 Dataproc 获取的以下 jar 文件列表编译我的 java 代码。当我运行以下
我正在尝试使用HBase在Hadoop上制作mapreduce程序。我正在将Hadoop 2.5.1与HBase 0.98.10.1结合使用。 该程序可以成功编译并制成jar文件。但是,当我尝试使用“
我是一名优秀的程序员,十分优秀!