Permalink
Browse files

Fixes #923 added span convenience methods to scanner builder (#940)

* Added the following default methods to the ScannerBuilder interface:
  default ScannerBuilder over(Bytes row) {...}
  default ScannerBuilder over(CharSequence row) {...}
  default ScannerBuilder over(Bytes row, Column col){...}
  default ScannerBuilder over(CharSequence row, , Column col){...}

  default ScannerBuilder overPrefix(Bytes row) {...}
  default ScannerBuilder overPrefix(CharSequence row){...}
  default ScannerBuilder overPrefix(Bytes row, Column col){...}
  default ScannerBuilder overPrefix(CharSequence row, , Column col){...}

* Changed tests in the following classes to use the new over() and overprefix() methods
  ScannerIT
  WeakNotificationIT
  WorkerIT
  FluoIT
  LogIT

* Moved @SInCE tag to the bottom of javadoc info.
Changed param rowPrefix to row, and updated javadocs for the following methods:
  overPrefix(Bytes, Column){...}
  overPrefix(CharSequence, Column){...}
Removed use of Bytes.of(String) calls within over() calls from FloutIT tests

* fixed javadoc errors
  • Loading branch information...
jkosh44 authored and keith-turner committed Oct 17, 2017
1 parent 5c3ef12 commit c737df63acac07cf7f2ba4c7f6aaebe6a6b8a440
@@ -17,6 +17,7 @@
import java.util.Collection;
import org.apache.fluo.api.data.Bytes;
import org.apache.fluo.api.data.Column;
import org.apache.fluo.api.data.Span;
@@ -30,6 +31,96 @@
*/
ScannerBuilder over(Span span);
/**
*
* @since 1.2.0
* @see org.apache.fluo.api.data.Span#exact(Bytes)
* @param row restrict the scanner to data in an exact row
* @return self
*/
default ScannerBuilder over(Bytes row) {
return over(Span.exact(row));
}
/**
*
* @since 1.2.0
* @see org.apache.fluo.api.data.Span#exact(CharSequence)
* @param row restrict the scanner to data in an exact row. String parameters will be encoded as UTF-8
* @return self
*/
default ScannerBuilder over(CharSequence row) {
return over(Span.exact(row));
}
/**
*
* @see org.apache.fluo.api.data.Span#exact(Bytes, Column)
* @param row restrict the scanner to data in an exact row
* @param col restrict the scanner to data in exact {@link org.apache.fluo.api.data.Column}.
* @since 1.2.0
*/
default ScannerBuilder over(Bytes row, Column col) {
return over(Span.exact(row, col));
}
/**
*
* @see org.apache.fluo.api.data.Span#exact(CharSequence, Column)
* @param row restrict the scanner to data in an exact row
* @param col restrict the scanner to data in exact {@link org.apache.fluo.api.data.Column}.
* @return self
* @since 1.2.0
*/
default ScannerBuilder over(CharSequence row, Column col) {
return over(Span.exact(row, col));
}
/**
*
* @see org.apache.fluo.api.data.Span#prefix(Bytes)
* @param rowPrefix restrict the scanner to data in rows that begins with a prefix
* @return self
* @since 1.2.0
*/
default ScannerBuilder overPrefix(Bytes rowPrefix) {
return over(Span.prefix(rowPrefix));
}
/**
*
* @see org.apache.fluo.api.data.Span#prefix(CharSequence)
* @param rowPrefix restrict the scanner to data in rows that begins with a prefix.
* @return self
* @since 1.2.0
*/
default ScannerBuilder overPrefix(CharSequence rowPrefix) {
return over(Span.prefix(rowPrefix));
}
/**
*
* @see org.apache.fluo.api.data.Span#prefix(Bytes, Column)
* @param row restrict the scanner to data in an exact row.
* @param colPrefix restrict scanner to data that begins with specifiec {@link org.apache.fluo.api.data.Column} prefix.
* @return self
* @since 1.2.0
*/
default ScannerBuilder overPrefix(Bytes row, Column colPrefix) {
return over(Span.prefix(row, colPrefix));
}
/**
*
* @see org.apache.fluo.api.data.Span#prefix(CharSequence, Column)
* @param row restrict the scanner to data in an exact row.
* @param colPrefix restrict scanner to data that begins with specifiec {@link org.apache.fluo.api.data.Column} prefix.
* @return self
* @since 1.2.0
*/
default ScannerBuilder overPrefix(CharSequence row, Column colPrefix) {
return over(Span.prefix(row, colPrefix));
}
/**
* Passing in a Column with only the family set will fetch the entire column family.
@@ -463,8 +463,7 @@ public void testRange() throws Exception {
HashSet<Column> columns = new HashSet<>();
CellScanner cellScanner =
tx2.scanner().over(Span.exact(Bytes.of("d00001"))).fetch(new Column("outlink")).build();
CellScanner cellScanner = tx2.scanner().over("d00001").fetch(new Column("outlink")).build();
for (RowColumnValue rcv : cellScanner) {
columns.add(rcv.getColumn());
}
@@ -480,8 +479,7 @@ public void testRange() throws Exception {
TestTransaction tx4 = new TestTransaction(env);
columns.clear();
cellScanner =
tx4.scanner().over(Span.exact(Bytes.of("d00001"))).fetch(new Column("outlink")).build();
cellScanner = tx4.scanner().over("d00001").fetch(new Column("outlink")).build();
for (RowColumnValue rcv : cellScanner) {
columns.add(rcv.getColumn());
}
@@ -67,12 +67,11 @@ public void testFiltering() {
try (Snapshot snap = client.newSnapshot()) {
HashSet<RowColumnValue> actual = new HashSet<>();
Iterables.addAll(actual, snap.scanner().over(Span.exact("r2")).build());
Iterables.addAll(actual, snap.scanner().over("r2").build());
Assert.assertEquals(expectedR2, actual);
actual.clear();
Iterables.addAll(actual,
snap.scanner().over(Span.exact("r2")).fetch(new Column("f1", "q2")).build());
Iterables.addAll(actual, snap.scanner().over("r2").fetch(new Column("f1", "q2")).build());
Assert.assertEquals(expectedR2c, actual);
actual.clear();
@@ -44,8 +44,7 @@
@Override
public void process(TransactionBase tx, Bytes row, Column col) throws Exception {
CellScanner cellScanner =
tx.scanner().over(Span.exact(row, new Column(Bytes.of("stats")))).build();
CellScanner cellScanner = tx.scanner().over(row, new Column(Bytes.of("stats"))).build();
int sum = 0;
@@ -56,8 +56,7 @@ public void process(TransactionBase tx, String row, Column col) throws Exception
String degree = tx.gets(row, DEGREE);
// calculate new degree
String degree2 =
"" + Iterables.size(tx.scanner().over(Span.exact(row, new Column("link"))).build());
String degree2 = "" + Iterables.size(tx.scanner().over(row, new Column("link")).build());
if (degree == null || !degree.equals(degree2)) {
tx.set(row, DEGREE, degree2);
@@ -513,10 +513,10 @@ public void testScanLogging() {
CellScanner scanner1 = snap.scanner().build();
assertEqual(scanner1, rcv1, rcv2, rcv3, rcv4);
CellScanner scanner2 = snap.scanner().over(Span.exact("r1")).build();
CellScanner scanner2 = snap.scanner().over("r1").build();
assertEqual(scanner2, rcv1, rcv2);
CellScanner scanner3 = snap.scanner().over(Span.exact("r1")).fetch(c1).build();
CellScanner scanner3 = snap.scanner().over("r1").fetch(c1).build();
assertEqual(scanner3, rcv1);
CellScanner scanner4 = snap.scanner().fetch(c1).build();
@@ -527,10 +527,10 @@ public void testScanLogging() {
RowScanner rowScanner1 = snap.scanner().byRow().build();
assertEqual(rowScanner1, "r1", c1, "v1", c2, "v2", "r2", c1, "v3", c2, "v4");
RowScanner rowScanner2 = snap.scanner().over(Span.exact("r1")).byRow().build();
RowScanner rowScanner2 = snap.scanner().over("r1").byRow().build();
assertEqual(rowScanner2, "r1", c1, "v1", c2, "v2");
RowScanner rowScanner3 = snap.scanner().over(Span.exact("r1")).fetch(c1).byRow().build();
RowScanner rowScanner3 = snap.scanner().over("r1").fetch(c1).byRow().build();
assertEqual(rowScanner3, "r1", c1, "v1");
RowScanner rowScanner4 = snap.scanner().fetch(c1).byRow().build();

0 comments on commit c737df6

Please sign in to comment.