withAttributes
The withAttributes
method returns a table with an AttributeMap
identical to the source table's, but with the specified attributes added/replaced. If the supplied attributes toAdd
would not result in any changes, the original object may be returned.
Syntax
withAttributes(toAdd)
withAttributes(toAdd, toRemove)
Parameters
Parameter | Type | Description |
---|---|---|
toAdd> | Map<String,Object> | Attribute key-value pairs to add or replace (if the key already exists in the source table's |
toRemove> | Collection<String> | Attribute keys to remove. |
Returns
A table with an AttributeMap
that is the same as the source table's, but with the specified attributes added or removed.
Examples
In this example, we create a source table, then create a result
table with a call to withAttributes()
. This returns a result
table that is identical to our source table, but with the attribute we specify ("MyAttribute"
) added.
import io.deephaven.engine.table.AttributeMap
source = newTable(
doubleCol("Doubles", 3.1, 5.45, -1.0),
stringCol("Strings", "Creating", "New", "Tables")
)
result = source.withAttributes(Map.of("MyAttribute", "MyBooleanValue"))
println source.getAttributeKeys()
println result.getAttributeKeys()
- source
- result
- Log