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

Function MakeWriter

python/pyarrow/src/arrow/python/arrow_to_pandas.cc:2045–2119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2043};
2044
2045Status MakeWriter(const PandasOptions& options, PandasWriter::type writer_type,
2046 const DataType& type, int64_t num_rows, int num_columns,
2047 std::shared_ptr<PandasWriter>* writer) {
2048#define BLOCK_CASE(NAME, TYPE) \
2049 case PandasWriter::NAME: \
2050 *writer = std::make_shared<TYPE>(options, num_rows, num_columns); \
2051 break;
2052
2053#define CATEGORICAL_CASE(TYPE) \
2054 case TYPE::type_id: \
2055 *writer = std::make_shared<CategoricalWriter<TYPE>>(options, num_rows); \
2056 break;
2057
2058#define TZ_CASE(NAME, TYPE) \
2059 case PandasWriter::NAME: { \
2060 const auto& ts_type = checked_cast<const TimestampType&>(type); \
2061 *writer = std::make_shared<TYPE>(options, ts_type.timezone(), num_rows); \
2062 } break;
2063
2064 switch (writer_type) {
2065 case PandasWriter::CATEGORICAL: {
2066 const auto& index_type = *checked_cast<const DictionaryType&>(type).index_type();
2067 switch (index_type.id()) {
2068 CATEGORICAL_CASE(Int8Type);
2069 CATEGORICAL_CASE(Int16Type);
2070 CATEGORICAL_CASE(Int32Type);
2071 CATEGORICAL_CASE(Int64Type);
2072 CATEGORICAL_CASE(UInt8Type);
2073 CATEGORICAL_CASE(UInt16Type);
2074 CATEGORICAL_CASE(UInt32Type);
2075 CATEGORICAL_CASE(UInt64Type);
2076 default:
2077 // Unreachable
2078 ARROW_DCHECK(false);
2079 break;
2080 }
2081 } break;
2082 case PandasWriter::EXTENSION:
2083 *writer = std::make_shared<ExtensionWriter>(options, num_rows, num_columns);
2084 break;
2085 BLOCK_CASE(OBJECT, ObjectWriter);
2086 BLOCK_CASE(UINT8, UInt8Writer);
2087 BLOCK_CASE(INT8, Int8Writer);
2088 BLOCK_CASE(UINT16, UInt16Writer);
2089 BLOCK_CASE(INT16, Int16Writer);
2090 BLOCK_CASE(UINT32, UInt32Writer);
2091 BLOCK_CASE(INT32, Int32Writer);
2092 BLOCK_CASE(UINT64, UInt64Writer);
2093 BLOCK_CASE(INT64, Int64Writer);
2094 BLOCK_CASE(HALF_FLOAT, Float16Writer);
2095 BLOCK_CASE(FLOAT, Float32Writer);
2096 BLOCK_CASE(DOUBLE, Float64Writer);
2097 BLOCK_CASE(BOOL, BoolWriter);
2098 BLOCK_CASE(DATETIME_DAY, DatetimeDayWriter);
2099 BLOCK_CASE(DATETIME_SECOND, DatetimeSecondWriter);
2100 BLOCK_CASE(DATETIME_MILLI, DatetimeMilliWriter);
2101 BLOCK_CASE(DATETIME_MICRO, DatetimeMicroWriter);
2102 BLOCK_CASE(DATETIME_NANO, DatetimeNanoWriter);

Callers 3

CreateBlocksMethod · 0.70
GetWriterMethod · 0.70

Calls 4

index_typeMethod · 0.80
NotImplementedFunction · 0.50
OKFunction · 0.50
idMethod · 0.45

Tested by

no test coverage detected