Author: jwills
Date: Wed Oct 29 03:06:51 2014
New Revision: 1635029
URL: http://svn.apache.org/r1635029
Log:
Core PTypes generics fixes
Modified:
crunch/site/trunk/content/user-guide.mdtext
Modified: crunch/site/trunk/content/user-guide.mdtext
URL:
http://svn.apache.org/viewvc/crunch/site/trunk/content/user-guide.mdtext?rev=1635029&r1=1635028&r2=1635029&view=diff
==============================================================================
--- crunch/site/trunk/content/user-guide.mdtext (original)
+++ crunch/site/trunk/content/user-guide.mdtext Wed Oct 29 03:06:51 2014
@@ -500,32 +500,32 @@ import java.util.Map;
public class MyPipeline {
// Common primitive types
- PType<Integer> intType = ints();
- PType<Long> longType = longs();
- PType<Double> doubleType = doubles();
+ PType<Integer> intType = ints();
+ PType<Long> longType = longs();
+ PType<Double> doubleType = doubles();
// Bytes are represented by java.nio.ByteBuffer
- PType<ByteBuffer> bytesType = bytes();
+ PType<ByteBuffer> bytesType = bytes();
// A PTableType: using tableOf will return a PTable instead of a
// PCollection from a parallelDo call.
- PTableType<String, Boolean> tableType = tableOf(strings(), booleans());
+ PTableType<String, Boolean> tableType = tableOf(strings(), booleans());
// Pair types:
- PType<Pair<String, Boolean>> pairType = pairs(strings(), booleans());
- PType<Pair<String, Pair<Long, Long>> nestedPairType = pairs(strings(),
pairs(longs(), longs()));
+ PType<Pair<String, Boolean>> pairType = pairs(strings(),
booleans());
+ PType<Pair<String, Pair<Long, Long>> nestedPairType =
pairs(strings(), pairs(longs(), longs()));
// A triple
- PType<Tuple3<Long, Float, Float>> tripType = trips(longs(), floats(),
floats());
+ PType<Tuple3<Long, Float, Float>> tripType = trips(longs(),
floats(), floats());
// An arbitrary length tuple-- note that we lose the generic type information
- PType<TupleN> tupleType = tupleN(ints(), ints(), floats(), strings(),
strings(), ints());
+ PType<TupleN> tupleType = tupleN(ints(), ints(), floats(), strings(),
strings(), ints());
// A Collection type
- PType<Collection<Long>> longsType = collections(longs());
+ PType<Collection<Long>> longsType = collections(longs());
// A Map Type-- note that the keys are always strings, we only specify the
value.
- PType<Map<String, Boolean>> mapType = maps(booleans());
+ PType<Map<String, Boolean>> mapType = maps(booleans());
// A Pair of collections
- PType<Pair<Collection<String>, Collection<Long>>> pairColType = pairs(
+ PType<Pair<Collection<String>, Collection<Long>>>
pairColType = pairs(
collections(strings()),
collections(longs()));
}
@@ -537,17 +537,17 @@ interface, and for the AvroTypeFamily, t
includes both Avro generic and specific records:
<pre>
- PType<FooWritable> fwType1 = Writables.records(FooWritable.class);
+ PType<FooWritable> fwType1 = Writables.records(FooWritable.class);
// The more obvious "writables" method also works.
- PType<FooWritable> fwType = Writables.writables(FooWritable.class);
+ PType<FooWritable> fwType = Writables.writables(FooWritable.class);
// For a generated Avro class, this works:
- PType<Person> personType1 = Avros.records(Person.class);
+ PType<Person> personType1 = Avros.records(Person.class);
// As does this:
- PType<Person> personType2 = Avros.containers(Person.class);
+ PType<Person> personType2 = Avros.containers(Person.class);
// If you only have a schema, you can create a generic type, like this:
org.apache.avro.Schema schema = ...;
- PType<Record> avroGenericType = Avros.generics(schema);
+ PType<Record> avroGenericType = Avros.generics(schema);
</pre>
The [Avros](apidocs/0.10.0/org/apache/crunch/types/avro/Avros.html) class also
has a `reflects` method for creating PTypes
@@ -575,8 +575,8 @@ the POJO:
}
}
- PType<UrlData> urlDataType = Avros.reflects(UrlData.class);
- PTableType<String, UrlData> pageRankType = Avros.tableOf(Avros.strings(),
urlDataType);
+ PType<UrlData> urlDataType = Avros.reflects(UrlData.class);
+ PTableType<String, UrlData> pageRankType =
Avros.tableOf(Avros.strings(), urlDataType);
</pre>
Avro reflection is a great way to define intermediate types for your Crunch
pipelines; not only is your logic clear
@@ -597,12 +597,12 @@ A common pattern in MapReduce programs i
easy to work with the POJO directly in your DoFns, while still taking
advantage of the custom serialization of your Writable implementation:
<pre>
- PType<Foo> fooType = Writables.derived(
+ PType<Foo> fooType = Writables.derived(
Foo.class,
- new MapFn<FooWritable, Foo>() {
+ new MapFn<FooWritable, Foo>() {
public Foo map(FooWritable fw) { return fw.get(); }
},
- new MapFn<Foo, FooWritable>() {
+ new MapFn<Foo, FooWritable>() {
public FooWritable map(Foo foo) { return new FooWritable(foo); }
},
Writables.writable(FooWritable.class));