Class LastByTableImportState<KEY_TYPE>
- All Implemented Interfaces:
ImportState
,LiveTable
,Externalizable
,Serializable
public class LastByTableImportState<KEY_TYPE> extends Object implements ImportState, LiveTable, Externalizable
ImportState that publishes a last-by view of the data being imported, producing a table intended for concurrent usage by clients with access to the importing process.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LastByTableImportState.ResultTableMap
LocalTableMap with an associated LiveTableRefreshCombiner. -
Constructor Summary
Constructors Constructor Description LastByTableImportState()
Constructor for an empty import state with null name.LastByTableImportState(String name)
Constructor for an empty import state. -
Method Summary
Modifier and Type Method Description void
ensureInitialized(FullTableLocationKey locationKey)
Called when non-import code needs to ensure that an ImportState's internals have been initialized because of their side effects.Properties
getImportDetails()
static LastByTableImportState.ResultTableMap
getTableMap(TableKey tableKey)
Get aLocalTableMap
keyed byTableLocationKey
ofDynamicTable
s that contain only anIndex
and no user-facingColumnSource
s.static LastByTableImportState.ResultTableMap
getTableMap(TableKey tableKey, String name)
Get aLocalTableMap
keyed byTableLocationKey
ofDynamicTable
s that contain only anIndex
and no user-facingColumnSource
s.void
newRow(Object keyElement)
Observe a new row for the specified uni-element key.void
newRow(Object... keyElements)
Observe a new row for the specified multi-element key.void
newRow(Object keyElement1, Object keyElement2)
Observe a new row for the specified bi-element key.void
newRow(Object keyElement1, Object keyElement2, Object keyElement3)
Observe a new row for the specified tri-element key.void
newRowForKey(KEY_TYPE key)
Observe a new row for the specified key, which may be compound.void
onClose()
Called when the data ingestion process for the location observed by this ImportState is finished, temporarily or permanently, in a consistent state.void
onFlush()
Called when the data ingestion process for the location observed by this ImportState is flushed (properly, after it has been flushed and when the resulting size has been made visible if applicable).void
onRelease()
Call when the data ingestion process for the location observed by this ImportState is finished, temporarily or permanently, in an inconsistent state.void
onResume(FullTableLocationKey locationKey)
Called when data ingestion is resumed for the location observed by this ImportState.void
onTruncate(FullTableLocationKey locationKey)
Called when the underlying table location has been truncated.Object
prepareElement(Object element)
Prepare a key element (that is, a component of a compound key) before using it to build a key that will be passed tonewRow(Object)
.KEY_TYPE
prepareKey(KEY_TYPE key)
Prepare a key for inclusion in the import state.void
readExternal(ObjectInput in)
void
refresh()
Refresh this LiveTable.void
skipRow()
Observe the passing of a row that will not be a part of the last-by view.void
writeExternal(ObjectOutput out)
-
Constructor Details
-
LastByTableImportState
public LastByTableImportState()Constructor for an empty import state with null name. -
LastByTableImportState
Constructor for an empty import state.- Parameters:
name
- The name for this last-by view (seegetTableMap(TableKey, String)
).
-
-
Method Details
-
getTableMap
Get aLocalTableMap
keyed byTableLocationKey
ofDynamicTable
s that contain only anIndex
and no user-facingColumnSource
s. The contents of the result are produced by LastByImportState instances for the suppliedTableKey
and null name- Parameters:
tableKey
- The key- Returns:
- The table map, possibly empty
-
getTableMap
public static LastByTableImportState.ResultTableMap getTableMap(@NotNull TableKey tableKey, String name)Get aLocalTableMap
keyed byTableLocationKey
ofDynamicTable
s that contain only anIndex
and no user-facingColumnSource
s. The contents of the result are produced by LastByTableImportState instances for the suppliedTableKey
and name. Distinct names should be used for distinct last-by import state views of the same table. TODO: Consider whether we should implement a LocalTableMap equivalent that stores weakly-reachable values.- Parameters:
tableKey
- The keyname
- The name- Returns:
- The table map, possibly empty
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
newRowForKey
Observe a new row for the specified key, which may be compound.
It is required that users of this method render their key immutable.
The recommended way to do so is to invoke
prepareElement(Object)
on single element keys, or construct aCanonicalizableTuple
directly from primitive elements and the result ofprepareElement(Object)
on all Object elements of a compound key. Alternatively,prepareKey(Object)
tries to do the correct thing, but may not be as performant. Users must not useSmartKey
orPair
directly as keys or indirectly as elements.- Parameters:
key
- The key
-
skipRow
public final void skipRow()Observe the passing of a row that will not be a part of the last-by view. -
newRow
Observe a new row for the specified uni-element key.
Note that key elements must be either functionally immutable or instances of StringCompatible.
It is recommended that users of compound keys use
newRowForKey(Object)
coupled with appropriate key and/or key element preparation.- Parameters:
keyElement
- The key element
-
newRow
Observe a new row for the specified bi-element key.
Note that key elements must be either functionally immutable or instances of StringCompatible.
It is recommended that users of compound keys use
newRowForKey(Object)
coupled with appropriate key and/or key element preparation.- Parameters:
keyElement1
- The first element that makes up the bi-element keykeyElement2
- The second element that makes up the bi-element key
-
newRow
Observe a new row for the specified tri-element key.
Note that key elements must be either functionally immutable or instances of StringCompatible.
It is recommended that users of compound keys use
newRowForKey(Object)
coupled with appropriate key and/or key element preparation.- Parameters:
keyElement1
- The first element that makes up the tri-element keykeyElement2
- The second element that makes up the tri-element keykeyElement3
- The second element that makes up the tri-element key
-
newRow
Observe a new row for the specified multi-element key.
Note that key elements must be either functionally immutable or instances of StringCompatible.
It is recommended that users of compound keys use
newRowForKey(Object)
coupled with appropriate key and/or key element preparation.- Parameters:
keyElements
- The elements that makes up the multi-element key
-
prepareElement
Prepare a key element (that is, a component of a compound key) before using it to build a key that will be passed tonewRow(Object)
. This entails canonicalization, and convertingStringCompatible
instances toString
s.- Parameters:
element
- The element to prepare- Returns:
- The preparation result
-
prepareKey
Prepare a key for inclusion in the import state.- Parameters:
key
- The key- Returns:
- The prepared result
-
getImportDetails
- Specified by:
getImportDetails
in interfaceImportState
-
ensureInitialized
Description copied from interface:ImportState
Called when non-import code needs to ensure that an ImportState's internals have been initialized because of their side effects. Must not interfere with concurrent data ingestion in the same process. Generally should be treated as a query operation, and the caller should hold theLiveTableMonitor
lock.- Specified by:
ensureInitialized
in interfaceImportState
- Parameters:
locationKey
- The full table location key of the location whose ImportState is being initialized
-
onResume
Description copied from interface:ImportState
Called when data ingestion is resumed for the location observed by this ImportState.- Specified by:
onResume
in interfaceImportState
- Parameters:
locationKey
- The full table location key of the location that has been resumed
-
onTruncate
Description copied from interface:ImportState
Called when the underlying table location has been truncated. Useful for resetting any in-memory state that may otherwise linger inappropriately.- Specified by:
onTruncate
in interfaceImportState
- Parameters:
locationKey
- The full table location key of the location that has been truncated
-
onFlush
public void onFlush()Description copied from interface:ImportState
Called when the data ingestion process for the location observed by this ImportState is flushed (properly, after it has been flushed and when the resulting size has been made visible if applicable).- Specified by:
onFlush
in interfaceImportState
-
onRelease
public void onRelease()Description copied from interface:ImportState
Call when the data ingestion process for the location observed by this ImportState is finished, temporarily or permanently, in an inconsistent state.- Specified by:
onRelease
in interfaceImportState
-
onClose
public void onClose()Description copied from interface:ImportState
Called when the data ingestion process for the location observed by this ImportState is finished, temporarily or permanently, in a consistent state.- Specified by:
onClose
in interfaceImportState
-
refresh
public void refresh()Description copied from interface:LiveTable
Refresh this LiveTable.
-