Class AbstractMapStore<K,V>

java.lang.Object
org.datanucleus.store.rdbms.scostore.BaseContainerStore
org.datanucleus.store.rdbms.scostore.AbstractMapStore<K,V>
All Implemented Interfaces:
org.datanucleus.store.types.scostore.MapStore<K,V>, org.datanucleus.store.types.scostore.Store
Direct Known Subclasses:
FKMapStore, JoinMapStore

public abstract class AbstractMapStore<K,V> extends BaseContainerStore implements org.datanucleus.store.types.scostore.MapStore<K,V>
Abstract representation of the backing store for a Map.
  • Field Details

    • iterateUsingDiscriminator

      protected boolean iterateUsingDiscriminator
      Flag to set whether the iterator statement will use a discriminator or not.
    • keyCmd

      protected org.datanucleus.metadata.AbstractClassMetaData keyCmd
      Metadata for the keys (if persistable).
    • valueCmd

      protected org.datanucleus.metadata.AbstractClassMetaData valueCmd
      Metadata for the values (if persistable).
    • keyMapping

      protected JavaTypeMapping keyMapping
      Mapping to the key from the mapTable.
    • valueMapping

      protected JavaTypeMapping valueMapping
      Mapping to the value from the mapTable.
    • keyType

      protected String keyType
      Type of the key.
    • valueType

      protected String valueType
      Type of the value.
    • keysAreEmbedded

      protected boolean keysAreEmbedded
      Whether the keys are embedded.
    • keysAreSerialised

      protected boolean keysAreSerialised
      Whether the keys are serialised.
    • valuesAreEmbedded

      protected boolean valuesAreEmbedded
      Whether the values are embedded.
    • valuesAreSerialised

      protected boolean valuesAreSerialised
      Whether the values are serialised.
    • containsValueStmt

      protected String containsValueStmt
  • Constructor Details

    • AbstractMapStore

      public AbstractMapStore(RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
  • Method Details

    • getValueMapping

      public JavaTypeMapping getValueMapping()
    • getKeyMapping

      public JavaTypeMapping getKeyMapping()
    • getKeyClassMetaData

      public org.datanucleus.metadata.AbstractClassMetaData getKeyClassMetaData()
    • getValueClassMetaData

      public org.datanucleus.metadata.AbstractClassMetaData getValueClassMetaData()
    • keysAreEmbedded

      public boolean keysAreEmbedded()
      Accessor for whether the keys are embedded or not. If they are PC instances then returns false;
      Specified by:
      keysAreEmbedded in interface org.datanucleus.store.types.scostore.MapStore<K,V>
      Returns:
      Whether the keys are embedded
    • keysAreSerialised

      public boolean keysAreSerialised()
      Accessor for whether the keys are serialised or not. If they are PC instances then returns false;
      Specified by:
      keysAreSerialised in interface org.datanucleus.store.types.scostore.MapStore<K,V>
      Returns:
      Whether the keys are serialised
    • valuesAreEmbedded

      public boolean valuesAreEmbedded()
      Accessor for whether the values are embedded or not. If they are PC instances then returns false;
      Specified by:
      valuesAreEmbedded in interface org.datanucleus.store.types.scostore.MapStore<K,V>
      Returns:
      Whether the values are embedded
    • valuesAreSerialised

      public boolean valuesAreSerialised()
      Accessor for whether the values are serialised or not. If they are PC instances then returns false;
      Specified by:
      valuesAreSerialised in interface org.datanucleus.store.types.scostore.MapStore<K,V>
      Returns:
      Whether the values are serialised
    • containsKey

      public boolean containsKey(org.datanucleus.state.DNStateManager sm, Object key)
      Specified by:
      containsKey in interface org.datanucleus.store.types.scostore.MapStore<K,V>
    • containsValue

      public boolean containsValue(org.datanucleus.state.DNStateManager sm, Object value)
      Specified by:
      containsValue in interface org.datanucleus.store.types.scostore.MapStore<K,V>
    • get

      public V get(org.datanucleus.state.DNStateManager sm, Object key)
      Specified by:
      get in interface org.datanucleus.store.types.scostore.MapStore<K,V>
    • putAll

      public void putAll(org.datanucleus.state.DNStateManager sm, Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface org.datanucleus.store.types.scostore.MapStore<K,V>
    • validateKeyType

      protected void validateKeyType(org.datanucleus.ClassLoaderResolver clr, Object key)
      Utility to validate the type of a key for storing in the Map.
      Parameters:
      clr - The ClassLoaderResolver
      key - The key to check.
    • validateValueType

      protected void validateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)
      Utility to validate the type of a value for storing in the Map.
      Parameters:
      clr - The ClassLoaderResolver
      value - The value to check.
    • validateKeyForReading

      protected boolean validateKeyForReading(org.datanucleus.state.DNStateManager sm, Object key)
      Utility to validate a key is ok for reading.
      Parameters:
      sm - StateManager for the map.
      key - The key to check.
      Returns:
      Whether it is validated.
    • validateValueForReading

      protected boolean validateValueForReading(org.datanucleus.state.DNStateManager sm, Object value)
      Utility to validate a value is ok for reading.
      Parameters:
      sm - StateManager for the map.
      value - The value to check.
      Returns:
      Whether it is validated.
    • validateKeyForWriting

      protected void validateKeyForWriting(org.datanucleus.state.DNStateManager ownerSM, Object key)
      Utility to validate a key is ok for writing (present in the datastore).
      Parameters:
      ownerSM - StateManager for the owner of the map
      key - The key to check.
    • validateValueForWriting

      protected void validateValueForWriting(org.datanucleus.state.DNStateManager ownerSM, Object value)
      Utility to validate a value is ok for writing (present in the datastore).
      Parameters:
      ownerSM - StateManager for the owner of the map
      value - The value to check.
    • getValue

      protected abstract V getValue(org.datanucleus.state.DNStateManager sm, Object key) throws NoSuchElementException
      Method to retrieve a value from the Map given the key.
      Parameters:
      sm - StateManager for the map.
      key - The key to retrieve the value for.
      Returns:
      The value for this key
      Throws:
      NoSuchElementException - if the value for the key was not found
    • getContainsValueStmt

      protected static String getContainsValueStmt(JavaTypeMapping ownerMapping, JavaTypeMapping valueMapping, Table mapTable)
      Generate statement to check if a value is contained in the Map.
       SELECT OWNERCOL
       FROM MAPTABLE
       WHERE OWNERCOL=? AND VALUECOL = ?
       
      Parameters:
      ownerMapping - the owner mapping
      valueMapping - the value mapping
      mapTable - the map table
      Returns:
      Statement to check if a value is contained in the Map.