Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving data from an abstract class
    primarykey
    data
    text
    <p>I am having difficulty accessing some data. I am using <a href="https://github.com/brianfrankcooper/YCSB/" rel="nofollow">YCSB</a> to talk to a number of different databases, such as Cassandra and MongoDB.</p> <p>The only class I can really modify is my "Workload" class, which is doing some insertions and reads. The method I am using to read from the database is in the class:</p> <pre><code>public void doRead(DB db) { String keyname = buildKeyName(keynum); System.out.println(keyname); HashSet&lt;String&gt; fields = null; if (!readallfields) { // read a random field String fieldname = "field" + fieldchooser.nextString(); fields = new HashSet&lt;String&gt;(); fields.add(fieldname); } db.read(table,keyname,fields,new HashMap&lt;String,ByteIterator&gt;()); } </code></pre> <p>I tried to modify the code so I could read the contents of the hashmap. I removed the db.read line and replaced it with</p> <pre><code>HashMap&lt;String, ByteIterator&gt; kv_hashmap = new HashMap&lt;String, ByteIterator&gt;(); db.read(table, keyname, fields, kv_hashmap); </code></pre> <p>Then tried to read from kv_hashmap:</p> <pre><code>System.out.println(kv_hashmap.get(fields)); </code></pre> <p><strong>BUT</strong> db.read returns only an int. DB is a public abstract class which I would rather not modify and its purpose is to talk to a variety of databases:</p> <p>This is what db.read calls:</p> <pre><code>public abstract int read(String table, String key, Set&lt;String&gt; fields, HashMap&lt;String,ByteIterator&gt; result); </code></pre> <p>Which returns, to quote from the javadoc:</p> <blockquote> <p>Zero on success, a non-zero error code on error or "not found".</p> </blockquote> <p>I need to read the values from kv_hashmap. I don't understand why I can't access its values.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload