1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <arrow-glib/enums.h>
#include <arrow-glib/error.hpp>
#include <arrow-glib/file-system.hpp>
#include <arrow-glib/input-stream.hpp>
#include <arrow-glib/local-file-system.h>
#include <arrow-glib/output-stream.hpp>
G_BEGIN_DECLS
/**
* SECTION: file-system
* @section_id: file-system-classes
* @title: File system classes
* @include: arrow-glib/arrow-glib.h
*
* #GArrowFileInfo is a class for information for a file system entry.
*
* #GArrowFileSelector is a class for a selector for file system APIs.
*
* #GArrowFileSystem is an interface for file system.
*
* #GArrowSubTreeFileSystem is a delegator to another file system that is
* a logical view of a subtree of a file system, such as a directory in
* a local file system.
*
* #GArrowSlowFileSystem is a delegator to another file system.
* This inserts latencies at various points.
*
* #GArrowMockFileSystem is a class for mock file system that holds
* its contents in memory.
*
* #GArrowHDFSFileSystem is a class for HDFS-backed file system.
*
* #GArrowS3FileSystem is a class for S3-backed file system.
*/
/* arrow::fs::FileInfo */
typedef struct GArrowFileInfoPrivate_ {
arrow::fs::FileInfo file_info;
} GArrowFileInfoPrivate;
enum {
PROP_FILE_INFO_TYPE = 1,
PROP_FILE_INFO_PATH,
PROP_FILE_INFO_BASE_NAME,
PROP_FILE_INFO_DIR_NAME,
PROP_FILE_INFO_EXTENSION,
PROP_FILE_INFO_SIZE,
PROP_FILE_INFO_MTIME,
};
G_DEFINE_TYPE_WITH_PRIVATE(GArrowFileInfo, garrow_file_info, G_TYPE_OBJECT)
#define GARROW_FILE_INFO_GET_PRIVATE(obj) \
static_cast<GArrowFileInfoPrivate *>( \
garrow_file_info_get_instance_private( \
GARROW_FILE_INFO(obj)))
static void
garrow_file_info_finalize(GObject *object)
{
auto priv = GARROW_FILE_INFO_GET_PRIVATE(object);
priv->file_info.~FileInfo();
G_OBJECT_CLASS(garrow_file_info_parent_class)->finalize(object);
}
static void
garrow_file_info_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
auto arrow_file_info = garrow_file_info_get_raw(GARROW_FILE_INFO(object));
switch (prop_id) {
case PROP_FILE_INFO_TYPE:
{
auto arrow_file_type =
static_cast<arrow::fs::FileType>(g_value_get_enum(value));
arrow_file_info->set_type(arrow_file_type);
}
break;
case PROP_FILE_INFO_PATH:
arrow_file_info->set_path(g_value_get_string(value));
break;
case PROP_FILE_INFO_SIZE:
arrow_file_info->set_size(g_value_get_int64(value));
break;
case PROP_FILE_INFO_MTIME:
{
const gint64 mtime = g_value_get_int64(value);
const arrow::fs::TimePoint::duration duration(mtime);
arrow_file_info->set_mtime(arrow::fs::TimePoint(duration));
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_file_info_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
const auto arrow_file_info =
garrow_file_info_get_raw(GARROW_FILE_INFO(object));
switch (prop_id) {
case PROP_FILE_INFO_TYPE:
{
const auto arrow_file_type = arrow_file_info->type();
const auto file_type = static_cast<GArrowFileType>(arrow_file_type);
g_value_set_enum(value, file_type);
}
break;
case PROP_FILE_INFO_PATH:
g_value_set_string(value, arrow_file_info->path().c_str());
break;
case PROP_FILE_INFO_BASE_NAME:
g_value_set_string(value, arrow_file_info->base_name().c_str());
break;
case PROP_FILE_INFO_DIR_NAME:
g_value_set_string(value, arrow_file_info->dir_name().c_str());
break;
case PROP_FILE_INFO_EXTENSION:
g_value_set_string(value, arrow_file_info->extension().c_str());
break;
case PROP_FILE_INFO_SIZE:
g_value_set_int64(value, arrow_file_info->size());
break;
case PROP_FILE_INFO_MTIME:
{
const auto arrow_mtime = arrow_file_info->mtime();
const auto mtime = arrow_mtime.time_since_epoch().count();
g_value_set_int64(value, mtime);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_file_info_init(GArrowFileInfo *object)
{
auto priv = GARROW_FILE_INFO_GET_PRIVATE(object);
new(&priv->file_info) arrow::fs::FileInfo;
}
static void
garrow_file_info_class_init(GArrowFileInfoClass *klass)
{
GParamSpec *spec;
auto gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = garrow_file_info_finalize;
gobject_class->set_property = garrow_file_info_set_property;
gobject_class->get_property = garrow_file_info_get_property;
auto info = arrow::fs::FileInfo();
/**
* GArrowFileInfo:type:
*
* The type of the entry.
*
* Since: 0.17.0
*/
spec = g_param_spec_enum("type",
"Type",
"The type of the entry",
GARROW_TYPE_FILE_TYPE,
GARROW_FILE_TYPE_UNKNOWN,
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_FILE_INFO_TYPE, spec);
/**
* GArrowFileInfo:path:
*
* The full file path in the file system.
*
* Since: 0.17.0
*/
spec = g_param_spec_string("path",
"Path",
"The full file path",
info.path().c_str(),
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_FILE_INFO_PATH, spec);
/**
* GArrowFileInfo:base-name:
*
* The file base name (component after the last directory separator).
*
* Since: 0.17.0
*/
spec = g_param_spec_string("base-name",
"Base name",
"The file base name",
info.base_name().c_str(),
static_cast<GParamFlags>(G_PARAM_READABLE));
g_object_class_install_property(gobject_class,
PROP_FILE_INFO_BASE_NAME,
spec);
/**
* GArrowFileInfo:dir-name:
*
* The directory base name (component before the file base name).
*
* Since: 0.17.0
*/
spec = g_param_spec_string("dir-name",
"Directory name",
"The directory base name",
info.dir_name().c_str(),
static_cast<GParamFlags>(G_PARAM_READABLE));
g_object_class_install_property(gobject_class,
PROP_FILE_INFO_DIR_NAME,
spec);
/**
* GArrowFileInfo:extension:
*
* The file extension (excluding the dot).
*
* Since: 0.17.0
*/
spec = g_param_spec_string("extension",
"Extension",
"The file extension",
info.extension().c_str(),
static_cast<GParamFlags>(G_PARAM_READABLE));
g_object_class_install_property(gobject_class,
PROP_FILE_INFO_EXTENSION,
spec);
/**
* GArrowFileInfo:size:
*
* The size in bytes, if available
* Only regular files are guaranteed to have a size.
*
* Since: 0.17.0
*/
spec = g_param_spec_int64("size",
"Size",
"The size in bytes",
arrow::fs::kNoSize,
INT64_MAX,
info.size(),
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_FILE_INFO_SIZE, spec);
/**
* GArrowFileInfo:mtime:
*
* The time of last modification, if available.
*
* Since: 0.17.0
*/
spec = g_param_spec_int64("mtime",
"Last modified time",
"The time of last modification",
arrow::fs::kNoTime.time_since_epoch().count(),
INT64_MAX,
info.mtime().time_since_epoch().count(),
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_FILE_INFO_MTIME, spec);
}
/**
* garrow_file_info_new:
*
* Returns: A newly created #GArrowFileInfo.
*
* Since: 0.17.0
*/
GArrowFileInfo *
garrow_file_info_new(void)
{
return GARROW_FILE_INFO(g_object_new(GARROW_TYPE_FILE_INFO, NULL));
}
/**
* garrow_file_info_equal:
* @file_info: A #GArrowFileInfo.
* @other_file_info: A #GArrowFileInfo to be compared.
*
* Returns: %TRUE if both of them have the same data, %FALSE
* otherwise.
*
* Since: 0.17.0
*/
gboolean
garrow_file_info_equal(GArrowFileInfo *file_info,
GArrowFileInfo *other_file_info)
{
const auto arrow_file_info = garrow_file_info_get_raw(file_info);
const auto arrow_other_file_info = garrow_file_info_get_raw(other_file_info);
return arrow_file_info->Equals(*arrow_other_file_info);
}
/**
* garrow_file_info_is_file:
* @file_info: A #GArrowFileInfo.
*
* Returns: %TRUE if the entry is a file, %FALSE otherwise.
*
* Since: 0.17.0
*/
gboolean
garrow_file_info_is_file(GArrowFileInfo *file_info)
{
const auto arrow_file_info = garrow_file_info_get_raw(file_info);
return arrow_file_info->IsFile();
}
/**
* garrow_file_info_is_dir
* @file_info: A #GArrowFileInfo.
*
* Returns: %TRUE if the entry is a directory, %FALSE otherwise.
*
* Since: 0.17.0
*/
gboolean
garrow_file_info_is_dir(GArrowFileInfo *file_info)
{
const auto arrow_file_info = garrow_file_info_get_raw(file_info);
return arrow_file_info->IsDirectory();
}
/**
* garrow_file_info_to_string:
* @file_info: A #GArrowFileInfo.
*
* Returns: The string representation of the file statistics.
*
* It should be freed with g_free() when no longer needed.
*
* Since: 0.17.0
*/
gchar *
garrow_file_info_to_string(GArrowFileInfo *file_info)
{
const auto arrow_file_info = garrow_file_info_get_raw(file_info);
return g_strdup(arrow_file_info->ToString().c_str());
}
/* arrow::fs::FileSelector */
typedef struct GArrowFileSelectorPrivate_ {
arrow::fs::FileSelector file_selector;
} GArrowFileSelectorPrivate;
enum {
PROP_FILE_SELECTOR_BASE_DIR = 1,
PROP_FILE_SELECTOR_ALLOW_NOT_FOUND,
PROP_FILE_SELECTOR_RECURSIVE,
PROP_FILE_SELECTOR_MAX_RECURSION
};
G_DEFINE_TYPE_WITH_PRIVATE(GArrowFileSelector, garrow_file_selector, G_TYPE_OBJECT)
#define GARROW_FILE_SELECTOR_GET_PRIVATE(obj) \
static_cast<GArrowFileSelectorPrivate *>( \
garrow_file_selector_get_instance_private( \
GARROW_FILE_SELECTOR(obj)))
static void
garrow_file_selector_finalize(GObject *object)
{
auto priv = GARROW_FILE_SELECTOR_GET_PRIVATE(object);
priv->file_selector.~FileSelector();
G_OBJECT_CLASS(garrow_file_selector_parent_class)->finalize(object);
}
static void
garrow_file_selector_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
auto priv = GARROW_FILE_SELECTOR_GET_PRIVATE(object);
switch (prop_id) {
case PROP_FILE_SELECTOR_BASE_DIR:
priv->file_selector.base_dir = g_value_get_string(value);
break;
case PROP_FILE_SELECTOR_ALLOW_NOT_FOUND:
priv->file_selector.allow_not_found = g_value_get_boolean(value);
break;
case PROP_FILE_SELECTOR_RECURSIVE:
priv->file_selector.recursive = g_value_get_boolean(value);
break;
case PROP_FILE_SELECTOR_MAX_RECURSION:
priv->file_selector.max_recursion = g_value_get_int(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_file_selector_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
auto priv = GARROW_FILE_SELECTOR_GET_PRIVATE(object);
switch (prop_id) {
case PROP_FILE_SELECTOR_BASE_DIR:
g_value_set_string(value, priv->file_selector.base_dir.c_str());
break;
case PROP_FILE_SELECTOR_ALLOW_NOT_FOUND:
g_value_set_boolean(value, priv->file_selector.allow_not_found);
break;
case PROP_FILE_SELECTOR_RECURSIVE:
g_value_set_boolean(value, priv->file_selector.recursive);
break;
case PROP_FILE_SELECTOR_MAX_RECURSION:
g_value_set_int(value, priv->file_selector.max_recursion);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_file_selector_init(GArrowFileSelector *object)
{
auto priv = GARROW_FILE_SELECTOR_GET_PRIVATE(object);
new(&priv->file_selector) arrow::fs::FileSelector;
}
static void
garrow_file_selector_class_init(GArrowFileSelectorClass *klass)
{
GParamSpec *spec;
auto gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = garrow_file_selector_finalize;
gobject_class->set_property = garrow_file_selector_set_property;
gobject_class->get_property = garrow_file_selector_get_property;
auto file_selector = arrow::fs::FileSelector();
/**
* GArrowFileSelector:base-dir:
*
* The directory in which to select files.
* If the path exists but doesn't point to a directory, this should
* be an error.
*
* Since: 0.17.0
*/
spec = g_param_spec_string("base-dir",
"Base dir",
"The directory in which to select files",
file_selector.base_dir.c_str(),
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
PROP_FILE_SELECTOR_BASE_DIR,
spec);
/**
* GArrowFileSelector:allow-not-found:
*
* The behavior if `base_dir` isn't found in the file system.
* If false, an error is returned. If true, an empty selection is returned.
*
* Since: 0.17.0
*/
spec = g_param_spec_boolean("allow-not-found",
"Allow not found",
"The behavior if `base_dir` isn't found in the file system",
file_selector.allow_not_found,
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
PROP_FILE_SELECTOR_ALLOW_NOT_FOUND,
spec);
/**
* GArrowFileSelector:recursive:
*
* Whether to recurse into subdirectories.
*
* Since: 0.17.0
*/
spec = g_param_spec_boolean("recursive",
"Recursive",
"Whether to recurse into subdirectories",
file_selector.recursive,
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
PROP_FILE_SELECTOR_RECURSIVE,
spec);
/**
* GArrowFileSelector:max-recursion:
*
* The maximum number of subdirectories to recurse into.
*
* Since: 0.17.0
*/
spec = g_param_spec_int("max-recursion",
"Max recursion",
"The maximum number of subdirectories to recurse into",
0,
INT32_MAX,
file_selector.max_recursion,
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
PROP_FILE_SELECTOR_MAX_RECURSION,
spec);
}
/* arrow::fs::FileSystem */
typedef struct GArrowFileSystemPrivate_ {
std::shared_ptr<arrow::fs::FileSystem> file_system;
} GArrowFileSystemPrivate;
enum {
PROP_FILE_SYSTEM = 1
};
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(GArrowFileSystem,
garrow_file_system,
G_TYPE_OBJECT)
#define GARROW_FILE_SYSTEM_GET_PRIVATE(obj) \
static_cast<GArrowFileSystemPrivate *>( \
garrow_file_system_get_instance_private( \
GARROW_FILE_SYSTEM(obj)))
static void
garrow_file_system_finalize(GObject *object)
{
auto priv = GARROW_FILE_SYSTEM_GET_PRIVATE(object);
priv->file_system.~shared_ptr();
G_OBJECT_CLASS(garrow_file_system_parent_class)->finalize(object);
}
static void
garrow_file_system_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
auto priv = GARROW_FILE_SYSTEM_GET_PRIVATE(object);
switch (prop_id) {
case PROP_FILE_SYSTEM:
priv->file_system =
*static_cast<std::shared_ptr<arrow::fs::FileSystem> *>(g_value_get_pointer(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_file_system_init(GArrowFileSystem *object)
{
auto priv = GARROW_FILE_SYSTEM_GET_PRIVATE(object);
new(&priv->file_system) std::shared_ptr<arrow::fs::FileSystem>;
}
static void
garrow_file_system_class_init(GArrowFileSystemClass *klass)
{
GParamSpec *spec;
auto gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = garrow_file_system_finalize;
gobject_class->set_property = garrow_file_system_set_property;
spec = g_param_spec_pointer("file-system",
"FileSystem",
"The raw std::shared<arrow::fs::FileSystem> *",
static_cast<GParamFlags>(G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(gobject_class, PROP_FILE_SYSTEM, spec);
}
/**
* garrow_file_system_create:
* @uri: An URI to specify file system with options. If you only have an
* absolute path, g_filename_to_uri() will help you.
* @error: (nullable): Return location for a #GError or %NULL.
*
* This is a factory function to create a specific #GArrowFileSystem
* object.
*
* Returns: (nullable) (transfer full): The newly created file system
* that is an object of a subclass of #GArrowFileSystem.
*
* Since: 3.0.0
*/
GArrowFileSystem *
garrow_file_system_create(const gchar *uri, GError **error)
{
auto arrow_file_system_result = arrow::fs::FileSystemFromUri(uri);
if (garrow::check(error,
arrow_file_system_result,
"[file-system][create]")) {
auto arrow_file_system = *arrow_file_system_result;
return garrow_file_system_new_raw(&arrow_file_system);
} else {
return NULL;
}
}
/**
* garrow_file_system_get_type_name:
* @file_system: A #GArrowFileSystem.
*
* Returns: The name of file system type.
*
* It should be freed with g_free() when no longer needed.
*
* Since: 0.17.0
*/
gchar *
garrow_file_system_get_type_name(GArrowFileSystem *file_system)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
const auto &type_name = arrow_file_system->type_name();
return g_strndup(type_name.data(), type_name.size());
}
/**
* garrow_file_system_get_file_info:
* @file_system: A #GArrowFileSystem.
* @path: The path of the target.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Get information for the given target.
*
* Any symlink is automatically dereferenced, recursively.
* A non-existing or unreachable file returns an OK status and has
* a #GArrowFileType of value %GARROW_FILE_TYPE_NOT_FOUND.
* An error status indicates a truly exceptional condition
* (low-level I/O error, etc.).
*
* Returns: (nullable) (transfer full): A #GArrowFileInfo.
*
* Since: 0.17.0
*/
GArrowFileInfo *
garrow_file_system_get_file_info(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto arrow_result = arrow_file_system->GetFileInfo(path);
if (garrow::check(error, arrow_result, "[file-system][get-file-info]")) {
const auto &arrow_file_info = *arrow_result;
return garrow_file_info_new_raw(arrow_file_info);
} else {
return NULL;
}
}
static inline GList *
garrow_file_infos_new(arrow::Result<std::vector<arrow::fs::FileInfo>>&& arrow_result,
GError **error,
const gchar *context)
{
if (garrow::check(error, arrow_result, context)) {
auto arrow_file_infos = *arrow_result;
GList *file_infos = NULL;
for (auto arrow_file_info : arrow_file_infos) {
auto file_info = garrow_file_info_new_raw(arrow_file_info);
file_infos = g_list_prepend(file_infos, file_info);
}
return g_list_reverse(file_infos);
} else {
return NULL;
}
}
/**
* garrow_file_system_get_file_infos_paths:
* @file_system: A #GArrowFileSystem.
* @paths: (array length=n_paths): The paths of the targets.
* @n_paths: The number of items in @paths.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Get information same as garrow_file_system_get_file_info()
* for the given many targets at once.
*
* Returns: (element-type GArrowFileInfo) (transfer full):
* A list of #GArrowFileInfo.
*
* Since: 0.17.0
*/
GList *
garrow_file_system_get_file_infos_paths(GArrowFileSystem *file_system,
const gchar **paths,
gsize n_paths,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
std::vector<std::string> arrow_paths;
for (gsize i = 0; i < n_paths; ++i) {
arrow_paths.push_back(paths[i]);
}
return garrow_file_infos_new(arrow_file_system->GetFileInfo(arrow_paths),
error,
"[file-system][get-file-infos][paths]");
}
/**
* garrow_file_system_get_file_infos_selector:
* @file_system: A #GArrowFileSystem.
* @file_selector: A #GArrowFileSelector.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Get information same as garrow_file_system_get_file_info()
* according to a selector.
*
* The selector's base directory will not be part of the results,
* even if it exists.
*
* Returns: (element-type GArrowFileInfo) (transfer full):
* A list of #GArrowFileInfo.
*
* Since: 0.17.0
*/
GList *
garrow_file_system_get_file_infos_selector(GArrowFileSystem *file_system,
GArrowFileSelector *file_selector,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
const auto &arrow_file_selector =
GARROW_FILE_SELECTOR_GET_PRIVATE(file_selector)->file_selector;
return garrow_file_infos_new(arrow_file_system->GetFileInfo(arrow_file_selector),
error,
"[file-system][get-file-infos][selector]");
}
/**
* garrow_file_system_create_dir:
* @file_system: A #GArrowFileSystem.
* @path: The paths of the directory.
* @recursive: Whether creating directory recursively or not.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Create a directory and subdirectories.
* This function succeeds if the directory already exists.
*
* Returns: %TRUE on success, %FALSE if there was an error.
*
* Since: 0.17.0
*/
gboolean
garrow_file_system_create_dir(GArrowFileSystem *file_system,
const gchar *path,
gboolean recursive,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto status = arrow_file_system->CreateDir(path, recursive);
return garrow::check(error, status, "[file-system][create-dir]");
}
/**
* garrow_file_system_delete_dir:
* @file_system: A #GArrowFileSystem.
* @path: The paths of the directory.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Delete a directory and its contents, recursively.
*
* Returns: %TRUE on success, %FALSE if there was an error.
*
* Since: 0.17.0
*/
gboolean
garrow_file_system_delete_dir(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto status = arrow_file_system->DeleteDir(path);
return garrow::check(error, status, "[file-system][delete-dir]");
}
/**
* garrow_file_system_delete_dir_contents:
* @file_system: A #GArrowFileSystem.
* @path: The paths of the directory.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Delete a directory's contents, recursively. Like
* garrow_file_system_delete_dir(), but doesn't delete the directory
* itself. Passing an empty path (`""`) will wipe the entire file
* system tree.
*
* Returns: %TRUE on success, %FALSE if there was an error.
*
* Since: 0.17.0
*/
gboolean
garrow_file_system_delete_dir_contents(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto status = arrow_file_system->DeleteDirContents(path);
return garrow::check(error, status, "[file-system][delete-dir-contents]");
}
/**
* garrow_file_system_delete_file:
* @file_system: A #GArrowFileSystem.
* @path: The paths of the file to be delete.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Delete a file.
*
* Returns: %TRUE on success, %FALSE if there was an error.
*
* Since: 0.17.0
*/
gboolean
garrow_file_system_delete_file(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto status = arrow_file_system->DeleteFile(path);
return garrow::check(error, status, "[file-system][delete-file]");
}
/**
* garrow_file_system_delete_files:
* @file_system: A #GArrowFileSystem.
* @paths: (array length=n_paths):
* The paths of the files to be delete.
* @n_paths: The number of items in @paths.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Delete many files.
*
* Returns: %TRUE on success, %FALSE if there was an error.
*
* Since: 0.17.0
*/
gboolean
garrow_file_system_delete_files(GArrowFileSystem *file_system,
const gchar **paths,
gsize n_paths,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
std::vector<std::string> arrow_paths;
arrow_paths.reserve(n_paths);
for (gsize i = 0; i < n_paths; ++i) {
arrow_paths.emplace_back(paths[i]);
}
auto status = arrow_file_system->DeleteFiles(arrow_paths);
return garrow::check(error, status, "[file-system][delete-files]");
}
/**
* garrow_file_system_move:
* @file_system: A #GArrowFileSystem.
* @src: The path of the source file.
* @dest: The path of the destination.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Move / rename a file or a directory.
* If the destination exists:
* - if it is a non-empty directory, an error is returned
* - otherwise, if it has the same type as the source, it is replaced
* - otherwise, behavior is unspecified (implementation-dependent).
*
* Returns: %TRUE on success, %FALSE if there was an error.
*
* Since: 0.17.0
*/
gboolean
garrow_file_system_move(GArrowFileSystem *file_system,
const gchar *src,
const gchar *dest,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto status = arrow_file_system->Move(src, dest);
return garrow::check(error, status, "[file-system][move]");
}
/**
* garrow_file_system_copy_file:
* @file_system: A #GArrowFileSystem.
* @src: The path of the source file.
* @dest: The path of the destination.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Copy a file.
* If the destination exists and is a directory, an error is returned.
* Otherwise, it is replaced.
*
* Returns: %TRUE on success, %FALSE if there was an error.
*
* Since: 0.17.0
*/
gboolean
garrow_file_system_copy_file(GArrowFileSystem *file_system,
const gchar *src,
const gchar *dest,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto status = arrow_file_system->CopyFile(src, dest);
return garrow::check(error, status, "[file-system][copy-file]");
}
/**
* garrow_file_system_open_input_stream:
* @file_system: A #GArrowFileSystem.
* @path: The path of the input stream.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Open an input stream for sequential reading.
*
* Returns: (nullable) (transfer full): A newly created
* #GArrowInputStream.
*
* Since: 0.17.0
*/
GArrowInputStream *
garrow_file_system_open_input_stream(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto arrow_input_stream = arrow_file_system->OpenInputStream(path);
if (garrow::check(error,
arrow_input_stream,
"[file-system][open-input-stream]")) {
return garrow_input_stream_new_raw(&(*arrow_input_stream));
} else {
return NULL;
}
}
/**
* garrow_file_system_open_input_file:
* @file_system: A #GArrowFileSystem.
* @path: The path of the input file.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Open an input file for random access reading.
*
* Returns: (nullable) (transfer full): A newly created
* #GArrowSeekableInputStream.
*
* Since: 0.17.0
*/
GArrowSeekableInputStream *
garrow_file_system_open_input_file(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto arrow_random_access_file = arrow_file_system->OpenInputFile(path);
if (garrow::check(error,
arrow_random_access_file,
"[file-system][open-input-file]")) {
return garrow_seekable_input_stream_new_raw(&(*arrow_random_access_file));
} else {
return NULL;
}
}
/**
* garrow_file_system_open_output_stream:
* @file_system: A #GArrowFileSystem.
* @path: The path of the output stream.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Open an output stream for sequential writing.
* If the target already exists, the existing data is truncated.
*
* Returns: (nullable) (transfer full): A newly created
* #GArrowOutputStream.
*
* Since: 0.17.0
*/
GArrowOutputStream *
garrow_file_system_open_output_stream(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto arrow_output_stream = arrow_file_system->OpenOutputStream(path);
if (garrow::check(error,
arrow_output_stream,
"[file-system][open-output-stream]")) {
return garrow_output_stream_new_raw(&(*arrow_output_stream));
} else {
return NULL;
}
}
/**
* garrow_file_system_open_append_stream:
* @file_system: A #GArrowFileSystem.
* @path: The path of the output stream.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Open an output stream for appending.
* If the target doesn't exist, a new empty file is created.
*
* Returns: (nullable) (transfer full): A newly created #GArrowOutputStream
* for appending.
*
* Since: 0.17.0
*/
GArrowOutputStream *
garrow_file_system_open_append_stream(GArrowFileSystem *file_system,
const gchar *path,
GError **error)
{
auto arrow_file_system = garrow_file_system_get_raw(file_system);
auto arrow_output_stream = arrow_file_system->OpenAppendStream(path);
if (garrow::check(error,
arrow_output_stream,
"[file-system][open-append-stream]")) {
return garrow_output_stream_new_raw(&(*arrow_output_stream));
} else {
return NULL;
}
}
/* arrow::fs::SubTreeFileSystem */
typedef struct GArrowSubTreeFileSystemPrivate_ {
GArrowFileSystem *base_file_system;
} GArrowSubTreeFileSystemPrivate;
enum {
PROP_BASE_FILE_SYSTEM = 1,
};
G_DEFINE_TYPE_WITH_PRIVATE(GArrowSubTreeFileSystem,
garrow_sub_tree_file_system,
GARROW_TYPE_FILE_SYSTEM)
#define GARROW_SUB_TREE_FILE_SYSTEM_GET_PRIVATE(object) \
static_cast<GArrowSubTreeFileSystemPrivate *>( \
garrow_sub_tree_file_system_get_instance_private( \
GARROW_SUB_TREE_FILE_SYSTEM(object)))
static void
garrow_sub_tree_file_system_dispose(GObject *object)
{
auto priv = GARROW_SUB_TREE_FILE_SYSTEM_GET_PRIVATE(object);
if (priv->base_file_system) {
g_object_unref(priv->base_file_system);
priv->base_file_system = NULL;
}
G_OBJECT_CLASS(garrow_sub_tree_file_system_parent_class)->dispose(object);
}
static void
garrow_sub_tree_file_system_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
auto priv = GARROW_SUB_TREE_FILE_SYSTEM_GET_PRIVATE(object);
switch (prop_id) {
case PROP_BASE_FILE_SYSTEM:
priv->base_file_system = GARROW_FILE_SYSTEM(g_value_dup_object(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_sub_tree_file_system_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
auto priv = GARROW_SUB_TREE_FILE_SYSTEM_GET_PRIVATE(object);
switch (prop_id) {
case PROP_BASE_FILE_SYSTEM:
g_value_set_object(value, priv->base_file_system);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_sub_tree_file_system_init(GArrowSubTreeFileSystem *file_system)
{
}
static void
garrow_sub_tree_file_system_class_init(GArrowSubTreeFileSystemClass *klass)
{
auto gobject_class = G_OBJECT_CLASS(klass);
gobject_class->dispose = garrow_sub_tree_file_system_dispose;
gobject_class->set_property = garrow_sub_tree_file_system_set_property;
gobject_class->get_property = garrow_sub_tree_file_system_get_property;
GParamSpec *spec;
spec = g_param_spec_object("base-file-system",
"Base file system",
"The base GArrowFileSystem",
GARROW_TYPE_FILE_SYSTEM,
static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(gobject_class, PROP_BASE_FILE_SYSTEM, spec);
}
/**
* garrow_sub_tree_file_system_new:
* @base_path: A base path of the sub tree file system.
* @base_file_system: A #GArrowFileSystem as the base file system.
*
* Returns: (transfer full): A newly created #GArrowSubTreeFileSystem.
*
* Since: 0.17.0
*/
GArrowSubTreeFileSystem *
garrow_sub_tree_file_system_new(const gchar *base_path,
GArrowFileSystem *base_file_system)
{
auto arrow_base_file_system = garrow_file_system_get_raw(base_file_system);
auto arrow_sub_tree_file_system =
std::static_pointer_cast<arrow::fs::FileSystem>(
std::make_shared<arrow::fs::SubTreeFileSystem>(base_path,
arrow_base_file_system));
return garrow_sub_tree_file_system_new_raw(&arrow_sub_tree_file_system,
base_file_system);
}
/* arrow::fs::SlowFileSystem */
typedef struct GArrowSlowFileSystemPrivate_ {
GArrowFileSystem *base_file_system;
} GArrowSlowFileSystemPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(GArrowSlowFileSystem,
garrow_slow_file_system,
GARROW_TYPE_FILE_SYSTEM)
#define GARROW_SLOW_FILE_SYSTEM_GET_PRIVATE(object) \
static_cast<GArrowSlowFileSystemPrivate *>( \
garrow_slow_file_system_get_instance_private( \
GARROW_SLOW_FILE_SYSTEM(object)))
static void
garrow_slow_file_system_dispose(GObject *object)
{
auto priv = GARROW_SLOW_FILE_SYSTEM_GET_PRIVATE(object);
if (priv->base_file_system) {
g_object_unref(priv->base_file_system);
priv->base_file_system = NULL;
}
G_OBJECT_CLASS(garrow_slow_file_system_parent_class)->dispose(object);
}
static void
garrow_slow_file_system_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
auto priv = GARROW_SLOW_FILE_SYSTEM_GET_PRIVATE(object);
switch (prop_id) {
case PROP_BASE_FILE_SYSTEM:
priv->base_file_system = GARROW_FILE_SYSTEM(g_value_dup_object(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_slow_file_system_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
auto priv = GARROW_SLOW_FILE_SYSTEM_GET_PRIVATE(object);
switch (prop_id) {
case PROP_BASE_FILE_SYSTEM:
g_value_set_object(value, priv->base_file_system);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
garrow_slow_file_system_init(GArrowSlowFileSystem *file_system)
{
}
static void
garrow_slow_file_system_class_init(GArrowSlowFileSystemClass *klass)
{
auto gobject_class = G_OBJECT_CLASS(klass);
gobject_class->dispose = garrow_slow_file_system_dispose;
gobject_class->set_property = garrow_slow_file_system_set_property;
gobject_class->get_property = garrow_slow_file_system_get_property;
GParamSpec *spec;
spec = g_param_spec_object("base-file-system",
"Base file system",
"The base GArrowFileSystem",
GARROW_TYPE_FILE_SYSTEM,
static_cast<GParamFlags>(G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(gobject_class, PROP_BASE_FILE_SYSTEM, spec);
}
/**
* garrow_slow_file_system_new_average_latency:
* @base_file_system: A #GArrowFileSystem as the base file system.
* @average_latency: The average value of the latency.
*
* The latency is normally distributed with a standard deviation of
* @average_latency * 0.1.
*
* The random seed is given by the default random device.
*
* Returns: (transfer full): A newly created #GArrowSlowFileSystem.
*
* Since: 0.17.0
*/
GArrowSlowFileSystem *
garrow_slow_file_system_new_average_latency(GArrowFileSystem *base_file_system,
gdouble average_latency)
{
auto arrow_base_file_system = garrow_file_system_get_raw(base_file_system);
auto arrow_slow_file_system =
std::static_pointer_cast<arrow::fs::FileSystem>(
std::make_shared<arrow::fs::SlowFileSystem>(arrow_base_file_system,
average_latency));
return garrow_slow_file_system_new_raw(&arrow_slow_file_system,
base_file_system);
}
/**
* garrow_slow_file_system_new_average_latency_and_seed:
* @base_file_system: A #GArrowFileSystem as the base file system.
* @average_latency: The average value of the latency.
* @seed: A random seed.
*
* The latency is normally distributed with a standard deviation of
* @average_latency * 0.1.
*
* Returns: (transfer full): A newly created #GArrowSlowFileSystem.
*
* Since: 0.17.0
*/
GArrowSlowFileSystem *
garrow_slow_file_system_new_average_latency_and_seed(GArrowFileSystem *base_file_system,
gdouble average_latency,
gint32 seed)
{
auto arrow_base_file_system = garrow_file_system_get_raw(base_file_system);
auto arrow_slow_file_system =
std::static_pointer_cast<arrow::fs::FileSystem>(
std::make_shared<arrow::fs::SlowFileSystem>(arrow_base_file_system,
average_latency,
seed));
return garrow_slow_file_system_new_raw(&arrow_slow_file_system,
base_file_system);
}
G_DEFINE_TYPE(GArrowMockFileSystem,
garrow_mock_file_system,
GARROW_TYPE_FILE_SYSTEM)
static void
garrow_mock_file_system_init(GArrowMockFileSystem *file_system)
{
}
static void
garrow_mock_file_system_class_init(GArrowMockFileSystemClass *klass)
{
}
G_DEFINE_TYPE(GArrowHDFSFileSystem,
garrow_hdfs_file_system,
GARROW_TYPE_FILE_SYSTEM)
static void
garrow_hdfs_file_system_init(GArrowHDFSFileSystem *file_system)
{
}
static void
garrow_hdfs_file_system_class_init(GArrowHDFSFileSystemClass *klass)
{
}
G_DEFINE_TYPE(GArrowS3FileSystem,
garrow_s3_file_system,
GARROW_TYPE_FILE_SYSTEM)
static void
garrow_s3_file_system_init(GArrowS3FileSystem *file_system)
{
}
static void
garrow_s3_file_system_class_init(GArrowS3FileSystemClass *klass)
{
}
G_END_DECLS
GArrowFileInfo *
garrow_file_info_new_raw(const arrow::fs::FileInfo &arrow_file_info)
{
auto file_info = garrow_file_info_new();
GARROW_FILE_INFO_GET_PRIVATE(file_info)->file_info = arrow_file_info;
return file_info;
}
arrow::fs::FileInfo *
garrow_file_info_get_raw(GArrowFileInfo *file_info)
{
auto priv = GARROW_FILE_INFO_GET_PRIVATE(file_info);
return &(priv->file_info);
}
GArrowFileSystem *
garrow_file_system_new_raw(
std::shared_ptr<arrow::fs::FileSystem> *arrow_file_system)
{
const auto &type_name = (*arrow_file_system)->type_name();
GType file_system_type = GARROW_TYPE_FILE_SYSTEM;
if (type_name == "local") {
file_system_type = GARROW_TYPE_LOCAL_FILE_SYSTEM;
} else if (type_name == "hdfs") {
file_system_type = GARROW_TYPE_HDFS_FILE_SYSTEM;
} else if (type_name == "s3") {
file_system_type = GARROW_TYPE_S3_FILE_SYSTEM;
} else if (type_name == "mock") {
file_system_type = GARROW_TYPE_MOCK_FILE_SYSTEM;
}
return GARROW_FILE_SYSTEM(g_object_new(file_system_type,
"file-system", arrow_file_system,
NULL));
}
std::shared_ptr<arrow::fs::FileSystem>
garrow_file_system_get_raw(GArrowFileSystem *file_system)
{
auto priv = GARROW_FILE_SYSTEM_GET_PRIVATE(file_system);
return priv->file_system;
}
GArrowSubTreeFileSystem *
garrow_sub_tree_file_system_new_raw(
std::shared_ptr<arrow::fs::FileSystem> *arrow_file_system,
GArrowFileSystem *base_file_system)
{
return GARROW_SUB_TREE_FILE_SYSTEM(
g_object_new(GARROW_TYPE_SUB_TREE_FILE_SYSTEM,
"file-system", arrow_file_system,
"base-file-system", base_file_system,
NULL));
}
GArrowSlowFileSystem *
garrow_slow_file_system_new_raw(
std::shared_ptr<arrow::fs::FileSystem> *arrow_file_system,
GArrowFileSystem *base_file_system)
{
return GARROW_SLOW_FILE_SYSTEM(
g_object_new(GARROW_TYPE_SLOW_FILE_SYSTEM,
"file-system", arrow_file_system,
"base-file-system", base_file_system,
NULL));
}
|