Package com.macrofocus.molap.dataframe
Class DefaultDataFrame<V>
- java.lang.Object
-
- com.macrofocus.molap.dataframe.AbstractDataFrame<java.lang.Integer,java.lang.String,V>
-
- com.macrofocus.molap.dataframe.DefaultDataFrame<V>
-
- Type Parameters:
V
- the type of values
- All Implemented Interfaces:
DataFrame<java.lang.Integer,java.lang.String,V>
,MutableDataFrame<java.lang.Integer,java.lang.String,V>
,java.io.Externalizable
,java.io.Serializable
public class DefaultDataFrame<V> extends AbstractDataFrame<java.lang.Integer,java.lang.String,V> implements MutableDataFrame<java.lang.Integer,java.lang.String,V>, java.io.Externalizable
A data frame with direct integer indexing on the rows and textual indexing on the columns.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultDataFrame()
DefaultDataFrame(DataFrame dataFrame)
DefaultDataFrame(DataFrame<java.lang.Integer,java.lang.String,V> dataFrame, boolean autoConvert)
DefaultDataFrame(DataFrame dataFrame, UniqueIndex.Duplicate duplicate)
DefaultDataFrame(UniqueIndex<java.lang.Integer> rowIndex, DefaultUniqueIndex<java.lang.String> columnIndex, MutableSeries<java.lang.Integer,V>[] series)
DefaultDataFrame(java.io.File file)
Deprecated.DefaultDataFrame(java.lang.String[] names, java.lang.Class[] classes, V[][] data)
DefaultDataFrame(javax.swing.table.TableModel tableModel)
DefaultDataFrame(javax.swing.table.TableModel tableModel, boolean autoConvert)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Iterable<java.lang.String>
columns()
Returns the column keys.void
freeze(java.io.File file)
void
freeze(java.io.OutputStream os)
Deprecated.Series<java.lang.Integer,V>
getColumn(java.lang.String column)
Returns a series of all the values of a given column.int
getColumnAddress(java.lang.String column)
Returns the absolute index for the specified column key.java.lang.Class
getColumnClass(java.lang.String column)
Returns the most specific superclass for all cell values in a columnint
getColumnCount()
Returns the number of columns contained by this data frame.DefaultUniqueIndex<java.lang.String>
getColumnIndex()
Gets the index used to access the columns.java.lang.String
getColumnKey(int index)
Returns the column key at the specified absolute index.Series<java.lang.String,?>
getRow(java.lang.Integer row)
Returns a series of all the values of a given row.int
getRowAddress(java.lang.Integer row)
Returns the absolute index for the specified row key.java.lang.Class
getRowClass(java.lang.Integer row)
Returns the most specific superclass for all cell values in a row.int
getRowCount()
Returns the number of rows contained by the this data frame.UniqueIndex<java.lang.Integer>
getRowIndex()
Gets the index used to access the rows.java.lang.Integer
getRowKey(int index)
Returns the row key at the specified absolute index.V
getValueAt(java.lang.Integer row, java.lang.String column)
Returns the value for the cell at the intersection of thecolumn
key androw
key.DataFrame
join(Series series, java.lang.String[] columns)
DataFrame<java.lang.Integer,java.lang.String,V>
leftJoin(DataFrame<MultiKey,java.lang.String,V> dataFrame, java.lang.String[] cs)
DefaultDataFrame<V>
leftJoin(DataFrame<java.lang.Object,java.lang.String,V> dataFrame, java.lang.String c)
DataFrame<java.lang.Integer,java.lang.String,V>
leftJoin(UniqueIndex.Duplicate duplicate, DataFrame<MultiKey,java.lang.String,V> dataFrame, java.lang.String[] cs)
void
readExternal(java.io.ObjectInput in)
MutableDataFrame<MultiKey,java.lang.String,V>
reindexRows(java.lang.String... rows)
Returns a new data frame reindexed using the values coming from the specified rows.DefaultDataFrame<V>
removeColumns(java.lang.String... columns)
java.lang.Iterable<java.lang.Integer>
rows()
Returns the row keys.void
setValueAt(java.lang.Integer row, java.lang.String column, V value)
Sets the value for the cell at the intersection of thecolumn
key androw
key.void
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class com.macrofocus.molap.dataframe.AbstractDataFrame
addDataFrameListener, addWeakDataFrameListener, aggregate, aggregate, append, appendAndReindex, benchmark, filter, getCentroid, getColumnName, getConstant, getCount, getCountDistinct, getCountDistinctWithNull, getCube, getDataFrameAggregation, getDistributiveStatistics, getFirst, getFirstQuartile, getMax, getMean, getMedian, getMin, getRandom, getStatistics, getStdDev, getSum, getThirdQuartile, getUnivariateStatistics, getVariance, getVarianceByPopulation, getWeightedMean, getWeightedSum, notifyDataFrameChanged, orderRows, print, print, printSchema, reindexColumns, reindexRows, reindexRows, reindexRows, reindexRows, remapColumns, removeDataFrameListener, removeDataFrameListeners, removeDuplicates
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.macrofocus.molap.dataframe.DataFrame
addDataFrameListener, addWeakDataFrameListener, aggregate, aggregate, append, appendAndReindex, benchmark, filter, getCentroid, getColumnName, getConstant, getCount, getCountDistinct, getCountDistinctWithNull, getDataFrameAggregation, getDistributiveStatistics, getFirst, getFirstQuartile, getMax, getMean, getMedian, getMin, getRandom, getStatistics, getStdDev, getSum, getThirdQuartile, getUnivariateStatistics, getVariance, getVarianceByPopulation, getWeightedMean, getWeightedSum, orderRows, print, print, printSchema, reindexColumns, reindexRows, reindexRows, reindexRows, remapColumns, removeDataFrameListener, removeDataFrameListeners, removeDuplicates
-
Methods inherited from interface com.macrofocus.molap.dataframe.MutableDataFrame
reindexRows
-
-
-
-
Constructor Detail
-
DefaultDataFrame
public DefaultDataFrame()
-
DefaultDataFrame
@Deprecated public DefaultDataFrame(java.io.File file) throws java.io.IOException
Deprecated.Deserialize the DataFrame in optimized binary format. This works, but has never been put into production.- Parameters:
file
-- Throws:
java.io.IOException
-
DefaultDataFrame
public DefaultDataFrame(javax.swing.table.TableModel tableModel, boolean autoConvert)
-
DefaultDataFrame
public DefaultDataFrame(DataFrame<java.lang.Integer,java.lang.String,V> dataFrame, boolean autoConvert)
-
DefaultDataFrame
public DefaultDataFrame(javax.swing.table.TableModel tableModel)
-
DefaultDataFrame
public DefaultDataFrame(java.lang.String[] names, java.lang.Class[] classes, V[][] data)
-
DefaultDataFrame
public DefaultDataFrame(DataFrame dataFrame)
-
DefaultDataFrame
public DefaultDataFrame(DataFrame dataFrame, UniqueIndex.Duplicate duplicate)
-
DefaultDataFrame
public DefaultDataFrame(UniqueIndex<java.lang.Integer> rowIndex, DefaultUniqueIndex<java.lang.String> columnIndex, MutableSeries<java.lang.Integer,V>[] series)
-
-
Method Detail
-
freeze
public void freeze(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
freeze
@Deprecated public void freeze(java.io.OutputStream os) throws java.io.IOException
Deprecated.Serialize the DataFrame in optimized binary format. This works, but has never been put into production.- Parameters:
os
-- Throws:
java.io.IOException
-
getColumnIndex
public DefaultUniqueIndex<java.lang.String> getColumnIndex()
Description copied from interface:DataFrame
Gets the index used to access the columns.- Specified by:
getColumnIndex
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Returns:
- the column index
-
getRowIndex
public UniqueIndex<java.lang.Integer> getRowIndex()
Description copied from interface:DataFrame
Gets the index used to access the rows.- Specified by:
getRowIndex
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Returns:
- the row index
-
columns
public java.lang.Iterable<java.lang.String> columns()
Description copied from interface:DataFrame
Returns the column keys.
-
getRowClass
public java.lang.Class getRowClass(java.lang.Integer row)
Description copied from interface:DataFrame
Returns the most specific superclass for all cell values in a row.- Specified by:
getRowClass
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
row
- the key of the row- Returns:
- the common ancestor class of the object values in the row.
-
getColumnClass
public java.lang.Class getColumnClass(java.lang.String column)
Description copied from interface:DataFrame
Returns the most specific superclass for all cell values in a column- Specified by:
getColumnClass
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
column
- the key of the column- Returns:
- the common ancestor class of the object values in the column.
-
getRow
public Series<java.lang.String,?> getRow(java.lang.Integer row)
Description copied from interface:DataFrame
Returns a series of all the values of a given row.
-
getColumn
public Series<java.lang.Integer,V> getColumn(java.lang.String column)
Description copied from interface:DataFrame
Returns a series of all the values of a given column.
-
getValueAt
public V getValueAt(java.lang.Integer row, java.lang.String column)
Description copied from interface:DataFrame
Returns the value for the cell at the intersection of thecolumn
key androw
key.- Specified by:
getValueAt
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
row
- the row key whose value is to be queriedcolumn
- the column key whose value is to be queried- Returns:
- the value Object at the specified cell
-
setValueAt
public void setValueAt(java.lang.Integer row, java.lang.String column, V value)
Description copied from interface:MutableDataFrame
Sets the value for the cell at the intersection of thecolumn
key androw
key.- Specified by:
setValueAt
in interfaceMutableDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
row
- the row key whose value is to be changedcolumn
- the column key whose value is to be changedvalue
- the new value at the specified cell
-
rows
public java.lang.Iterable<java.lang.Integer> rows()
Description copied from interface:DataFrame
Returns the row keys.
-
getRowKey
public java.lang.Integer getRowKey(int index)
Description copied from interface:DataFrame
Returns the row key at the specified absolute index. This is the inverse ofDataFrame.getRowAddress(Object)
.
-
getColumnKey
public java.lang.String getColumnKey(int index)
Description copied from interface:DataFrame
Returns the column key at the specified absolute index. This is the inverse ofDataFrame.getColumnAddress(Object)
.- Specified by:
getColumnKey
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Overrides:
getColumnKey
in classAbstractDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
index
- the index- Returns:
- the column key
-
getRowAddress
public int getRowAddress(java.lang.Integer row)
Description copied from interface:DataFrame
Returns the absolute index for the specified row key. This is the inverse ofDataFrame.getRowKey(int)
.- Specified by:
getRowAddress
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Overrides:
getRowAddress
in classAbstractDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
row
- the row key- Returns:
- the absolute index of the specified key.
-
getColumnAddress
public int getColumnAddress(java.lang.String column)
Description copied from interface:DataFrame
Returns the absolute index for the specified column key. This is the inverse ofDataFrame.getColumnKey(int)
.- Specified by:
getColumnAddress
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Overrides:
getColumnAddress
in classAbstractDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
column
- the column key- Returns:
- the absolute index of the specified key.
-
getRowCount
public int getRowCount()
Description copied from interface:DataFrame
Returns the number of rows contained by the this data frame.- Specified by:
getRowCount
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Overrides:
getRowCount
in classAbstractDataFrame<java.lang.Integer,java.lang.String,V>
- Returns:
- the number of rows.
-
getColumnCount
public int getColumnCount()
Description copied from interface:DataFrame
Returns the number of columns contained by this data frame.- Specified by:
getColumnCount
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Overrides:
getColumnCount
in classAbstractDataFrame<java.lang.Integer,java.lang.String,V>
- Returns:
- the number of columns.
-
reindexRows
public MutableDataFrame<MultiKey,java.lang.String,V> reindexRows(java.lang.String... rows)
Description copied from interface:DataFrame
Returns a new data frame reindexed using the values coming from the specified rows.- Specified by:
reindexRows
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Specified by:
reindexRows
in interfaceMutableDataFrame<java.lang.Integer,java.lang.String,V>
- Overrides:
reindexRows
in classAbstractDataFrame<java.lang.Integer,java.lang.String,V>
- Parameters:
rows
- the columns to use for the label values- Returns:
- the reindexed data frame.
-
leftJoin
public DefaultDataFrame<V> leftJoin(DataFrame<java.lang.Object,java.lang.String,V> dataFrame, java.lang.String c)
-
leftJoin
public DataFrame<java.lang.Integer,java.lang.String,V> leftJoin(DataFrame<MultiKey,java.lang.String,V> dataFrame, java.lang.String[] cs)
-
leftJoin
public DataFrame<java.lang.Integer,java.lang.String,V> leftJoin(UniqueIndex.Duplicate duplicate, DataFrame<MultiKey,java.lang.String,V> dataFrame, java.lang.String[] cs)
-
removeColumns
public DefaultDataFrame<V> removeColumns(java.lang.String... columns)
- Specified by:
removeColumns
in interfaceDataFrame<java.lang.Integer,java.lang.String,V>
- Overrides:
removeColumns
in classAbstractDataFrame<java.lang.Integer,java.lang.String,V>
-
-