Class Row
java.lang.Object
com.datastax.astra.client.tables.definition.rows.Row
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
TableUpdateOperation
Record present in a Cassandra Table.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionData to be used in the document.protected static final DataAPISerializer
Serializer for the Rows. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionPut the given key/value pair into this Document and return this.Adds an ASCII-encoded text value to the row.Adds a BigInt value to the row.Adds a Blob (byte array) to the row.addBoolean
(String key, Boolean value) Adds a Boolean value to the row.Adds a Date value to the row.addDecimal
(String key, BigDecimal value) Adds a Decimal (BigDecimal) value to the row.Adds a Double value to the row.addDuration
(String key, Duration duration) Adds a Duration value to the row.addDuration
(String key, Period period) Adds a duration value composed of only a Period to the row.addDuration
(String key, Period period, Duration duration) Adds a Duration value to the row.Adds a Float value to the row.addInet
(String key, InetAddress value) Adds an InetAddress value to the row.Adds an Integer value to the row.<T> Row
Adds a list to the row.addLocalDate
(String key, LocalDate localDate) Adds a LocalDate value to the row, converting it to a Date.<K,
V> Row Adds a map to the row.<T> Row
Adds a set to the row.addSmallInt
(String key, Short value) Adds a SmallInt value to the row.addTableDuration
(String key, TableDuration value) Adds a TableDuration value to the row.Adds a text value to the row.Adds a LocalTime value to the row.addTimeStamp
(String key, Instant instant) Adds a timestamp (Instant) value to the row.addTinyInt
(String key, Byte value) Adds a TinyInt value to the row.Adds a UUID value to the row.addVarInt
(String key, BigInteger value) Adds a variable-length integer (VarInt) value to the row.Adds a vector (float array) to the row, wrapping it in a DataAPIVector.addVector
(String key, DataAPIVector vector) Adds a DataAPIVector value to the row.addVectorize
(String key, String value) Adds a vectorized value to the row.boolean
containsKey
(Object key) Gets the value of the given key.static Row
create()
Create a row with no attributes.boolean
<T> T
Gets the value of the given key, casting it to the givenClass<T>
.Access element from the map<K> K[]
Return an Array of items.Gets the value of the given key as a String.Gets the value of the given key as a Long.getBoolean
(String key) Gets the value of the given key as a Boolean.Access element from the mapAccess element from the mapAccess element from the mapAccess internal property map.Gets the value of the given key as a Date.Access element from the mapGets the value of the given key as a Double.Access element from the mapgetInstant
(String k) Access element from the mapgetInteger
(String key) Gets the value of the given key as an Integer.<T> List
<T> Gets the list value of the given key, casting the list elements to the givenClass<T>
.Access element from the mapGets the value of the given key as a String.Access element from the mapGets the value of the given key as a DataAPIVector.int
hashCode()
<T> T
Marshall as a row if needed.static Row
Parses a string in MongoDB Extended JSON format to aDocument
Add a key/value pair to the document.void
Add all information from the input row.void
Add all information from the map.void
setProperty
(String key, Object value) Set a property in the row.toString()
Serialization with Jackson.
-
Field Details
-
SERIALIZER
Serializer for the Rows. -
columnMap
Data to be used in the document.
-
-
Constructor Details
-
Row
public Row()Default Constructor. -
Row
Creates a Document instance initialized with the given map.- Parameters:
map
- initial map
-
-
Method Details
-
getColumnMap
Access internal property map.- Returns:
- internal map
-
setProperty
Set a property in the row.- Parameters:
key
- keyvalue
- value
-
create
Create a row with no attributes.- Returns:
- instance of document
-
map
Marshall as a row if needed.- Type Parameters:
T
- current type- Parameters:
clazz
- target class- Returns:
- instance of pojo
-
parse
Parses a string in MongoDB Extended JSON format to aDocument
- Parameters:
json
- the JSON string- Returns:
- the document
-
add
Put the given key/value pair into this Document and return this. Useful for chaining puts in a single expression, e.g.doc.append("a", 1).append("b", 2)}
- Parameters:
key
- keyvalue
- value- Returns:
- this
-
addText
Adds a text value to the row.- Parameters:
key
- the key for the text valuevalue
- the text value to add- Returns:
- the updated row
Example usage:
row.addText("name", "example");
-
addAscii
Adds an ASCII-encoded text value to the row.- Parameters:
key
- the key for the ASCII valuevalue
- the ASCII value to add- Returns:
- the updated row
Example usage:
row.addAscii("key", "ASCII value");
-
addVectorize
Adds a vectorized value to the row.- Parameters:
key
- the key for the vectorized valuevalue
- the vectorized value to add- Returns:
- the updated row
Example usage:
row.addVectorize("vectorKey", "vectorizedData");
-
addVarInt
Adds a variable-length integer (VarInt) value to the row.- Parameters:
key
- the key for the VarInt valuevalue
- the VarInt value to add- Returns:
- the updated row
Example usage:
row.addVarInt("key", new BigInteger("123456789"));
-
addBigInt
Adds a BigInt value to the row.- Parameters:
key
- the key for the BigInt valuevalue
- the BigInt value to add- Returns:
- the updated row
Example usage:
row.addBigInt("key", 123456789L);
-
addInt
Adds an Integer value to the row.- Parameters:
key
- the key for the Integer valuevalue
- the Integer value to add- Returns:
- the updated row
Example usage:
row.addInt("key", 42);
-
addSmallInt
Adds a SmallInt value to the row.- Parameters:
key
- the key for the SmallInt valuevalue
- the SmallInt value to add- Returns:
- the updated row
Example usage:
row.addSmallInt("key", (short) 32000);
-
addTinyInt
Adds a TinyInt value to the row.- Parameters:
key
- the key for the TinyInt valuevalue
- the TinyInt value to add- Returns:
- the updated row
Example usage:
row.addTinyInt("key", (byte) 127);
-
addBoolean
Adds a Boolean value to the row.- Parameters:
key
- the key for the Boolean valuevalue
- the Boolean value to add- Returns:
- the updated row
Example usage:
row.addBoolean("key", true);
-
addBlob
Adds a Blob (byte array) to the row.- Parameters:
key
- the key for the Blob valuevalue
- the byte array to add- Returns:
- the updated row
Example usage:
byte[] data = {1, 2, 3}; row.addBlob("key", data);
-
addFloat
Adds a Float value to the row.- Parameters:
key
- the key for the Float valuevalue
- the Float value to add- Returns:
- the updated row
Example usage:
row.addFloat("key", 3.14f);
-
addDecimal
Adds a Decimal (BigDecimal) value to the row.- Parameters:
key
- the key for the Decimal valuevalue
- the BigDecimal value to add- Returns:
- the updated row
Example usage:
row.addDecimal("key", new BigDecimal("12345.6789"));
-
addDouble
Adds a Double value to the row.- Parameters:
key
- the key for the Double valuevalue
- the Double value to add- Returns:
- the updated row
Example usage:
row.addDouble("key", 3.14159);
-
addDate
Adds a Date value to the row.- Parameters:
key
- the key for the Date valuevalue
- the Date value to add- Returns:
- the updated row
Example usage:
row.addDate("key", new Date());
-
addLocalDate
Adds a LocalDate value to the row, converting it to a Date.- Parameters:
key
- the key for the LocalDate valuelocalDate
- the LocalDate value to add- Returns:
- the updated row
Example usage:
row.addDate("key", LocalDate.now());
-
addInet
Adds an InetAddress value to the row.- Parameters:
key
- the key for the InetAddress valuevalue
- the InetAddress value to add- Returns:
- the updated row
Example usage:
row.addInet("key", InetAddress.getByName("127.0.0.1"));
-
addDuration
Adds a Duration value to the row.- Parameters:
key
- the key for the Duration valueduration
- the Duration value to add- Returns:
- the updated row
Example usage:
row.addDuration("key", Duration.ofMinutes(10));
-
addDuration
Adds a Duration value to the row.- Parameters:
key
- the key for the Duration valueperiod
- the Period value to addduration
- the Duration value to add- Returns:
- the updated row
Example usage:
row.addDuration("key", Period.ofDays(1), Duration.ofMinutes(10));
-
addDuration
Adds a duration value composed of only a Period to the row.- Parameters:
key
- the key for the duration valueperiod
- the period component of the duration- Returns:
- the updated row
Example usage:
row.addDuration("key", Period.ofWeeks(2));
-
addTableDuration
Adds a TableDuration value to the row.- Parameters:
key
- the key for the TableDuration valuevalue
- the TableDuration value to add- Returns:
- the updated row
Example usage:
row.addTableDuration("key", new TableDuration(Period.ofMonths(1), Duration.ofMinutes(30)));
-
addUUID
Adds a UUID value to the row.- Parameters:
key
- the key for the UUID valuevalue
- the UUID value to add- Returns:
- the updated row
Example usage:
row.addUUID("key", UUID.randomUUID());
-
addTimeStamp
Adds a timestamp (Instant) value to the row.- Parameters:
key
- the key for the timestampinstant
- the Instant value to add- Returns:
- the updated row
Example usage:
row.addTimeStamp("key", Instant.now());
-
addTime
Adds a LocalTime value to the row.- Parameters:
key
- the key for the time valueltime
- the LocalTime value to add- Returns:
- the updated row
Example usage:
row.addTime("key", LocalTime.now());
-
addVector
Adds a DataAPIVector value to the row.- Parameters:
key
- the key for the vectorvector
- the DataAPIVector to add- Returns:
- the updated row
Example usage:
DataAPIVector vector = new DataAPIVector(new float[]{1.0f, 2.0f, 3.0f}); row.addVector("key", vector);
-
addVector
Adds a vector (float array) to the row, wrapping it in a DataAPIVector.- Parameters:
key
- the key for the vectorvector
- the float array to add- Returns:
- the updated row
Example usage:
row.addVector("key", new float[]{1.0f, 2.0f, 3.0f});
-
addList
Adds a list to the row.- Type Parameters:
T
- the type of elements in the list- Parameters:
key
- the key for the listlist
- the list to add- Returns:
- the updated row
Example usage:
List<String> names = List.of("Alice", "Bob"); row.addList("key", names);
-
addSet
Adds a set to the row.- Type Parameters:
T
- the type of elements in the set- Parameters:
key
- the key for the setset
- the set to add- Returns:
- the updated row
Example usage:
Set<Integer> numbers = Set.of(1, 2, 3); row.addSet("key", numbers);
-
addMap
Adds a map to the row.- Type Parameters:
K
- the type of keys in the mapV
- the type of values in the map- Parameters:
key
- the key for the mapmyMap
- the map to add- Returns:
- the updated row
Example usage:
Map<String, Integer> exampleMap = Map.of("one", 1, "two", 2); row.addMap("key", exampleMap);
-
get
Gets the value of the given key, casting it to the givenClass<T>
. This is useful to avoid having casts in client code, though the effect is the same. So to get the value of a key that is of type String, you would writeString name = doc.get("name", String.class)
instead ofString name = (String) doc.get("x")
.- Type Parameters:
T
- the type of the class- Parameters:
key
- the keyclazz
- the non-null class to cast the value to- Returns:
- the value of the given key, or null if the instance does not contain this key.
- Throws:
ClassCastException
- if the value of the given key is not of type T
-
getInteger
Gets the value of the given key as an Integer.- Parameters:
key
- the key- Returns:
- the value as an integer, which may be null
- Throws:
ClassCastException
- if the value is not an integer
-
getDouble
Gets the value of the given key as a Double.- Parameters:
key
- the key- Returns:
- the value as a double, which may be null
- Throws:
ClassCastException
- if the value is not a double
-
getAscii
Gets the value of the given key as a String.- Parameters:
key
- the key- Returns:
- the value as a String, which may be null
- Throws:
ClassCastException
- if the value is not a String
-
getText
Gets the value of the given key as a String.- Parameters:
key
- the key- Returns:
- the value as a String, which may be null
- Throws:
ClassCastException
- if the value is not a String
-
getBigInt
Gets the value of the given key as a Long.- Parameters:
key
- the key- Returns:
- the value as a Long, which may be null
- Throws:
ClassCastException
- if the value is not a Long
-
getVector
Gets the value of the given key as a DataAPIVector.- Parameters:
key
- the key- Returns:
- the value as a DataAPIVector, which may be null
- Throws:
ClassCastException
- if the value is not a DataAPIVector
-
getBoolean
Gets the value of the given key as a Boolean.- Parameters:
key
- the key- Returns:
- the value as a Boolean, which may be null
- Throws:
ClassCastException
- if the value is not a boolean
-
getDate
Gets the value of the given key as a Date.- Parameters:
key
- the key- Returns:
- the value as a Date, which may be null
- Throws:
ClassCastException
- if the value is not a Date
-
getArray
Return an Array of items.- Type Parameters:
K
- type of item- Parameters:
k
- keyitemClass
- expected class- Returns:
- list of items
-
getUUID
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getFloat
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getShort
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getByte
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getCharacter
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getDate
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getCalendar
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getInstant
Access element from the map- Parameters:
k
- current configuration key- Returns:
- configuration value
-
getList
Gets the list value of the given key, casting the list elements to the givenClass<T>
. This is useful to avoid having casts in client code, though the effect is the same.- Type Parameters:
T
- the type of the class- Parameters:
key
- the keyclazz
- the non-null class to cast the list value to- Returns:
- the list value of the given key, or null if the instance does not contain this key.
- Throws:
ClassCastException
- if the elements in the list value of the given key is not of type T or the value is not a list
-
toString
Serialization with Jackson. -
containsKey
Gets the value of the given key. This is useful to avoid having casts in client code, though the effect is the same. So to get the value of a key that is of type String, you would writeString name = doc.get("name")
instead ofString name = (String) doc.get("x")
.- Parameters:
key
- the key- Returns:
- the value of the given key, or null if the instance does not contain this key.
-
get
Access element from the map- Parameters:
key
- current configuration key- Returns:
- configuration value
-
put
Add a key/value pair to the document.- Parameters:
key
- keyvalue
- value- Returns:
- current map
-
putAll
Add all information from the map.- Parameters:
map
- map to add
-
putAll
Add all information from the input row.- Parameters:
row
- row to add
-
equals
-
hashCode
public int hashCode()
-