Note that there are some explanatory texts on larger screens.

plurals
  1. POaccumulo - batchscanner: one result per range
    primarykey
    data
    text
    <p>So my general question is "Is it possible to have an Accumulo BatchScanner only pull back the first result per Range I give it?"</p> <p>Now some details about my use case as there may be a better way to approach this anyway. I have data that represent messages from different systems. There can be different types of messages. My users want to be able to ask the system questions, such as "give me the most recent message of a certain type as of a certain time for all these systems".</p> <p>My table layout looks like this</p> <pre><code> rowid: system_name, family: message_type, qualifier: masked_timestamp, value: message_text </code></pre> <p>The idea is that the user gives me a list of systems they care about, the type of message, and a certain timestamp. I used masked timestamp so that the table sorts most recent first. That way when I scan for a timestamp, the first result is the most recent prior to that time. I am using a BatchScanner because I have multiple systems I am searching for per query. Can I make the BatchScanner only fetch the first result for each Range? I can't specify a specific key because the most recent may not match the datetime given by the user.</p> <p>Currently, I am using the BatchScanner and ignoring all but the first result per Key. It works right now, but it seems like a waste to pull back all the data for a specific system/type over the network when I only care about the first result per system/type.</p> <p>EDIT</p> <p>My attempt using the FirstEntryInRowIterator</p> <pre><code>@Test public void testFirstEntryIterator() throws Exception { Connector connector = new MockInstance("inst").getConnector("user", new PasswordToken("password")); connector.tableOperations().create("testing"); BatchWriter writer = writer(connector, "testing"); writer.addMutation(mutation("row", "fam", "qual1", "val1")); writer.addMutation(mutation("row", "fam", "qual2", "val2")); writer.addMutation(mutation("row", "fam", "qual3", "val3")); writer.close(); Scanner scanner = connector.createScanner("testing", new Authorizations()); scanner.addScanIterator(new IteratorSetting(50, FirstEntryInRowIterator.class)); Key begin = new Key("row", "fam", "qual2"); scanner.setRange(new Range(begin, begin.followingKey(PartialKey.ROW_COLFAM_COLQUAL))); int numResults = 0; for (Map.Entry&lt;Key, Value&gt; entry : scanner) { Assert.assertEquals("qual2", entry.getKey().getColumnQualifier().toString()); numResults++; } Assert.assertEquals(1, numResults); } </code></pre> <p>My goal is that the returned entry will be the ("row", "fam", "qual2", "val2") but I get 0 results. It almost seems like the Iterator is being applied before the Range maybe? I haven't dug into this yet.</p>
    singulars
    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.
    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