ExtensionType: ExtensionType class

ExtensionTypeR Documentation

ExtensionType class

Description

ExtensionType class

Methods

The ExtensionType class inherits from DataType, but also defines extra methods specific to extension types:

  • ⁠$storage_type()⁠: Returns the underlying DataType used to store values.

  • ⁠$storage_id()⁠: Returns the Type identifier corresponding to the ⁠$storage_type()⁠.

  • ⁠$extension_name()⁠: Returns the extension name.

  • ⁠$extension_metadata()⁠: Returns the serialized version of the extension metadata as a raw() vector.

  • ⁠$extension_metadata_utf8()⁠: Returns the serialized version of the extension metadata as a UTF-8 encoded string.

  • ⁠$WrapArray(array)⁠: Wraps a storage Array into an ExtensionArray with this extension type.

In addition, subclasses may override the following methods to customize the behaviour of extension classes.

  • ⁠$deserialize_instance()⁠: This method is called when a new ExtensionType is initialized and is responsible for parsing and validating the serialized extension_metadata (a raw() vector) such that its contents can be inspected by fields and/or methods of the R6 ExtensionType subclass. Implementations must also check the storage_type to make sure it is compatible with the extension type.

  • ⁠$as_vector(extension_array)⁠: Convert an Array or ChunkedArray to an R vector. This method is called by as.vector() on ExtensionArray objects, when a RecordBatch containing an ExtensionArray is converted to a data.frame(), or when a ChunkedArray (e.g., a column in a Table) is converted to an R vector. The default method returns the converted storage array.

  • ⁠$ToString()⁠ Return a string representation that will be printed to the console when this type or an Array of this type is printed.


arrow documentation built on Sept. 11, 2024, 8:02 p.m.