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

Function main

c_glib/example/read-stream.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/stream.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 GArrowRecordBatchReader *reader;
104 GArrowRecordBatchStreamReader *stream_reader;
105
106 stream_reader =
107 garrow_record_batch_stream_reader_new(GARROW_INPUT_STREAM(input), &error);
108 if (!stream_reader) {
109 g_print("failed to open stream reader: %s\n", error->message);
110 g_error_free(error);
111 g_object_unref(input);
112 return EXIT_FAILURE;
113 }
114
115 reader = GARROW_RECORD_BATCH_READER(stream_reader);
116 while (TRUE) {
117 GArrowRecordBatch *record_batch;
118
119 record_batch = garrow_record_batch_reader_read_next(reader, &error);
120 if (error) {
121 g_print("failed to read the next record batch: %s\n", error->message);
122 g_error_free(error);
123 g_object_unref(reader);
124 g_object_unref(input);
125 return EXIT_FAILURE;
126 }
127
128 if (!record_batch) {
129 break;
130 }
131
132 print_record_batch(record_batch);
133 g_object_unref(record_batch);
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