Class WritableRowSetImpl
- All Implemented Interfaces:
LogOutputAppendable,RowSequence,RowSet,WritableRowSet,LongSizedDataStructure,SafeCloseable,Externalizable,Serializable,AutoCloseable
- Direct Known Subclasses:
TrackingWritableRowSetImpl
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.engine.rowset.RowSequence
RowSequence.IteratorNested classes/interfaces inherited from interface io.deephaven.engine.rowset.RowSet
RowSet.Evaluator<T extends Comparable<T>>, RowSet.Iterator, RowSet.RangeIterator, RowSet.SearchIterator, RowSet.TargetComparator -
Field Summary
Fields inherited from interface io.deephaven.engine.rowset.RowSequence
NULL_ROW_KEYFields inherited from interface io.deephaven.engine.rowset.RowSet
EMPTY_ITERATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddToBuilderFromImpl(OrderedLongSet.BuilderRandom builder, WritableRowSetImpl rowSet) final RowSetasRowSet()Get aRowSetrepresentation of thisRowSequence.final voidclear()voidclose()Free any resources associated with this object.final voidcompact()May reclaim some unused memory.final booleancontainsRange(long start, long end) Queries whether this RowSet contains every element in the range provided.final WritableRowSetcopy()Make a newWritableRowSetwith the same row keys asthisthat is safe for further mutation.final booleanfinal voidfillRowKeyChunk(WritableLongChunk<? super OrderedRowKeys> chunkToFill) Fill the suppliedWritableLongChunkwith individual row keys from thisRowSequence.final voidfillRowKeyRangesChunk(WritableLongChunk<OrderedRowKeyRanges> chunkToFill) Fill the suppliedWritableLongChunkwith row key ranges from thisRowSequence.final longfind(long key) Returns the position in [0..(size-1)] where the key is found.final longGet the first row key in this RowSet.final booleanProvide each value contained in this RowSet, in increased sorted order to the consumer.final booleanFor as long as the consumer wants more ranges, call accept on the consumer with the individual row key ranges in this RowSequence, in increasing order.final longget(long rowPosition) Returns the row key at the given row position.final longGet an estimate of the average (mean) length of runs of adjacent row keys in thisRowSequence.final OrderedLongSetprotected static OrderedLongSetgetInnerSet(RowSet rowSet) final voidgetKeysForPositions(PrimitiveIterator.OfLong positions, LongConsumer outputKeys) Returns the sequence of (increasing) keys corresponding to the positions provided as input.final RowSequencegetRowSequenceByKeyRange(long startRowKeyInclusive, long endRowKeyInclusive) Get an ordered subset of the row keys in thisRowSequencefor a row key range.final RowSequencegetRowSequenceByPosition(long startPositionInclusive, long length) Get an ordered subset of the row keys in thisRowSequencefor a position range.final RowSequence.IteratorGet anRowSequence.Iteratorover thisRowSequence.final voidinsert(long key) Add a single key to this RowSet if it's not already present.final voidinsert(LongChunk<OrderedRowKeys> keys, int offset, int length) Add all of the (ordered) keys in a slice ofkeysto this RowSet if they are not already present.final voidAdd all of the keys inaddedto this RowSet if they are not already present.final voidinsertRange(long startKey, long endKey) Add all keys in a closed range to this RowSet if they are not already present.final voidinsertWithShift(long shiftAmount, RowSet other) For each key in the provided RowSet, shift it by shiftAmount and insert it in the current RowSet.final @NotNull WritableRowSetReturns a new RowSet representing the intersection of the current RowSet with the input RowSetfinal WritableRowSetReturns the row positions ofkeysin the current set as aWritableRowSet, stopping at maximumPosition.final booleanisEmpty()Queries whether this RowSet is empty (i.e.final RowSet.Iteratoriterator()final longGet the last row key in thisRowSequence.final WritableRowSetReturns a new RowSet representing the keys of the current set not present inside rowSetToRemove.final booleanReturns true if a RowSet has any overlap.final booleanoverlapsRange(long start, long end) Returns true if this RowSet has any overlap with the provided range.protected voidprotected voidfinal RowSet.RangeIteratorfinal longvoidreadExternal(@NotNull ObjectInput in) final voidremove(long key) Remove a single key from this RowSet if it's present.final voidremove(LongChunk<OrderedRowKeys> keys, int offset, int length) Remove all of the (ordered) keys in a slice ofkeysfrom this RowSet if they are present.final voidRemove all of the keys inremovedthat are present in this RowSet.final voidremoveRange(long start, long end) Remove all keys in a closed range from this RowSet if they are present.voidReset this WritableRowSetImpl to match another RowSet by updating theinnerSet.final voidModifies the RowSet by removing any keys not in the rowSetToIntersect argument.final voidretainRange(long startRowKey, long endRowKey) Modifies the RowSet by keeping only keys in the interval [startRowKey, endRowKey]final RowSet.SearchIteratorfinal RowSet.SearchIteratorfinal WritableRowSetshift(long shiftAmount) final voidshiftInPlace(long shiftAmount) final longsize()How many keys are in this RowSet.final WritableRowSetsubSetByKeyRange(long startKey, long endKey) Get a subset of this RowSet within the specified closed range of row keys.final WritableRowSetsubSetByPositionRange(long startPos, long endPos) Get a subset of this RowSet within the specified half-closed range of row positions.final WritableRowSetsubSetForPositions(RowSequence positions) Get a subset of this RowSet according to the supplied sequence of row positions inposRowSequence.final WritableRowSetsubSetForPositions(RowSequence posRowSequence, boolean reversed) Get a subset of this RowSet according to the supplied sequence of row positions inposRowSequence.final WritableRowSetsubSetForReversePositions(RowSequence positions) Get a subset of this RowSet according to the supplied sequence of row positions relative toRowSet.size()inposRowSequence.final booleanReturns true if this RowSet is a (possibly improper) subset of other.toString()toString(int maxRanges) Destructively convert this WritableRowSet into aTrackingWritableRowSet.final WritableRowSetReturns a new RowSet representing the keys present in both this RowSet and the argument RowSet.final voidSimultaneously adds the keys from the first RowSet and removes the keys from the second one.final voidfinal voidwriteExternal(@NotNull ObjectOutput out) voidwriteImpl(ObjectOutput out) Debugging tool to serialize the inner set implementation.Methods inherited from class io.deephaven.engine.rowset.impl.RowSequenceAsChunkImpl
asRowKeyChunk, asRowKeyRangesChunk, closeRowSequenceAsChunkImpl, invalidateRowSequenceAsChunkImpl, runsUpperBoundMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.deephaven.util.datastructures.LongSizedDataStructure
intSize, intSizeMethods inherited from interface io.deephaven.engine.rowset.RowSequence
asRowKeyChunk, asRowKeyRangesChunk, forAllRowKeyRanges, isContiguousMethods inherited from interface io.deephaven.engine.rowset.RowSet
forAllRowKeys, invert, isFlat, isNonempty, isTracking, isWritable, toRowKeyArray, toRowKeyArray, validate, writableCastMethods inherited from interface io.deephaven.engine.rowset.WritableRowSet
extract, trackingCast
-
Constructor Details
-
WritableRowSetImpl
public WritableRowSetImpl() -
WritableRowSetImpl
-
-
Method Details
-
getInnerSet
-
copy
Description copied from interface:RowSetMake a newWritableRowSetwith the same row keys asthisthat is safe for further mutation. As in other operations that return aWritableRowSet, the result must beclosedby the caller when it is no longer needed. The result will never be aTrackingRowSet; useWritableRowSet.toTracking()on the result as needed.- Specified by:
copyin interfaceRowSet- Returns:
- The copied
WritableRowSet
-
toTracking
Description copied from interface:WritableRowSetDestructively convert this WritableRowSet into a
TrackingWritableRowSet.This is really only suitable when the caller "owns" this WritableRowSet. Programming errors may occur if the any code holds onto references to
thisrather than the result, because there may be ambiguity about resource ownership.Implementations are free to transfer ownership of resources from this object to the result. As such, it is an error to directly use this object afterwards; callers must instead use the returned result.
It is an error to invoke this on an instance that is already tracking.
- Specified by:
toTrackingin interfaceWritableRowSet- Returns:
- A
TrackingWritableRowSetconstructed from this WritableRowSet, orthisif already tracking
-
close
@OverridingMethodsMustInvokeSuper public void close()Description copied from interface:RowSequenceFree any resources associated with this object.
Using any
RowSequencemethods afterclose()is an error and may produce exceptions or undefined results.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceRowSequence- Specified by:
closein interfaceRowSet- Specified by:
closein interfaceSafeCloseable- Overrides:
closein classRowSequenceAsChunkImpl
-
preMutationHook
protected void preMutationHook() -
postMutationHook
protected void postMutationHook() -
resetTo
Reset this WritableRowSetImpl to match another RowSet by updating theinnerSet. This will internally assignthis.innerSetto a copy-on-write reference to((WritableRowSetImpl) other).innerSet. The two sets will diverge when either is modified. To maintain continuity between the sets, this function should be called each UGP cycle.- Specified by:
resetToin interfaceWritableRowSet- Parameters:
other- The RowSet to reset to
-
insert
public final void insert(long key) Description copied from interface:WritableRowSetAdd a single key to this RowSet if it's not already present.- Specified by:
insertin interfaceWritableRowSet- Parameters:
key- The key to add
-
insertRange
public final void insertRange(long startKey, long endKey) Description copied from interface:WritableRowSetAdd all keys in a closed range to this RowSet if they are not already present.- Specified by:
insertRangein interfaceWritableRowSet- Parameters:
startKey- The first key to addendKey- The last key to add (inclusive)
-
insert
Description copied from interface:WritableRowSetAdd all of the (ordered) keys in a slice ofkeysto this RowSet if they are not already present.- Specified by:
insertin interfaceWritableRowSet- Parameters:
keys- TheLongChunkofOrderedRowKeysto insertoffset- The offset inkeysto begin inserting keys fromlength- The number of keys to insert
-
insert
Description copied from interface:WritableRowSetAdd all of the keys inaddedto this RowSet if they are not already present.- Specified by:
insertin interfaceWritableRowSet- Parameters:
added- The RowSet to add
-
remove
public final void remove(long key) Description copied from interface:WritableRowSetRemove a single key from this RowSet if it's present.- Specified by:
removein interfaceWritableRowSet- Parameters:
key- The key to remove
-
removeRange
public final void removeRange(long start, long end) Description copied from interface:WritableRowSetRemove all keys in a closed range from this RowSet if they are present.- Specified by:
removeRangein interfaceWritableRowSet- Parameters:
start- The first key to removeend- The last key to remove (inclusive)
-
remove
Description copied from interface:WritableRowSetRemove all of the (ordered) keys in a slice ofkeysfrom this RowSet if they are present.- Specified by:
removein interfaceWritableRowSet- Parameters:
keys- TheLongChunkofOrderedRowKeysto removeoffset- The offset inkeysto begin removing keys fromlength- The number of keys to remove
-
remove
Description copied from interface:WritableRowSetRemove all of the keys inremovedthat are present in this RowSet.- Specified by:
removein interfaceWritableRowSet- Parameters:
removed- The RowSet to remove
-
update
Description copied from interface:WritableRowSetSimultaneously adds the keys from the first RowSet and removes the keys from the second one. API assumption: the intersection of added and removed is empty.- Specified by:
updatein interfaceWritableRowSet
-
retain
Description copied from interface:WritableRowSetModifies the RowSet by removing any keys not in the rowSetToIntersect argument.- Specified by:
retainin interfaceWritableRowSet- Parameters:
rowSetToIntersect- a rowSet with the keys to retain; any other keys not in rowSetToIntersect will be removed.
-
retainRange
public final void retainRange(long startRowKey, long endRowKey) Description copied from interface:WritableRowSetModifies the RowSet by keeping only keys in the interval [startRowKey, endRowKey]- Specified by:
retainRangein interfaceWritableRowSet- Parameters:
startRowKey- beginning of interval of keys to keep.endRowKey- endRowKey of interval of keys to keep (inclusive).
-
clear
public final void clear()- Specified by:
clearin interfaceWritableRowSet
-
shiftInPlace
public final void shiftInPlace(long shiftAmount) - Specified by:
shiftInPlacein interfaceWritableRowSet
-
insertWithShift
Description copied from interface:WritableRowSetFor each key in the provided RowSet, shift it by shiftAmount and insert it in the current RowSet.- Specified by:
insertWithShiftin interfaceWritableRowSet- Parameters:
shiftAmount- the amount to add to each key in the RowSet argument before insertion.other- the RowSet with the keys to shift and insert.
-
compact
public final void compact()Description copied from interface:WritableRowSetMay reclaim some unused memory.- Specified by:
compactin interfaceWritableRowSet
-
size
public final long size()Description copied from interface:RowSetHow many keys are in this RowSet.- Specified by:
sizein interfaceLongSizedDataStructure- Specified by:
sizein interfaceRowSequence- Specified by:
sizein interfaceRowSet- Returns:
- the number of keys in this RowSet.
-
isEmpty
public final boolean isEmpty()Description copied from interface:RowSetQueries whether this RowSet is empty (i.e. has no keys).- Specified by:
isEmptyin interfaceRowSequence- Specified by:
isEmptyin interfaceRowSet- Returns:
- true if the size() of this RowSet is zero, false if the size is greater than zero
-
firstRowKey
public final long firstRowKey()Description copied from interface:RowSetGet the first row key in this RowSet.- Specified by:
firstRowKeyin interfaceRowSequence- Specified by:
firstRowKeyin interfaceRowSet- Returns:
- The first row key, or
RowSequence.NULL_ROW_KEYif there is none.
-
lastRowKey
public final long lastRowKey()Description copied from interface:RowSequenceGet the last row key in thisRowSequence.- Specified by:
lastRowKeyin interfaceRowSequence- Specified by:
lastRowKeyin interfaceRowSet- Specified by:
lastRowKeyin classRowSequenceAsChunkImpl- Returns:
- The last row key, or
RowSequence.NULL_ROW_KEYif there is none.
-
rangesCountUpperBound
public final long rangesCountUpperBound()- Specified by:
rangesCountUpperBoundin classRowSequenceAsChunkImpl
-
getRowSequenceIterator
Description copied from interface:RowSequenceGet anRowSequence.Iteratorover thisRowSequence.- Specified by:
getRowSequenceIteratorin interfaceRowSequence- Returns:
- A new iterator, positioned at the first row key
-
getRowSequenceByPosition
Description copied from interface:RowSequenceGet an ordered subset of the row keys in this
RowSequencefor a position range. The result will contain the set of row keys inthisthat lie at positions in the half-open range [startPositionInclusive,startPositionInclusive + length). The returned reference is owned by the caller, who should callclose()when it is done with it.- Specified by:
getRowSequenceByPositionin interfaceRowSequence- Parameters:
startPositionInclusive- The position of the first row key to includelength- The number of row keys to include- Returns:
- The subset as an
RowSequence, which may bethis
-
getRowSequenceByKeyRange
public final RowSequence getRowSequenceByKeyRange(long startRowKeyInclusive, long endRowKeyInclusive) Description copied from interface:RowSequenceGet an ordered subset of the row keys in this
RowSequencefor a row key range. The returned set will be the intersection of the row keys inthiswith the row keys in the closed interval [startRowKeyInclusive,endRowKeyInclusive]. The returned reference is owned by the caller, who should callclose()when it is done with it.- Specified by:
getRowSequenceByKeyRangein interfaceRowSequence- Parameters:
startRowKeyInclusive- The minimum row key to includeendRowKeyInclusive- The maximum row key to include- Returns:
- The subset as an
RowSequence, which may bethis
-
asRowSet
Description copied from interface:RowSequenceGet aRowSetrepresentation of thisRowSequence.- Specified by:
asRowSetin interfaceRowSequence- Returns:
- A
RowSetrepresentation for the same row keys in the same order
-
invert
Description copied from interface:RowSetReturns the row positions of
keysin the current set as aWritableRowSet, stopping at maximumPosition.This can be thought of as an iterative
RowSet.find(long)over the values in keys, but all keys must exist within this RowSet, because a RowSet result can not represent negative values.- Specified by:
invertin interfaceRowSet- Parameters:
keys- The keys to find positions formaximumPosition- The largest position for which we will find a key- Returns:
- A new
WritableRowSetcontaining the positions of the keys in this RowSet
-
intersect
Description copied from interface:RowSetReturns a new RowSet representing the intersection of the current RowSet with the input RowSet -
overlaps
Description copied from interface:RowSetReturns true if a RowSet has any overlap. -
overlapsRange
public final boolean overlapsRange(long start, long end) Description copied from interface:RowSetReturns true if this RowSet has any overlap with the provided range.- Specified by:
overlapsRangein interfaceRowSet- Parameters:
start- Start of range, inclusive.end- End of range, inclusive.- Returns:
- true if any value x in start <= x <= end is contained in this RowSet.
-
subsetOf
Description copied from interface:RowSetReturns true if this RowSet is a (possibly improper) subset of other. -
minus
Description copied from interface:RowSetReturns a new RowSet representing the keys of the current set not present inside rowSetToRemove. This operation is equivalent to set difference. This RowSet is not modified. -
union
Description copied from interface:RowSetReturns a new RowSet representing the keys present in both this RowSet and the argument RowSet. -
shift
-
validate
-
forEachRowKey
Description copied from interface:RowSetProvide each value contained in this RowSet, in increased sorted order to the consumer. If the consumer returns false for a key, stops after that key (does not provide any keys after that key).- Specified by:
forEachRowKeyin interfaceRowSequence- Specified by:
forEachRowKeyin interfaceRowSet- Parameters:
lc- the consumer.- Returns:
- false if the consumer returned false at some point, true if the consumer always returned true and all values in the RowSet were consumed.
-
forEachRowKeyRange
Description copied from interface:RowSequenceFor as long as the consumer wants more ranges, call accept on the consumer with the individual row key ranges in this RowSequence, in increasing order.- Specified by:
forEachRowKeyRangein interfaceRowSequence- Parameters:
larc- a consumer to feed the individual row key values to.- Returns:
- false if the consumer provided ever returned false, true otherwise.
-
subSetByPositionRange
Description copied from interface:RowSetGet a subset of this RowSet within the specified half-closed range of row positions.- Specified by:
subSetByPositionRangein interfaceRowSet- Parameters:
startPos- The first position to included in the output (inclusive)endPos- The last position to included in the output (exclusive)- Returns:
- A new RowSet, containing only positions >= startPos and < endPos
-
subSetByKeyRange
Description copied from interface:RowSetGet a subset of this RowSet within the specified closed range of row keys.- Specified by:
subSetByKeyRangein interfaceRowSet- Parameters:
startKey- The first key to include in the output.endKey- The last key (inclusive) to include in the output.- Returns:
- A new RowSet, containing only values >= startKey and <= endKey.
-
subSetForPositions
Description copied from interface:RowSetGet a subset of this RowSet according to the supplied sequence of row positions inposRowSequence.- Specified by:
subSetForPositionsin interfaceRowSet- Parameters:
posRowSequence- TheRowSequenceof positions ranges to get (as inRowSet.get(long))reversed- Whether to treatposRowSetas offsets relative toRowSet.size()rather than0- Returns:
- A new RowSet, containing the row keys from this RowSet at the row positions in
posRowSequence
-
subSetForPositions
Description copied from interface:RowSetGet a subset of this RowSet according to the supplied sequence of row positions inposRowSequence.- Specified by:
subSetForPositionsin interfaceRowSet- Parameters:
positions- TheRowSequenceof position-based ranges to extract.- Returns:
- A new RowSet, containing values at the locations in the provided RowSet.
-
subSetForReversePositions
Description copied from interface:RowSetGet a subset of this RowSet according to the supplied sequence of row positions relative toRowSet.size()inposRowSequence.- Specified by:
subSetForReversePositionsin interfaceRowSet- Parameters:
positions- TheRowSequenceof positions ranges to get (as inRowSet.get(long))- Returns:
- A new RowSet, containing the row keys from this RowSet at the row positions in
posRowSequence
-
get
public final long get(long rowPosition) Description copied from interface:RowSetReturns the row key at the given row position. -
getKeysForPositions
Description copied from interface:RowSetReturns the sequence of (increasing) keys corresponding to the positions provided as input.- Specified by:
getKeysForPositionsin interfaceRowSet- Parameters:
positions- an iterator providing row positions in increasing order.outputKeys- a consumer of corresponding keys for the positions provided as input.
-
find
public final long find(long key) Description copied from interface:RowSetReturns the position in [0..(size-1)] where the key is found. If not found, then return (-(position it would be) - 1), a la Array.binarySearch. -
iterator
-
searchIterator
- Specified by:
searchIteratorin interfaceRowSet
-
reverseIterator
- Specified by:
reverseIteratorin interfaceRowSet
-
rangeIterator
- Specified by:
rangeIteratorin interfaceRowSet
-
getAverageRunLengthEstimate
public final long getAverageRunLengthEstimate()Description copied from interface:RowSequenceGet an estimate of the average (mean) length of runs of adjacent row keys in this
RowSequence.Implementations should strive to keep this method efficient (O(1) preferred) at the expense of accuracy.
Empty
RowSequenceshould return an arbitrary valid value, usually 1.- Specified by:
getAverageRunLengthEstimatein interfaceRowSequence- Returns:
- An estimate of the average run length in this
RowSequence, in [1,size()]
-
containsRange
public final boolean containsRange(long start, long end) Description copied from interface:RowSetQueries whether this RowSet contains every element in the range provided.- Specified by:
containsRangein interfaceRowSet- Parameters:
start- Start of the range, inclusive.end- End of the range, inclusive.- Returns:
- true if this RowSet contains every element x in start <= x <= end.
-
fillRowKeyChunk
Description copied from interface:RowSequenceFill the supplied
WritableLongChunkwith individual row keys from thisRowSequence.The chunk's capacity is assumed to be big enough.
- Specified by:
fillRowKeyChunkin interfaceRowSequence- Parameters:
chunkToFill- A chunk to fill with individual row keys
-
fillRowKeyRangesChunk
Description copied from interface:RowSequenceFill the supplied
WritableLongChunkwith row key ranges from thisRowSequence.The chunk's capacity is assumed to be big enough.
- Specified by:
fillRowKeyRangesChunkin interfaceRowSequence- Parameters:
chunkToFill- A chunk to fill with row key ranges
-
append
- Specified by:
appendin interfaceLogOutputAppendable
-
toString
-
toString
-
equals
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
writeImpl
Debugging tool to serialize the inner set implementation.- Parameters:
out- The destination- Throws:
IOException
-
addToBuilderFromImpl
public static void addToBuilderFromImpl(OrderedLongSet.BuilderRandom builder, WritableRowSetImpl rowSet) -
getInnerSet
-