public abstract class DefaultAbstractBag extends java.lang.Object implements DataBag
Modifier and Type | Class and Description |
---|---|
static class |
DefaultAbstractBag.BagDelimiterTuple |
static class |
DefaultAbstractBag.EndBag |
static class |
DefaultAbstractBag.StartBag |
Modifier and Type | Field and Description |
---|---|
static Tuple |
endBag |
protected static int |
MAX_SPILL_FILES |
protected java.util.Collection<Tuple> |
mContents |
protected long |
mSize |
protected FileList |
mSpillFiles |
static Tuple |
startBag |
Constructor and Description |
---|
DefaultAbstractBag() |
Modifier and Type | Method and Description |
---|---|
void |
add(Tuple t)
Add a tuple to the bag.
|
void |
addAll(java.util.Collection<Tuple> c) |
void |
addAll(DataBag b)
Add contents of a bag to the bag.
|
void |
addAll(java.lang.Iterable<Tuple> iterable)
Add contents of an iterable (a collection or a DataBag)
|
void |
clear()
Clear out the contents of the bag, both on disk and in memory.
|
int |
compareTo(java.lang.Object other)
This method is potentially very expensive since it may require a
sort of the bag; don't call it unless you have to.
|
boolean |
equals(java.lang.Object other) |
long |
getMemorySize()
Return the size of memory usage.
|
protected java.io.DataOutputStream |
getSpillFile()
Get a file to spill contents to.
|
int |
hashCode() |
protected void |
incSpillCount(java.lang.Enum counter) |
protected void |
incSpillCount(java.lang.Enum counter,
long numRecsSpilled) |
protected void |
markSpillableIfNecessary()
All bag implementations that can get big enough to be spilled
should call this method after every time they add an element.
|
void |
markStale(boolean stale)
This is used by FuncEvalSpec.FakeDataBag.
|
void |
readFields(java.io.DataInput in)
Read a bag from disk.
|
protected void |
reportProgress()
Report progress to HDFS.
|
protected void |
sampleContents()
Sample every SPILL_SAMPLE_FREQUENCYth tuple
until we reach a max of SPILL_SAMPLE_SIZE
to get an estimate of the tuple sizes.
|
long |
size()
Get the number of elements in the bag, both in memory and on disk.
|
java.lang.String |
toString()
Write the bag into a string.
|
protected void |
warn(java.lang.String msg,
java.lang.Enum warningEnum,
java.lang.Throwable e) |
void |
write(java.io.DataOutput out)
Write a bag's contents to disk.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isDistinct, isSorted, iterator
protected java.util.Collection<Tuple> mContents
protected FileList mSpillFiles
protected long mSize
public static final Tuple startBag
public static final Tuple endBag
protected static final int MAX_SPILL_FILES
public long size()
protected void sampleContents()
public void add(Tuple t)
protected void markSpillableIfNecessary()
public void addAll(DataBag b)
DataBag
public void addAll(java.util.Collection<Tuple> c)
public void addAll(java.lang.Iterable<Tuple> iterable)
iterable
- a Collection or DataBag to add contents ofpublic long getMemorySize()
getMemorySize
in interface Spillable
public void clear()
public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public void write(java.io.DataOutput out) throws java.io.IOException
write
in interface org.apache.hadoop.io.Writable
out
- DataOutput to write data to.java.io.IOException
- (passes it on from underlying calls).public void readFields(java.io.DataInput in) throws java.io.IOException
readFields
in interface org.apache.hadoop.io.Writable
in
- DataInput to read data from.java.io.IOException
- (passes it on from underlying calls).public void markStale(boolean stale)
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected java.io.DataOutputStream getSpillFile() throws java.io.IOException
java.io.IOException
protected void reportProgress()
protected void warn(java.lang.String msg, java.lang.Enum warningEnum, java.lang.Throwable e)
protected void incSpillCount(java.lang.Enum counter)
protected void incSpillCount(java.lang.Enum counter, long numRecsSpilled)
Copyright © 2007-2017 The Apache Software Foundation