Package com.kuzudb

Class KuzuStruct

java.lang.Object
com.kuzudb.KuzuStruct
All Implemented Interfaces:
AutoCloseable

public class KuzuStruct extends Object implements AutoCloseable
  • Constructor Details

    • KuzuStruct

      public KuzuStruct(Value value)
      Construct a struct from a value
      Parameters:
      value - the value to construct the struct from
    • KuzuStruct

      public KuzuStruct(Map<String,Value> fields)
      Construct a struct literal from a given set of fields represented as a Java map.
      Parameters:
      fields - : The fields of the struct, with the keys representing the field names and the values representing the field values.
    • KuzuStruct

      public KuzuStruct(String[] fieldNames, Value[] fieldValues)
      Construct a struct literal from a given set of fields. The length of the fieldName/fieldValue arrays must be the same.
      Parameters:
      fieldNames - : The name of the struct fields
      fieldValues - : The values of the struct fields
  • Method Details

    • getValue

      public Value getValue()
      Returns:
      Gets the underlying Value for the struct
    • getNumFields

      public long getNumFields()
      Returns:
      The number of fields in the struct.
      Throws:
      RuntimeException - If the struct has been destroyed.
    • getIndexByFieldName

      public long getIndexByFieldName(String fieldName)
      Get the index of the field with the given name
      Parameters:
      fieldName - : The name of the field.
      Returns:
      The index of the field with the given name, or -1 if it doesn't exist
      Throws:
      RuntimeException - If the struct has been destroyed.
    • getFieldNameByIndex

      public String getFieldNameByIndex(long index)
      Get the name of the field at the given index
      Parameters:
      index - : The index of the field.
      Returns:
      The name of the field at the given index
      Throws:
      RuntimeException - If the struct has been destroyed.
    • getValueByFieldName

      public Value getValueByFieldName(String fieldName)
      Get the value of the field with the given name
      Parameters:
      fieldName - : The name of the field.
      Returns:
      The value of the field with the given name value.
      Throws:
      RuntimeException - If the struct has been destroyed.
    • getValueByIndex

      public Value getValueByIndex(long index)
      Get the value of the field at the given index
      Parameters:
      index - : The index of the field.
      Returns:
      The value of the field at the given index value.
      Throws:
      RuntimeException - If the struct has been destroyed.
    • toMap

      public Map<String,Value> toMap()
      Gets the elements the struct as a Java map. This will be truncated if the number of fields doesn't fit in a 32-bit integer.
      Returns:
      the struct as a Java map
      Throws:
      RuntimeException
    • close

      public void close()
      Closes this object, relinquishing the underlying value
      Specified by:
      close in interface AutoCloseable
      Throws:
      RuntimeException