Skip to content

Commit

Permalink
[GLib] Add GArrowRecordBatchBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 29, 2017
1 parent 74a934a commit c6ed17a
Show file tree
Hide file tree
Showing 11 changed files with 510 additions and 2 deletions.
3 changes: 3 additions & 0 deletions c_glib/arrow-glib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ libarrow_glib_la_headers = \
record-batch.h \
schema.h \
table.h \
table-builder.h \
tensor.h \
type.h

Expand Down Expand Up @@ -97,6 +98,7 @@ libarrow_glib_la_sources = \
record-batch.cpp \
schema.cpp \
table.cpp \
table-builder.cpp \
tensor.cpp \
type.cpp \
$(libarrow_glib_la_headers) \
Expand Down Expand Up @@ -133,6 +135,7 @@ libarrow_glib_la_cpp_headers = \
record-batch.hpp \
schema.hpp \
table.hpp \
table-builder.hpp \
tensor.hpp \
type.hpp

Expand Down
28 changes: 26 additions & 2 deletions c_glib/arrow-glib/array-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ G_BEGIN_DECLS

typedef struct GArrowArrayBuilderPrivate_ {
arrow::ArrayBuilder *array_builder;
gboolean have_ownership;
} GArrowArrayBuilderPrivate;

enum {
Expand All @@ -225,7 +226,9 @@ garrow_array_builder_finalize(GObject *object)

priv = GARROW_ARRAY_BUILDER_GET_PRIVATE(object);

delete priv->array_builder;
if (priv->have_ownership) {
delete priv->array_builder;
}

G_OBJECT_CLASS(garrow_array_builder_parent_class)->finalize(object);
}
Expand Down Expand Up @@ -267,6 +270,10 @@ garrow_array_builder_get_property(GObject *object,
static void
garrow_array_builder_init(GArrowArrayBuilder *builder)
{
GArrowArrayBuilderPrivate *priv;

priv = GARROW_ARRAY_BUILDER_GET_PRIVATE(builder);
priv->have_ownership = TRUE;
}

static void
Expand Down Expand Up @@ -301,7 +308,24 @@ garrow_array_builder_new(const std::shared_ptr<arrow::DataType> &type,
return NULL;
}
return garrow_array_builder_new_raw(arrow_builder.release());
};
}

/**
* garrow_array_builder_release_ownership: (skip)
* @builder: A #GArrowArrayBuilder.
*
* Release ownership of `arrow::ArrayBuilder` in `builder`.
*
* Since: 0.8.8
*/
void
garrow_array_builder_release_ownership(GArrowArrayBuilder *builder)
{
GArrowArrayBuilderPrivate *priv;

priv = GARROW_ARRAY_BUILDER_GET_PRIVATE(builder);
priv->have_ownership = FALSE;
}

/**
* garrow_array_builder_finish:
Expand Down
2 changes: 2 additions & 0 deletions c_glib/arrow-glib/array-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct _GArrowArrayBuilderClass
GObjectClass parent_class;
};

void garrow_array_builder_release_ownership(GArrowArrayBuilder *builder);

GArrowArray *garrow_array_builder_finish (GArrowArrayBuilder *builder,
GError **error);

Expand Down
1 change: 1 addition & 0 deletions c_glib/arrow-glib/arrow-glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <arrow-glib/record-batch.h>
#include <arrow-glib/schema.h>
#include <arrow-glib/table.h>
#include <arrow-glib/table-builder.h>
#include <arrow-glib/tensor.h>
#include <arrow-glib/type.h>

Expand Down
1 change: 1 addition & 0 deletions c_glib/arrow-glib/arrow-glib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <arrow-glib/record-batch.hpp>
#include <arrow-glib/schema.hpp>
#include <arrow-glib/table.hpp>
#include <arrow-glib/table-builder.hpp>
#include <arrow-glib/tensor.hpp>
#include <arrow-glib/type.hpp>

Expand Down
3 changes: 3 additions & 0 deletions c_glib/arrow-glib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sources = files(
'record-batch.cpp',
'schema.cpp',
'table.cpp',
'table-builder.cpp',
'tensor.cpp',
'type.cpp',
)
Expand Down Expand Up @@ -70,6 +71,7 @@ c_headers = files(
'record-batch.h',
'schema.h',
'table.h',
'table-builder.h',
'tensor.h',
'type.h',
)
Expand Down Expand Up @@ -110,6 +112,7 @@ cpp_headers = files(
'record-batch.hpp',
'schema.hpp',
'table.hpp',
'table-builder.hpp',
'tensor.hpp',
'type.hpp',
)
Expand Down
Loading

0 comments on commit c6ed17a

Please sign in to comment.