Class JsonType
java.lang.Object
org.apache.arrow.vector.types.pojo.ArrowType
org.apache.arrow.vector.types.pojo.ArrowType.ComplexType
org.apache.arrow.vector.types.pojo.ArrowType.ExtensionType
org.apache.arrow.vector.extension.JsonType
Canonical extension type for UTF-8 encoded RFC 8259 JSON values.
The storage type is ArrowType.Utf8, ArrowType.LargeUtf8, or ArrowType.Utf8View. Values use the corresponding string vector; this type does not parse or
validate individual JSON values.
Register the type before reading schemas containing arrow.json:
JsonType.ensureRegistered();
Field field = Field.nullable("json", new JsonType(ArrowType.Utf8.INSTANCE));
try (JsonVector vector = (JsonVector) field.createVector(allocator)) {
VarCharVector storage = (VarCharVector) vector.getUnderlyingVector();
storage.setSafe(0, "{}".getBytes(java.nio.charset.StandardCharsets.UTF_8));
vector.setValueCount(1);
Text value = vector.getObject(0);
}
-
Nested Class Summary
Nested classes/interfaces inherited from class ArrowType
ArrowType.ArrowTypeID, ArrowType.ArrowTypeVisitor<T>, ArrowType.Binary, ArrowType.BinaryView, ArrowType.Bool, ArrowType.ComplexType, ArrowType.ComplexTypeVisitor<T>, ArrowType.Date, ArrowType.Decimal, ArrowType.Duration, ArrowType.ExtensionType, ArrowType.FixedSizeBinary, ArrowType.FixedSizeList, ArrowType.FloatingPoint, ArrowType.Int, ArrowType.Interval, ArrowType.LargeBinary, ArrowType.LargeList, ArrowType.LargeListView, ArrowType.LargeUtf8, ArrowType.List, ArrowType.ListView, ArrowType.Map, ArrowType.Null, ArrowType.PrimitiveType, ArrowType.PrimitiveTypeVisitor<T>, ArrowType.RunEndEncoded, ArrowType.Struct, ArrowType.Time, ArrowType.Timestamp, ArrowType.Union, ArrowType.Utf8, ArrowType.Utf8View -
Field Summary
FieldsFields inherited from class ArrowType.ExtensionType
EXTENSION_METADATA_KEY_METADATA, EXTENSION_METADATA_KEY_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(ArrowType storageType, String serializedData) Given saved metadata and the underlying storage type, construct a new instance of the user type.static voidRegister a prototype that can deserialize all supported JSON storage types.booleanCheck equality of this type to another user-defined type.The name of this user-defined type.getNewVector(String name, FieldType fieldType, BufferAllocator allocator) Construct a vector for the user type.booleanSave any metadata for this type.The on-wire type for this user-defined type.Methods inherited from class ArrowType.ExtensionType
accept, equals, getNewFieldWriter, getType, getTypeID, hashCode, toStringMethods inherited from class ArrowType
getInt, getTypeForField
-
Field Details
-
EXTENSION_NAME
- See Also:
-
-
Constructor Details
-
JsonType
Create a JSON type backed by the specified string type.- Parameters:
storageType- Utf8, LargeUtf8, or Utf8View- Throws:
IllegalArgumentException- if the storage type is not a supported string type
-
-
Method Details
-
ensureRegistered
public static void ensureRegistered()Register a prototype that can deserialize all supported JSON storage types. -
storageType
Description copied from class:ArrowType.ExtensionTypeThe on-wire type for this user-defined type.- Specified by:
storageTypein classArrowType.ExtensionType
-
extensionName
Description copied from class:ArrowType.ExtensionTypeThe name of this user-defined type. Used to identify the type during serialization.- Specified by:
extensionNamein classArrowType.ExtensionType
-
extensionEquals
Description copied from class:ArrowType.ExtensionTypeCheck equality of this type to another user-defined type.- Specified by:
extensionEqualsin classArrowType.ExtensionType
-
serialize
Description copied from class:ArrowType.ExtensionTypeSave any metadata for this type.- Specified by:
serializein classArrowType.ExtensionType
-
deserialize
Description copied from class:ArrowType.ExtensionTypeGiven saved metadata and the underlying storage type, construct a new instance of the user type.- Specified by:
deserializein classArrowType.ExtensionType
-
isComplex
public boolean isComplex()- Overrides:
isComplexin classArrowType.ComplexType
-
getNewVector
Description copied from class:ArrowType.ExtensionTypeConstruct a vector for the user type.- Specified by:
getNewVectorin classArrowType.ExtensionType
-