Class AbstractDataStorageBuilder
- All Implemented Interfaces:
DataStorageBuilder
- Direct Known Subclasses:
DoubleDataStorageBuilder
,FloatDataStorageBuilder
,IntDataStorageBuilder
,LongDataStorageBuilder
ApfloatContext
, different types of data storages
are created.- Since:
- 1.7.0
- Version:
- 1.8.2
- Author:
- Mikko Tommila
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DataStorage
Create a cached data storage.createCachedDataStorage
(long size) Get a data storage that is cached in memory, if possible, for the requested size of data.createDataStorage
(long size) Get an appropriate type of data storage for the requested size of data.createDataStorage
(DataStorage dataStorage) Convert cached data storage to the appropriate normal data storage type.protected abstract DataStorage
Create a non-cached data storage.protected abstract long
Get the maximum cached data storage size.protected abstract boolean
isCached
(DataStorage dataStorage) Test if the data storage is of cached type.
-
Constructor Details
-
AbstractDataStorageBuilder
protected AbstractDataStorageBuilder()Subclass constructor.
-
-
Method Details
-
createDataStorage
Description copied from interface:DataStorageBuilder
Get an appropriate type of data storage for the requested size of data.Note that the returned data storage object is not set to have the requested size, so the client should call the object's
DataStorage.setSize(long)
method before storing data to it.- Specified by:
createDataStorage
in interfaceDataStorageBuilder
- Parameters:
size
- The size of data to be stored in the storage, in bytes.- Returns:
- An empty
DataStorage
object of an appropriate type for storingsize
bytes of data. - Throws:
ApfloatRuntimeException
-
createCachedDataStorage
Description copied from interface:DataStorageBuilder
Get a data storage that is cached in memory, if possible, for the requested size of data.Note that the returned data storage object is not set to have the requested size, so the client should call the object's
DataStorage.setSize(long)
method before storing data to it.- Specified by:
createCachedDataStorage
in interfaceDataStorageBuilder
- Parameters:
size
- The size of data to be stored in the storage, in bytes.- Returns:
- An empty
DataStorage
object of an appropriate type for storingsize
bytes of data, cached if possible. - Throws:
ApfloatRuntimeException
-
createDataStorage
Description copied from interface:DataStorageBuilder
Convert cached data storage to the appropriate normal data storage type.If the data storage already has the appropriate type for its size, the data storage may be returned unchanged. The argument data storage does not necessarily have to be created with the
DataStorageBuilder.createCachedDataStorage(long)
method, it can be created as well with theDataStorageBuilder.createDataStorage(long)
method.If the given data storage does not have the appropriate type for its size, then a new data storage of the appropriate type is created and the data is copied to it.
- Specified by:
createDataStorage
in interfaceDataStorageBuilder
- Parameters:
dataStorage
- The data storage to be converted, if necessary.- Returns:
- A
DataStorage
that can be the original data storage or a copy of it, with the appropriate type. - Throws:
ApfloatRuntimeException
-
getMaxCachedSize
protected abstract long getMaxCachedSize()Get the maximum cached data storage size.- Returns:
- The maximum cached data storage size.
-
createCachedDataStorage
Create a cached data storage.- Returns:
- A new cached data storage.
- Throws:
ApfloatRuntimeException
-
createNonCachedDataStorage
Create a non-cached data storage.- Returns:
- A new non-cached data storage.
- Throws:
ApfloatRuntimeException
-
isCached
Test if the data storage is of cached type.- Parameters:
dataStorage
- The data storage.- Returns:
- If the data storage is cached.
- Throws:
ApfloatRuntimeException
-