gpt4 book ai didi

java - 从 Oracle NOSQL 检索批量数据时,获取类型无法创建 Double : class oracle. kv.impl.api.table.IntegerDefImpl

转载 作者:行者123 更新时间:2023-12-02 05:45:56 25 4
gpt4 key购买 nike

我正在尝试使用 java 类从 Oracle NoSQL 表中检索批量数据。

//Connection part omitted
public static void main(String args[]) {
try {
LoadBulkData runLoader = new LoadBulkData();
runLoader.run();
} catch (Exception e) {
System.err.print("Error: " + e.getMessage());
}
}



void run() {
Integer[] myId = {100,101};
List keys =
new ArrayList(myId.length);

TableAPI tableAPI = store.getTableAPI();
Table myTable = tableAPI.getTable(tableName);
if (myTable == null) {
throw new IllegalArgumentException("Table not found: " + tableName);
}

for (Integer id : myId) {
PrimaryKey pk = myTable.createPrimaryKey();
pk.put("UID", id);
keys.add(pk);
}
FieldRange range = myTable.createFieldRange("myId");
range.setStart(100d, true).setEnd(500d, true);
MultiRowOptions mro = new MultiRowOptions(range, null, null);

int batchResultsSize = 200;
int parallalism = 9;
TableIteratorOptions tio =
new TableIteratorOptions(Direction.UNORDERED ,
null ,
0 ,
null,
parallalism,
batchResultsSize);

TableIterator itr = null;
int count = 0;
try {
itr = tableAPI.tableIterator(keys.iterator(), mro, tio);
while (itr.hasNext()) {
Row myRow = (Row) itr.next();
System.out.println(myRow.toJsonString(false));
count++;
/* ... */
}
System.out.println(count + " rows to print.");
} catch (StoreIteratorException sie) {

} finally {
if (itr != null) {
itr.close();
}
}
}
}

下面是表结构

->show table -name SampleTable
{
"json_version" : 1,
"type" : "table",
"name" : "SampleTable",
"owner" : "root(id:u1)",
"shardKey" : [ "myId" ],
"primaryKey" : [ "myId" ],
"fields" : [ {
"name" : "myId",
"type" : "INTEGER",
"nullable" : false,
"default" : null
}, {
"name" : "myString",
"type" : "STRING",
"nullable" : true,
"default" : null
} ]
}

运行此程序时,我遇到以下错误:-

类型无法创建 Double:类 oracle.kv.impl.api.table.IntegerDefImpl

有人可以帮忙吗?我是 NoSQL 新手,非常感谢您。

最佳答案

这是因为转换错误。您正尝试将 double 值插入需要整数的字段中。

您需要使用:

public FieldRange setStart(int value,boolean isInclusive)

关于java - 从 Oracle NOSQL 检索批量数据时,获取类型无法创建 Double : class oracle. kv.impl.api.table.IntegerDefImpl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56096154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com