public final class MemoryUsageSetting
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private long |
maxMainMemoryBytes
maximum number of main-memory bytes allowed to be used;
-1 means 'unrestricted' |
private long |
maxStorageBytes
maximum number of bytes allowed for storage at all (main-memory+file);
-1 means 'unrestricted' |
private java.io.File |
tempDir
directory to be used for scratch file
|
private boolean |
useMainMemory |
private boolean |
useTempFile |
Modifier | Constructor and Description |
---|---|
private |
MemoryUsageSetting(boolean useMainMemory,
boolean useTempFile,
long maxMainMemoryBytes,
long maxStorageBytes)
Private constructor for setup buffering memory usage called by one of the setup methods.
|
Modifier and Type | Method and Description |
---|---|
long |
getMaxMainMemoryBytes()
Returns maximum size of main-memory in bytes to be used.
|
long |
getMaxStorageBytes()
Returns maximum size of storage bytes to be used
(main-memory in temporary files all together).
|
MemoryUsageSetting |
getPartitionedCopy(int parallelUseCount)
Returns a copy of this instance with the maximum memory/storage restriction
divided by the provided number of parallel uses.
|
java.io.File |
getTempDir()
Returns directory to be used for temporary files or
null
if it was not set. |
boolean |
isMainMemoryRestricted()
Returns
true if maximum main memory is restricted to a specific
number of bytes. |
boolean |
isStorageRestricted()
Returns
true if maximum amount of storage is restricted to a specific
number of bytes. |
MemoryUsageSetting |
setTempDir(java.io.File tempDir)
Sets directory to be used for temporary files.
|
static MemoryUsageSetting |
setupMainMemoryOnly()
Setups buffering memory usage to only use main-memory (no temporary file)
which is not restricted in size.
|
static MemoryUsageSetting |
setupMainMemoryOnly(long maxMainMemoryBytes)
Setups buffering memory usage to only use main-memory with the defined maximum.
|
static MemoryUsageSetting |
setupMixed(long maxMainMemoryBytes)
Setups buffering memory usage to use a portion of main-memory and additionally
temporary file(s) in case the specified portion is exceeded.
|
static MemoryUsageSetting |
setupMixed(long maxMainMemoryBytes,
long maxStorageBytes)
Setups buffering memory usage to use a portion of main-memory and additionally
temporary file(s) in case the specified portion is exceeded.
|
static MemoryUsageSetting |
setupTempFileOnly()
Setups buffering memory usage to only use temporary file(s) (no main-memory)
with not restricted size.
|
static MemoryUsageSetting |
setupTempFileOnly(long maxStorageBytes)
Setups buffering memory usage to only use temporary file(s) (no main-memory)
with the specified maximum size.
|
java.lang.String |
toString() |
boolean |
useMainMemory()
Returns
true if main-memory is to be used. |
boolean |
useTempFile()
Returns
true if temporary file is to be used. |
private final boolean useMainMemory
private final boolean useTempFile
private final long maxMainMemoryBytes
-1
means 'unrestricted'private final long maxStorageBytes
-1
means 'unrestricted'private java.io.File tempDir
private MemoryUsageSetting(boolean useMainMemory, boolean useTempFile, long maxMainMemoryBytes, long maxStorageBytes)
useMainMemory
- if true
main memory usage is enabled; in case of
false
and useTempFile
is false
too
we set this to true
useTempFile
- if true
using of temporary file(s) is enabledmaxMainMemoryBytes
- maximum number of main-memory to be used;
if -1
means 'unrestricted';
if 0
we only use temporary file if useTempFile
is true
otherwise main-memory usage will have restriction
defined by maxStorageBytesmaxStorageBytes
- maximum size the main-memory and temporary file(s) may have all together;
0
or less will be ignored; if it is less than
maxMainMemoryBytes we use maxMainMemoryBytes value insteadpublic static MemoryUsageSetting setupMainMemoryOnly()
public static MemoryUsageSetting setupMainMemoryOnly(long maxMainMemoryBytes)
maxMainMemoryBytes
- maximum number of main-memory to be used;
-1
for no restriction;
0
will also be interpreted here as no restrictionpublic static MemoryUsageSetting setupTempFileOnly()
public static MemoryUsageSetting setupTempFileOnly(long maxStorageBytes)
maxStorageBytes
- maximum size the temporary file(s) may have all together;
-1
for no restriction;
0
will also be interpreted here as no restrictionpublic static MemoryUsageSetting setupMixed(long maxMainMemoryBytes)
maxMainMemoryBytes
- maximum number of main-memory to be used;
if -1
this is the same as setupMainMemoryOnly()
;
if 0
this is the same as setupTempFileOnly()
public static MemoryUsageSetting setupMixed(long maxMainMemoryBytes, long maxStorageBytes)
maxMainMemoryBytes
- maximum number of main-memory to be used;
if -1
this is the same as setupMainMemoryOnly()
;
if 0
this is the same as setupTempFileOnly()
maxStorageBytes
- maximum size the main-memory and temporary file(s) may have all together;
0
or less will be ignored; if it is less than
maxMainMemoryBytes we use maxMainMemoryBytes value insteadpublic MemoryUsageSetting getPartitionedCopy(int parallelUseCount)
parallelUseCount
- specifies the number of parallel usages for the setting to
be returnedpublic MemoryUsageSetting setTempDir(java.io.File tempDir)
tempDir
- directory for temporary filespublic boolean useMainMemory()
true
if main-memory is to be used.
If this returns false
it is ensured useTempFile()
returns true
.
public boolean useTempFile()
true
if temporary file is to be used.
If this returns false
it is ensured useMainMemory
returns true
.
public boolean isMainMemoryRestricted()
true
if maximum main memory is restricted to a specific
number of bytes.public boolean isStorageRestricted()
true
if maximum amount of storage is restricted to a specific
number of bytes.public long getMaxMainMemoryBytes()
public long getMaxStorageBytes()
public java.io.File getTempDir()
null
if it was not set.public java.lang.String toString()
toString
in class java.lang.Object