ExtensionType {arrow} | R 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 araw()
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 (araw()
vector) such that its contents can be inspected by fields and/or methods of the R6 ExtensionType subclass. Implementations must also check thestorage_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 byas.vector()
on ExtensionArray objects, when a RecordBatch containing an ExtensionArray is converted to adata.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.