java.lang.Object
com.datastax.astra.client.tables.definition.rows.Row
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TableUpdateOperation

public class Row extends Object implements Serializable
Record present in a Cassandra Table.
See Also:
  • Field Details

    • SERIALIZER

      protected static final DataAPISerializer SERIALIZER
      Serializer for the Rows.
    • columnMap

      public transient Map<String,Object> columnMap
      Data to be used in the document.
  • Constructor Details

    • Row

      public Row()
      Default Constructor.
    • Row

      public Row(Map<String,?> map)
      Creates a Document instance initialized with the given map.
      Parameters:
      map - initial map
  • Method Details

    • getColumnMap

      public Map<String,Object> getColumnMap()
      Access internal property map.
      Returns:
      internal map
    • setProperty

      public void setProperty(String key, Object value)
      Set a property in the row.
      Parameters:
      key - key
      value - value
    • create

      public static Row create()
      Create a row with no attributes.
      Returns:
      instance of document
    • map

      public <T> T map(Class<T> clazz)
      Marshall as a row if needed.
      Type Parameters:
      T - current type
      Parameters:
      clazz - target class
      Returns:
      instance of pojo
    • parse

      public static Row parse(String json)
      Parses a string in MongoDB Extended JSON format to a Document
      Parameters:
      json - the JSON string
      Returns:
      the document
    • add

      public Row add(String key, Object value)
      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 - key
      value - value
      Returns:
      this
    • addText

      public Row addText(String key, String value)
      Adds a text value to the row.
      Parameters:
      key - the key for the text value
      value - the text value to add
      Returns:
      the updated row

      Example usage:

       
       row.addText("name", "example");
       
       
    • addAscii

      public Row addAscii(String key, String value)
      Adds an ASCII-encoded text value to the row.
      Parameters:
      key - the key for the ASCII value
      value - the ASCII value to add
      Returns:
      the updated row

      Example usage:

       
       row.addAscii("key", "ASCII value");
       
       
    • addVectorize

      public Row addVectorize(String key, String value)
      Adds a vectorized value to the row.
      Parameters:
      key - the key for the vectorized value
      value - the vectorized value to add
      Returns:
      the updated row

      Example usage:

       
       row.addVectorize("vectorKey", "vectorizedData");
       
       
    • addVarInt

      public Row addVarInt(String key, BigInteger value)
      Adds a variable-length integer (VarInt) value to the row.
      Parameters:
      key - the key for the VarInt value
      value - the VarInt value to add
      Returns:
      the updated row

      Example usage:

       
       row.addVarInt("key", new BigInteger("123456789"));
       
       
    • addBigInt

      public Row addBigInt(String key, Long value)
      Adds a BigInt value to the row.
      Parameters:
      key - the key for the BigInt value
      value - the BigInt value to add
      Returns:
      the updated row

      Example usage:

       
       row.addBigInt("key", 123456789L);
       
       
    • addInt

      public Row addInt(String key, Integer value)
      Adds an Integer value to the row.
      Parameters:
      key - the key for the Integer value
      value - the Integer value to add
      Returns:
      the updated row

      Example usage:

       
       row.addInt("key", 42);
       
       
    • addSmallInt

      public Row addSmallInt(String key, Short value)
      Adds a SmallInt value to the row.
      Parameters:
      key - the key for the SmallInt value
      value - the SmallInt value to add
      Returns:
      the updated row

      Example usage:

       
       row.addSmallInt("key", (short) 32000);
       
       
    • addTinyInt

      public Row addTinyInt(String key, Byte value)
      Adds a TinyInt value to the row.
      Parameters:
      key - the key for the TinyInt value
      value - the TinyInt value to add
      Returns:
      the updated row

      Example usage:

       
       row.addTinyInt("key", (byte) 127);
       
       
    • addBoolean

      public Row addBoolean(String key, Boolean value)
      Adds a Boolean value to the row.
      Parameters:
      key - the key for the Boolean value
      value - the Boolean value to add
      Returns:
      the updated row

      Example usage:

       
       row.addBoolean("key", true);
       
       
    • addBlob

      public Row addBlob(String key, byte[] value)
      Adds a Blob (byte array) to the row.
      Parameters:
      key - the key for the Blob value
      value - the byte array to add
      Returns:
      the updated row

      Example usage:

       
       byte[] data = {1, 2, 3};
       row.addBlob("key", data);
       
       
    • addFloat

      public Row addFloat(String key, Float value)
      Adds a Float value to the row.
      Parameters:
      key - the key for the Float value
      value - the Float value to add
      Returns:
      the updated row

      Example usage:

       
       row.addFloat("key", 3.14f);
       
       
    • addDecimal

      public Row addDecimal(String key, BigDecimal value)
      Adds a Decimal (BigDecimal) value to the row.
      Parameters:
      key - the key for the Decimal value
      value - the BigDecimal value to add
      Returns:
      the updated row

      Example usage:

       
       row.addDecimal("key", new BigDecimal("12345.6789"));
       
       
    • addDouble

      public Row addDouble(String key, Double value)
      Adds a Double value to the row.
      Parameters:
      key - the key for the Double value
      value - the Double value to add
      Returns:
      the updated row

      Example usage:

       
       row.addDouble("key", 3.14159);
       
       
    • addDate

      public Row addDate(String key, Date value)
      Adds a Date value to the row.
      Parameters:
      key - the key for the Date value
      value - the Date value to add
      Returns:
      the updated row

      Example usage:

       
       row.addDate("key", new Date());
       
       
    • addLocalDate

      public Row addLocalDate(String key, LocalDate localDate)
      Adds a LocalDate value to the row, converting it to a Date.
      Parameters:
      key - the key for the LocalDate value
      localDate - the LocalDate value to add
      Returns:
      the updated row

      Example usage:

       
       row.addDate("key", LocalDate.now());
       
       
    • addInet

      public Row addInet(String key, InetAddress value)
      Adds an InetAddress value to the row.
      Parameters:
      key - the key for the InetAddress value
      value - the InetAddress value to add
      Returns:
      the updated row

      Example usage:

       
       row.addInet("key", InetAddress.getByName("127.0.0.1"));
       
       
    • addDuration

      public Row addDuration(String key, Duration duration)
      Adds a Duration value to the row.
      Parameters:
      key - the key for the Duration value
      duration - the Duration value to add
      Returns:
      the updated row

      Example usage:

       
       row.addDuration("key", Duration.ofMinutes(10));
       
       
    • addDuration

      public Row addDuration(String key, Period period, Duration duration)
      Adds a Duration value to the row.
      Parameters:
      key - the key for the Duration value
      period - the Period value to add
      duration - the Duration value to add
      Returns:
      the updated row

      Example usage:

       
       row.addDuration("key", Period.ofDays(1), Duration.ofMinutes(10));
       
       
    • addDuration

      public Row addDuration(String key, Period period)
      Adds a duration value composed of only a Period to the row.
      Parameters:
      key - the key for the duration value
      period - the period component of the duration
      Returns:
      the updated row

      Example usage:

       
       row.addDuration("key", Period.ofWeeks(2));
       
       
    • addTableDuration

      public Row addTableDuration(String key, TableDuration value)
      Adds a TableDuration value to the row.
      Parameters:
      key - the key for the TableDuration value
      value - the TableDuration value to add
      Returns:
      the updated row

      Example usage:

       
       row.addTableDuration("key", new TableDuration(Period.ofMonths(1), Duration.ofMinutes(30)));
       
       
    • addUUID

      public Row addUUID(String key, UUID value)
      Adds a UUID value to the row.
      Parameters:
      key - the key for the UUID value
      value - the UUID value to add
      Returns:
      the updated row

      Example usage:

       
       row.addUUID("key", UUID.randomUUID());
       
       
    • addTimeStamp

      public Row addTimeStamp(String key, Instant instant)
      Adds a timestamp (Instant) value to the row.
      Parameters:
      key - the key for the timestamp
      instant - the Instant value to add
      Returns:
      the updated row

      Example usage:

       
       row.addTimeStamp("key", Instant.now());
       
       
    • addTime

      public Row addTime(String key, LocalTime ltime)
      Adds a LocalTime value to the row.
      Parameters:
      key - the key for the time value
      ltime - the LocalTime value to add
      Returns:
      the updated row

      Example usage:

       
       row.addTime("key", LocalTime.now());
       
       
    • addVector

      public Row addVector(String key, DataAPIVector vector)
      Adds a DataAPIVector value to the row.
      Parameters:
      key - the key for the vector
      vector - 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

      public Row addVector(String key, float[] vector)
      Adds a vector (float array) to the row, wrapping it in a DataAPIVector.
      Parameters:
      key - the key for the vector
      vector - the float array to add
      Returns:
      the updated row

      Example usage:

       
       row.addVector("key", new float[]{1.0f, 2.0f, 3.0f});
       
       
    • addList

      public <T> Row addList(String key, List<T> list)
      Adds a list to the row.
      Type Parameters:
      T - the type of elements in the list
      Parameters:
      key - the key for the list
      list - the list to add
      Returns:
      the updated row

      Example usage:

       
       List<String> names = List.of("Alice", "Bob");
       row.addList("key", names);
       
       
    • addSet

      public <T> Row addSet(String key, Set<T> set)
      Adds a set to the row.
      Type Parameters:
      T - the type of elements in the set
      Parameters:
      key - the key for the set
      set - the set to add
      Returns:
      the updated row

      Example usage:

       
       Set<Integer> numbers = Set.of(1, 2, 3);
       row.addSet("key", numbers);
       
       
    • addMap

      public <K, V> Row addMap(String key, Map<K,V> myMap)
      Adds a map to the row.
      Type Parameters:
      K - the type of keys in the map
      V - the type of values in the map
      Parameters:
      key - the key for the map
      myMap - 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

      public <T> T get(@NonNull @NonNull String key, @NonNull @NonNull Class<T> clazz)
      Gets the value of the given key, casting it to the given Class<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 write String name = doc.get("name", String.class) instead of String name = (String) doc.get("x") .
      Type Parameters:
      T - the type of the class
      Parameters:
      key - the key
      clazz - 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

      public Integer getInteger(String key)
      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

      public Double getDouble(String key)
      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

      public String getAscii(String key)
      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

      public String getText(String key)
      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

      public Long getBigInt(String key)
      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

      public DataAPIVector getVector(String key)
      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

      public Boolean getBoolean(String key)
      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

      public Date getDate(Object key)
      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

      public <K> K[] getArray(String k, Class<K> itemClass)
      Return an Array of items.
      Type Parameters:
      K - type of item
      Parameters:
      k - key
      itemClass - expected class
      Returns:
      list of items
    • getUUID

      public UUID getUUID(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getFloat

      public Float getFloat(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getShort

      public Short getShort(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getByte

      public Byte getByte(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getCharacter

      public Character getCharacter(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getDate

      public Date getDate(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getCalendar

      public Calendar getCalendar(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getInstant

      public Instant getInstant(String k)
      Access element from the map
      Parameters:
      k - current configuration key
      Returns:
      configuration value
    • getList

      public <T> List<T> getList(@NonNull @NonNull String key, @NonNull @NonNull Class<T> clazz)
      Gets the list value of the given key, casting the list elements to the given Class<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 key
      clazz - 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

      public String toString()
      Serialization with Jackson.
      Overrides:
      toString in class Object
      Returns:
      json string
    • containsKey

      public boolean containsKey(Object key)
      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 write String name = doc.get("name") instead of String 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

      public Object get(Object key)
      Access element from the map
      Parameters:
      key - current configuration key
      Returns:
      configuration value
    • put

      public Object put(String key, Object value)
      Add a key/value pair to the document.
      Parameters:
      key - key
      value - value
      Returns:
      current map
    • putAll

      public void putAll(Map<? extends String,?> map)
      Add all information from the map.
      Parameters:
      map - map to add
    • putAll

      public void putAll(Row row)
      Add all information from the input row.
      Parameters:
      row - row to add
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object