com.bigdata.btree
Class ReadOnlyIndex

java.lang.Object
  extended by com.bigdata.btree.DelegateIndex
      extended by com.bigdata.btree.ReadOnlyIndex
All Implemented Interfaces:
IAutoboxBTree, IIndex, IIndexLocalCounter, IRangeQuery, ISimpleBTree, ICounterSetAccess

public class ReadOnlyIndex
extends DelegateIndex

A fly-weight wrapper that does not permit write operations and reads through onto an underlying IIndex.

Note: use this class sparingly. An index loaded from a historical commit point will always be read-only.

Version:
$Id: ReadOnlyIndex.java 3672 2010-09-28 23:39:42Z thompsonbry $
Author:
Bryan Thompson
See Also:
IResourceManager#getIndex(String, long)}

Field Summary
 
Fields inherited from interface com.bigdata.btree.IRangeQuery
ALL, CURSOR, DEFAULT, DELETED, FIXED_LENGTH_SUCCESSOR, KEYS, NONE, PARALLEL, READONLY, REMOVEALL, REVERSE, VALS
 
Constructor Summary
ReadOnlyIndex(IIndex src)
           
 
Method Summary
 ICounter getCounter()
          Counter is read-only.
 IndexMetadata getIndexMetadata()
          IndexMetadata is cloned to disallow modification.
 IResourceMetadata[] getResourceMetadata()
          IResourceMetadata[] is cloned to disallow modification (the IResourceMetadata instances in the array are all dynamically created so changes to them do not propagate back to the index).
 byte[] insert(byte[] key, byte[] value)
          Disabled.
 ITupleIterator rangeIterator(byte[] fromKey, byte[] toKey, int capacity, int flags, IFilter filter)
          IRangeQuery.REMOVEALL and Iterator.remove() are disabled.
 byte[] remove(byte[] key)
          Disabled.
 void submit(byte[] fromKey, byte[] toKey, IIndexProcedure proc, IResultHandler handler)
          Overriden to ensure that procedure is applied against read-only view and not the DelegateIndex.
 Object submit(byte[] key, IIndexProcedure proc)
          Overriden to ensure that procedure is applied against read-only view and not the DelegateIndex.
 void submit(int fromIndex, int toIndex, byte[][] keys, byte[][] vals, AbstractKeyArrayIndexProcedureConstructor ctor, IResultHandler aggregator)
          Overriden to ensure that procedure is applied against read-only view and not the DelegateIndex.
 
Methods inherited from class com.bigdata.btree.DelegateIndex
contains, contains, getCounters, insert, lookup, lookup, rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, remove, submit, submit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadOnlyIndex

public ReadOnlyIndex(IIndex src)
Method Detail

getIndexMetadata

public final IndexMetadata getIndexMetadata()
IndexMetadata is cloned to disallow modification.

Specified by:
getIndexMetadata in interface IIndex
Overrides:
getIndexMetadata in class DelegateIndex

getResourceMetadata

public final IResourceMetadata[] getResourceMetadata()
IResourceMetadata[] is cloned to disallow modification (the IResourceMetadata instances in the array are all dynamically created so changes to them do not propagate back to the index).

Specified by:
getResourceMetadata in interface IIndex
Overrides:
getResourceMetadata in class DelegateIndex

getCounter

public final ICounter getCounter()
Counter is read-only.

Specified by:
getCounter in interface IIndexLocalCounter
Overrides:
getCounter in class DelegateIndex

insert

public final byte[] insert(byte[] key,
                           byte[] value)
Disabled.

Specified by:
insert in interface ISimpleBTree
Overrides:
insert in class DelegateIndex
Parameters:
key - The key.
value - The value (may be null).
Returns:
The previous value under that key or null if the key was not found or if the previous entry for that key was marked as deleted.

remove

public final byte[] remove(byte[] key)
Disabled.

Specified by:
remove in interface ISimpleBTree
Overrides:
remove in class DelegateIndex
Parameters:
key - The key.
Returns:
The value stored under that key or null if the key was not found or if the previous entry under that key was marked as deleted.

rangeIterator

public final ITupleIterator rangeIterator(byte[] fromKey,
                                          byte[] toKey,
                                          int capacity,
                                          int flags,
                                          IFilter filter)
IRangeQuery.REMOVEALL and Iterator.remove() are disabled.

Specified by:
rangeIterator in interface IRangeQuery
Overrides:
rangeIterator in class DelegateIndex
Parameters:
fromKey - 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.
See Also:
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.

submit

public final Object submit(byte[] key,
                           IIndexProcedure proc)
Overriden to ensure that procedure is applied against read-only view and not the DelegateIndex.


submit

public final void submit(byte[] fromKey,
                         byte[] toKey,
                         IIndexProcedure proc,
                         IResultHandler handler)
Overriden to ensure that procedure is applied against read-only view and not the DelegateIndex.


submit

public final void submit(int fromIndex,
                         int toIndex,
                         byte[][] keys,
                         byte[][] vals,
                         AbstractKeyArrayIndexProcedureConstructor ctor,
                         IResultHandler aggregator)
Overriden to ensure that procedure is applied against read-only view and not the DelegateIndex.

Specified by:
submit in interface IIndex
Overrides:
submit in class DelegateIndex
Parameters:
fromIndex - 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.


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.