com.hammurapi.store.local

## Class LocalStoreBase<T,PK,S extends Store<T,PK,S>>

- java.lang.Object
- - com.hammurapi.store.AbstractStore<T,PK,S>
  - - com.hammurapi.store.local.LocalStoreBase<T,PK,S>

- Type Parameters:
    `T` -
  All Implemented Interfaces:
    Store<T,PK,S>, Iterable<T>, ReadWriteLock
  Direct Known Subclasses:
    LocalStoreImpl

      public abstract class LocalStoreBase<T,PK,S extends Store<T,PK,S>>
      extends AbstractStore<T,PK,S>

  In-memory object store.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `LocalStoreBase.Config<T,PK,S extends Store<T,PK,S>>` Store configuration.

    - ### Nested classes/interfaces inherited from class com.hammurapi.store.AbstractStore

      `AbstractStore.ExtractorTask<V>, AbstractStore.IndexizationTask<V>, AbstractStore.QueryCallable<V>, AbstractStore.QueryItemCallable<V>, AbstractStore.QueryMultipleCallable<V>, AbstractStore.RemoveTask, AbstractStore.SelectorTask, AbstractStore.UpdateCallable, AbstractStore.ValueSelectorTask<V>`

    - ### Nested classes/interfaces inherited from interface com.hammurapi.store.Store

      `Store.Handle<T,PK,S extends Store<T,PK,S>>, Store.QueryTask<T,PK,S extends Store<?,PK,S>>, Store.StoreIterator<T>, Store.UpdateTask<T,PK,S extends Store<T,PK,S>>, Store.ViewType`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected LocalStoreBase.Config<T,PK,S>` | `config`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `LocalStoreBase(LocalStoreBase.Config<T,PK,S> config)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Map<S,Map<Extractor<T,? super PK,S>,? super PK>>` | `createCache()`
    `protected abstract S` | `createDeputy()` Creates a store which encapsulates current call state (e.g.
    `protected Store.Handle<T,PK,S>` | `createHandle(T obj, PK primaryKey, Map<S,Map<Extractor<T,? super PK,S>,? super PK>> cache, Predicate<T,S>[] validators)` Creates handle.
    `protected <V,ST extends T> AbstractIndex<T,ST,PK,V,S>` | `createIndex(Predicate<T,S> predicate, Extractor<ST,V,S> extractor, Index.Type type, boolean ordered, Comparator<V> comparator)`
    `protected Collection<Store.Handle<T,PK,S>>` | `createIndexCollection(boolean unique, boolean ordered, Comparator<T> comparator)` Creates collection for index entries
    `protected ReadWriteLock` | `createMasterLock()`
    `protected ExecutorService` | `getExecutorService()`
    `protected Collection<AbstractIndex<T,? extends T,PK,?,S>>` | `getIndices()`
    `protected Collection<Store.Handle<T,PK,S>>` | `getNoPkStore()` Store for the mode without primary key or pkStore values collection.
    `protected Map<PK,Store.Handle<T,PK,S>>` | `getPkStore()`
    `Extractor<T,PK,S>` | `getPrimaryKeyExtractor()` If primary key is set, then the store shall use equals on the value returned from the primaryKeyExtractor instead of equals on the object to compare objects for removal and update (put).
    `protected void` | `handleIndexAsynchException(Exception e)`
    `protected void` | `onRemoved(int removed)` If there is a lot of cleared handles this method posts a task to compact store collections..
    `Lock` | `readLock()`
    `protected void` | `updateIndices(Store.Handle<T,PK,S> handle, boolean isNew)` To make it visible to LocalHandle.
    `Lock` | `writeLock()`

    - ### Methods inherited from class com.hammurapi.store.AbstractStore

      `addIndex, clear, createHandle, createLiveView, createView, get, get, getAll, getByPrimaryKey, getHandles, getMultiple, iterator, put, query, query, queryAll, queryMultiple, remove, remove, removeByPrimaryKey, update`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.hammurapi.store.Store

      `createUnmodifiableFacade`

- - ### Field Detail

    - #### config

          protected LocalStoreBase.Config<T,PK,S extends Store<T,PK,S>> config

  - ### Constructor Detail

    - #### LocalStoreBase

          protected LocalStoreBase(LocalStoreBase.Config<T,PK,S> config)

  - ### Method Detail

    - #### readLock

          public Lock readLock()

    - #### writeLock

          public Lock writeLock()

    - #### getPkStore

          protected Map<PK,Store.Handle<T,PK,S>> getPkStore()

      Specified by:
        `getPkStore` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`
      Returns:
        Store for the mode with primary key.

    - #### getNoPkStore

          protected Collection<Store.Handle<T,PK,S>> getNoPkStore()

      Description copied from class: `AbstractStore`
      Store for the mode without primary key or pkStore values collection.
      Specified by:
        `getNoPkStore` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`

    - #### getExecutorService

          protected ExecutorService getExecutorService()

      Specified by:
        `getExecutorService` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`
      Returns:
        Executor service to parallel processing.

    - #### createHandle

          protected Store.Handle<T,PK,S> createHandle(T obj,
                                          PK primaryKey,
                                          Map<S,Map<Extractor<T,? super PK,S>,? super PK>> cache,
                                          Predicate<T,S>[] validators)

      Description copied from class: `AbstractStore`
      Creates handle.
      Specified by:
        `createHandle` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`

    - #### createIndexCollection

          protected Collection<Store.Handle<T,PK,S>> createIndexCollection(boolean unique,
                                                               boolean ordered,
                                                               Comparator<T> comparator)

      Description copied from class: `AbstractStore`
      Creates collection for index entries
      Specified by:
        `createIndexCollection` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`
      Parameters:
        `unique` - Collection should be unique (set)
        `ordered` - Collection should be ordered by the comparator or by natural order.
      Returns:

    - #### createCache

          protected Map<S,Map<Extractor<T,? super PK,S>,? super PK>> createCache()

      Specified by:
        `createCache` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`
      Returns:
        Cache for extractors.

    - #### createMasterLock

          protected ReadWriteLock createMasterLock()

      Specified by:
        `createMasterLock` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`

    - #### onRemoved

          protected void onRemoved(int removed)

      If there is a lot of cleared handles this method posts a task to compact store collections..
      Specified by:
        `onRemoved` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`
      Parameters:
        `removed` - Number of removed handles.

    - #### getPrimaryKeyExtractor

          public Extractor<T,PK,S> getPrimaryKeyExtractor()

      Description copied from interface: `Store`
      If primary key is set, then the store shall use equals on the value returned from the primaryKeyExtractor instead of equals on the object to compare objects for removal and update (put).

    - #### getIndices

          protected Collection<AbstractIndex<T,? extends T,PK,?,S>> getIndices()

      Specified by:
        `getIndices` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`

    - #### createIndex

          protected <V,ST extends T> AbstractIndex<T,ST,PK,V,S> createIndex(Predicate<T,S> predicate,
                                                                Extractor<ST,V,S> extractor,
                                                                Index.Type type,
                                                                boolean ordered,
                                                                Comparator<V> comparator)

      Specified by:
        `createIndex` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`

    - #### handleIndexAsynchException

          protected void handleIndexAsynchException(Exception e)

    - #### updateIndices

          protected void updateIndices(Store.Handle<T,PK,S> handle,
                           boolean isNew)

      To make it visible to LocalHandle.
      Overrides:
        `updateIndices` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`

    - #### createDeputy

          protected abstract S createDeputy()

      Description copied from class: `AbstractStore`
      Creates a store which encapsulates current call state (e.g. locks currently held) and can be passed to executor for asynchronous execution. Delegates operate on behalf of the master store. They don't acquire locks if the master store already holds them. If the master store holds read lock then attempt of a deputy to acquire write lock will result in StoreException.
      Specified by:
        `createDeputy` in class `AbstractStore<T,PK,S extends Store<T,PK,S>>`
      Returns: