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 DataStorageCreate 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 DataStorageCreate a non-cached data storage.protected abstract longGet the maximum cached data storage size.protected abstract booleanisCached(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:DataStorageBuilderGet 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:
createDataStoragein interfaceDataStorageBuilder- Parameters:
size- The size of data to be stored in the storage, in bytes.- Returns:
- An empty
DataStorageobject of an appropriate type for storingsizebytes of data. - Throws:
ApfloatRuntimeException
-
createCachedDataStorage
Description copied from interface:DataStorageBuilderGet 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:
createCachedDataStoragein interfaceDataStorageBuilder- Parameters:
size- The size of data to be stored in the storage, in bytes.- Returns:
- An empty
DataStorageobject of an appropriate type for storingsizebytes of data, cached if possible. - Throws:
ApfloatRuntimeException
-
createDataStorage
Description copied from interface:DataStorageBuilderConvert 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:
createDataStoragein interfaceDataStorageBuilder- Parameters:
dataStorage- The data storage to be converted, if necessary.- Returns:
- A
DataStoragethat 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
-