Project Crunch has retired. For details please refer to its Attic page.
Writables (Apache Crunch 0.10.0 API)

org.apache.crunch.types.writable
Class Writables

java.lang.Object
  extended by org.apache.crunch.types.writable.Writables

public class Writables
extends Object

Defines static methods that are analogous to the methods defined in WritableTypeFamily for convenient static importing.


Method Summary
static WritableType<Boolean,org.apache.hadoop.io.BooleanWritable> booleans()
           
static WritableType<ByteBuffer,org.apache.hadoop.io.BytesWritable> bytes()
           
static
<T> WritableType<Collection<T>,org.apache.crunch.types.writable.GenericArrayWritable>
collections(PType<T> ptype)
           
static
<S,T> PType<T>
derived(Class<T> clazz, MapFn<S,T> inputFn, MapFn<T,S> outputFn, PType<S> base)
           
static
<S,T> PType<T>
derivedImmutable(Class<T> clazz, MapFn<S,T> inputFn, MapFn<T,S> outputFn, PType<S> base)
           
static WritableType<Double,org.apache.hadoop.io.DoubleWritable> doubles()
           
static WritableType<Float,org.apache.hadoop.io.FloatWritable> floats()
           
static
<T> PType<T>
getPrimitiveType(Class<T> clazz)
           
static WritableType<Integer,org.apache.hadoop.io.IntWritable> ints()
           
static
<T> PType<T>
jsons(Class<T> clazz)
           
static WritableType<Long,org.apache.hadoop.io.LongWritable> longs()
           
static
<T> WritableType<Map<String,T>,org.apache.hadoop.io.MapWritable>
maps(PType<T> ptype)
           
static WritableType<Void,org.apache.hadoop.io.NullWritable> nulls()
           
static
<V1,V2> WritableType<Pair<V1,V2>,TupleWritable>
pairs(PType<V1> p1, PType<V2> p2)
           
static
<V1,V2,V3,V4>
WritableType<Tuple4<V1,V2,V3,V4>,TupleWritable>
quads(PType<V1> p1, PType<V2> p2, PType<V3> p3, PType<V4> p4)
           
static
<T,W extends org.apache.hadoop.io.Writable>
WritableType<T,W>
records(Class<T> clazz)
           
static
<T> void
register(Class<T> clazz, WritableType<T,? extends org.apache.hadoop.io.Writable> ptype)
           
static void registerComparable(Class<? extends org.apache.hadoop.io.WritableComparable> clazz)
          Registers a WritableComparable class so that it can be used for comparing the fields inside of tuple types (e.g., pairs, trips, tupleN, etc.) for use in sorts and secondary sorts.
static void registerComparable(Class<? extends org.apache.hadoop.io.WritableComparable> clazz, int code)
          Registers a WritableComparable class with a given integer code to use for serializing and deserializing instances of this class that are defined inside of tuple types (e.g., pairs, trips, tupleN, etc.) Unregistered Writables are always serialized to bytes and cannot be used in comparisons (e.g., sorts and secondary sorts) according to their underlying types.
static WritableType<String,org.apache.hadoop.io.Text> strings()
           
static
<K,V> org.apache.crunch.types.writable.WritableTableType<K,V>
tableOf(PType<K> key, PType<V> value)
           
static
<V1,V2,V3> WritableType<Tuple3<V1,V2,V3>,TupleWritable>
triples(PType<V1> p1, PType<V2> p2, PType<V3> p3)
           
static
<T extends Tuple>
PType<T>
tuples(Class<T> clazz, PType... ptypes)
           
static WritableType<TupleN,TupleWritable> tuples(PType... ptypes)
           
static PType<Union> unionOf(PType<?>... ptypes)
           
static
<W extends org.apache.hadoop.io.Writable>
WritableType<W,W>
writables(Class<W> clazz)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerComparable

public static void registerComparable(Class<? extends org.apache.hadoop.io.WritableComparable> clazz)
Registers a WritableComparable class so that it can be used for comparing the fields inside of tuple types (e.g., pairs, trips, tupleN, etc.) for use in sorts and secondary sorts.

Parameters:
clazz - The WritableComparable class to register

registerComparable

public static void registerComparable(Class<? extends org.apache.hadoop.io.WritableComparable> clazz,
                                      int code)
Registers a WritableComparable class with a given integer code to use for serializing and deserializing instances of this class that are defined inside of tuple types (e.g., pairs, trips, tupleN, etc.) Unregistered Writables are always serialized to bytes and cannot be used in comparisons (e.g., sorts and secondary sorts) according to their underlying types.

Parameters:
clazz - The class to register
code - The unique registration code for the class, which must be greater than or equal to 8

getPrimitiveType

public static <T> PType<T> getPrimitiveType(Class<T> clazz)

register

public static <T> void register(Class<T> clazz,
                                WritableType<T,? extends org.apache.hadoop.io.Writable> ptype)

nulls

public static final WritableType<Void,org.apache.hadoop.io.NullWritable> nulls()

strings

public static final WritableType<String,org.apache.hadoop.io.Text> strings()

longs

public static final WritableType<Long,org.apache.hadoop.io.LongWritable> longs()

ints

public static final WritableType<Integer,org.apache.hadoop.io.IntWritable> ints()

floats

public static final WritableType<Float,org.apache.hadoop.io.FloatWritable> floats()

doubles

public static final WritableType<Double,org.apache.hadoop.io.DoubleWritable> doubles()

booleans

public static final WritableType<Boolean,org.apache.hadoop.io.BooleanWritable> booleans()

bytes

public static final WritableType<ByteBuffer,org.apache.hadoop.io.BytesWritable> bytes()

records

public static final <T,W extends org.apache.hadoop.io.Writable> WritableType<T,W> records(Class<T> clazz)

writables

public static <W extends org.apache.hadoop.io.Writable> WritableType<W,W> writables(Class<W> clazz)

tableOf

public static <K,V> org.apache.crunch.types.writable.WritableTableType<K,V> tableOf(PType<K> key,
                                                                                    PType<V> value)

pairs

public static <V1,V2> WritableType<Pair<V1,V2>,TupleWritable> pairs(PType<V1> p1,
                                                                    PType<V2> p2)

triples

public static <V1,V2,V3> WritableType<Tuple3<V1,V2,V3>,TupleWritable> triples(PType<V1> p1,
                                                                              PType<V2> p2,
                                                                              PType<V3> p3)

quads

public static <V1,V2,V3,V4> WritableType<Tuple4<V1,V2,V3,V4>,TupleWritable> quads(PType<V1> p1,
                                                                                  PType<V2> p2,
                                                                                  PType<V3> p3,
                                                                                  PType<V4> p4)

tuples

public static WritableType<TupleN,TupleWritable> tuples(PType... ptypes)

tuples

public static <T extends Tuple> PType<T> tuples(Class<T> clazz,
                                                PType... ptypes)

unionOf

public static PType<Union> unionOf(PType<?>... ptypes)

derived

public static <S,T> PType<T> derived(Class<T> clazz,
                                     MapFn<S,T> inputFn,
                                     MapFn<T,S> outputFn,
                                     PType<S> base)

derivedImmutable

public static <S,T> PType<T> derivedImmutable(Class<T> clazz,
                                              MapFn<S,T> inputFn,
                                              MapFn<T,S> outputFn,
                                              PType<S> base)

collections

public static <T> WritableType<Collection<T>,org.apache.crunch.types.writable.GenericArrayWritable> collections(PType<T> ptype)

maps

public static <T> WritableType<Map<String,T>,org.apache.hadoop.io.MapWritable> maps(PType<T> ptype)

jsons

public static <T> PType<T> jsons(Class<T> clazz)


Copyright © 2014 The Apache Software Foundation. All Rights Reserved.