| 103 | } |
| 104 | |
| 105 | int |
| 106 | main(int argc, char **argv) |
| 107 | { |
| 108 | if (argc != 2) { |
| 109 | g_print("Usage: %s PORT\n", argv[0]); |
| 110 | g_print(" e.g.: %s 2929\n", argv[0]); |
| 111 | return EXIT_FAILURE; |
| 112 | } |
| 113 | |
| 114 | guint port = atoi(argv[1]); |
| 115 | |
| 116 | GSocketClient *client = g_socket_client_new(); |
| 117 | GSocketAddress *address = g_inet_socket_address_new_from_string("127.0.0.1", port); |
| 118 | GError *error = NULL; |
| 119 | GSocketConnection *connection = |
| 120 | g_socket_client_connect(client, G_SOCKET_CONNECTABLE(address), NULL, &error); |
| 121 | if (!connection) { |
| 122 | g_print("failed to connect: %s\n", error->message); |
| 123 | g_error_free(error); |
| 124 | return EXIT_FAILURE; |
| 125 | } |
| 126 | |
| 127 | GArrowSchema *schema = build_schema(); |
| 128 | if (!schema) { |
| 129 | return EXIT_FAILURE; |
| 130 | } |
| 131 | GArrowGIOOutputStream *output = |
| 132 | garrow_gio_output_stream_new(g_io_stream_get_output_stream(G_IO_STREAM(connection))); |
| 133 | GArrowRecordBatchStreamWriter *writer = |
| 134 | garrow_record_batch_stream_writer_new(GARROW_OUTPUT_STREAM(output), schema, &error); |
| 135 | g_object_unref(schema); |
| 136 | if (!writer) { |
| 137 | g_print("failed to create writer: %s\n", error->message); |
| 138 | g_error_free(error); |
| 139 | g_object_unref(output); |
| 140 | g_object_unref(connection); |
| 141 | g_object_unref(client); |
| 142 | return EXIT_FAILURE; |
| 143 | } |
| 144 | |
| 145 | gsize n_record_batches = 5; |
| 146 | gsize i; |
| 147 | for (i = 0; i < n_record_batches; i++) { |
| 148 | GArrowRecordBatch *record_batch = build_record_batch(); |
| 149 | if (!record_batch) { |
| 150 | g_object_unref(writer); |
| 151 | g_object_unref(output); |
| 152 | g_object_unref(connection); |
| 153 | g_object_unref(client); |
| 154 | return EXIT_FAILURE; |
| 155 | } |
| 156 | gboolean success = |
| 157 | garrow_record_batch_writer_write_record_batch(GARROW_RECORD_BATCH_WRITER(writer), |
| 158 | record_batch, |
| 159 | &error); |
| 160 | g_object_unref(record_batch); |
| 161 | if (!success) { |
| 162 | g_print("failed to write record batch: %s\n", error->message); |
nothing calls this directly
no test coverage detected