Class InMemoryStorage<ModelOutput_ extends ModelOutput>

java.lang.Object
ai.timefold.solver.service.definition.impl.storage.inmemory.InMemoryStorage<ModelOutput_>
All Implemented Interfaces:
Storage<ModelOutput_>

public abstract class InMemoryStorage<ModelOutput_ extends ModelOutput> extends Object implements Storage<ModelOutput_>
  • Constructor Details

    • InMemoryStorage

      public InMemoryStorage()
    • InMemoryStorage

      public InMemoryStorage(com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details

    • store

      public void store(StorageAddress options, String id, ModelOutput_ dataset)
      Description copied from interface: Storage
      Stores given data set into location defined by StorageOptions
      Specified by:
      store in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      dataset - data set to be stored
    • update

      public void update(StorageAddress options, String id, ModelOutput_ dataset)
      Description copied from interface: Storage
      Updates existing data set in the storage into location defined by StorageOptions
      Specified by:
      update in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      dataset - data set to be stored
    • complete

      public void complete(StorageAddress options, String id, ModelOutput_ dataset)
      Description copied from interface: Storage
      Final update of the data set upon completion of solving into location defined by StorageOptions
      Specified by:
      complete in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      dataset - data set to be stored
    • get

      public ModelOutput_ get(StorageAddress options, String id)
      Description copied from interface: Storage
      Retrieves data set by its unique identifier from location defined by StorageOptions
      Specified by:
      get in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      Returns:
      loaded data set if found
    • delete

      public void delete(StorageAddress options, String id)
      Description copied from interface: Storage
      Deletes data set with given identifier from location defined by StorageOptions
      Specified by:
      delete in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
    • restore

      public void restore(StorageAddress options, String id)
      Description copied from interface: Storage
      Restores previously deleted data set with given identifier from location defined by StorageOptions
      Specified by:
      restore in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
    • exists

      public boolean exists(StorageAddress options, String id)
      Description copied from interface: Storage
      Checks if data set with given identifier exists in the location defined by StorageOptions
      Specified by:
      exists in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      Returns:
      true if exists false otherwise
    • list

      public List<Metadata> list(StorageAddress options, int pageNumber, int pageSize)
      Description copied from interface: Storage
      Lists data sets (as statuses) stored in the location defined by StorageOptions
      Specified by:
      list in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      pageNumber - number of page to return (0-based)
      pageSize - number of data sets to return per page
      Returns:
      non null list of found data sets as statuses
    • getSubModel

      public <T> T getSubModel(StorageAddress options, String id, SubModelKind kind, Class<T> clazz)
      Description copied from interface: Storage
      Retrieves sub resource associated with data set with given identifier in the location defined by StorageOptions
      Specified by:
      getSubModel in interface Storage<ModelOutput_ extends ModelOutput>
      Type Parameters:
      T - type representing the returned value
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      kind - kind of the sub resource e.g. waypoints
      clazz - class that the sub resource should be unmarshalled
      Returns:
      loaded sub resource or null if no sub resource found
    • storeSubModel

      public void storeSubModel(StorageAddress options, String id, SubModelKind kind, Object subModel)
      Description copied from interface: Storage
      Stores sub resource associated with given data set given by identifier in the location defined by StorageOptions
      Specified by:
      storeSubModel in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      kind - kind of the sub resource e.g. waypoints
      subModel - the sub resource to be stored
    • updateSubModel

      public void updateSubModel(StorageAddress options, String id, SubModelKind subModelKind, Object subModel)
      Description copied from interface: Storage
      Stores sub resource associated with given data set given by identifier in the location defined by StorageOptions
      Specified by:
      updateSubModel in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      subModelKind - kind of the sub resource e.g. waypoints
      subModel - the sub resource to be stored
    • existsSubModel

      public boolean existsSubModel(StorageAddress options, String id, SubModelKind kind)
      Description copied from interface: Storage
      Checks if data set with given identifier exists in the location defined by StorageOptions
      Specified by:
      existsSubModel in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      kind - type of sub model
      Returns:
      true if exists false otherwise
    • getSubModelStream

      public void getSubModelStream(StorageAddress options, String id, SubModelKind subModelKind, OutputStream output)
      Description copied from interface: Storage
      Retrieves sub resource associated with data set with given identifier in the default location in the underlying data store as a stream of data
      Specified by:
      getSubModelStream in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
      id - unique identifier of the data set
      subModelKind - kind of the sub resource e.g. waypoints
      output - output stream where data should be written
    • clean

      public void clean(StorageAddress options)
      Description copied from interface: Storage
      Cleans up the storage starting in the location defined by StorageOptions. Removes all resources regardless of their type e.g. data sets, waypoints etc
      Specified by:
      clean in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      options - storage option to apply during the operation
    • create

      public void create(String location, StorageConfiguration configuration)
      Description copied from interface: Storage
      Create required data store specific settings to be able to storage data in given location.
      Specified by:
      create in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      location - named location to be created in the underlying storage e.g. name of the bucket
      configuration - storage specific configuration
    • reconfigure

      public void reconfigure(String location, StorageConfiguration configuration)
      Description copied from interface: Storage
      Reconfigures already existing storage based on provided configuration
      Specified by:
      reconfigure in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      location - named location to be reconfigured in the underlying storage e.g. name of the bucket
      configuration - storage specific configuration
    • destroy

      public void destroy(String id)
      Description copied from interface: Storage
      Destroy data store specific settings, this will also remove all data stored under given location
      Specified by:
      destroy in interface Storage<ModelOutput_ extends ModelOutput>
      Parameters:
      id - named location to be destroyed in the underlying storage e.g. name of the bucket
    • getSubModel

      public <T> T getSubModel(StorageAddress options, String id, SubModelKind kind, com.fasterxml.jackson.core.type.TypeReference<T> configurationClass)
      Specified by:
      getSubModel in interface Storage<ModelOutput_ extends ModelOutput>