Class ORidBag
java.lang.Object
com.orientechnologies.orient.core.db.record.ridbag.ORidBag
- All Implemented Interfaces:
OCollection<OIdentifiable>,OSizeable,OAutoConvertToRecord,ODetachable,ORecordElement,ORecordLazyMultiValue,OTrackedMultiValue<OIdentifiable,,OIdentifiable> OStringBuilderSerializable,Iterable<OIdentifiable>
public class ORidBag
extends Object
implements OStringBuilderSerializable, Iterable<OIdentifiable>, ORecordLazyMultiValue, OTrackedMultiValue<OIdentifiable,OIdentifiable>, OCollection<OIdentifiable>, ORecordElement
A collection that contain links to
The representation is automatically converted to tree-based implementation when top threshold is reached. And backward to embedded one when size is decreased to bottom threshold.
The thresholds could be configured by
This collection is used to efficiently manage relationships in graph model.
Does not implement
OIdentifiable. Bag is similar to set but can contain
several entering of the same object.Could be tree based and embedded representation.
- Embedded stores its content directly to the document that owns it.
It better fits for cases when only small amount of links are stored to the bag.
- Tree-based implementation stores its content in a separate data structure called
OSBTreeBonsai.
It fits great for cases when you have a huge amount of links.
The representation is automatically converted to tree-based implementation when top threshold is reached. And backward to embedded one when size is decreased to bottom threshold.
The thresholds could be configured by
OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD and OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD. This collection is used to efficiently manage relationships in graph model.
Does not implement
Collection interface because some operations could not be efficiently
implemented and that's why should be avoided.- Since:
- 1.7rc1
- Author:
- Artem Orobets (enisher-at-gmail.com), Andrey Lomakin (a.lomakin-at-orientdb.com)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.record.ORecordElement
ORecordElement.STATUS -
Constructor Summary
ConstructorsConstructorDescriptionORidBag()ORidBag(ORidBagDelegate delegate) ORidBag(OBonsaiCollectionPointer pointer, Map<OIdentifiable, Change> changes, UUID uuid) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(OIdentifiable identifiable) voidaddAll(Collection<OIdentifiable> values) booleanvoidbooleancontains(OIdentifiable identifiable) THIS IS VERY EXPENSIVE METHOD AND CAN NOT BE CALLED IN REMOTE STORAGE.voidBrowse all the set to convert all the items into records.booleanBrowse all the set to convert all the items into links.copy()voiddebugPrint(PrintStream writer) voiddelete()booleandetach()Detaches the object.voiddisableTracking(ORecordElement document) voidenableTracking(ORecordElement parent) booleanvoidfromStream(byte[] stream) voidfromStream(BytesContainer stream) static ORidBagfromStream(String value) fromStream(StringBuilder input) Class<?> getOwner()Temporary id of collection to track changes in remote mode.protected voidinit()protected voidbooleanbooleanbooleanisEmpty()booleanbooleanbooleaniterator()voidvoidmakeTree()voidnotifySaved(OBonsaiCollectionPointer newPointer) Notify collection that changes has been saved.voidremove(OIdentifiable identifiable) voidreplace(OMultiValueChangeEvent<Object, Object> event, Object newValue) returnOriginalState(List<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>> multiValueChangeEvents) Reverts all operations that were performed on collection and return original collection state.voidsetAutoConvertToRecord(boolean convertToRecord) <RET> RETsetDirty()Marks the instance as dirty.voidvoidsetOwner(ORecordElement owner) voidsetRecordAndField(ORecordId id, String fieldName) voidsetTemporaryId(UUID uuid) intsize()inttoStream(BytesContainer bytesContainer, OSerializationContext ctx) toStream(StringBuilder output) toString()voidbooleanIMPORTANT!Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ORidBag
-
ORidBag
public ORidBag() -
ORidBag
-
ORidBag
-
ORidBag
-
-
Method Details
-
fromStream
-
copy
-
contains
THIS IS VERY EXPENSIVE METHOD AND CAN NOT BE CALLED IN REMOTE STORAGE.- Parameters:
identifiable- Object to check.- Returns:
- true if ridbag contains at leas one instance with the same rid as passed in identifiable.
-
addAll
-
add
- Specified by:
addin interfaceOCollection<OIdentifiable>
-
addInternal
- Specified by:
addInternalin interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
remove
- Specified by:
removein interfaceOCollection<OIdentifiable>
-
isEmpty
public boolean isEmpty() -
iterator
- Specified by:
iteratorin interfaceIterable<OIdentifiable>
-
rawIterator
- Specified by:
rawIteratorin interfaceORecordLazyMultiValue
-
convertLinks2Records
public void convertLinks2Records()Description copied from interface:ORecordLazyMultiValueBrowse all the set to convert all the items into records.It converts only items that already loaded into memory from storage. To convert records that will be fetched from disk later use
OAutoConvertToRecord.setAutoConvertToRecord(boolean)- Specified by:
convertLinks2Recordsin interfaceORecordLazyMultiValue
-
convertRecords2Links
public boolean convertRecords2Links()Description copied from interface:ORecordLazyMultiValueBrowse all the set to convert all the items into links.- Specified by:
convertRecords2Linksin interfaceORecordLazyMultiValue- Returns:
-
isAutoConvertToRecord
public boolean isAutoConvertToRecord()- Specified by:
isAutoConvertToRecordin interfaceOAutoConvertToRecord
-
setAutoConvertToRecord
public void setAutoConvertToRecord(boolean convertToRecord) - Specified by:
setAutoConvertToRecordin interfaceOAutoConvertToRecord
-
detach
public boolean detach()Description copied from interface:ODetachableDetaches the object.- Specified by:
detachin interfaceODetachable- Returns:
- true if the object has been fully detached, otherwise false
-
size
public int size() -
isEmbedded
public boolean isEmbedded() -
isToSerializeEmbedded
public boolean isToSerializeEmbedded() -
toStream
public int toStream(BytesContainer bytesContainer, OSerializationContext ctx) throws OSerializationException - Throws:
OSerializationException
-
checkAndConvert
public void checkAndConvert() -
toStream
- Specified by:
toStreamin interfaceOStringBuilderSerializable- Throws:
OSerializationException
-
toString
-
delete
public void delete() -
fromStream
- Specified by:
fromStreamin interfaceOStringBuilderSerializable- Throws:
OSerializationException
-
fromStream
public void fromStream(byte[] stream) -
fromStream
-
returnOriginalState
public Object returnOriginalState(List<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>> multiValueChangeEvents) Description copied from interface:OTrackedMultiValueReverts all operations that were performed on collection and return original collection state.- Specified by:
returnOriginalStatein interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable> - Parameters:
multiValueChangeEvents- List of operations that were performed on collection.- Returns:
- Original collection state.
-
getGenericClass
- Specified by:
getGenericClassin interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
setOwner
-
getTemporaryId
Temporary id of collection to track changes in remote mode.WARNING! Method is for internal usage.
- Returns:
- UUID
-
setTemporaryId
-
notifySaved
Notify collection that changes has been saved. Converts to non embedded implementation if needed.WARNING! Method is for internal usage.
- Parameters:
newPointer- new collection pointer
-
getPointer
-
tryMerge
IMPORTANT! Only for internal usage. -
initThresholds
protected void initThresholds() -
init
protected void init() -
debugPrint
- Throws:
IOException
-
getDelegate
-
getChanges
-
replace
- Specified by:
replacein interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
equals
-
enableTracking
- Specified by:
enableTrackingin interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
disableTracking
- Specified by:
disableTrackingin interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
transactionClear
public void transactionClear()- Specified by:
transactionClearin interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
isModified
public boolean isModified()- Specified by:
isModifiedin interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
getTimeLine
- Specified by:
getTimeLinein interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
setDirty
public <RET> RET setDirty()Description copied from interface:ORecordElementMarks the instance as dirty. The dirty status could be propagated up if the implementation supports ownership concept.- Specified by:
setDirtyin interfaceORecordElement- Returns:
- The object it self. Useful to call methods in chain.
-
setDirtyNoChanged
public void setDirtyNoChanged()- Specified by:
setDirtyNoChangedin interfaceORecordElement
-
getOwner
- Specified by:
getOwnerin interfaceORecordElement- Returns:
- Returns record element which contains given one.
-
isTransactionModified
public boolean isTransactionModified()- Specified by:
isTransactionModifiedin interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
getTransactionTimeLine
- Specified by:
getTransactionTimeLinein interfaceOTrackedMultiValue<OIdentifiable,OIdentifiable>
-
setRecordAndField
-
makeTree
public void makeTree() -
makeEmbedded
public void makeEmbedded()
-