Reputation: 33
How do I use the Java API to scan accumulo using only the rowid. For example accumulo has the following row entry when I scan the table using the accumulo shell:
12lj314t1u43td1 Documents:Entity [U] {values}
I know the rowid in Java which is '12lj314t1u43td1'. I want to retrieve {values}
for all possible column families and qualifiers. I already checked the accumulo documentation on scanner's but they do not say how to set the Ranges to only return based on the rowid.
Upvotes: 1
Views: 2368
Reputation: 2512
You can scan over a range in the shell with scan -b startRow -e endRow
. See scan --help
for more options.
Note: you should use the Java API if you want performance, but this gets you a range for the shell.
Upvotes: 2
Reputation: 4681
If there is just one rowID that you are interested in, than you can use the Scanner to accomplish this:
Scanner scanner = connector.createScanner(myTable, new Authorizations("U"));
scanner.setRange(new Range("12lj314t1u43td1"));
for(Entry<Key,Value> entry : scanner){
System.out.println(entry);
}
This will give you every "12lj314t1u43td1" row. If you only wanted the rows with the Documents cf, you'd add this after the setRange
line
scanner.fetchColumnFamily(new Text("Documents"));
or if you wanted just the Documents with the Entity CQ you'd do
scanner.fetchColumn(new Text("Documents"), new Text("Entity"));
If you are looking for lots of discontiguous rows, then you might want to try the BatchScanner
. It is also possible to use a myriad of iterators and regex's, but this should get you what you want.
Upvotes: 4