Package org.apache.beam.sdk.util
Class WindowedValue<T>
- java.lang.Object
-
- org.apache.beam.sdk.util.WindowedValue<T>
-
- Type Parameters:
T
- the type of the value
@Internal public abstract class WindowedValue<T> extends java.lang.Object
An immutable triple of value, timestamp, and windows.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WindowedValue.FullWindowedValueCoder<T>
Coder forWindowedValue
.static class
WindowedValue.ParamWindowedValueCoder<T>
A parameterized coder forWindowedValue
.static interface
WindowedValue.SingleWindowedValue
AWindowedValue
which holds exactly single window per value.static class
WindowedValue.ValueOnlyWindowedValueCoder<T>
Deprecated.Use ParamWindowedValueCoder instead, it is a general purpose implementation of the same concept but makes timestamp, windows and pane info configurable.static class
WindowedValue.WindowedValueCoder<T>
Abstract class forWindowedValue
coder.
-
Constructor Summary
Constructors Constructor Description WindowedValue()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(@Nullable java.lang.Object other)
java.lang.Iterable<WindowedValue<T>>
explodeWindows()
Returns a collection ofWindowedValues
identical to this one, except each is in exactly one of the windows that thisWindowedValue
is in.static <T> WindowedValue.FullWindowedValueCoder<T>
getFullCoder(Coder<T> valueCoder, Coder<? extends BoundedWindow> windowCoder)
Returns theCoder
to use for aWindowedValue<T>
, using the given valueCoder and windowCoder.abstract PaneInfo
getPane()
Returns the pane of thisWindowedValue
in its window.static <T> WindowedValue.ParamWindowedValueCoder<T>
getParamWindowedValueCoder(Coder<T> valueCoder)
Returns theParamWindowedValueCoder
from the given valueCoder.abstract org.joda.time.Instant
getTimestamp()
Returns the timestamp of thisWindowedValue
.abstract T
getValue()
Returns the value of thisWindowedValue
.static <T> WindowedValue.ValueOnlyWindowedValueCoder<T>
getValueOnlyCoder(Coder<T> valueCoder)
Returns theValueOnlyCoder
from the given valueCoder.abstract java.util.Collection<? extends BoundedWindow>
getWindows()
Returns the windows of thisWindowedValue
.int
hashCode()
boolean
isSingleWindowedValue()
Returnstrue
if this WindowedValue has exactly one window.static <T> WindowedValue<T>
of(T value, org.joda.time.Instant timestamp, java.util.Collection<? extends BoundedWindow> windows, PaneInfo pane)
Returns aWindowedValue
with the given value, timestamp, and windows.static <T> WindowedValue<T>
of(T value, org.joda.time.Instant timestamp, BoundedWindow window, PaneInfo pane)
Returns aWindowedValue
with the given value, timestamp, and window.static <T> WindowedValue<T>
timestampedValueInGlobalWindow(T value, org.joda.time.Instant timestamp)
Returns aWindowedValue
with the given value and timestamp,GlobalWindow
and default pane.static <T> WindowedValue<T>
timestampedValueInGlobalWindow(T value, org.joda.time.Instant timestamp, PaneInfo paneInfo)
Returns aWindowedValue
with the given value, timestamp, and pane in theGlobalWindow
.abstract java.lang.String
toString()
static <T> WindowedValue<T>
valueInGlobalWindow(T value)
Returns aWindowedValue
with the given value in theGlobalWindow
using the default timestamp and pane.static <T> WindowedValue<T>
valueInGlobalWindow(T value, PaneInfo pane)
Returns aWindowedValue
with the given value in theGlobalWindow
using the default timestamp and the specified pane.abstract <NewT> WindowedValue<NewT>
withValue(NewT value)
Returns a newWindowedValue
that is a copy of this one, but with a different value, which may have a new typeNewT
.
-
-
-
Method Detail
-
of
public static <T> WindowedValue<T> of(T value, org.joda.time.Instant timestamp, java.util.Collection<? extends BoundedWindow> windows, PaneInfo pane)
Returns aWindowedValue
with the given value, timestamp, and windows.
-
of
public static <T> WindowedValue<T> of(T value, org.joda.time.Instant timestamp, BoundedWindow window, PaneInfo pane)
Returns aWindowedValue
with the given value, timestamp, and window.
-
valueInGlobalWindow
public static <T> WindowedValue<T> valueInGlobalWindow(T value)
Returns aWindowedValue
with the given value in theGlobalWindow
using the default timestamp and pane.
-
valueInGlobalWindow
public static <T> WindowedValue<T> valueInGlobalWindow(T value, PaneInfo pane)
Returns aWindowedValue
with the given value in theGlobalWindow
using the default timestamp and the specified pane.
-
timestampedValueInGlobalWindow
public static <T> WindowedValue<T> timestampedValueInGlobalWindow(T value, org.joda.time.Instant timestamp)
Returns aWindowedValue
with the given value and timestamp,GlobalWindow
and default pane.
-
timestampedValueInGlobalWindow
public static <T> WindowedValue<T> timestampedValueInGlobalWindow(T value, org.joda.time.Instant timestamp, PaneInfo paneInfo)
Returns aWindowedValue
with the given value, timestamp, and pane in theGlobalWindow
.
-
withValue
public abstract <NewT> WindowedValue<NewT> withValue(NewT value)
Returns a newWindowedValue
that is a copy of this one, but with a different value, which may have a new typeNewT
.
-
getValue
public abstract T getValue()
Returns the value of thisWindowedValue
.
-
getTimestamp
public abstract org.joda.time.Instant getTimestamp()
Returns the timestamp of thisWindowedValue
.
-
getWindows
public abstract java.util.Collection<? extends BoundedWindow> getWindows()
Returns the windows of thisWindowedValue
.
-
getPane
public abstract PaneInfo getPane()
Returns the pane of thisWindowedValue
in its window.
-
isSingleWindowedValue
public boolean isSingleWindowedValue()
Returnstrue
if this WindowedValue has exactly one window.
-
explodeWindows
public java.lang.Iterable<WindowedValue<T>> explodeWindows()
Returns a collection ofWindowedValues
identical to this one, except each is in exactly one of the windows that thisWindowedValue
is in.
-
equals
public boolean equals(@Nullable java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public abstract java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getFullCoder
public static <T> WindowedValue.FullWindowedValueCoder<T> getFullCoder(Coder<T> valueCoder, Coder<? extends BoundedWindow> windowCoder)
Returns theCoder
to use for aWindowedValue<T>
, using the given valueCoder and windowCoder.
-
getValueOnlyCoder
public static <T> WindowedValue.ValueOnlyWindowedValueCoder<T> getValueOnlyCoder(Coder<T> valueCoder)
Returns theValueOnlyCoder
from the given valueCoder.
-
getParamWindowedValueCoder
public static <T> WindowedValue.ParamWindowedValueCoder<T> getParamWindowedValueCoder(Coder<T> valueCoder)
Returns theParamWindowedValueCoder
from the given valueCoder.
-
-