This project has retired. For details please refer to its Attic page.
Sort (Apache Crunch 0.3.0-incubating API)

org.apache.crunch.lib
Class Sort

java.lang.Object
  extended by org.apache.crunch.lib.Sort

public class Sort
extends Object

Utilities for sorting PCollection instances.


Nested Class Summary
static class Sort.ColumnOrder
          To sort by column 2 ascending then column 1 descending, you would use: sortPairs(coll, by(2, ASCENDING), by(1, DESCENDING)) Column numbering is 1-based.
static class Sort.Order
           
 
Constructor Summary
Sort()
           
 
Method Summary
static
<T> PCollection<T>
sort(PCollection<T> collection)
          Sorts the PCollection using the natural ordering of its elements.
static
<T> PCollection<T>
sort(PCollection<T> collection, Sort.Order order)
          Sorts the PCollection using the natural ordering of its elements in the order specified.
static
<K,V> PTable<K,V>
sort(PTable<K,V> table)
          Sorts the PTable using the natural ordering of its keys.
static
<K,V> PTable<K,V>
sort(PTable<K,V> table, Sort.Order key)
          Sorts the PTable using the natural ordering of its keys in the order specified.
static
<U,V> PCollection<Pair<U,V>>
sortPairs(PCollection<Pair<U,V>> collection, Sort.ColumnOrder... columnOrders)
          Sorts the PCollection of Pairs using the specified column ordering.
static
<V1,V2,V3,V4>
PCollection<Tuple4<V1,V2,V3,V4>>
sortQuads(PCollection<Tuple4<V1,V2,V3,V4>> collection, Sort.ColumnOrder... columnOrders)
          Sorts the PCollection of Tuple4s using the specified column ordering.
static
<V1,V2,V3> PCollection<Tuple3<V1,V2,V3>>
sortTriples(PCollection<Tuple3<V1,V2,V3>> collection, Sort.ColumnOrder... columnOrders)
          Sorts the PCollection of Tuple3s using the specified column ordering.
static PCollection<TupleN> sortTuples(PCollection<TupleN> collection, Sort.ColumnOrder... columnOrders)
          Sorts the PCollection of TupleNs using the specified column ordering.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sort

public Sort()
Method Detail

sort

public static <T> PCollection<T> sort(PCollection<T> collection)
Sorts the PCollection using the natural ordering of its elements.

Returns:
a PCollection representing the sorted collection.

sort

public static <T> PCollection<T> sort(PCollection<T> collection,
                                      Sort.Order order)
Sorts the PCollection using the natural ordering of its elements in the order specified.

Returns:
a PCollection representing the sorted collection.

sort

public static <K,V> PTable<K,V> sort(PTable<K,V> table)
Sorts the PTable using the natural ordering of its keys.

Returns:
a PTable representing the sorted table.

sort

public static <K,V> PTable<K,V> sort(PTable<K,V> table,
                                     Sort.Order key)
Sorts the PTable using the natural ordering of its keys in the order specified.

Returns:
a PTable representing the sorted collection.

sortPairs

public static <U,V> PCollection<Pair<U,V>> sortPairs(PCollection<Pair<U,V>> collection,
                                                     Sort.ColumnOrder... columnOrders)
Sorts the PCollection of Pairs using the specified column ordering.

Returns:
a PCollection representing the sorted collection.

sortTriples

public static <V1,V2,V3> PCollection<Tuple3<V1,V2,V3>> sortTriples(PCollection<Tuple3<V1,V2,V3>> collection,
                                                                   Sort.ColumnOrder... columnOrders)
Sorts the PCollection of Tuple3s using the specified column ordering.

Returns:
a PCollection representing the sorted collection.

sortQuads

public static <V1,V2,V3,V4> PCollection<Tuple4<V1,V2,V3,V4>> sortQuads(PCollection<Tuple4<V1,V2,V3,V4>> collection,
                                                                       Sort.ColumnOrder... columnOrders)
Sorts the PCollection of Tuple4s using the specified column ordering.

Returns:
a PCollection representing the sorted collection.

sortTuples

public static PCollection<TupleN> sortTuples(PCollection<TupleN> collection,
                                             Sort.ColumnOrder... columnOrders)
Sorts the PCollection of TupleNs using the specified column ordering.

Returns:
a PCollection representing the sorted collection.


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