public class DirectStore extends Object implements BytesStore, AutoCloseable
Constructor and Description |
---|
DirectStore(long size) |
DirectStore(ObjectSerializer objectSerializer,
long size,
boolean zeroOut) |
Modifier and Type | Method and Description |
---|---|
long |
address() |
static DirectStore |
allocate(long size) |
static DirectStore |
allocateLazy(long size) |
static BytesStore |
allocateLazy(long sizeInBytes,
ObjectSerializer objectSerializer) |
DirectBytes |
bytes()
Create a bytes whose content is the whole bytes store.
|
DirectBytes |
bytes(long offset,
long length)
|
void |
close()
calls free
|
File |
file() |
void |
free() |
ObjectSerializer |
objectSerializer() |
void |
resize(long newSize,
boolean zeroOut)
Resizes this
DirectStore to the newSize . |
long |
size() |
public DirectStore(long size)
public DirectStore(ObjectSerializer objectSerializer, long size, boolean zeroOut)
@NotNull public static DirectStore allocate(long size)
@NotNull public static DirectStore allocateLazy(long size)
public static BytesStore allocateLazy(long sizeInBytes, ObjectSerializer objectSerializer)
public ObjectSerializer objectSerializer()
objectSerializer
in interface BytesStore
public void resize(long newSize, boolean zeroOut)
DirectStore
to the newSize
.
If zeroOut
is false
, the memory past the old size is not zeroed out and
will generally be garbage.
DirectStore
don't keep track of the child DirectBytes
instances, so after
the resize they might point to the wrong memory. Use at your own risk.
newSize
- new size of this DirectStore
zeroOut
- if the memory past the old size should be zeroed out on increasing resizeIllegalArgumentException
- if the newSize
is not positive@NotNull public DirectBytes bytes()
BytesStore
bytes(0, size())
call.bytes
in interface BytesStore
BytesStore.bytes(long, long)
@NotNull public DirectBytes bytes(long offset, long length)
BytesStore
Bytes
object with start address of
address
+ offset
and capacity of length
.
If this BytesStore
is Bytes
itself rather than natural
BytesStore
object, this method will offset the new bytes from the
bytes' start, not from bytes' position like
BytesCommon.slice(long, long)
.
offset
should be non-negative, length
should be positive,
offset + length
should be less or equal to size
.
bytes
in interface BytesStore
offset
- offset of the new bytes from the bytes store addresslength
- capacity and limit of the new bytesBytes
BytesStore.bytes()
public long address()
address
in interface BytesStore
public void free()
free
in interface BytesStore
public long size()
size
in interface BytesStore
public File file()
file
in interface BytesStore
public void close()
close
in interface AutoCloseable
Copyright © 2019. All rights reserved.