Interface ChangeDataStore

  • All Known Implementing Classes:
    FileChangeDataStore, LazyChangeDataStore

    public interface ChangeDataStore
    Stores and retrieves ChangeData objects keyed by a pair: - the id of the change it belongs to - a string id for which part of the change it represents (such that changes can potentially register multiple change data)

    A serializer is provided for both methods if they want to store the change data physically somewhere.

    • Method Detail

      • store

        <T> void store​(ChangeData<T> data,
                       ChangeDataId changeDataId,
                       ChangeDataSerializer<T> serializer,
                       Optional<ProgressReporter> progressReporter)
                throws IOException
        Stores a ChangeData, which might imply explicitly computing all its values (if the store persists its changes).
        Parameters:
        data - the data to store
        changeDataId - the id of the change data to store
        serializer - to serialize the data to a file, for instance
        progressReporter - reports the progress of the change data computation and serialization
        Throws:
        IOException - if serialization failed
      • storeAsync

        <T> ProgressingFuture<Void> storeAsync​(ChangeData<T> data,
                                               ChangeDataId changeDataId,
                                               ChangeDataSerializer<T> serializer)
        Asynchronously stores a ChangeData, which might imply explicitly computing all its values (if the store persists its changes).
        Parameters:
        data - the data to store
        changeDataId - the id of the change data to store
        serializer - to serialize the data to a file, for instance
      • retrieveOrCompute

        <T> ChangeData<T> retrieveOrCompute​(ChangeDataId changeDataId,
                                            ChangeDataSerializer<T> serializer,
                                            Function<Optional<ChangeData<T>>,​ChangeData<T>> completionProcess,
                                            String description)
                                     throws IOException
        Retrieves a change data if it exists already, and if it does not (or is incomplete), start a process to finish computing it.
        Parameters:
        changeDataId - the id of the change data to retrieve
        serializer - the serializer to read it back from a file and to write its completion if it is incomplete
        completionProcess - a function taking the existing state of the change data and returning the complete version
        description - a description of the completion process, to be reported to the user
        Throws:
        IOException
      • needsRefreshing

        boolean needsRefreshing​(long historyEntryId)
        Returns true when a change data object is being fetched by a process and should therefore be refreshed as the process may have refreshed the contents on disk.
      • getChangeDataIds

        List<ChangeDataId> getChangeDataIds​(long historyEntryId)
        Retrieve the list of change data ids associated with a given history entry.
      • discardAll

        void discardAll​(long historyEntryId)
        Discards all change data objects which belong to a given history entry id.
      • dispose

        void dispose()
        Stops all the processes and shuts down the thread pool.