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

Function main

c_glib/example/read-file.c:86–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86int
87main(int argc, char **argv)
88{
89 const char *input_path = "/tmp/batch.arrow";
90 GArrowMemoryMappedInputStream *input;
91 GError *error = NULL;
92
93 if (argc > 1)
94 input_path = argv[1];
95 input = garrow_memory_mapped_input_stream_new(input_path, &error);
96 if (!input) {
97 g_print("failed to open file: %s\n", error->message);
98 g_error_free(error);
99 return EXIT_FAILURE;
100 }
101
102 {
103 GArrowRecordBatchFileReader *reader;
104
105 reader =
106 garrow_record_batch_file_reader_new(GARROW_SEEKABLE_INPUT_STREAM(input), &error);
107 if (!reader) {
108 g_print("failed to open file reader: %s\n", error->message);
109 g_error_free(error);
110 g_object_unref(input);
111 return EXIT_FAILURE;
112 }
113
114 {
115 guint i, n;
116
117 n = garrow_record_batch_file_reader_get_n_record_batches(reader);
118 for (i = 0; i < n; i++) {
119 GArrowRecordBatch *record_batch;
120
121 record_batch =
122 garrow_record_batch_file_reader_read_record_batch(reader, i, &error);
123 if (!record_batch) {
124 g_print("failed to read %u-th record batch: %s\n", i, error->message);
125 g_error_free(error);
126 g_object_unref(reader);
127 g_object_unref(input);
128 return EXIT_FAILURE;
129 }
130
131 print_record_batch(record_batch);
132 g_object_unref(record_batch);
133 }
134 }
135
136 g_object_unref(reader);
137 }
138
139 g_object_unref(input);
140
141 return EXIT_SUCCESS;
142}

Callers

nothing calls this directly

Tested by

no test coverage detected