Skip to content

Commit

Permalink
Fluo recipes updates (#149)
Browse files Browse the repository at this point in the history
- Java 8 Translation/simplification
- Spelling corrections in comments/javadocs
- Updated Travis to test Accumulo 1.9.2
  • Loading branch information
cjmctague committed Aug 29, 2018
1 parent 8e22a64 commit 24c1123
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -29,6 +29,6 @@ before_script:
- unset _JAVA_OPTIONS
env:
- ADDITIONAL_MAVEN_OPTS=
- ADDITIONAL_MAVEN_OPTS=-Daccumulo.version=1.8.1
- ADDITIONAL_MAVEN_OPTS=-Daccumulo.version=1.9.2
script:
- mvn clean verify javadoc:jar $ADDITIONAL_MAVEN_OPTS
2 changes: 1 addition & 1 deletion contrib/create-release-candidate.sh
Expand Up @@ -68,7 +68,7 @@ gitCommit() { gitCommits -n1 "$@"; }
gitSubject() { pretty %s "$@"; }

createEmail() {
# $1 version (optional); $2 rc seqence num (optional); $3 staging repo num (optional)
# $1 version (optional); $2 rc sequence num (optional); $3 staging repo num (optional)
local ver; [[ -n $1 ]] && ver=$1 || ver=$(prompter 'version to be released (eg. x.y.z)' '[0-9]+[.][0-9]+[.][0-9]+')
local rc; [[ -n $2 ]] && rc=$2 || rc=$(prompter 'release candidate sequence number (eg. 1, 2, etc.)' '[0-9]+')
local stagingrepo; [[ -n $3 ]] && stagingrepo=$3 || stagingrepo=$(prompter 'staging repository number from https://repository.apache.org/#stagingRepositories' '[0-9]+')
Expand Down
Expand Up @@ -90,7 +90,7 @@ public AccumuloExporter(String configId, SimpleConfiguration appConfig,
@Override
public void export(Iterator<SequencedExport<K, V>> t) {
ArrayList<Mutation> buffer = new ArrayList<>();
Consumer<Mutation> consumer = m -> buffer.add(m);
Consumer<Mutation> consumer = buffer::add;

while (t.hasNext()) {
translator.translate(t.next(), consumer);
Expand Down
Expand Up @@ -74,7 +74,7 @@ public static void addDel(Mutation m, String key, String val, long seq) {
@Test
public void testDifferenceExport() {
final Collection<Mutation> mutations = new ArrayList<>();
Consumer<Mutation> consumer = m -> mutations.add(m);
Consumer<Mutation> consumer = mutations::add;

genMutations("k1", 1, Optional.empty(), Optional.of("a"), consumer);
Assert.assertEquals(1, mutations.size());
Expand Down
Expand Up @@ -156,7 +156,7 @@ public static interface Initializer<K2, V2> extends Serializable {
/**
* A {@link CombineQueue} stores data in its own data format in the Fluo table. When initializing
* a Fluo table with something like Map Reduce or Spark, data will need to be written in this
* format. Thats the purpose of this method, it provides a simple class that can do this
* format. That's the purpose of this method, it provides a simple class that can do this
* conversion.
*/
public static <K2, V2> Initializer<K2, V2> getInitializer(String cqId, int numBuckets,
Expand Down
Expand Up @@ -23,7 +23,7 @@
import com.google.common.collect.Iterators;
import org.apache.fluo.api.data.Bytes;

// intentionally package priave
// intentionally package private
class InputImpl<K, V> implements Combiner.Input<K, V> {
private K key;
private Collection<Bytes> valuesCollection;
Expand Down
Expand Up @@ -118,7 +118,7 @@ public void add(long seq, byte[] key, byte[] value) {
}

/**
* Computes the minimial row for a bucket
* Computes the minimal row for a bucket
*/
private Bytes getMinimalRow() {
return Bytes.builder(bucketRow.length() + 1).append(bucketRow).append(':').toBytes();
Expand Down
Expand Up @@ -89,7 +89,7 @@ public void addAll(TransactionBase tx, Iterator<Export<K, V>> exports) {
}
}

// TODO maybe add for stream and interable
// TODO maybe add for stream and iterable

public static <K2, V2> ExportQueue<K2, V2> getInstance(String exportQueueId,
SimpleConfiguration appConfig) {
Expand Down
Expand Up @@ -224,7 +224,7 @@ public static <K2, V2> CollisionFreeMap<K2, V2> getInstance(String mapId,
/**
* A {@link CollisionFreeMap} stores data in its own data format in the Fluo table. When
* initializing a Fluo table with something like Map Reduce or Spark, data will need to be written
* in this format. Thats the purpose of this method, it provide a simple class that can do this
* in this format. That's the purpose of this method, it provide a simple class that can do this
* conversion.
*/
public static <K2, V2> Initializer<K2, V2> getInitializer(String mapId, int numBuckets,
Expand Down Expand Up @@ -401,7 +401,7 @@ public static void configure(FluoConfiguration fluoConfig, Options opts) {
public static class Optimizer implements TableOptimizationsFactory {

/**
* Return suggested Fluo table optimizations for the specified collisiong free map.
* Return suggested Fluo table optimizations for the specified collision free map.
*
* @param appConfig Must pass in the application configuration obtained from
* {@code FluoClient.getAppConfiguration()} or
Expand Down
Expand Up @@ -220,7 +220,7 @@ public RtxRowScanner(RowScanner scanner) {

@Override
public Iterator<ColumnScanner> iterator() {
return Iterators.transform(scanner.iterator(), cs -> new RtxColumnScanner(cs));
return Iterators.transform(scanner.iterator(), RtxColumnScanner::new);
}

}
Expand Down
Expand Up @@ -524,7 +524,7 @@ public ScannerBuilder scanner() {

@SuppressWarnings({"unchecked"})
private Map<Column, Value> wrap(Map<Column, Bytes> map) {
Map<Column, Value> ret = Maps.transformValues(map, input -> new Value(input));
Map<Column, Value> ret = Maps.transformValues(map, Value::new);
return Collections.unmodifiableMap(DefaultedMap.decorate(ret, new Value((Bytes) null)));
}

Expand Down
Expand Up @@ -161,13 +161,8 @@ public void testGetRows() {
@Test
public void testGetScanIter() {
ScannerBuilder sb = mock(ScannerBuilder.class);
expect(sb.build()).andReturn(new CellScanner() {
@Override
public Iterator<RowColumnValue> iterator() {
return Iterators
.singletonIterator(new RowColumnValue("r7", new Column("cf7", "cq7"), "v7"));
}
});
expect(sb.build()).andReturn(() -> Iterators
.singletonIterator(new RowColumnValue("r7", new Column("cf7", "cq7"), "v7")));

expect(tx.scanner()).andReturn(sb);

Expand Down
Expand Up @@ -77,27 +77,21 @@ public Kryo create() {

@Override
public <T> byte[] serialize(T obj) {
return getPool().run(new KryoCallback<byte[]>() {
@Override
public byte[] execute(Kryo kryo) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
kryo.writeClassAndObject(output, obj);
output.close();
return baos.toByteArray();
}
return getPool().run(kryo -> {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
kryo.writeClassAndObject(output, obj);
output.close();
return baos.toByteArray();
});
}

@Override
public <T> T deserialize(byte[] serObj, Class<T> clazz) {
return getPool().run(new KryoCallback<T>() {
@Override
public T execute(Kryo kryo) {
ByteArrayInputStream bais = new ByteArrayInputStream(serObj);
Input input = new Input(bais);
return clazz.cast(kryo.readClassAndObject(input));
}
return getPool().run(kryo -> {
ByteArrayInputStream bais = new ByteArrayInputStream(serObj);
Input input = new Input(bais);
return clazz.cast(kryo.readClassAndObject(input));
});
}

Expand Down
Expand Up @@ -39,7 +39,7 @@
/**
* This class is intended to be extended by classes testing exporting from Fluo to Accumulo. Using
* MiniFluo by itself is easy. However, using MiniAccumulo and MiniFluo together involves writing a
* lot of boiler plate code. Thats why this class exists, its a place to put that boiler plate code.
* lot of boilerplate code. That's why this class exists: it's a place to put that boilerplate code.
*
* <p>
* Below is some example code showing how to use this class to write a test.
Expand Down

0 comments on commit 24c1123

Please sign in to comment.