Class: Nanoarrow::CSchemaView

Inherits:
Object
  • Object
show all
Defined in:
ext/nanoarrow/schema_view.c

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'ext/nanoarrow/schema_view.c', line 40

VALUE schema_view_initialize(VALUE self, VALUE schema)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    view->base = schema;
    view->schema_view.type = NANOARROW_TYPE_UNINITIALIZED;
    view->schema_view.storage_type = NANOARROW_TYPE_UNINITIALIZED;

    schema_t* schema_ptr;
    GetSchema(schema, schema_ptr);

    struct ArrowError error;
    int code = ArrowSchemaViewInit(&view->schema_view, schema_ptr->ptr, &error);
    raise_message_not_ok(&error, "ArrowSchemaViewInit()", code);

    view->nullable = schema_ptr->ptr->flags & ARROW_FLAG_NULLABLE;

    return self;
}

Instance Method Details

#decimal_precisionObject



146
147
148
149
150
151
152
153
154
155
# File 'ext/nanoarrow/schema_view.c', line 146

VALUE schema_view_decimal_precision(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    if (is_decimal(view->schema_view.type))
        return INT2NUM(view->schema_view.decimal_precision);
    else
        return Qnil;
}

#decimal_scaleObject



157
158
159
160
161
162
163
164
165
166
# File 'ext/nanoarrow/schema_view.c', line 157

VALUE schema_view_decimal_scale(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    if (is_decimal(view->schema_view.type))
        return INT2NUM(view->schema_view.decimal_scale);
    else
        return Qnil;
}

#fixed_sizeObject



135
136
137
138
139
140
141
142
143
144
# File 'ext/nanoarrow/schema_view.c', line 135

VALUE schema_view_fixed_size(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    if (is_fixed_size(view->schema_view.type))
        return INT2NUM(view->schema_view.fixed_size);
    else
        return Qnil;
}

#nullableObject



89
90
91
92
93
94
95
# File 'ext/nanoarrow/schema_view.c', line 89

VALUE schema_view_nullable(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    return view->nullable != 0 ? Qtrue : Qfalse;
}

#storage_type_idObject



69
70
71
72
73
74
75
# File 'ext/nanoarrow/schema_view.c', line 69

VALUE schema_view_storage_type_id(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    return INT2NUM(view->schema_view.storage_type);
}

#time_unitObject



168
169
170
171
172
173
174
175
176
177
# File 'ext/nanoarrow/schema_view.c', line 168

VALUE schema_view_time_unit(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    if (has_time_unit(view->schema_view.type))
        return rb_utf8_str_new_cstr(ArrowTimeUnitString(view->schema_view.time_unit));
    else
        return Qnil;
}

#timezoneObject



179
180
181
182
183
184
185
186
187
188
# File 'ext/nanoarrow/schema_view.c', line 179

VALUE schema_view_timezone(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    if (view->schema_view.type == NANOARROW_TYPE_TIMESTAMP)
        return rb_utf8_str_new_cstr(view->schema_view.timezone);
    else
        return Qnil;
}

#typeObject



77
78
79
80
81
82
83
84
85
86
87
# File 'ext/nanoarrow/schema_view.c', line 77

VALUE schema_view_type(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    const char* type_str = ArrowTypeString(view->schema_view.type);
    if (type_str != NULL)
        return rb_utf8_str_new_cstr(type_str);
    else
        rb_raise(rb_eArgError, "ArrowTypeString() returned NULL");
}

#type_idObject



61
62
63
64
65
66
67
# File 'ext/nanoarrow/schema_view.c', line 61

VALUE schema_view_type_id(VALUE self)
{
    schema_view_t* view;
    GetSchemaView(self, view);

    return INT2NUM(view->schema_view.type);
}