MCPcopy Create free account
hub / github.com/apache/arrow / ScalarPrinter

Class ScalarPrinter

cpp/gdb_arrow.py:1249–1291  ·  view source on GitHub ↗

Pretty-printer for arrow::Scalar and subclasses.

Source from the content-addressed store, hash-verified

1247
1248
1249class ScalarPrinter:
1250 """
1251 Pretty-printer for arrow::Scalar and subclasses.
1252 """
1253
1254 def __new__(cls, val):
1255 # Lookup actual (derived) class to instantiate
1256 type_id = int(deref(val['type'])['id_'])
1257 type_class = lookup_type_class(type_id)
1258 if type_class is not None:
1259 cls = type_class.scalar_printer
1260 assert issubclass(cls, ScalarPrinter)
1261 self = object.__new__(cls)
1262 self.type_class = type_class
1263 self.type_name = type_class.name
1264 self.name = scalar_class_from_type(self.type_name)
1265 self.type_id = type_id
1266 # Cast to concrete Scalar class to access derived attributes.
1267 concrete_type = gdb.lookup_type(f"arrow::{self.name}")
1268 self.val = cast_to_concrete(val, concrete_type)
1269 self.is_valid = bool(self.val['is_valid'])
1270 return self
1271
1272 @property
1273 def type(self):
1274 """
1275 The concrete DataTypeClass instance.
1276 """
1277 concrete_type = gdb.lookup_type(f"arrow::{self.type_name}")
1278 return cast_to_concrete(deref(self.val['type']),
1279 concrete_type)
1280
1281 def _format_type(self):
1282 return f"arrow::{self.name}"
1283
1284 def _format_null(self):
1285 if self.type_class.is_parametric:
1286 return f"{self._format_type()} of type {self.type}, null value"
1287 else:
1288 return f"{self._format_type()} of null value"
1289
1290 def _for_evaluation(self):
1291 return for_evaluation(self.val)
1292
1293
1294class NullScalarPrinter(ScalarPrinter):

Callers 1

arrow_pretty_printFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected