@TypeInfo(value=ListViewTypeInfoFactory.class) @PublicEvolving public class ListView<T> extends Object implements DataView
ListView
provides List functionality for accumulators used by user-defined aggregate
functions AggregateFunction
.
A ListView
can be backed by a Java ArrayList or a state backend, depending on the
context in which the aggregate function is used.
At runtime ListView
will be replaced by a state ListView which is backed by a
ListState
instead of ArrayList
if it works
in streaming.
Example of an accumulator type with a ListView
and an aggregate function that uses it:
public class MyAccum { public ListViewlist; public long count; } public class MyAgg extends AggregateFunction {
Modifier and Type | Field and Description |
---|---|
TypeInformation<?> |
elementType |
List<T> |
list |
Constructor and Description |
---|
ListView()
Creates a list view.
|
ListView(TypeInformation<?> elementType)
Creates a list view for elements of the specified type.
|
ListView(TypeInformation<?> elementType,
List<T> list) |
Modifier and Type | Method and Description |
---|---|
void |
add(T value)
Adds the given value to the list.
|
void |
addAll(List<T> list)
Adds all of the elements of the specified list to this list view.
|
void |
clear()
Removes all of the elements from this list view.
|
boolean |
equals(Object o) |
Iterable<T> |
get()
Returns an iterable of the list view.
|
int |
hashCode() |
boolean |
remove(T value)
Removes the given value from the list.
|
public transient TypeInformation<?> elementType
public ListView(TypeInformation<?> elementType, List<T> list)
public ListView(TypeInformation<?> elementType)
elementType
- The type of the list view elements.public ListView()
public Iterable<T> get() throws Exception
Exception
- Thrown if the system cannot get data.public void add(T value) throws Exception
value
- The element to be appended to this list view.Exception
- Thrown if the system cannot add data.public void addAll(List<T> list) throws Exception
list
- The list with the elements that will be stored in this list view.Exception
- Thrown if the system cannot add all data.public boolean remove(T value) throws Exception
value
- The element to be removed from this list view.Exception
public void clear()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.