Class JsonRecordUtil

java.lang.Object
io.deephaven.kafka.ingest.JsonRecordUtil

public class JsonRecordUtil
extends Object

Provides methods and classes for retrieving typed values from a JsonRecord. The embedded classes are used to connect set methods of RowSetter objects so they can be called without boxing primitive types as they are read.

If allowMissingKeys is false in the JsonRecord being used and a requested key does not exist in the record, an IllegalArgumentException will be thrown. If missing keys are allowed, then the type-appropriate null value will be returned for get requests of missing keys.

If allowNullValues is false in the JsonRecord being used and a requested key has a null value in the record, an IllegalArgumentException will be thrown. If null values are allowed, then the type-appropriate null value will be returned for get requests of a key whose value is null.

If caseInsensitiveSearch is true in the JsonRecord being searched and a requested key does not exist in the record, then the record will be searched to find a key that matches in a case-insensitive manner.

  • Constructor Details

  • Method Details

    • getSetter

      public static JsonRecordSetter getSetter​(Class columnClass)
      Gets the appropriate JsonRecordSetter for the type of the Deephaven column to be populated.
      Parameters:
      columnClass - Class of the column to be populated.
      Returns:
      A JsonRecordSetter
    • getInt

      public static int getInt​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Deephaven int (primitive int with reserved values for null) from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Deephaven int (primitive int with reserved values for null)
    • getInt

      public static int getInt​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Deephaven int (primitive int with reserved values for null) from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Deephaven int (primitive int with reserved values for null)
    • getBoxedInt

      @Nullable public static Integer getBoxedInt​(@NotNull JsonRecord record, @NotNull String key)
      Returns an Integer from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      An Integer
    • getBoxedInt

      @Nullable public static Integer getBoxedInt​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns an Integer from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      An Integer
    • getShort

      public static short getShort​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Deephaven short (primitive short with reserved values for Null) from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Deephaven short (primitive short with reserved values for Null)
    • getShort

      public static short getShort​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Deephaven short (primitive short with reserved values for Null) from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Deephaven short (primitive short with reserved values for Null)
    • getBoxedShort

      @Nullable public static Short getBoxedShort​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Short from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Short
    • getBoxedShort

      @Nullable public static Short getBoxedShort​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
    • getLong

      public static long getLong​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Deephaven long (primitive long with reserved values for Null) from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Deephaven long (primitive long with reserved values for Null)
    • getLong

      public static long getLong​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Deephaven long (primitive long with reserved values for null) from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Deephaven long (primitive long with reserved values for null)
    • getBoxedLong

      @Nullable public static Long getBoxedLong​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Long from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Long
    • getBoxedLong

      @Nullable public static Long getBoxedLong​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Long from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Long
    • getDouble

      public static double getDouble​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Deephaven double (primitive double with reserved values for null) from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Deephaven double (primitive double with reserved values for null)
    • getDouble

      public static double getDouble​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Deephaven double (primitive double with reserved values for null) from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Deephaven double (primitive double with reserved values for null)
    • getBoxedDouble

      @Nullable public static Double getBoxedDouble​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Double from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Double
    • getBoxedDouble

      @Nullable public static Double getBoxedDouble​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Double from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Double
    • getFloat

      public static float getFloat​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Deephaven float (primitive float with reserved values for Null) from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Deephaven float (primitive float with reserved values for Null)
    • getFloat

      public static float getFloat​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Deephaven float (primitive float with reserved values for Null) from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Deephaven float (primitive float with reserved values for Null)
    • getBoxedFloat

      @Nullable public static Float getBoxedFloat​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Float from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Float
    • getBoxedFloat

      @Nullable public static Float getBoxedFloat​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Float from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Float
    • getByte

      public static byte getByte​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Deephaven byte (primitive byte with a reserved value for Null) from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Deephaven byte (primitive byte with a reserved value for Null)
    • getByte

      public static byte getByte​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Deephaven byte (primitive byte with a reserved value for Null) from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Deephaven byte (primitive byte with a reserved value for Null)
    • getBoxedByte

      @Nullable public static Byte getBoxedByte​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Byte from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Byte
    • getBoxedByte

      @Nullable public static Byte getBoxedByte​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Byte from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Byte
    • getChar

      public static char getChar​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Deephaven char (primitive char with a reserved value for Null) from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Deephaven char (primitive char with a reserved value for Null)
    • getChar

      public static char getChar​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Deephaven char (primitive char with a reserved value for Null) from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Deephaven char (primitive char with a reserved value for Null)
    • getBoxedChar

      @Nullable public static Character getBoxedChar​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Character from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Character
    • getBoxedChar

      @Nullable public static Character getBoxedChar​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode tmpNode)
    • getString

      @Nullable public static String getString​(@NotNull JsonRecord record, @NotNull String key)
      Returns a String from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A String
    • getString

      @Nullable public static String getString​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a String from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A String
    • getBoolean

      public static Boolean getBoolean​(@NotNull JsonRecord record, @NotNull String key)
      Returns a Boolean from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A Boolean
    • getBoolean

      @Nullable public static Boolean getBoolean​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a Boolean from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A Boolean
    • getBigInteger

      public static BigInteger getBigInteger​(@NotNull JsonRecord record, @NotNull String key)
      Returns a BigInteger from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A BigInteger
    • getBigInteger

      @Nullable public static BigInteger getBigInteger​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a BigInteger from a JsonRecord.
      Parameters:
      node - The JsonRecord from which to retrieve the value.
      Returns:
      A BigInteger
    • getBigDecimal

      @Nullable public static BigDecimal getBigDecimal​(@NotNull JsonRecord record, @NotNull String key)
      Returns a BigDecimal from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A BigDecimal
    • getBigDecimal

      @Nullable public static BigDecimal getBigDecimal​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a BigDecimal from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A BigDecimal
    • getValue

      @Nullable public static Object getValue​(@NotNull JsonRecord record, @NotNull String key)
      Returns a generic Object from a JsonRecord.
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      An Object
    • getValue

      @Nullable public static Object getValue​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a generic Object from a JsonNode.
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      An Object
    • getDBDateTime

      @Nullable public static DBDateTime getDBDateTime​(@NotNull JsonRecord record, @NotNull String key)
      Returns a DBDateTime from a JsonRecord. Will try to infer precision of a long value to be parsed using DBTimeUtils autoEpochToTime. If the value in the JSON record is not numeric, this method will attempt to parse it as a Deephaven DBDateTime string (yyyy-MM-ddThh:mm:ss[.nnnnnnnnn] TZ).
      Parameters:
      record - The JsonRecord from which to retrieve the value.
      key - The String key of the value to retrieve.
      Returns:
      A DBDateTime
    • getDBDateTime

      @Nullable public static DBDateTime getDBDateTime​(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
      Returns a DBDateTime from a JsonNode. Will try to infer precision of a long value to be parsed using DBTimeUtils autoEpochToTime. If the value in the JSON record is not numeric, this method will attempt to parse it as a Deephaven DBDateTime string (yyyy-MM-ddThh:mm:ss[.nnnnnnnnn] TZ).
      Parameters:
      node - The JsonNode from which to retrieve the value.
      Returns:
      A DBDateTime