public abstract class DataFrameColumn<T extends Comparable<T>,C extends DataFrameColumn<T,C>> extends Object implements Iterable<T>
| Modifier and Type | Field and Description |
|---|---|
static String |
ERROR_APPENDING |
| Constructor and Description |
|---|
DataFrameColumn() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
append(Object value)
Append a value at the end of this column.
|
boolean |
append(Row<?,?> row,
int index)
A new value is appended at the end of this column using
doAppend(Comparable). |
<H> boolean |
append(Row<?,H> row,
H headerName)
A new value is appended at the end of this column using
doAppend(Comparable). |
boolean |
append(T value)
A new value is appended at the end of this column using
doAppend(Comparable). |
boolean |
appendAll(Collection<? extends T> c)
Appends all values of in a collection to this column.
|
boolean |
appendNA()
Appends a
NA value to the end of this column. |
abstract void |
clear()
Clears this column.
|
abstract boolean |
contains(T o)
Returns true if the specified value exists in this column.
|
abstract boolean |
containsAll(Collection<?> c)
Returns true if all values of a specified collection are present in this column.
|
abstract C |
copy()
Creates a copy of this column
|
protected abstract boolean |
doAppend(T value)
Used by
append(Comparable) to append a value to this column. |
protected abstract boolean |
doAppendAll(Collection<? extends T> c)
Used by
appendAll(Collection)} to append a collection of values. |
protected abstract boolean |
doAppendNA()
Used by
appendNA() to append NA at the end of this column. |
protected abstract void |
doMap(MapFunction<T> mapFunction)
Used by
map(MapFunction). |
protected abstract void |
doReverse()
Used by
reverse() to reverse the order of this column |
protected abstract void |
doSet(int index,
T value)
Used by
set(int, Comparable) to set a value at a specified index |
protected abstract void |
doSetNA(int index)
Used by
setNA(int) to set a specified index to NA. |
protected abstract void |
doSort()
Used by
sort() to sort the column values by their natural ordering |
protected abstract void |
doSort(Comparator<T> comparator)
Used by
sort(Comparator) to sort the values in this column |
protected void |
endDataFrameAppend()
Internal method used by the parent data frame to disable appending.
|
abstract T |
get(int index)
Returns the value at a specified index
|
DataFrame |
getDataFrame()
Returns the parent
data frame |
String |
getName()
Returns the name of this column
|
abstract Parser<T> |
getParser()
Returns a
Parser for the type of the values in this column. |
protected abstract C |
getThis()
Used to return the right column type for
|
abstract Class<T> |
getType()
Returns the type of the values in this column.
|
abstract T |
getValueFromRow(Row<?,?> row,
int headerIdex) |
abstract <H> T |
getValueFromRow(Row<?,H> row,
H headerName) |
abstract boolean |
isEmpty()
Returns true if this column contains no values.
|
abstract boolean |
isNA(int index)
Returns true if the value at the specified index equals
NA. |
C |
map(MapFunction<T> mapFunction)
A map function is applied to the values in this column.
|
void |
notifyDataFrameColumnChanged()
Notifies the parent
data frame that this column changed. |
void |
notifyDataFrameValueChanged(int index)
Notifies the parent
data frame about a value change at a specified index. |
C |
reverse()
Reverses the order of the column values
Calls
notifyDataFrameColumnChanged() to ensure data frame index consistency |
C |
set(int index,
T value)
Sets a value at a specified index.
|
protected void |
setDataFrame(DataFrame dataFrame)
Used internally by the data frame.
|
C |
setNA(int index)
Sets the value at a specified index to
NA. |
void |
setName(String name)
Sets the name of this column.
|
abstract int |
size()
Returns the number of values in this column.
|
C |
sort()
Sorts the column values by their natural ordering
Calls
notifyDataFrameValueChanged(int) to ensure data frame index consistency |
C |
sort(Comparator<T> comparator)
Sorts values in the column using a provided comparator
Calls
notifyDataFrameValueChanged(int) to ensure data frame index consistency |
protected void |
startDataFrameAppend()
Internal method used by the parent data frame to enable appending.
|
abstract Comparable[] |
toArray()
Returns an
Comparable array that contains all values of this column. |
abstract T[] |
toArray(T[] a)
Copies the values of this column to a specified array of the same type.
|
Double |
toDouble(int index)
Returns the double value at a specified index.
|
DataFrame |
transform(ColumnDataFrameTransform<C> transformer)
Used to apply transformations on a column
|
<R extends DataFrameColumn<?,R>> |
transform(ColumnTransform<C,R> transformer)
Used to apply transformations on a column
|
void |
validateAppend()
Throws an
exception if appending is currently not allowed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, iterator, spliteratorpublic static final String ERROR_APPENDING
protected abstract C getThis()
public <R extends DataFrameColumn<?,R>> R transform(ColumnTransform<C,R> transformer)
R - type of resulting columntransformer - column transformerpublic DataFrame transform(ColumnDataFrameTransform<C> transformer)
transformer - column transformerprotected abstract void doSort(Comparator<T> comparator)
sort(Comparator) to sort the values in this columncomparator - sort comparatorsort()public final C sort(Comparator<T> comparator)
Calls notifyDataFrameValueChanged(int) to ensure data frame index consistency
comparator - the comparator used to sort the column valuesprotected abstract void doSort()
sort() to sort the column values by their natural orderingsort()public final C sort()
Calls notifyDataFrameValueChanged(int) to ensure data frame index consistency
public Double toDouble(int index)
index - index of valuepublic String getName()
public void setName(String name)
name - new name of this columnpublic abstract Parser<T> getParser()
Parser for the type of the values in this column.public abstract Class<T> getType()
Comparableprotected abstract void doSet(int index,
T value)
set(int, Comparable) to set a value at a specified indexindex - index of the new valuevalue - value to be doSetset(int, Comparable)public final C set(int index, T value)
Calls notifyDataFrameValueChanged(int) to ensure data frame index consistency
index - index of the new valuevalue - value to be doSetprotected abstract void doMap(MapFunction<T> mapFunction)
map(MapFunction).
A map function is applied to the values in this column.mapFunction - function applied to each valuemap(MapFunction)public final C map(MapFunction<T> mapFunction)
MapFunction.map(Object) is called for each value.
CallsnotifyDataFrameColumnChanged() to ensure data frame index consistency
mapFunction - The function applied to each valueprotected abstract void doReverse()
reverse() to reverse the order of this columnpublic final C reverse()
CallsnotifyDataFrameColumnChanged() to ensure data frame index consistency
public abstract T get(int index)
index - Index of the returned valuepublic abstract C copy()
public abstract void clear()
public abstract T[] toArray(T[] a)
a - The array the values are copied topublic abstract Comparable[] toArray()
Comparable array that contains all values of this column.public abstract boolean containsAll(Collection<?> c)
c - Collection that contains the tested valuespublic abstract boolean contains(T o)
o - value that is testedprotected abstract boolean doAppend(T value)
append(Comparable) to append a value to this column.value - value to be appendedpublic final boolean append(T value)
doAppend(Comparable).
CallsvalidateAppend() to ensure data frame index consistency
value - value to be appendedvalidateAppend()public final <H> boolean append(Row<?,H> row, H headerName)
doAppend(Comparable).
CallsvalidateAppend() to ensure data frame index consistency
row - row containing the valueheaderName - headerName of the value within the rowvalidateAppend()public final boolean append(Row<?,?> row, int index)
doAppend(Comparable).
CallsvalidateAppend() to ensure data frame index consistency
row - row containing the valueindex - index of the value within the rowvalidateAppend()protected final boolean append(Object value)
RuntimeException if anything goes wrong.value - value to be appendedappend(Comparable)protected abstract boolean doAppendAll(Collection<? extends T> c)
appendAll(Collection)} to append a collection of values.c - collection containing values to be added to this columnappend(Comparable)public final boolean appendAll(Collection<? extends T> c)
Calls validateAppend() to ensure data frame index consistency
c - collection containing values to be added to this columnappend(Comparable)protected abstract boolean doAppendNA()
appendNA() to append NA at the end of this column.appendNA()public final boolean appendNA()
NA value to the end of this column.
Calls validateAppend() to ensure data frame index consistency
public abstract int size()
public abstract boolean isEmpty()
public abstract boolean isNA(int index)
NA.index - index to be tested for NAprotected abstract void doSetNA(int index)
setNA(int) to set a specified index to NA.index - index to be doSet to NApublic final C setNA(int index)
NA.
Calls notifyDataFrameValueChanged(int) to ensure data frame index consistency
index - index to be set NApublic void validateAppend()
throws DataFrameException
exception if appending is currently not allowed.
Appending is not allowed if the column is part of a data frame.
This step is necessary to ensure consistency of indices in the data frame.DataFrameException - Exception thrown if appending is not allowedpublic void notifyDataFrameValueChanged(int index)
data frame about a value change at a specified index.
This tells the data frame to update the indices if required.index - index of the changed valuepublic void notifyDataFrameColumnChanged()
data frame that this column changed.
This tells the data frame to update the indices if required.protected void startDataFrameAppend()
protected void endDataFrameAppend()
public DataFrame getDataFrame()
data frameprotected void setDataFrame(DataFrame dataFrame) throws DataFrameException
data frame.
Columns can only be part of one data frame.
Throws an exception if this column is already appended to an other data frame.dataFrame - parent data frameDataFrameException - thrown if column already assigned to other data frameCopyright © 2017. All rights reserved.