Accumulo-Scala is a light wrapper to provide a fluent api for reading data from Apache Accumulo in Scala.
- Provide a fluent API
- Avoid needing to close resources explicitly
- Embrace Scala!
- import com.tetra.accumulo_scala.ConnectorOps._
- val connector = instance.getConnector(user, passwordToken)
- connector scan ...
scan table 'abc' from 'a' to 'z'
connector scan "abc" from "a" to "z" foreach { e =>
//do something with each entry ...
}
scan table 'abc' for multiple ids
connector scan "abc" in List("a", "b", "c") foreach { e =>
//do something with each entry ...
}
scan table 'abc' for only family f and qualifier q
connector scan "abc" filter "f:q" foreach { e =>
//do something with each entry ...
}
- com.tetra.accumulo_scala.auths (DEFAULT: Auths.Empty)
- com.tetra.accumulo_scala.auths.delim (DEFAULT: ',')
- com.tetra.accumulo_scala.fq.delim (DEFAULT: ':')
- com.tetra.accumulo_scala.strict (DEFAULT: false)
zero
Then you can ask for a parallel implementation using par.
scan table 'abc' par 5 foreach { e => ... }
Here is an example of where we embrace scala.
scan table 'abc' take 10 foreach { e => ... }
Here, Scala can help ... but eventually we would like to add a server-side iterator for this.
scan table 'abc' drop 10 foreach { e => ... }
Ask and you shall receive!
connector scan "data" in (connector scan "index" from "a" to "b" map(...)) foreach { e =>
...
}
Sure is!
connector.scan("abc").foldLeft(0)((count,_) => count+1)
I guess, if you really want to ...
Connector connector = instance.getConnector("", new PasswordToken());
ConnectorOps conn = new ConnectorOps(connector);
CloseableIterator<Entry<Key, Value>> ci = conn.scan("abc").from(new Key("a")).to(new Key("b"));
try {
Entry<Key, Value> e;
while(ci.hasNext()) {
e = ci.next();
//do something
}
} finally {
ci.close();
}
Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html)