public abstract class AbstractKeyArrayIndexProcedure<T> extends AbstractIndexProcedure<T> implements IKeyArrayIndexProcedure<T>, Externalizable
IKeyArrayIndexProcedure
execution (procedures may be executed on a
local index, but they are only (de-)serialized when executed on a remote
index).(Schedule more IOs when loading data)
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
AbstractKeyArrayIndexProcedure.ResultBitBuffer
A class useful for sending a logical
boolean[] back from a
remote procedure call. |
static class |
AbstractKeyArrayIndexProcedure.ResultBitBufferCounter
Counts the #of
true bits in the AbstractKeyArrayIndexProcedure.ResultBitBuffer (s). |
static class |
AbstractKeyArrayIndexProcedure.ResultBitBufferHandler
Knows how to aggregate
AbstractKeyArrayIndexProcedure.ResultBitBuffer objects. |
static class |
AbstractKeyArrayIndexProcedure.ResultBuffer
A class useful for sending some kinds of data back from a remote
procedure call (those readily expressed as a
byte[][] ). |
static class |
AbstractKeyArrayIndexProcedure.ResultBufferHandler
Knows how to aggregate
AbstractKeyArrayIndexProcedure.ResultBuffer objects. |
Modifier | Constructor and Description |
---|---|
protected |
AbstractKeyArrayIndexProcedure()
De-serialization constructor.
|
protected |
AbstractKeyArrayIndexProcedure(IRabaCoder keysCoder,
IRabaCoder valsCoder,
int fromIndex,
int toIndex,
byte[][] keys,
byte[][] vals) |
Modifier and Type | Method and Description |
---|---|
T |
apply(IIndex ndx)
Applies the logic of the procedure.
|
protected abstract T |
applyOnce(IIndex ndx,
IRaba keys,
IRaba vals)
Apply the procedure to the specified key range of the index.
|
IRaba |
getKeys()
The keys.
|
protected IRabaCoder |
getKeysCoder()
The object used to (de-)code the keys when they are sent to the remote
service.
|
IRaba |
getValues()
The values.
|
protected IRabaCoder |
getValuesCoder()
The object used to (de-)code the values when they are sent to the remote
service.
|
protected abstract IResultHandler<T,T> |
newAggregator()
Return an
IResultHandler that will be used to combine the results
if the index procedure is parallelized against a local index (including a
scale-out shard). |
void |
readExternal(ObjectInput in) |
protected void |
readMetadata(ObjectInput in)
Reads metadata written by
writeMetadata(ObjectOutput) . |
void |
writeExternal(ObjectOutput out) |
protected void |
writeMetadata(ObjectOutput out)
Writes metadata (not the keys or values, but just other metadata used by
the procedure).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isReadOnly
protected AbstractKeyArrayIndexProcedure()
protected AbstractKeyArrayIndexProcedure(IRabaCoder keysCoder, IRabaCoder valsCoder, int fromIndex, int toIndex, byte[][] keys, byte[][] vals)
keysCoder
- The object used to serialize the keys.valsCoder
- The object used to serialize the vals (optional IFF
vals is null
).fromIndex
- The index of the first key in keys to be processed
(inclusive).toIndex
- The index of the last key in keys to be processed.keys
- The keys (unsigned variable length byte[]s) MUST
be in sorted order (the logic to split procedures across
partitioned indices depends on this, plus ordered reads and
writes on indices are MUCH more efficient).vals
- The values (optional, must be co-indexed with keys
when non-null
).protected IRabaCoder getKeysCoder()
protected IRabaCoder getValuesCoder()
public final IRaba getKeys()
IKeyArrayIndexProcedure
getKeys
in interface IKeyArrayIndexProcedure<T>
null
.public final IRaba getValues()
IKeyArrayIndexProcedure
getValues
in interface IKeyArrayIndexProcedure<T>
null
if no values were associated
with the IIndexProcedure
.protected abstract IResultHandler<T,T> newAggregator()
IResultHandler
that will be used to combine the results
if the index procedure is parallelized against a local index (including a
scale-out shard). If a null
is returned, then the index
procedure WILL NOT be parallelized against the local index. To
parallelize index procedures that do not return anything against a local
index, just use NopAggregator
. A non-null
value will
permit both index local parallelization of the index procedure and (in
scale-out) parallelization of the index procedure across the shards as
well. In order to be parallelized, the index procedure must also be
marked as IParallelizableIndexProcedure
.IResultHandler
-or- null
NopAggregator
,
IParallelizableIndexProcedure
,
(Schedule more IOs when loading data)
public final T apply(IIndex ndx)
Note: For invocations where the IRaba.size()
of the
keys
is large, this class breaks down the keys
into a multiple key ranges to parallelize the work. If the
procedure is read-only, then we can trivially parallelize the operation.
When the procedure is read-write, a prefetch pattern is used to ensure
that the index pages are in cache and then work is handed off to a single
thread that does the actual work while obeying the single-threaded for
writer constraint on the index.
apply
in interface IIndexProcedure<T>
ndx
- The index.null
. In general,
this MUST be Serializable
since it may have to pass
across a network interface.(Schedule more IOs when loading data)
protected abstract T applyOnce(IIndex ndx, IRaba keys, IRaba vals)
ndx
- The index.public final void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public final void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
protected void readMetadata(ObjectInput in) throws IOException, ClassNotFoundException
writeMetadata(ObjectOutput)
.in
- IOException
ClassNotFoundException
protected void writeMetadata(ObjectOutput out) throws IOException
The default implementation writes out the getKeysCoder()
and the
getValuesCoder()
.
out
- IOException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.