Class ArrayListRowsAndColumns<RowType>
- java.lang.Object
-
- org.apache.druid.query.rowsandcols.ArrayListRowsAndColumns<RowType>
-
- Type Parameters:
RowType
-
- All Implemented Interfaces:
RowsAndColumns
,AppendableRowsAndColumns
public class ArrayListRowsAndColumns<RowType> extends Object implements AppendableRowsAndColumns
ArrayListRowsAndColumns is a RowsAndColumns implementation that believes it has all of its data on-heap.It is an AppendableRowsAndColumns and, as with all RowsAndColumns, it is not thread-safe for multiple writes. Under certain circumstances, concurrent reads from multiple threads can be correct, but the code has to be follow a very strict ordering of code that ensures that reads only happen after writes and once a value is read, it will never be overwritten.
Additionally, this object implements various of the semantic interfaces directly to provide some degree of processing and memory optimization.
-
-
Constructor Summary
Constructors Constructor Description ArrayListRowsAndColumns(ArrayList<RowType> rows, RowAdapter<RowType> rowAdapter, RowSignature rowSignature)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(String name, Column column)
Mutates the RowsAndColumns by appending the requested Column.<T> T
as(Class<T> clazz)
Asks the RowsAndColumns to return itself as a concrete implementation of a specific interface.Column
findColumn(String name)
Finds a column by name.Collection<String>
getColumnNames()
The set of column names available from the RowsAndColumnsint
numRows()
The number of rows in the RowsAndColumns objectvoid
sort(ArrayList<ColumnWithDirection> ordering)
-
-
-
Constructor Detail
-
ArrayListRowsAndColumns
public ArrayListRowsAndColumns(ArrayList<RowType> rows, RowAdapter<RowType> rowAdapter, RowSignature rowSignature)
-
-
Method Detail
-
getColumnNames
public Collection<String> getColumnNames()
Description copied from interface:RowsAndColumns
The set of column names available from the RowsAndColumns- Specified by:
getColumnNames
in interfaceRowsAndColumns
- Returns:
- The set of column names available from the RowsAndColumns
-
numRows
public int numRows()
Description copied from interface:RowsAndColumns
The number of rows in the RowsAndColumns object- Specified by:
numRows
in interfaceRowsAndColumns
- Returns:
- the integer number of rows
-
findColumn
@Nullable public Column findColumn(String name)
Description copied from interface:RowsAndColumns
Finds a column by name. null is returned if the column is not found. The RowsAndColumns object should not attempt to default not-found columns to pretend as if they exist, instead the user of the RowsAndColumns object should decide the correct semantic interpretation of a column that does not exist. It is expected that most locations will choose to believe that the column does exist and is always null, but there are often optimizations that can effect this same assumption without doing a lot of extra work if the calling code knows that it does not exist.- Specified by:
findColumn
in interfaceRowsAndColumns
- Parameters:
name
- the name of the column to find- Returns:
- the Column, if found. null if not found.
-
as
@Nullable public <T> T as(Class<T> clazz)
Description copied from interface:RowsAndColumns
Asks the RowsAndColumns to return itself as a concrete implementation of a specific interface. The interface asked for will tend to be a semantically-meaningful interface. This method allows the calling code to interrogate the RowsAndColumns object about whether it can offer a meaningful optimization of the semantic interface. If a RowsAndColumns cannot do anything specifically optimal for the interface requested, it should return null instead of trying to come up with its own default implementation.- Specified by:
as
in interfaceRowsAndColumns
- Type Parameters:
T
- The interface that the calling code wants a concrete implementation of- Parameters:
clazz
- A class object representing the interface that the calling code wants a concrete implementation of- Returns:
- A concrete implementation of the interface, or null if there is no meaningful optimization to be had through a local implementation of the interface.
-
addColumn
public void addColumn(String name, Column column)
Description copied from interface:AppendableRowsAndColumns
Mutates the RowsAndColumns by appending the requested Column.- Specified by:
addColumn
in interfaceAppendableRowsAndColumns
- Parameters:
name
- the name of the new columncolumn
- the Column object representing the new column
-
sort
public void sort(ArrayList<ColumnWithDirection> ordering)
-
-