|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.service.ndx.DataServiceIndex
public class DataServiceIndex
A view onto an unpartitioned index living inside an embedded
DataService. Access to the index is moderated by the concurrency
control mechanisms of the data service.
Applications writing to this interface are directly portable to scale-out partitioned indices and to embedded indices without concurrency control.
Note: Since the index is NOT partitioned we do not have to handle stale
locators. That makes this implementation MUCH simpler than the
ClientIndexView.
| Field Summary | |
|---|---|
protected static boolean |
DEBUG
|
protected static boolean |
INFO
|
protected static org.apache.log4j.Logger |
log
Note: Invocations of the non-batch API are logged at the WARN level since they result in an application that can not scale efficiently to partitioned indices. |
protected static boolean |
WARN
|
| Fields inherited from interface com.bigdata.btree.IRangeQuery |
|---|
ALL, CURSOR, DEFAULT, DELETED, FIXED_LENGTH_SUCCESSOR, KEYS, NONE, PARALLEL, READONLY, REMOVEALL, REVERSE, VALS |
| Constructor Summary | |
|---|---|
DataServiceIndex(LocalDataServiceFederation fed,
String name,
long timestamp)
Creates a view onto an unpartitioned index living on an embedded data service. |
|
| Method Summary | |
|---|---|
boolean |
contains(byte[] key)
Return true iff there is a (non-deleted) index entry for
the key. |
boolean |
contains(Object key)
Return true iff there is an entry for the key. |
ICounter |
getCounter()
Counters are local to a specific index partition and are only available to unisolated procedures running inside of an IConcurrencyManager
(which includes procedures run on an IDataService). |
ICounterSet |
getCounters()
FIXME populate with counters concerning the client's access to the index rather than the index's counters. |
IndexMetadata |
getIndexMetadata()
The metadata for the index. |
String |
getName()
The name of the scale-out index. |
IResourceMetadata[] |
getResourceMetadata()
The resources associated with the cached IndexMetadata. |
long |
getTimestamp()
The transaction identifier -or- ITx.UNISOLATED iff the index
view is unisolated -or- - timestamp for a historical read
of the most recent committed state not later than timestamp. |
protected ITupleSerializer |
getTupleSerializer()
|
byte[] |
insert(byte[] key,
byte[] value)
Insert or update a value under the key. |
Object |
insert(Object key,
Object val)
Insert with auto-magic handling of keys and value objects. |
byte[] |
lookup(byte[] key)
Lookup a value for a key. |
Object |
lookup(Object key)
Lookup a value for a key. |
long |
rangeCount()
Return the #of tuples in the index. |
long |
rangeCount(byte[] fromKey,
byte[] toKey)
Return the #of tuples in a half-open key range. |
long |
rangeCountExact(byte[] fromKey,
byte[] toKey)
Return the exact #of tuples in a half-open key range. |
long |
rangeCountExactWithDeleted(byte[] fromKey,
byte[] toKey)
Return the exact #of tuples in a half-open key range, including any deleted tuples. |
ITupleIterator |
rangeIterator()
Visits all tuples in key order. |
ITupleIterator |
rangeIterator(byte[] fromKey,
byte[] toKey)
Return an iterator that visits the entries in a half-open key range. |
ITupleIterator |
rangeIterator(byte[] fromKey,
byte[] toKey,
int capacity,
int flags,
IFilterConstructor filter)
Designated variant (the one that gets overridden) for an iterator that visits the entries in a half-open key range. |
byte[] |
remove(byte[] key)
Remove the key and its associated value. |
Object |
remove(Object key)
Remove the key and its associated value. |
void |
submit(byte[] fromKey,
byte[] toKey,
IKeyRangeIndexProcedure proc,
IResultHandler handler)
The procedure will be transparently applied against each index partition spanned by the given key range. |
Object |
submit(byte[] key,
ISimpleIndexProcedure proc)
Submits an index procedure that operations on a single key to the appropriate index partition returning the result of that procedure. |
void |
submit(int fromIndex,
int toIndex,
byte[][] keys,
byte[][] vals,
AbstractKeyArrayIndexProcedureConstructor ctor,
IResultHandler aggregator)
Runs a procedure against an index. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
protected static final boolean WARN
protected static final boolean INFO
protected static final boolean DEBUG
| Constructor Detail |
|---|
public DataServiceIndex(LocalDataServiceFederation fed,
String name,
long timestamp)
fed - The LocalDataServiceFederation.name - The index name.timestamp - The transaction identifier -or- ITx.UNISOLATED iff the
index view is unisolated -or- - timestamp for a
historical read of the most recent committed state not later
than timestamp.
NoSuchIndexException - if the named index does not exist.| Method Detail |
|---|
public long getTimestamp()
ITx.UNISOLATED iff the index
view is unisolated -or- - timestamp for a historical read
of the most recent committed state not later than timestamp.
getTimestamp in interface IClientIndexpublic String getName()
IClientIndex
getName in interface IClientIndexpublic String toString()
toString in class Objectpublic IndexMetadata getIndexMetadata()
IIndex
getIndexMetadata in interface IIndexpublic ICounterSet getCounters()
ClientIndexView and the DataServiceIndex.
getCounters in interface IIndexpublic ICounter getCounter()
IClientIndexIConcurrencyManager
(which includes procedures run on an IDataService).
getCounter in interface IIndexgetCounter in interface IClientIndexprotected ITupleSerializer getTupleSerializer()
public boolean contains(Object key)
IAutoboxBTree
contains in interface IAutoboxBTreekey - The key is implicitly converted to an unsigned
byte[].
public boolean contains(byte[] key)
ISimpleBTreetrue iff there is a (non-deleted) index entry for
the key. An index entry with a null value will cause this
method to return true. A deleted index entry will cause
this method to return false.
contains in interface ISimpleBTreekey - The key.
true if the index contains an (un-deleted) entry
for that key.
public Object insert(Object key,
Object val)
IAutoboxBTree
insert in interface IAutoboxBTreekey - The key is implicitly converted to an unsigned
byte[].val - The value is implicitly converted to a byte[].
null if there was
no value stored under that key.
public byte[] insert(byte[] key,
byte[] value)
ISimpleBTree
insert in interface ISimpleBTreekey - The key.value - The value (may be null).
null if the
key was not found or if the previous entry for that key was
marked as deleted.public Object lookup(Object key)
IAutoboxBTree
lookup in interface IAutoboxBTreekey - The key is implicitly converted to an unsigned
byte[].
null if there is no
entry for that key.public byte[] lookup(byte[] key)
ISimpleBTree
lookup in interface ISimpleBTreenull if there
is no entry for that key or if the entry under that key is marked
as deleted.public Object remove(Object key)
IAutoboxBTree
remove in interface IAutoboxBTreekey - The key is implicitly converted to an unsigned
byte[].
null if the key was not found.public byte[] remove(byte[] key)
ISimpleBTree
remove in interface ISimpleBTreekey - The key.
null if the key
was not found or if the previous entry under that key was marked
as deleted.public long rangeCount()
IRangeQueryNote: If the index supports deletion markers then the range count will be an upper bound and may double count tuples which have been overwritten, including the special case where the overwrite is a delete.
rangeCount in interface IRangeQuery
public long rangeCount(byte[] fromKey,
byte[] toKey)
IRangeQueryNote: If the index supports deletion markers then the range count will be an upper bound and may double count tuples which have been overwritten, including the special case where the overwrite is a delete.
rangeCount in interface IRangeQueryfromKey - The lowest key that will be counted (inclusive). When
null there is no lower bound.toKey - The first key that will not be counted (exclusive). When
null there is no upper bound.
public long rangeCountExact(byte[] fromKey,
byte[] toKey)
IRangeQueryNote: If the index supports deletion markers then this operation will require a key-range scan.
rangeCountExact in interface IRangeQueryfromKey - The lowest key that will be counted (inclusive). When
null there is no lower bound.toKey - The first key that will not be counted (exclusive). When
null there is no upper bound.
public long rangeCountExactWithDeleted(byte[] fromKey,
byte[] toKey)
IRangeQuery
When the view is just an AbstractBTree the result is the same as
for IRangeQuery.rangeCount(byte[], byte[]), which already
reports all tuples regardless of whether or not they are deleted.
When the index is a view with multiple sources, this operation requires a key-range scan where both deleted and undeleted tuples are visited.
rangeCountExactWithDeleted in interface IRangeQueryfromKey - The lowest key that will be counted (inclusive). When
null there is no lower bound.toKey - The first key that will not be counted (exclusive). When
null there is no upper bound.
IRangeQuery.rangeCountExact(byte[], byte[])public final ITupleIterator rangeIterator()
IRangeQueryrangeIterator(null, null)
rangeIterator in interface IRangeQuery
public ITupleIterator rangeIterator(byte[] fromKey,
byte[] toKey)
IRangeQuery
rangeIterator in interface IRangeQueryfromKey - The first key that will be visited (inclusive lower bound).
When null there is no lower bound.toKey - The first key that will NOT be visited (exclusive upper
bound). When null there is no upper bound.SuccessorUtil, which may be used to compute the successor of a value
before encoding it as a component of a key.,
BytesUtil#successor(byte[]), which may be used to compute the
successor of an encoded key.,
EntryFilter, which may be used to filter the entries visited by the
iterator.
public ITupleIterator rangeIterator(byte[] fromKey,
byte[] toKey,
int capacity,
int flags,
IFilterConstructor filter)
IRangeQuery
rangeIterator in interface IRangeQueryfromKey - The first key that will be visited (inclusive lower bound).
When null there is no lower bound.toKey - The first key that will NOT be visited (exclusive upper
bound). When null there is no upper bound.capacity - The #of entries to buffer at a time. This is a hint and MAY be
zero (0) to use an implementation specific default
capacity. A non-zero value may be used if you know that you
want at most N results or if you want to override the default
#of results to be buffered before sending them across a
network interface. (Note that you can control the default
value using
IBigdataClient.Options#DEFAULT_CLIENT_RANGE_QUERY_CAPACITY).flags - A bitwise OR of IRangeQuery.KEYS, IRangeQuery.VALS, etc.filter - An optional object used to construct a stacked iterator. When
IRangeQuery.CURSOR is specified in flags, the base
iterator will implement ITupleCursor and the first
filter in the stack can safely cast the source iterator to an
ITupleCursor. If the outermost filter in the stack
does not implement ITupleIterator, then it will be
wrapped an ITupleIterator.SuccessorUtil, which may be used to compute the successor of a value
before encoding it as a component of a key.,
BytesUtil#successor(byte[]), which may be used to compute the
successor of an encoded key.,
IFilterConstructor, which may be used to construct an iterator stack
performing filtering or other operations.
public Object submit(byte[] key,
ISimpleIndexProcedure proc)
IIndex
submit in interface IIndexkey - The key.proc - The procedure.
IIndexProcedure.apply(IIndex)
public void submit(byte[] fromKey,
byte[] toKey,
IKeyRangeIndexProcedure proc,
IResultHandler handler)
IIndex
Note: Since this variant of submit() does not split keys the
fromIndex and toIndex in the Splits reported to
the IResultHandler will be zero (0).
submit in interface IIndexfromKey - The lower bound (inclusive) -or- null if there
is no lower bound.toKey - The upper bound (exclusive) -or- null if there
is no upper bound.proc - The procedure. If the procedure implements the
IParallelizableIndexProcedure marker interface then it
MAY be executed in parallel against the relevant index
partition(s).
public void submit(int fromIndex,
int toIndex,
byte[][] keys,
byte[][] vals,
AbstractKeyArrayIndexProcedureConstructor ctor,
IResultHandler aggregator)
IIndex
Note: This may be used to send custom logic together with the data to a
remote index or index partition. When the index is remote both the
procedure and the return value MUST be Serializable.
Note: The scale-out indices add support for auto-split of the procedure such that it runs locally against each relevant index partition.
submit in interface IIndexfromIndex - The index of the first key to be used (inclusive).toIndex - The index of the last key to be used (exclusive).keys - The keys (required).vals - The values (optional depending on the procedure).ctor - An object that can create instances of the procedure.aggregator - When defined, results from each procedure application will be
reported to this object.public IResourceMetadata[] getResourceMetadata()
IndexMetadata.
getResourceMetadata in interface IIndex
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||