public class AtomicBlockAppendProc extends Object implements ISimpleIndexProcedure<Object>, Externalizable
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEBUG
True iff the
log level is DEBUG or less. |
protected static boolean |
INFO
True iff the
log level is INFO or less. |
protected static org.apache.log4j.Logger |
log |
Constructor and Description |
---|
AtomicBlockAppendProc(BigdataFileSystem repo,
String id,
int version,
byte[] b,
int off,
int len) |
Modifier and Type | Method and Description |
---|---|
Object |
apply(IIndex ndx)
This procedure runs on the unisolated index.
|
protected long |
getNextBlockFromPriorKey(IKeyBuilder keyBuilder,
byte[] key)
Decode the block identifier in the key and return the block
identifier plus one, which is the block identifier to be used for the
atomic append operation.
|
protected long |
getNextBlockIdentifierInFileVersion(IIndex ndx,
IKeyBuilder keyBuilder)
Find the key for the last block written for this file version.
|
protected long |
getNextBlockIdentifierInFileVersion2(IIndex ndx,
IKeyBuilder keyBuilder)
Find the key for the last block written for this file version.
|
boolean |
isReadOnly()
Return
true iff the procedure asserts that it will not
write on the index. |
void |
readExternal(ObjectInput in) |
void |
writeExternal(ObjectOutput out) |
protected static transient org.apache.log4j.Logger log
protected static final transient boolean INFO
log
level is INFO or less.protected static final transient boolean DEBUG
log
level is DEBUG or less.public AtomicBlockAppendProc(BigdataFileSystem repo, String id, int version, byte[] b, int off, int len)
id
- The file identifier.version
- The file version.b
- The buffer containing the data to be written.off
- The offset in the buffer of the first byte to be written.len
- The #of bytes to be written.public final boolean isReadOnly()
IReadOnly
true
iff the procedure asserts that it will not
write on the index. When true
, the procedure may be run
against a view of the index that is read-only or which allows concurrent
processes to read on the same index object. When false
the
procedure will be run against a mutable view of the index (assuming that
the procedure is executed in a context that has access to a mutable index
view).isReadOnly
in interface IReadOnly
public Object apply(IIndex ndx)
Journal
and an index entry is added for the file,
version, and block whose value is the address of the block's data on
the Journal
.
Note: The caller MUST have correctly identified the data service on which the tail of the file exists (or on which the head of the file will be written).
The block identifier is computed by reading and decoding the key for the last block written for this file version (if any). Special cases exist when the file version spans more than one index partition, when the block would be the first block (in key order) for the index partition, and when the block would be the last block (in key order) for the index partition.
apply
in interface IIndexProcedure<Object>
ndx
- The index.true
iff the block was overwritten.protected long getNextBlockIdentifierInFileVersion2(IIndex ndx, IKeyBuilder keyBuilder)
Note: This implementation uses an IRangeQuery.REVERSE
iterator to
locate the last block in the file and is capable of scale-out.
ndx
- keyBuilder
- protected long getNextBlockIdentifierInFileVersion(IIndex ndx, IKeyBuilder keyBuilder)
Note: This implementation uses the ILinearList
API to locate the
last block in the file and is NOT capable of scale-out since that API is
NOT available for an index partition view (a FusedView
).
protected long getNextBlockFromPriorKey(IKeyBuilder keyBuilder, byte[] key)
keyBuilder
- The key builder.key
- The key - either from the index partition or in some cases
from the leftSeparator of the index partition metadata.
Note that the leftSeparator MAY be an empty byte[] (e.g., for the 1st index partition in the key order) and MIGHT NOT include the block identifier (the block identifier is only included when it is necessary to split a file across index partitions). When the block identifier is omitted from the key and the key encodes the same file and version we therefore use zero (0L) as the next block identifier since we will be appending the first block to the file version.
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.