public class HollowWriteStateEngine extends java.lang.Object implements HollowStateEngine
HollowWriteStateEngine
is our main handle to a Hollow dataset as a data producer.
A dataset changes over time. A core concept in Hollow is that the timeline for a changing dataset can be broken down into discrete data states, each of which is a complete snapshot of the data at a particular point in time. Data producers handle data states with a HollowWriteStateEngine.
A HollowWriteStateEngine cycles back and forth between two-phases:
During the "adding records" phase, all of the records comprising the dataset are added to the state engine. During the "writing" phase, we can write snapshot blobs to initialize and/or delta blobs to keep up-to-date consumers of the dataset.
Each cycle between the phases will produce a state. During each cycle, all of the current records in the dataset should be re-added to the write state engine.
Constructor and Description |
---|
HollowWriteStateEngine() |
HollowWriteStateEngine(HollowObjectHashCodeFinder hasher) |
Modifier and Type | Method and Description |
---|---|
int |
add(java.lang.String type,
HollowWriteRecord rec)
Add a record to the state.
|
void |
addAllObjectsFromPreviousCycle()
Add all of the objects from the previous cycle, exactly as they were in the previous cycle.
|
void |
addHeaderTag(java.lang.String name,
java.lang.String value) |
void |
addHeaderTags(java.util.Map<java.lang.String,java.lang.String> headerTags) |
void |
addTypeState(HollowTypeWriteState writeState)
Add a type to the dataset.
|
HollowObjectHashCodeFinder |
getHashCodeFinder() |
java.lang.String |
getHeaderTag(java.lang.String name) |
java.util.Map<java.lang.String,java.lang.String> |
getHeaderTags() |
long |
getNextStateRandomizedTag() |
java.util.List<HollowTypeWriteState> |
getOrderedTypeStates() |
long |
getPreviousStateRandomizedTag() |
HollowSchema |
getSchema(java.lang.String schemaName) |
java.util.List<HollowSchema> |
getSchemas() |
HollowTypeWriteState |
getTypeState(java.lang.String typeName) |
boolean |
hasChangedSinceLastCycle() |
boolean |
isRestored() |
void |
overrideNextStateRandomizedTag(long nextStateRandomizedTag) |
void |
overridePreviousStateRandomizedTag(long previousStateRandomizedTag) |
void |
prepareForNextCycle()
Transition from the "writing" phase of a cycle to the "adding records" phase of the next cycle.
|
void |
prepareForWrite()
Transition from the "adding records" phase of a cycle to the "writing" phase of a cycle.
|
void |
resetToLastPrepareForNextCycle()
If a state was partially constructed after the last call to prepareForNextCycle(), this call
will remove all of those objects from the state engine and reset to the state it was in at the
last prepareForNextCycle() call.
|
void |
restoreFrom(HollowReadStateEngine readStateEngine)
Restore from the data state contained in the provided
HollowReadStateEngine . |
void |
setTargetMaxTypeShardSize(long targetMaxTypeShardSize)
Setting a target max type shard size (specified in bytes) will limit the excess memory pool required to perform delta transitions.
|
public HollowWriteStateEngine()
public HollowWriteStateEngine(HollowObjectHashCodeFinder hasher)
public int add(java.lang.String type, HollowWriteRecord rec)
public void addTypeState(HollowTypeWriteState writeState)
public void restoreFrom(HollowReadStateEngine readStateEngine)
HollowReadStateEngine
. This is used to continue
a delta chain after a producer is restarted.
Before calling this method, the data model should be pre-initialized. This can be accomplished by:
HollowWriteStateCreator
HollowObjectMapper.initializeTypeState(Class)
with each of the top-level classes in the data modeladdTypeState(HollowTypeWriteState)
public void prepareForWrite()
public void prepareForNextCycle()
public void addAllObjectsFromPreviousCycle()
public void resetToLastPrepareForNextCycle()
This method can be called at any time, and will leave the state engine in the same state it was in immediately
after the last call to prepareForNextCycle()
public boolean hasChangedSinceLastCycle()
public boolean isRestored()
public java.util.List<HollowTypeWriteState> getOrderedTypeStates()
public HollowTypeWriteState getTypeState(java.lang.String typeName)
HollowTypeWriteState
public java.util.List<HollowSchema> getSchemas()
getSchemas
in interface HollowDataset
getSchemas
in interface HollowStateEngine
public HollowSchema getSchema(java.lang.String schemaName)
getSchema
in interface HollowDataset
getSchema
in interface HollowStateEngine
public java.util.Map<java.lang.String,java.lang.String> getHeaderTags()
getHeaderTags
in interface HollowStateEngine
public void addHeaderTag(java.lang.String name, java.lang.String value)
public void addHeaderTags(java.util.Map<java.lang.String,java.lang.String> headerTags)
public java.lang.String getHeaderTag(java.lang.String name)
getHeaderTag
in interface HollowStateEngine
public HollowObjectHashCodeFinder getHashCodeFinder()
public long getPreviousStateRandomizedTag()
public void overridePreviousStateRandomizedTag(long previousStateRandomizedTag)
public long getNextStateRandomizedTag()
public void overrideNextStateRandomizedTag(long nextStateRandomizedTag)
public void setTargetMaxTypeShardSize(long targetMaxTypeShardSize)