Package io.deephaven.engine.table.impl
Class LiveAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>,IMPL_TYPE extends LiveAttributeMap<IFACE_TYPE,IMPL_TYPE>>
java.lang.Object
io.deephaven.util.referencecounting.ReferenceCounted
io.deephaven.engine.liveness.ReferenceCountedLivenessReferent
io.deephaven.engine.liveness.ReferenceCountedLivenessNode
io.deephaven.engine.liveness.LivenessArtifact
io.deephaven.engine.table.impl.LiveAttributeMap<IFACE_TYPE,IMPL_TYPE>
- All Implemented Interfaces:
LogOutputAppendable,LivenessManager,LivenessNode,LivenessReferent,AttributeMap<IFACE_TYPE>,Serializable
- Direct Known Subclasses:
BaseGridAttributes
public abstract class LiveAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>,IMPL_TYPE extends LiveAttributeMap<IFACE_TYPE,IMPL_TYPE>>
extends LivenessArtifact
implements AttributeMap<IFACE_TYPE>
Re-usable
AttributeMap implementation that is also a LivenessArtifact.- See Also:
- ImplNote:
- Rather than rely on
final, explicitly-immutableMapinstances for storage, this implementation does allow for mutation after construction. This allows a pattern wherein operations fill their resultAttributeMapafter construction usingsetAttribute(String, Object), which by convention must only be done before the result is published. No mutation is permitted after first access using any ofgetAttribute(String),getAttributeKeys(),hasAttribute(String),getAttributes(), orAttributeMap.getAttributes(Predicate).
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLiveAttributeMap(@Nullable Map<String, Object> initialAttributes) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract IMPL_TYPEcopy()Create a copy ofthiswith initially-sharedmutableAttributes.protected static voidcopyAttributes(@NotNull AttributeMap<?> source, @NotNull LiveAttributeMap<?, ?> destination, @NotNull Predicate<String> shouldCopy) Copy attributes between AttributeMaps, filtered by a predicate.@Nullable ObjectgetAttribute(@NotNull String key) Get the value for the specified attribute key.Get an immutable set of all the attributes that have values in this AttributeMap.Get all attributes in this AttributeMap.getAttributes(@NotNull Predicate<String> included) Get all attributes from this AttributeMap whose keys are accepted byincluded.booleanhasAttribute(@NotNull String name) Check if the specified attribute exists in this AttributeMap.protected IFACE_TYPEprotected IFACE_TYPEbooleanTest if this LiveAttributeMap has been published yet.retainingAttributes(@NotNull Collection<String> toRetain) Get an AttributeMap that is the same asthis, but with only the specified attributes retained.voidsetAttribute(@NotNull String key, @NotNull Object object) Set the value of an attribute.voidsetAttribute(@NotNull String key, @NotNull UnaryOperator<Object> updater) Read and update the value of an attribute.withAttributes(@NotNull Map<String, Object> toAdd) Get an AttributeMap that is the same asthis, but with the specified attributes added/replaced.withAttributes(@NotNull Map<String, Object> toAdd, @NotNull Collection<String> toRemove) Get an AttributeMap that is the same asthis, but with the specified attributes added/replaced or removed.withoutAttributes(@NotNull Collection<String> toRemove) Get an AttributeMap that is the same asthis, but with the specified attributes removed.Methods inherited from class io.deephaven.engine.liveness.LivenessArtifact
manageWithCurrentScopeMethods inherited from class io.deephaven.engine.liveness.ReferenceCountedLivenessNode
getWeakReference, initializeTransientFieldsForLiveness, onReferenceCountAtZero, tryManage, tryUnmanage, tryUnmanageMethods inherited from class io.deephaven.engine.liveness.ReferenceCountedLivenessReferent
destroy, dropReference, tryRetainReferenceMethods inherited from class io.deephaven.util.referencecounting.ReferenceCounted
append, decrementReferenceCount, forceReferenceCountToZero, getReferenceCountDebug, incrementReferenceCount, resetReferenceCount, toString, tryDecrementReferenceCount, tryIncrementReferenceCountMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.deephaven.engine.liveness.LivenessManager
manage, unmanage, unmanageMethods inherited from interface io.deephaven.engine.liveness.LivenessReferent
dropReference, getReferentDescription, retainReference, tryRetainReference
-
Constructor Details
-
LiveAttributeMap
- Parameters:
initialAttributes- The attributes map to use until mutated, or elsenullto allocate a new one
-
-
Method Details
-
setAttribute
@InternalUseOnly public void setAttribute(@NotNull @NotNull String key, @NotNull @NotNull Object object) Set the value of an attribute. This is for internal use by operations that build result AttributeMaps, and should never be used from multiple threads or after a result has been published.- Parameters:
key- The name of the attribute; must not benullobject- The value to be assigned; must not benull
-
setAttribute
@InternalUseOnly public void setAttribute(@NotNull @NotNull String key, @NotNull @NotNull UnaryOperator<Object> updater) Read and update the value of an attribute. This is for internal use by operations that build result AttributeMaps, and should never be used from multiple threads or after a result has been published.- Parameters:
key- The name of the attribute; must not benullupdater- Function on the (possibly-null) existing value to produce the non-nullnew value
-
copyAttributes
protected static void copyAttributes(@NotNull @NotNull AttributeMap<?> source, @NotNull @NotNull LiveAttributeMap<?, ?> destination, @NotNull @NotNull Predicate<String> shouldCopy) Copy attributes between AttributeMaps, filtered by a predicate.- Parameters:
source- The AttributeMap to copy attributes fromdestination- The LiveAttributeMap to copy attributes toshouldCopy- Should we copy this attribute key?
-
published
public boolean published()Test if this LiveAttributeMap has been published yet. This determines whether it's safe to callsetAttribute(String, Object)orsetAttribute(String, UnaryOperator).- Returns:
- Whether this LiveAttributeMap has been published
-
prepareReturnThis
-
prepareReturnCopy
-
withAttributes
public IFACE_TYPE withAttributes(@NotNull @NotNull Map<String, Object> toAdd, @NotNull @NotNull Collection<String> toRemove) Description copied from interface:AttributeMapGet an AttributeMap that is the same asthis, but with the specified attributes added/replaced or removed. If the supplied attributestoAddandtoRemovewould not result in any changes tothis, implementations may returnthis.- Specified by:
withAttributesin interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Parameters:
toAdd- Attribute key-value pairs to add or replace (if the key already exists onthis). Neither keys nor values may benull.toRemove- Attribute keys to remove- Returns:
- The result AttributeMap
-
withAttributes
Description copied from interface:AttributeMapGet an AttributeMap that is the same asthis, but with the specified attributes added/replaced. If the supplied attributestoAddwould not result in any changes tothis, implementations may returnthis.- Specified by:
withAttributesin interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Parameters:
toAdd- Attribute key-value pairs to add or replace (if the key already exists onthis)- Returns:
- The result AttributeMap
-
withoutAttributes
Description copied from interface:AttributeMapGet an AttributeMap that is the same asthis, but with the specified attributes removed. If the supplied attributestoRemovewould not result in any changes tothis, implementations may returnthis.- Specified by:
withoutAttributesin interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Parameters:
toRemove- Attribute keys to remove- Returns:
- The result AttributeMap
-
retainingAttributes
Description copied from interface:AttributeMapGet an AttributeMap that is the same asthis, but with only the specified attributes retained. If the supplied attributestoAddwould not result in any changes tothis, implementations may returnthis.- Specified by:
retainingAttributesin interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Parameters:
toRetain- Attribute keys to retain- Returns:
- The result AttributeMap
-
copy
Create a copy ofthiswith initially-sharedmutableAttributes. -
getAttribute
Description copied from interface:AttributeMapGet the value for the specified attribute key.- Specified by:
getAttributein interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Parameters:
key- The name of the attribute- Returns:
- The value, or
nullif there was none.
-
getAttributeKeys
Description copied from interface:AttributeMapGet an immutable set of all the attributes that have values in this AttributeMap.- Specified by:
getAttributeKeysin interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Returns:
- An immutable set of attribute keys (names)
-
hasAttribute
Description copied from interface:AttributeMapCheck if the specified attribute exists in this AttributeMap.- Specified by:
hasAttributein interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Parameters:
name- The key (name) of the attribute- Returns:
trueif the attribute exists
-
getAttributes
Description copied from interface:AttributeMapGet all attributes in this AttributeMap.- Specified by:
getAttributesin interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Returns:
- An immutable map containing all attributes from this AttributeMap
-
getAttributes
@ConcurrentMethod @NotNull public @NotNull Map<String,Object> getAttributes(@NotNull @NotNull Predicate<String> included) Description copied from interface:AttributeMapGet all attributes from this AttributeMap whose keys are accepted byincluded.- Specified by:
getAttributesin interfaceAttributeMap<IFACE_TYPE extends AttributeMap<IFACE_TYPE>>- Parameters:
included- A predicate to determine which attribute keys to include- Returns:
- An immutable map containing AttributeMap's attributes whose keys are accepted by
included
-