hollow/src/main/java/com/netflix/hollow/tools/history/HollowHistory.java
public void doubleSnapshotOccurred(HollowReadStateEngine newHollowStateEngine, long newVersion) {
        if(!keyIndex.isInitialized())
            keyIndex.update(latestHollowReadStateEngine, false);

        keyIndex.update(newHollowStateEngine, false);

        HollowHistoricalStateDataAccess historicalDataAccess;

        DiffEqualityMapping mapping = new DiffEqualityMapping(latestHollowReadStateEngine, newHollowStateEngine, true, !ignoreListOrderingOnDoubleSnapshot);
        DiffEqualityMappingOrdinalRemapper remapper = new DiffEqualityMappingOrdinalRemapper(mapping);

        historicalDataAccess = creator.createHistoricalStateFromDoubleSnapshot(latestVersion, latestHollowReadStateEngine, newHollowStateEngine, remapper);

        HollowHistoricalStateDataAccess nextRemappedDataAccess = historicalDataAccess;
        HollowHistoricalState nextRemappedState = null;

        HollowHistoricalStateDataAccess[] remappedDataAccesses = new HollowHistoricalStateDataAccess[historicalStates.size()];
        HollowHistoricalStateKeyOrdinalMapping[] remappedKeyOrdinalMappings = new HollowHistoricalStateKeyOrdinalMapping[historicalStates.size()];

        remapHistoricalStateOrdinals(remapper, remappedDataAccesses, remappedKeyOrdinalMappings);

        for(int i=0;i<historicalStates.size();i++) {
            HollowHistoricalState historicalStateToRemap = historicalStates.get(i);
            HollowHistoricalStateDataAccess remappedDataAccess = remappedDataAccesses[i];
            HollowHistoricalStateKeyOrdinalMapping remappedKeyOrdinalMapping = remappedKeyOrdinalMappings[i];

            remappedDataAccess.setNextState(nextRemappedDataAccess);
            nextRemappedDataAccess = remappedDataAccess;
            HollowHistoricalState remappedState = new HollowHistoricalState(historicalStateToRemap.getVersion(), remappedKeyOrdinalMapping, remappedDataAccess, historicalStateToRemap.getHeaderEntries());
            remappedState.setNextState(nextRemappedState);
            nextRemappedState = remappedState;
            historicalStates.set(i, remappedState);
            historicalStateLookupMap.put(remappedState.getVersion(), remappedState);
        }

        historicalDataAccess.setNextState(newHollowStateEngine);

        HollowHistoricalStateKeyOrdinalMapping keyOrdinalMapping = createKeyOrdinalMappingFromDoubleSnapshot(newHollowStateEngine, remapper);
        HollowHistoricalState historicalState = new HollowHistoricalState(newVersion, keyOrdinalMapping, historicalDataAccess, latestHeaderEntries);

        addHistoricalState(historicalState);
        this.latestVersion = newVersion;
        this.latestHollowReadStateEngine = newHollowStateEngine;
        this.latestHeaderEntries = latestHollowReadStateEngine.getHeaderTags();
    }
public void doubleSnapshotOccurred(HollowReadStateEngine newHollowStateEngine, long newVersion) {
        if(!keyIndex.isInitialized())
            keyIndex.update(latestHollowReadStateEngine, false);

        keyIndex.update(newHollowStateEngine, false);

        HollowHistoricalStateDataAccess historicalDataAccess;

        DiffEqualityMapping mapping = new DiffEqualityMapping(latestHollowReadStateEngine, newHollowStateEngine, true, !ignoreListOrderingOnDoubleSnapshot);
        DiffEqualityMappingOrdinalRemapper remapper = new DiffEqualityMappingOrdinalRemapper(mapping);

        historicalDataAccess = creator.createHistoricalStateFromDoubleSnapshot(latestVersion, latestHollowReadStateEngine, newHollowStateEngine, remapper);

        HollowHistoricalStateDataAccess nextRemappedDataAccess = historicalDataAccess;
        HollowHistoricalState nextRemappedState = null;

        HollowHistoricalStateDataAccess[] remappedDataAccesses = new HollowHistoricalStateDataAccess[historicalStates.size()];
        HollowHistoricalStateKeyOrdinalMapping[] remappedKeyOrdinalMappings = new HollowHistoricalStateKeyOrdinalMapping[historicalStates.size()];

        remapHistoricalStateOrdinals(remapper, remappedDataAccesses, remappedKeyOrdinalMappings);

        for(int i=0;i<historicalStates.size();i++) {
            HollowHistoricalState historicalStateToRemap = historicalStates.get(i);
            HollowHistoricalStateDataAccess remappedDataAccess = remappedDataAccesses[i];
            HollowHistoricalStateKeyOrdinalMapping remappedKeyOrdinalMapping = remappedKeyOrdinalMappings[i];

            remappedDataAccess.setNextState(nextRemappedDataAccess);
            nextRemappedDataAccess = remappedDataAccess;
            HollowHistoricalState remappedState = new HollowHistoricalState(historicalStateToRemap.getVersion(), remappedKeyOrdinalMapping, remappedDataAccess, historicalStateToRemap.getHeaderEntries());
            remappedState.setNextState(nextRemappedState);
            nextRemappedState = remappedState;
            historicalStates.set(i, remappedState);
            historicalStateLookupMap.put(remappedState.getVersion(), remappedState);
        }

        historicalDataAccess.setNextState(newHollowStateEngine);

        HollowHistoricalStateKeyOrdinalMapping keyOrdinalMapping = createKeyOrdinalMappingFromDoubleSnapshot(newHollowStateEngine, remapper);
        HollowHistoricalState historicalState = new HollowHistoricalState(newVersion, keyOrdinalMapping, historicalDataAccess, latestHeaderEntries);

        addHistoricalState(historicalState);
        this.latestVersion = newVersion;
        this.latestHollowReadStateEngine = newHollowStateEngine;
        this.latestHeaderEntries = latestHollowReadStateEngine.getHeaderTags();
    }
public void doubleSnapshotOccurred ( HollowReadStateEngine newHollowStateEngine , long newVersion ) { if ( ! keyIndex . isInitialized ( ) ) keyIndex . update ( latestHollowReadStateEngine , false ) ; keyIndex . update ( newHollowStateEngine , false ) ; HollowHistoricalStateDataAccess historicalDataAccess ; DiffEqualityMapping mapping = new DiffEqualityMapping ( latestHollowReadStateEngine , newHollowStateEngine , true , ! ignoreListOrderingOnDoubleSnapshot ) ; DiffEqualityMappingOrdinalRemapper remapper = new DiffEqualityMappingOrdinalRemapper ( mapping ) ; historicalDataAccess = creator . createHistoricalStateFromDoubleSnapshot ( latestVersion , latestHollowReadStateEngine , newHollowStateEngine , remapper ) ; HollowHistoricalStateDataAccess nextRemappedDataAccess = historicalDataAccess ; HollowHistoricalState nextRemappedState = null ; HollowHistoricalStateDataAccess [ ] remappedDataAccesses = new HollowHistoricalStateDataAccess [ historicalStates . size ( ) ] ; HollowHistoricalStateKeyOrdinalMapping [ ] remappedKeyOrdinalMappings = new HollowHistoricalStateKeyOrdinalMapping [ historicalStates . size ( ) ] ; remapHistoricalStateOrdinals ( remapper , remappedDataAccesses , remappedKeyOrdinalMappings ) ; for ( int i = 0 ; i < historicalStates . size ( ) ; i ++ ) { HollowHistoricalState historicalStateToRemap = historicalStates . get ( i ) ; HollowHistoricalStateDataAccess remappedDataAccess = remappedDataAccesses [ i ] ; HollowHistoricalStateKeyOrdinalMapping remappedKeyOrdinalMapping = remappedKeyOrdinalMappings [ i ] ; remappedDataAccess . setNextState ( nextRemappedDataAccess ) ; nextRemappedDataAccess = remappedDataAccess ; HollowHistoricalState remappedState = new HollowHistoricalState ( historicalStateToRemap . getVersion ( ) , remappedKeyOrdinalMapping , remappedDataAccess , historicalStateToRemap . getHeaderEntries ( ) ) ; remappedState . setNextState ( nextRemappedState ) ; nextRemappedState = remappedState ; historicalStates . set ( i , remappedState ) ; historicalStateLookupMap . put ( remappedState . getVersion ( ) , remappedState ) ; } historicalDataAccess . setNextState ( newHollowStateEngine ) ; HollowHistoricalStateKeyOrdinalMapping keyOrdinalMapping = createKeyOrdinalMappingFromDoubleSnapshot ( newHollowStateEngine , remapper ) ; HollowHistoricalState historicalState = new HollowHistoricalState ( newVersion , keyOrdinalMapping , historicalDataAccess , latestHeaderEntries ) ; addHistoricalState ( historicalState ) ; this . latestVersion = newVersion ; this . latestHollowReadStateEngine = newHollowStateEngine ; this . latestHeaderEntries = latestHollowReadStateEngine . getHeaderTags ( ) ; }
Call this method after each time a double snapshot occurs.
<p>
This method will replace the previous backing {@link HollowReadStateEngine} with the newly
supplied one, stitch together all of the existing history with the new state currently in the
new {@link HollowReadStateEngine}, and create a new {@link HollowHistoricalState} to represent
the transition.

@param newHollowStateEngine the new state engine
@param newVersion the new version
Call this method after each time a double snapshot occurs . <p > This method will replace the previous backing { @link HollowReadStateEngine } with the newly supplied one stitch together all of the existing history with the new state currently in the new { @link HollowReadStateEngine } and create a new { @link HollowHistoricalState } to represent the transition .