public class Bag extends MRData implements Iterable<MRData>
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Bag.Modes |
Constructor and Description |
---|
Bag()
create an empty bag as an ArrayList
|
Bag(BagIterator i)
lazy construction (stream-based) of a Bag
|
Bag(int size)
create an empty bag as an ArrayList with a given capacity
|
Bag(List<MRData> as)
in-memory Bag construction (an ArrayList) initialized with data
|
Bag(MRData... as)
in-memory Bag construction (an ArrayList) initialized with data
|
Modifier and Type | Method and Description |
---|---|
Bag |
add_element(MRData x)
add a new value to a Bag (cache it in memory if necessary)
|
void |
add(MRData x)
add a new value to a Bag (cache it in memory if necessary)
|
Bag |
addAll(Bag b)
add the elements of a Bag to the end of this Bag
|
void |
clear()
make this Bag empty (cache it in memory if necessary)
|
static int |
compare(byte[] x,
int xs,
int xl,
byte[] y,
int ys,
int yl,
int[] size)
compare this Bag with a given Bag by comparing their associated elements
|
int |
compareTo(MRData x)
compare this Bag with a given Bag by comparing their associated elements
|
boolean |
contains(MRData x)
does this Bag contain an element?
Cache this Bag in memory befor tetsing if necessary
|
boolean |
equals(Object x)
is this Bag equal to another Bag (order is important)
|
MRData |
get(int n)
get the n'th element of a Bag (cache it in memory if necessary)
|
int |
hashCode()
the hash code of this Bag is the XOR of the hash code of its elements
|
Iterator<MRData> |
iterator()
return the Bag Iterator
|
static Bag |
lazy_read(DataInput in)
a lazy input serializer for a Bag (it doesn't need to cache a Bag in memory)
|
boolean |
map_contains(MRData key)
if this Bag is a Map from keys to values (a Bag of (key,value) pairs),
does it contain a given key?
|
MRData |
map_find(MRData key)
if this Bag is a Map from keys to values (a Bag of (key,value) pairs),
find the value with the given key; raise an error if not found
|
void |
materialize()
cache the Bag to an ArrayList when is absolutely necessary
|
void |
materializeAll()
cache MRData in memory by caching all Bags at any place and depth in MRData
|
boolean |
materialized()
is the Bag stored in an ArrayList?
|
static Bag |
read(DataInput in)
the input serializer for Bag
|
void |
readFields(DataInput in)
the input serializer for Bag
|
Bag |
set(int n,
MRData value)
replace the n'th element of a Bag with a new value
|
int |
size()
return the Bag size (cache it in memory if necessary)
|
void |
sort()
sort the Bag (cache it in memory if necessary).
|
boolean |
spilled()
is the Bag spilled into a file?
|
boolean |
streamed()
is the Bag stream-based?
|
String |
toString()
show the first few Bag elements (controlled by -bag_print)
|
void |
trim()
trim the ArrayList that caches the Bag
|
Bag |
union(Bag s)
concatenate the elements of a given Bag to the elements of this Bag.
|
void |
write(DataOutput out)
the output serializer for Bag.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public Bag()
public Bag(int size)
size
- initial capacitypublic Bag(MRData... as)
as
- a vector of MRData to insert in the Bagpublic Bag(List<MRData> as)
as
- a vector of MRData to insert in the Bagpublic Bag(BagIterator i)
i
- the Iterator that generates the Bag elementspublic boolean materialized()
public boolean streamed()
public boolean spilled()
public int size()
public void trim()
public MRData get(int n)
n
- the indexpublic Bag set(int n, MRData value)
n
- the indexvalue
- the new valuepublic void add(MRData x)
x
- the new valuepublic Bag add_element(MRData x)
x
- the new valuepublic Bag addAll(Bag b)
b
- the Bag whose elements are copiedpublic void clear()
public void materialize()
public void sort()
public void materializeAll()
materializeAll
in class MRData
public Bag union(Bag s)
s
- the given Bagpublic boolean contains(MRData x)
x
- the element to findpublic MRData map_find(MRData key)
key
- the search keypublic boolean map_contains(MRData key)
key
- the search keypublic final void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public static final Bag read(DataInput in) throws IOException
IOException
public static Bag lazy_read(DataInput in) throws IOException
IOException
public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
public int compareTo(MRData x)
compareTo
in interface Comparable<MRData>
public static final int compare(byte[] x, int xs, int xl, byte[] y, int ys, int yl, int[] size)
public boolean equals(Object x)
public int hashCode()
Copyright © 2013-2016 The Apache Software Foundation. All Rights Reserved.