繁体   English   中英

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

[英]Getting Type cannot create a Double: class oracle.kv.impl.api.table.IntegerDefImpl while retrieving bulk data from Oracle NOSQL

我正在尝试使用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
      } ]
    }

在运行此时,我得到以下错误: -

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

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

这是因为铸造错误。 您正在尝试将double值插入到期望整数的字段中。

你需要使用:

public FieldRange setStart(int value,boolean isInclusive)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM