nanoarrow/0000755000176200001440000000000014702646313012266 5ustar liggesusersnanoarrow/tests/0000755000176200001440000000000014307221533013422 5ustar liggesusersnanoarrow/tests/testthat/0000755000176200001440000000000014702646313015270 5ustar liggesusersnanoarrow/tests/testthat/test-array-stream.R0000644000176200001440000002063014641546020020774 0ustar liggesusers# 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. test_that("basic_array_stream() can create empty streams", { stream <- basic_array_stream(list(), na_int32()) expect_identical(stream$get_schema()$format, "i") expect_null(stream$get_next()) expect_error( basic_array_stream(list()), "Can't infer schema from first batch if there are zero batches" ) }) test_that("basic_array_stream() can create streams from batches", { stream <- basic_array_stream( list( data.frame(a = 1, b = "two", stringsAsFactors = FALSE), data.frame(a = 2, b = "three", stringsAsFactors = FALSE) ) ) expect_identical(stream$get_schema()$format, "+s") expect_identical( as.data.frame(stream$get_next()), data.frame(a = 1, b = "two", stringsAsFactors = FALSE) ) expect_identical( as.data.frame(stream$get_next()), data.frame(a = 2, b = "three", stringsAsFactors = FALSE) ) expect_null(stream$get_next()) }) test_that("basic_array_stream() can validate input or skip validation", { invalid_stream <- basic_array_stream( list( as_nanoarrow_array(1:5), as_nanoarrow_array(data.frame(a = 1:5)) ), validate = FALSE ) expect_s3_class(invalid_stream, "nanoarrow_array_stream") expect_error( basic_array_stream( list( as_nanoarrow_array(1:5), as_nanoarrow_array(data.frame(a = 1:5)) ), validate = TRUE ), "Expected array with 2 buffer" ) }) test_that("nanoarrow_array_stream format, print, and str methods work", { array_stream <- as_nanoarrow_array_stream(data.frame(x = 1:10)) expect_identical(format(array_stream), ">") expect_output(expect_identical(str(array_stream), array_stream), "nanoarrow_array_stream") expect_output(expect_identical(print(array_stream), array_stream), "nanoarrow_array_stream") }) test_that("released nanoarrow_array_stream format, print, and str methods work", { array_stream <- nanoarrow_allocate_array_stream() expect_identical(format(array_stream), "") expect_output(expect_identical(str(array_stream), array_stream), "nanoarrow_array_stream") expect_output(expect_identical(print(array_stream), array_stream), "nanoarrow_array_stream") }) test_that("as_nanoarrow_array_stream() works for nanoarrow_array_stream", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_identical(as_nanoarrow_array_stream(stream), stream) stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_identical( as_nanoarrow_array_stream(stream, schema = na_struct(list(x = na_int32()))), stream ) skip_if_not_installed("arrow") expect_snapshot_error( as_nanoarrow_array_stream(stream, schema = na_struct(list(x = na_double()))) ) }) test_that("as_nanoarrow_array_stream() works for nanoarrow_array", { array <- as_nanoarrow_array(data.frame(x = 1:5)) stream <- as_nanoarrow_array_stream(array) expect_identical(infer_nanoarrow_schema(stream)$format, "+s") expect_identical( lapply(collect_array_stream(stream), as.data.frame), list(data.frame(x = 1:5)) ) # With explicit but identical schema stream <- as_nanoarrow_array_stream(array, schema = na_struct(list(x = na_int32()))) expect_identical(infer_nanoarrow_schema(stream)$format, "+s") expect_identical( lapply(collect_array_stream(stream), as.data.frame), list(data.frame(x = 1:5)) ) # With schema requiring a cast (not implemented in arrow) skip_if_not_installed("arrow") expect_snapshot_error( as_nanoarrow_array_stream(array, schema = na_struct(list(x = na_double()))) ) }) test_that("infer_nanoarrow_schema() is implemented for streams", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) schema <- infer_nanoarrow_schema(stream) expect_identical(schema$children$x$format, "i") }) test_that("as.data.frame() is implemented for streams", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_identical( as.data.frame(stream), data.frame(x = 1:5) ) expect_false(nanoarrow_pointer_is_valid(stream)) }) test_that("as.vector() is implemented for streams", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_identical( as.vector(stream), data.frame(x = 1:5) ) expect_false(nanoarrow_pointer_is_valid(stream)) }) test_that("nanoarrow_array_stream list interface works", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_identical(length(stream), 3L) expect_identical(names(stream), c("get_schema", "get_next", "release")) expect_identical(formals(stream[["get_schema"]]), formals(stream$get_schema)) expect_identical(formals(stream[["get_next"]]), formals(stream$get_next)) expect_identical(formals(stream[["release"]]), formals(stream$release)) expect_null(stream[["this key does not exist"]]) }) test_that("nanoarrow_array_stream can get_schema() and get_next()", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_identical(stream$get_schema()$format, "+s") expect_identical(as.data.frame(stream$get_next()), data.frame(x = 1:5)) expect_null(stream$get_next()) }) test_that("nanoarrow_array_stream can release()", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_true(nanoarrow_pointer_is_valid(stream)) stream$release() expect_false(nanoarrow_pointer_is_valid(stream)) }) test_that("nanoarrow_array_stream can validate or not on get_next()", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_error( stream$get_next(schema = na_int32()), "Expected array with 2 buffer" ) stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) expect_silent( stream$get_next( schema = na_int32(), validate = FALSE ) ) }) test_that("nanoarrow_array_stream get_next() with schema = NULL", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) array <- stream$get_next(schema = NULL) expect_error(infer_nanoarrow_schema(array), "has no associated schema") }) test_that("User array stream finalizers are run on explicit release", { stream <- basic_array_stream(list(1:5)) stream <- array_stream_set_finalizer(stream, function() cat("All done!")) expect_output(stream$release(), "All done!") expect_silent(stream$release()) }) test_that("User array stream finalizers are run on explicit release even when moved", { stream <- basic_array_stream(list(1:5)) stream <- array_stream_set_finalizer(stream, function() cat("All done!")) stream2 <- nanoarrow_allocate_array_stream() nanoarrow_pointer_move(stream, stream2) expect_false(nanoarrow_pointer_is_valid(stream)) expect_silent(nanoarrow_pointer_release(stream)) expect_output(stream2$release(), "All done!") expect_silent(stream2$release()) }) test_that("User array stream finalizers are run on explicit release even when exported", { stream <- basic_array_stream(list(1:5)) stream <- array_stream_set_finalizer(stream, function() cat("All done!")) stream2 <- nanoarrow_allocate_array_stream() nanoarrow_pointer_export(stream, stream2) expect_false(nanoarrow_pointer_is_valid(stream)) expect_silent(nanoarrow_pointer_release(stream)) expect_output(stream2$release(), "All done!") expect_silent(stream2$release()) }) test_that("Errors from user array stream finalizer are ignored", { stream <- basic_array_stream(list(1:5)) stream <- array_stream_set_finalizer(stream, function() stop("Error that will be ignored")) # Because this comes from REprintf(), it's not a message and not "output" # according to testthat, so we use capture.output() expect_identical( capture.output(stream$release(), type = "message"), "Error evaluating user-supplied array stream finalizer" ) expect_false(nanoarrow_pointer_is_valid(stream)) expect_silent(stream$release()) }) nanoarrow/tests/testthat/test-convert-array.R0000644000176200001440000010057314701301265021163 0ustar liggesusers# 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. test_that("convert_array() errors for invalid arrays", { array <- as_nanoarrow_array(1:10) nanoarrow_array_set_schema( array, na_string(), validate = FALSE ) expect_error( convert_array(array), "Expected array with 3 buffer" ) }) test_that("convert_array() errors for unsupported ptype", { array <- as_nanoarrow_array(1:10) # an S3 unsupported type expect_error( convert_array(array, structure(list(), class = "some_class")), "Can't convert array to R vector of type some_class" ) # A non-S3 unsupported type expect_error( convert_array(array, environment()), "Can't convert array to R vector of type environment" ) # An array with a name to an unsupported type struct_array <- as_nanoarrow_array(data.frame(x = 1L)) expect_error( convert_array(struct_array$children$x, environment()), "Can't convert `x`" ) }) test_that("convert_array() errors for unsupported array", { unsupported_array <- nanoarrow_array_init(na_interval_day_time()) expect_error( convert_array(as_nanoarrow_array(unsupported_array)), "Can't infer R vector type for " ) }) test_that("convert to vector works for data.frame", { df <- data.frame(a = 1L, b = "two", c = 3, d = TRUE, stringsAsFactors = FALSE) array <- as_nanoarrow_array(df) expect_identical(convert_array(array, NULL), df) expect_identical(convert_array(array, df), df) expect_error( convert_array(array, data.frame(a = integer(), b = raw())), "Expected data.frame\\(\\) ptype with 4 column\\(s\\) but found 2 column\\(s\\)" ) bad_ptype <- data.frame(a = integer(), b = raw(), c = double(), d = integer()) expect_error( convert_array(array, bad_ptype), "Can't convert `b` to R vector of type raw" ) }) test_that("convert to vector works for partial_frame", { array <- as_nanoarrow_array( data.frame(a = 1L, b = "two", stringsAsFactors = FALSE) ) expect_identical( convert_array(array, vctrs::partial_frame()), data.frame(a = 1L, b = "two", stringsAsFactors = FALSE) ) }) test_that("convert to vector works for extension -> data.frame()", { array <- nanoarrow_extension_array( data.frame(x = c(TRUE, FALSE, NA, FALSE, TRUE)), "some_ext" ) expect_warning( expect_identical( convert_array(array, data.frame(x = logical())), data.frame(x = c(TRUE, FALSE, NA, FALSE, TRUE)) ), "Converting unknown extension" ) }) test_that("convert to vector works for dictionary -> data.frame()", { array <- as_nanoarrow_array(c(0L, 1L, 2L, 1L, 0L)) array$dictionary <- as_nanoarrow_array(data.frame(x = c(TRUE, FALSE, NA))) expect_identical( convert_array(array, data.frame(x = logical())), data.frame(x = c(TRUE, FALSE, NA, FALSE, TRUE)) ) }) test_that("convert to vector works for function()", { tibble_or_bust <- function(array, ptype) { if (is.data.frame(ptype)) { ptype <- tibble::as_tibble(ptype) ptype[] <- Map(tibble_or_bust, list(NULL), ptype) } ptype } df_nested_df <- as.data.frame( tibble::tibble(a = 1L, b = "two", c = data.frame(a = 3)) ) array_nested <- as_nanoarrow_array(df_nested_df) expect_identical( convert_array(array_nested, tibble_or_bust), tibble::tibble(a = 1L, b = "two", c = tibble::tibble(a = 3)) ) }) test_that("convert to vector works for tibble", { array <- as_nanoarrow_array( data.frame(a = 1L, b = "two", stringsAsFactors = FALSE) ) expect_identical( convert_array(array, tibble::tibble(a = integer(), b = character())), tibble::tibble(a = 1L, b = "two") ) # Check nested tibble at both levels tbl_nested_df <- tibble::tibble(a = 1L, b = "two", c = data.frame(a = 3)) array_nested <- as_nanoarrow_array(tbl_nested_df) expect_identical( convert_array(array_nested, tbl_nested_df), tbl_nested_df ) df_nested_tbl <- as.data.frame(tbl_nested_df) df_nested_tbl$c <- tibble::as_tibble(df_nested_tbl$c) expect_identical( convert_array(array_nested, df_nested_tbl), df_nested_tbl ) }) test_that("convert to vector works for nanoarrow_vctr()", { array <- as_nanoarrow_array(c("one", "two", "three")) # Check implicit/inferred nanoarrow_vctr() schema vctr <- convert_array(array, nanoarrow_vctr()) expect_s3_class(vctr, "nanoarrow_vctr") expect_length(vctr, 3) schema <- infer_nanoarrow_schema(vctr) expect_identical(schema$format, "u") # Check with explicit schema of the correct type vctr <- convert_array(array, nanoarrow_vctr(na_string())) expect_s3_class(vctr, "nanoarrow_vctr") expect_length(vctr, 3) schema <- infer_nanoarrow_schema(vctr) expect_identical(schema$format, "u") # Check conversion of a struct array df <- data.frame(x = c("one", "two", "three")) array <- as_nanoarrow_array(df) vctr <- convert_array(array, nanoarrow_vctr()) expect_s3_class(vctr, "nanoarrow_vctr") expect_length(vctr, 3) schema <- infer_nanoarrow_schema(vctr) expect_identical(schema$format, "+s") vctr <- convert_array(array, nanoarrow_vctr(na_struct(list(x = na_string())))) expect_s3_class(vctr, "nanoarrow_vctr") expect_length(vctr, 3) schema <- infer_nanoarrow_schema(vctr) expect_identical(schema$format, "+s") }) test_that("batched convert to vector works for nanoarrow_vctr()", { empty_stream <- basic_array_stream(list(), schema = na_string()) empty_vctr <- convert_array_stream(empty_stream, nanoarrow_vctr()) expect_length(empty_vctr, 0) expect_identical(infer_nanoarrow_schema(empty_vctr)$format, "u") stream1 <- basic_array_stream(list(c("one", "two", "three"))) vctr1 <- convert_array_stream(stream1, nanoarrow_vctr()) expect_length(vctr1, 3) stream2 <- basic_array_stream( list(c("one", "two", "three"), c("four", "five", "six", "seven")) ) vctr2 <- convert_array_stream(stream2, nanoarrow_vctr()) expect_length(vctr2, 7) expect_identical( convert_array_stream(as_nanoarrow_array_stream(vctr2)), c("one", "two", "three", "four", "five", "six", "seven") ) }) test_that("convert to vector works for data.frame(nanoarrow_vctr())", { array <- as_nanoarrow_array(data.frame(x = 1:5)) df_vctr <- convert_array(array, data.frame(x = nanoarrow_vctr())) expect_s3_class(df_vctr$x, "nanoarrow_vctr") expect_identical( convert_array_stream(as_nanoarrow_array_stream(df_vctr$x)), 1:5 ) }) test_that("convert to vector works for list_of(nanoarrow_vctr())", { skip_if_not_installed("arrow") skip_if_not_installed("vctrs") array <- as_nanoarrow_array( list(1:5, 6:10, NULL, 11:13), schema = na_list(na_int32()) ) list_vctr <- convert_array(array, vctrs::list_of(nanoarrow_vctr())) # Each item in the list should be a vctr with one chunk that is a slice # of the original array expect_s3_class(list_vctr[[1]], "nanoarrow_vctr") vctr_array <- attr(list_vctr[[1]], "chunks")[[1]] expect_identical(vctr_array$offset, 0L) expect_identical(vctr_array$length, 5L) expect_identical(convert_buffer(vctr_array$buffers[[2]]), 1:5) expect_s3_class(list_vctr[[2]], "nanoarrow_vctr") vctr_array <- attr(list_vctr[[2]], "chunks")[[1]] expect_identical(vctr_array$offset, 5L) expect_identical(vctr_array$length, 5L) expect_identical(convert_buffer(vctr_array$buffers[[2]]), 1:10) expect_null(list_vctr[[3]]) expect_s3_class(list_vctr[[4]], "nanoarrow_vctr") vctr_array <- attr(list_vctr[[4]], "chunks")[[1]] expect_identical(vctr_array$offset, 10L) expect_identical(vctr_array$length, 3L) expect_identical(convert_buffer(vctr_array$buffers[[2]]), 1:13) }) test_that("batched convert to vector works for nanoarrow_vctr() keeps subclass", { vctr_ptype <- nanoarrow_vctr(subclass = "some_subclass") empty_stream <- basic_array_stream(list(), schema = na_string()) empty_vctr <- convert_array_stream(empty_stream, vctr_ptype) expect_s3_class(empty_vctr, "some_subclass") stream1 <- basic_array_stream(list(c(""))) vctr1 <- convert_array_stream(stream1, vctr_ptype) expect_s3_class(vctr1, "some_subclass") stream2 <- basic_array_stream(list(c(""), c(""))) vctr2 <- convert_array_stream(stream2, vctr_ptype) expect_s3_class(vctr2, "some_subclass") }) test_that("convert to vector works for struct-style vectors", { array <- as_nanoarrow_array(as.POSIXlt("2021-01-01", tz = "America/Halifax")) expect_identical( convert_array(array), as.data.frame( unclass(as.POSIXlt("2021-01-01", tz = "America/Halifax")), stringsAsFactors = FALSE ) ) array <- as_nanoarrow_array(as.POSIXlt("2021-01-01", tz = "America/Halifax")) expect_identical( convert_array(array, as.POSIXlt("2021-01-01", tz = "America/Halifax")), as.POSIXlt("2021-01-01", tz = "America/Halifax") ) }) test_that("convert to vector works for unspecified()", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 # implicit for null type expect_identical( convert_array(array, to = NULL), vctrs::vec_cast(rep(NA, 10), vctrs::unspecified()) ) # explicit for null type expect_identical( convert_array(array, vctrs::unspecified()), vctrs::vec_cast(rep(NA, 10), vctrs::unspecified()) ) # explicit for non-null type that is all NAs array <- as_nanoarrow_array(rep(NA_integer_, 10)) expect_identical( convert_array(array, vctrs::unspecified()), vctrs::vec_cast(rep(NA, 10), vctrs::unspecified()) ) # explicit for non-null type that is not all NAs array <- as_nanoarrow_array(c(1L, rep(NA_integer_, 9))) expect_warning( expect_identical( convert_array(array, vctrs::unspecified()), vctrs::vec_cast(rep(NA, 10), vctrs::unspecified()) ), class = "nanoarrow_warning_lossy_conversion" ) }) test_that("convert to vector works for valid logical()", { skip_if_not_installed("arrow") arrow_numeric_types <- list( int8 = arrow::int8(), uint8 = arrow::uint8(), int16 = arrow::int16(), uint16 = arrow::uint16(), int32 = arrow::int32(), uint32 = arrow::uint32(), int64 = arrow::int64(), uint64 = arrow::uint64(), float32 = arrow::float32(), float64 = arrow::float64() ) vals <- c(NA, 0:10) for (nm in names(arrow_numeric_types)) { expect_identical( convert_array( as_nanoarrow_array(vals, schema = arrow_numeric_types[[!!nm]]), logical() ), vals != 0 ) } vals_no_na <- 0:10 for (nm in names(arrow_numeric_types)) { expect_identical( convert_array( as_nanoarrow_array(vals_no_na, schema = arrow_numeric_types[[!!nm]]), logical() ), vals_no_na != 0 ) } # Boolean array to logical expect_identical( convert_array( as_nanoarrow_array(c(NA, TRUE, FALSE), schema = arrow::boolean()), logical() ), c(NA, TRUE, FALSE) ) expect_identical( convert_array( as_nanoarrow_array(c(TRUE, FALSE), schema = arrow::boolean()), logical() ), c(TRUE, FALSE) ) }) test_that("convert to vector works for null -> logical()", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, logical()), rep(NA, 10) ) }) test_that("convert to vector works for extension -> logical()", { array <- nanoarrow_extension_array(c(TRUE, FALSE, NA), "some_ext") expect_warning( expect_identical( convert_array(array, logical()), c(TRUE, FALSE, NA) ), "Converting unknown extension" ) }) test_that("convert to vector works for dictionary -> logical()", { array <- as_nanoarrow_array(c(0L, 1L, 2L, 1L, 0L)) array$dictionary <- as_nanoarrow_array(c(TRUE, FALSE, NA)) expect_identical( convert_array(array, logical()), c(TRUE, FALSE, NA, FALSE, TRUE) ) }) test_that("convert to vector errors for bad array to logical()", { expect_error( convert_array(as_nanoarrow_array(letters), logical()), "Can't convert array to R vector of type logical" ) }) test_that("convert to vector works for valid integer()", { skip_if_not_installed("arrow") arrow_int_types <- list( int8 = arrow::int8(), uint8 = arrow::uint8(), int16 = arrow::int16(), uint16 = arrow::uint16(), int32 = arrow::int32(), uint32 = arrow::uint32(), int64 = arrow::int64(), uint64 = arrow::uint64(), float32 = arrow::float32(), float64 = arrow::float64() ) ints <- c(NA, 0:10) for (nm in names(arrow_int_types)) { expect_identical( convert_array( as_nanoarrow_array(ints, schema = arrow_int_types[[!!nm]]), integer() ), ints ) } ints_no_na <- 0:10 for (nm in names(arrow_int_types)) { expect_identical( convert_array( as_nanoarrow_array(ints_no_na, schema = arrow_int_types[[!!nm]]), integer() ), ints_no_na ) } # Boolean array to integer expect_identical( convert_array( as_nanoarrow_array(c(NA, TRUE, FALSE), schema = arrow::boolean()), integer() ), c(NA, 1L, 0L) ) expect_identical( convert_array( as_nanoarrow_array(c(TRUE, FALSE), schema = arrow::boolean()), integer() ), c(1L, 0L) ) }) test_that("convert to works for integer() -> character()", { skip_if_not_installed("arrow") arrow_int_types <- list( int8 = arrow::int8(), uint8 = arrow::uint8(), int16 = arrow::int16(), uint16 = arrow::uint16(), int32 = arrow::int32(), uint32 = arrow::uint32(), int64 = arrow::int64() ) ints <- c(NA, 0:10) for (nm in names(arrow_int_types)) { expect_identical( convert_array( as_nanoarrow_array(ints, schema = arrow_int_types[[!!nm]]), character() ), as.character(ints) ) } }) test_that("convert to vector works for null -> logical()", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, integer()), rep(NA_integer_, 10) ) }) test_that("convert to vector works for extension -> integer()", { array <- nanoarrow_extension_array(c(0L, 1L, NA_integer_), "some_ext") expect_warning( expect_identical( convert_array(array, integer()), c(0L, 1L, NA_integer_) ), "Converting unknown extension" ) }) test_that("convert to vector warns for invalid integer()", { array <- as_nanoarrow_array(.Machine$integer.max + 1) expect_warning( expect_identical(convert_array(array, integer()), NA_integer_), class = "nanoarrow_warning_lossy_conversion" ) array <- as_nanoarrow_array(c(NA, .Machine$integer.max + 1)) expect_warning( expect_identical(convert_array(array, integer()), c(NA_integer_, NA_integer_)), class = "nanoarrow_warning_lossy_conversion" ) }) test_that("convert to vector errors for bad array to integer()", { expect_error( convert_array(as_nanoarrow_array(letters), integer()), "Can't convert array to R vector of type integer" ) }) test_that("convert to vector works for valid double()", { skip_if_not_installed("arrow") arrow_numeric_types <- list( int8 = arrow::int8(), uint8 = arrow::uint8(), int16 = arrow::int16(), uint16 = arrow::uint16(), int32 = arrow::int32(), uint32 = arrow::uint32(), int64 = arrow::int64(), uint64 = arrow::uint64(), float16 = arrow::float16(), float32 = arrow::float32(), float64 = arrow::float64() ) vals <- as.double(c(NA, 0:10)) for (nm in names(arrow_numeric_types)) { expect_identical( convert_array( as_nanoarrow_array(vals, schema = arrow_numeric_types[[!!nm]]), double() ), vals ) } vals_no_na <- as.double(0:10) for (nm in names(arrow_numeric_types)) { expect_identical( convert_array( as_nanoarrow_array(vals_no_na, schema = arrow_numeric_types[[!!nm]]), double() ), vals_no_na ) } # Boolean array to double expect_identical( convert_array( as_nanoarrow_array(c(NA, TRUE, FALSE), schema = arrow::boolean()), double() ), as.double(c(NA, 1L, 0L)) ) expect_identical( convert_array( as_nanoarrow_array(c(TRUE, FALSE), schema = arrow::boolean()), double() ), as.double(c(1L, 0L)) ) }) test_that("convert to vector works for decimal128 -> double()", { skip_if_not_installed("arrow") array <- as_nanoarrow_array(arrow::Array$create(1:10)$cast(arrow::decimal128(20, 10))) # Check via S3 dispatch expect_equal( convert_array(array, double()), as.double(1:10) ) # ...and via C -> S3 dispatch expect_equal( convert_array.default(array, double()), as.double(1:10) ) }) test_that("convert to vector works for null -> double()", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, double()), rep(NA_real_, 10) ) }) test_that("convert to vector works for extension -> double()", { array <- nanoarrow_extension_array(c(0, 1, NA_real_), "some_ext") expect_warning( expect_identical( convert_array(array, double()), c(0, 1, NA_real_) ), "Converting unknown extension" ) }) test_that("convert to vector works for dictionary -> double()", { array <- as_nanoarrow_array(c(0L, 1L, 2L, 1L, 0L)) array$dictionary <- as_nanoarrow_array(c(123, 0, NA_real_)) expect_identical( convert_array(array, double()), c(123, 0, NA_real_, 0, 123) ) }) test_that("convert to vector warns for possibly invalid double()", { array <- as_nanoarrow_array(2^54, schema = na_int64()) expect_warning( convert_array(array, double()), class = "nanoarrow_warning_lossy_conversion" ) }) test_that("convert to vector errors for bad array to double()", { expect_error( convert_array(as_nanoarrow_array(letters), double()), "Can't convert array to R vector of type numeric" ) }) test_that("convert to vector works for valid integer64()", { skip_if_not_installed("bit64") skip_if_not_installed("arrow") arrow_numeric_types <- list( int8 = arrow::int8(), uint8 = arrow::uint8(), int16 = arrow::int16(), uint16 = arrow::uint16(), int32 = arrow::int32(), uint32 = arrow::uint32(), int64 = arrow::int64(), uint64 = arrow::uint64(), float32 = arrow::float32(), float64 = arrow::float64() ) vals <- bit64::as.integer64(c(NA, 0:10)) for (nm in names(arrow_numeric_types)) { expect_identical( convert_array( as_nanoarrow_array(vals, schema = arrow_numeric_types[[!!nm]]), bit64::integer64() ), vals ) } vals_no_na <- bit64::as.integer64(0:10) for (nm in names(arrow_numeric_types)) { expect_identical( convert_array( as_nanoarrow_array(vals_no_na, schema = arrow_numeric_types[[!!nm]]), bit64::integer64() ), vals_no_na ) } # Boolean array to double expect_identical( convert_array( as_nanoarrow_array(c(NA, TRUE, FALSE), schema = arrow::boolean()), bit64::integer64() ), bit64::as.integer64(c(NA, 1L, 0L)) ) expect_identical( convert_array( as_nanoarrow_array(c(TRUE, FALSE), schema = arrow::boolean()), bit64::integer64() ), bit64::as.integer64(c(1L, 0L)) ) }) test_that("convert to vector works for null -> integer64()", { skip_if_not_installed("bit64") array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, bit64::integer64()), rep(bit64::NA_integer64_, 10) ) }) test_that("convert to vector works for extension -> integer64()", { skip_if_not_installed("bit64") vec <- bit64::as.integer64(c(0, 1, NA)) array <- nanoarrow_extension_array(vec, "some_ext") expect_warning( expect_identical( convert_array(array, bit64::integer64()), vec ), "Converting unknown extension" ) }) test_that("convert to vector errors for bad array to integer64()", { skip_if_not_installed("bit64") expect_error( convert_array(as_nanoarrow_array(letters), bit64::integer64()), "Can't convert array to R vector of type integer64" ) }) test_that("convert to vector works for character()", { array <- as_nanoarrow_array(letters) expect_identical( convert_array(array, character()), letters ) # make sure we get altrep here expect_true(is_nanoarrow_altrep(convert_array(array, character()))) # check an array that we can't convert expect_error( convert_array(as_nanoarrow_array(1:5), list()), "Can't convert array to R vector of type list" ) }) test_that("convert to vector works for string_view -> character()", { array <- as_nanoarrow_array(letters, schema = na_string_view()) expect_identical( convert_array(array, character()), letters ) array_with_nulls <- as_nanoarrow_array(c(letters, NA), schema = na_string_view()) expect_identical( convert_array(array_with_nulls, character()), c(letters, NA) ) }) test_that("convert to vector works for null -> character()", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 all_nulls <- convert_array(array, character()) nanoarrow_altrep_force_materialize(all_nulls) expect_identical( all_nulls, rep(NA_character_, 10) ) }) test_that("convert to vector works for extension -> character()", { array <- nanoarrow_extension_array(c("a", "b", NA_character_), "some_ext") expect_warning( expect_identical( convert_array(array, character()), c("a", "b", NA_character_) ), "Converting unknown extension" ) }) test_that("convert to vector works for dictionary -> character()", { array <- as_nanoarrow_array(factor(letters[5:1])) # Via S3 dispatch expect_identical( convert_array(array, character()), c("e", "d", "c", "b", "a") ) # Via C -> S3 dispatch expect_identical( convert_array.default(array, character()), c("e", "d", "c", "b", "a") ) }) test_that("convert to vector works for dictionary -> factor()", { array <- as_nanoarrow_array(factor(letters[5:1])) # With empty levels expect_identical( convert_array(array, factor()), factor(letters[5:1]) ) # With identical levels expect_identical( convert_array(array, factor(levels = c("a", "b", "c", "d", "e"))), factor(letters[5:1]) ) # With mismatched levels expect_identical( convert_array(array, factor(levels = c("b", "a", "c", "e", "d"))), factor(letters[5:1], levels = c("b", "a", "c", "e", "d")) ) expect_error( convert_array(array, factor(levels = letters[-4])), "some levels in data do not exist" ) }) test_that("batched convert to vector works for dictionary -> factor()", { # A slightly different path: convert_array.factor() called from C multiple # times with different dictionaries each time. array1 <- as_nanoarrow_array(factor(letters[1:5])) array2 <- as_nanoarrow_array(factor(letters[6:10])) array3 <- as_nanoarrow_array(factor(letters[11:15])) stream <- basic_array_stream(list(array1, array2, array3)) expect_identical( convert_array_stream(stream, factor(levels = letters)), factor(letters[1:15], levels = letters) ) }) test_that("batched convert to vector errors for dictionary -> factor()", { # We can't currently handle a preallocate + fill style conversion where the # result is partial_factor(). array1 <- as_nanoarrow_array(factor(letters[1:5])) array2 <- as_nanoarrow_array(factor(letters[6:10])) array3 <- as_nanoarrow_array(factor(letters[11:15])) stream <- basic_array_stream(list(array1, array2, array3)) expect_error( convert_array_stream(stream, factor()), "Can't allocate ptype of class 'factor'" ) }) test_that("convert to vector works for blob::blob()", { skip_if_not_installed("blob") array <- as_nanoarrow_array(list(as.raw(1:5)), schema = na_binary()) expect_identical( convert_array(array), blob::blob(as.raw(1:5)) ) expect_identical( convert_array(array, blob::blob()), blob::blob(as.raw(1:5)) ) }) test_that("convert to vector works for binary_view -> blob::blob()", { skip_if_not_installed("blob") array <- as_nanoarrow_array(letters, schema = na_binary_view()) expect_identical( convert_array(array, blob::blob()), blob::as_blob(lapply(letters, charToRaw)) ) array_with_nulls <- as_nanoarrow_array(c(letters, NA), schema = na_binary_view()) expect_identical( convert_array(array_with_nulls, blob::blob()), blob::as_blob(c(lapply(letters, charToRaw), list(NULL))) ) }) test_that("convert to vector works for null -> blob::blob()", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, blob::blob()), blob::new_blob(rep(list(NULL), 10)) ) }) test_that("convert to vector works for list -> vctrs::list_of", { skip_if_not_installed("arrow") array_list <- as_nanoarrow_array( arrow::Array$create( list(1:5, 6:10, NULL), type = arrow::list_of(arrow::int32()) ) ) # Default conversion expect_identical( convert_array(array_list), vctrs::list_of(1:5, 6:10, NULL, .ptype = integer()) ) # With explicit ptype expect_identical( convert_array(array_list, vctrs::list_of(.ptype = double())), vctrs::list_of(as.double(1:5), as.double(6:10), NULL, .ptype = double()) ) # With bad ptype expect_error( convert_array(array_list, vctrs::list_of(.ptype = list())), "Can't convert `item`" ) # With malformed ptype ptype <- vctrs::list_of(.ptype = character()) attr(ptype, "ptype") <- NULL expect_error( convert_array(array_list, ptype), "Expected attribute 'ptype'" ) }) test_that("convert to vector works for large_list -> vctrs::list_of", { skip_if_not_installed("arrow") array_list <- as_nanoarrow_array( arrow::Array$create( list(1:5, 6:10, NULL), type = arrow::large_list_of(arrow::int32()) ) ) # Default conversion expect_identical( convert_array(array_list), vctrs::list_of(1:5, 6:10, NULL, .ptype = integer()) ) # With explicit ptype expect_identical( convert_array(array_list, vctrs::list_of(.ptype = double())), vctrs::list_of(as.double(1:5), as.double(6:10), NULL, .ptype = double()) ) # With bad ptype expect_error( convert_array(array_list, vctrs::list_of(.ptype = list())), "Can't convert `item`" ) }) test_that("convert to vector works for fixed_size_list -> vctrs::list_of", { skip_if_not_installed("arrow") array_list <- as_nanoarrow_array( arrow::Array$create( list(1:5, 6:10, NULL), type = arrow::fixed_size_list_of(arrow::int32(), 5) ) ) # Default conversion expect_identical( convert_array(array_list), vctrs::list_of(1:5, 6:10, NULL, .ptype = integer()) ) # With explicit ptype expect_identical( convert_array(array_list, vctrs::list_of(.ptype = double())), vctrs::list_of(as.double(1:5), as.double(6:10), NULL, .ptype = double()) ) # With bad ptype expect_error( convert_array(array_list, vctrs::list_of(.ptype = list())), "Can't convert `item`" ) }) test_that("convert to vector works for null -> vctrs::list_of()", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, vctrs::list_of(.ptype = integer())), vctrs::new_list_of(rep(list(NULL), 10), ptype = integer()) ) }) test_that("convert to vector works for Date", { array_date <- as_nanoarrow_array(as.Date(c(NA, "2000-01-01"))) expect_identical( convert_array(array_date), as.Date(c(NA, "2000-01-01")) ) array_date <- as_nanoarrow_array( as.Date(c(NA, "2000-01-01")), schema = na_date64() ) expect_identical( convert_array(array_date), as.POSIXct(c(NA, "2000-01-01"), tz = "UTC") ) }) test_that("convert to vector works for null -> Date", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, as.Date(character())), as.Date(rep(NA_character_, 10)) ) }) test_that("convert to vector works for hms", { array_time <- as_nanoarrow_array(hms::parse_hm("12:34")) expect_identical( convert_array(array_time), hms::parse_hm("12:34") ) }) test_that("convert to vector works for null -> hms", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, hms::hms()), hms::parse_hms(rep(NA_character_, 10)) ) }) test_that("convert to vector works for POSIXct", { array_timestamp <- as_nanoarrow_array( as.POSIXct("2000-01-01 12:33", tz = "America/Halifax") ) expect_identical( convert_array(array_timestamp), as.POSIXct("2000-01-01 12:33", tz = "America/Halifax") ) }) test_that("convert to vector works for null -> POSIXct", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, as.POSIXct(character(), tz = "America/Halifax")), as.POSIXct(rep(NA_character_, 10), tz = "America/Halifax") ) }) test_that("convert to vector works for difftime", { x <- as.difftime(123, units = "secs") array_duration <- as_nanoarrow_array(x) # default expect_identical(convert_array(array_duration), x) # explicit expect_identical(convert_array(array_duration, x), x) # explicit with other difftime units units(x) <- "mins" expect_identical(convert_array(array_duration, x), x) units(x) <- "hours" expect_identical(convert_array(array_duration, x), x) units(x) <- "days" expect_identical(convert_array(array_duration, x), x) units(x) <- "weeks" expect_equal(convert_array(array_duration, x), x) # with all Arrow units x <- as.difftime(123, units = "secs") array_duration <- as_nanoarrow_array(x, na_duration("s")) expect_identical(convert_array(array_duration), x) array_duration <- as_nanoarrow_array(x, na_duration("ms")) expect_identical(convert_array(array_duration), x) array_duration <- as_nanoarrow_array(x, na_duration("us")) expect_identical(convert_array(array_duration), x) array_duration <- as_nanoarrow_array(x, na_duration("ns")) expect_equal(convert_array(array_duration), x) # bad ptype values attr(x, "units") <- NULL expect_error( convert_array(array_duration, x), "Expected difftime 'units' attribute of type" ) attr(x, "units") <- character() expect_error( convert_array(array_duration, x), "Expected difftime 'units' attribute of type" ) attr(x, "units") <- integer(1) expect_error( convert_array(array_duration, x), "Expected difftime 'units' attribute of type" ) attr(x, "units") <- "gazornenplat" expect_error( convert_array(array_duration, x), "Unexpected value for difftime 'units' attribute" ) attr(x, "units") <- NA_character_ expect_error( convert_array(array_duration, x), "Unexpected value for difftime 'units' attribute" ) }) test_that("convert to vector works for null -> difftime", { array <- nanoarrow_array_init(na_na()) array$length <- 10 array$null_count <- 10 expect_identical( convert_array(array, as.difftime(numeric(), units = "secs")), as.difftime(rep(NA_real_, 10), units = "secs") ) }) test_that("convert to vector works for data frames nested inside lists", { skip_if_not_installed("arrow") df_in_list <- vctrs::list_of( data.frame(x = 1:5), data.frame(x = 6:10), data.frame(x = 11:15) ) nested_array <- as_nanoarrow_array(df_in_list) expect_identical( convert_array(nested_array), df_in_list ) }) test_that("convert to vector works for lists nested in data frames", { skip_if_not_installed("arrow") df_in_list_in_df <- data.frame( x = vctrs::list_of( data.frame(x = 1:5), data.frame(x = 6:10), data.frame(x = 11:15) ) ) nested_array <- as_nanoarrow_array(df_in_list_in_df) expect_identical( convert_array(nested_array), df_in_list_in_df ) }) nanoarrow/tests/testthat/test-altrep.R0000644000176200001440000000753314402162315017657 0ustar liggesusers# 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. test_that("nanoarrow_altrep_chr() returns NULL for unsupported types", { expect_null(nanoarrow_altrep_chr(as_nanoarrow_array(1:10))) expect_null(nanoarrow_altrep_chr(as_nanoarrow_array(1:10))) }) test_that("nanoarrow_altrep_chr() works for string", { x <- as_nanoarrow_array(c(NA, letters), schema = na_string()) x_altrep <- nanoarrow_altrep_chr(x) expect_output(.Internal(inspect(x_altrep)), "") # Check that some common operations that call the string elt method # don't materialize the vector expect_identical(x_altrep, c(NA, letters)) expect_length(x_altrep, 27) expect_false(is_nanoarrow_altrep_materialized(x_altrep)) # Setting an element will materialize, duplicate, then modify x_altrep2 <- x_altrep x_altrep2[1] <- "not a letter" expect_identical(x_altrep2, c("not a letter", letters)) expect_true(is_nanoarrow_altrep_materialized(x_altrep)) # Check the same operations on the materialized output expect_identical(x_altrep, c(NA, letters)) expect_length(x_altrep, 27) # Materialization should get printed in inspect() expect_output(.Internal(inspect(x_altrep)), "") # For good measure, force materialization again and check nanoarrow_altrep_force_materialize(x_altrep) expect_identical(x_altrep, c(NA, letters)) expect_length(x_altrep, 27) }) test_that("nanoarrow_altrep_chr() works for large string", { skip_if_not_installed("arrow") x <- as_nanoarrow_array(letters, schema = na_large_string()) x_altrep <- nanoarrow_altrep_chr(x) expect_identical(x_altrep, letters) }) test_that("is_nanoarrow_altrep() returns true for nanoarrow altrep objects", { expect_false(is_nanoarrow_altrep("not altrep")) expect_false(is_nanoarrow_altrep(1:10)) expect_true(is_nanoarrow_altrep(nanoarrow_altrep_chr(as_nanoarrow_array("whee")))) }) test_that("nanoarrow_altrep_chr_force_materialize() forces materialization", { x <- as_nanoarrow_array(letters, schema = na_string()) x_altrep <- nanoarrow_altrep_chr(x) expect_identical(nanoarrow_altrep_force_materialize("not altrep"), 0L) expect_identical(nanoarrow_altrep_force_materialize(x_altrep), 1L) x <- as_nanoarrow_array(letters, schema = na_string()) x_altrep_df <- data.frame(x = nanoarrow_altrep_chr(x), stringsAsFactors = FALSE) expect_identical( nanoarrow_altrep_force_materialize(x_altrep_df, recursive = FALSE), 0L ) expect_identical( nanoarrow_altrep_force_materialize(x_altrep_df, recursive = TRUE), 1L ) expect_identical( nanoarrow_altrep_force_materialize(x_altrep_df, recursive = TRUE), 0L ) }) test_that("is_nanoarrow_altrep_materialized() checks for materialization", { expect_identical(is_nanoarrow_altrep_materialized("not altrep"), NA) expect_identical(is_nanoarrow_altrep_materialized(1:10), NA) x <- as_nanoarrow_array(letters, schema = na_string()) x_altrep <- nanoarrow_altrep_chr(x) expect_false(is_nanoarrow_altrep_materialized(x_altrep)) expect_identical(nanoarrow_altrep_force_materialize(x_altrep), 1L) expect_true(is_nanoarrow_altrep_materialized(x_altrep)) }) nanoarrow/tests/testthat/test-vctr.R0000644000176200001440000001464314672341746017366 0ustar liggesusers# 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. test_that("as_nanoarrow_vctr() works for basic input", { array <- as_nanoarrow_array(c("one", "two")) vctr <- as_nanoarrow_vctr(array) expect_identical(as.integer(unclass(vctr)), 1:2) expect_identical(as_nanoarrow_vctr(vctr), vctr) expect_identical(infer_nanoarrow_schema(vctr)$format, "u") expect_identical(as_nanoarrow_schema(vctr)$format, "u") }) test_that("print() and str() work on empty nanoarrow_vctr", { vctr <- nanoarrow_vctr() expect_identical( expect_output(print(vctr),">"), vctr ) expect_identical( expect_output(str(vctr), ">"), vctr ) vctr <- nanoarrow_vctr(na_int32()) expect_identical( expect_output(print(vctr), "^[null]", fixed = TRUE) }) test_that("as_nanoarrow_buffer() errors for unsupported types", { expect_error( as_nanoarrow_buffer(NA_character_), "NA_character_ not supported" ) expect_error( as_nanoarrow_buffer(environment()), "Can't convert object of type environment to nanoarrow_buffer" ) }) nanoarrow/tests/testthat/test-ipc.R0000644000176200001440000002121214701301265017132 0ustar liggesusers# 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. test_that("read_nanoarrow() works for raw vectors", { stream <- read_nanoarrow(example_ipc_stream()) expect_s3_class(stream, "nanoarrow_array_stream") expect_identical( as.data.frame(stream), data.frame(some_col = c(1L, 2L, 3L)) ) }) test_that("read_nanoarrow() works for open connections", { con <- rawConnection(example_ipc_stream()) on.exit(close(con)) stream <- read_nanoarrow(con) expect_s3_class(stream, "nanoarrow_array_stream") expect_identical( as.data.frame(stream), data.frame(some_col = c(1L, 2L, 3L)) ) }) test_that("write_nanoarrow() works for open connections", { tf <- tempfile() on.exit(unlink(tf)) con <- rawConnection(raw(), "wb") on.exit(close(con)) write_nanoarrow(data.frame(), con) expect_identical( as.data.frame(read_nanoarrow(rawConnectionValue(con))), data.frame() ) }) test_that("read_nanoarrow() works for unopened connections", { tf <- tempfile() on.exit(unlink(tf)) con <- file(tf, "wb") writeBin(example_ipc_stream(), con) close(con) con <- file(tf) # Don't close on exit, because we're supposed to do that stream <- read_nanoarrow(con) expect_true(isOpen(con)) stream$release() expect_error( close(con), "invalid connection" ) }) test_that("write_nanoarrow() works for unopened connections", { tf <- tempfile() on.exit(unlink(tf)) con <- file(tf) # Don't close on exit, because we're supposed to do that write_nanoarrow(data.frame(), con) expect_error( close(con), "invalid connection" ) }) test_that("read_nanoarrow() works for file paths", { tf <- tempfile() on.exit(unlink(tf)) con <- file(tf, "wb") writeBin(example_ipc_stream(), con) close(con) stream <- read_nanoarrow(tf) expect_identical( as.data.frame(stream), data.frame(some_col = c(1L, 2L, 3L)) ) }) test_that("write_nanoarrow() works for file paths", { tf <- tempfile() on.exit(unlink(tf)) df <- data.frame(letters = letters, stringsAsFactors = FALSE) expect_identical(write_nanoarrow(df, tf), df) expect_identical(as.data.frame(read_nanoarrow(tf)), df) }) test_that("read_nanoarrow() works for URLs", { tf <- tempfile() on.exit(unlink(tf)) con <- file(tf, "wb") writeBin(example_ipc_stream(), con) close(con) stream <- read_nanoarrow(paste0("file://", tf)) expect_identical( as.data.frame(stream), data.frame(some_col = c(1L, 2L, 3L)) ) }) test_that("write_nanoarrow() works for URLs", { tf <- tempfile() on.exit(unlink(tf)) df <- data.frame(letters = letters, stringsAsFactors = FALSE) expect_identical(write_nanoarrow(df, paste0("file://", tf)), df) expect_identical(as.data.frame(read_nanoarrow(tf)), df) }) test_that("read_nanoarrow() works for compressed .gz file paths", { tf <- tempfile(fileext = ".gz") on.exit(unlink(tf)) con <- gzfile(tf, "wb") writeBin(example_ipc_stream(), con) close(con) stream <- read_nanoarrow(tf) expect_identical( as.data.frame(stream), data.frame(some_col = c(1L, 2L, 3L)) ) }) test_that("write_nanoarrow() works for compressed .gz file paths", { tf <- tempfile(fileext = ".gz") on.exit(unlink(tf)) df <- data.frame(letters = letters, stringsAsFactors = FALSE) expect_identical(write_nanoarrow(df, tf), df) expect_identical(as.data.frame(read_nanoarrow(tf)), df) }) test_that("read_nanoarrow() works for compressed .bz2 file paths", { tf <- tempfile(fileext = ".bz2") on.exit(unlink(tf)) con <- bzfile(tf, "wb") writeBin(example_ipc_stream(), con) close(con) stream <- read_nanoarrow(tf) expect_identical( as.data.frame(stream), data.frame(some_col = c(1L, 2L, 3L)) ) }) test_that("write_nanoarrow() works for compressed .bz2 file paths", { tf <- tempfile(fileext = ".bz2") on.exit(unlink(tf)) df <- data.frame(letters = letters, stringsAsFactors = FALSE) expect_identical(write_nanoarrow(df, tf), df) expect_identical(as.data.frame(read_nanoarrow(tf)), df) }) test_that("read_nanoarrow() works for compressed .zip file paths", { tf <- tempfile(fileext = ".zip") tdir <- tempfile() on.exit(unlink(c(tf, tdir), recursive = TRUE)) dir.create(tdir) uncompressed <- file.path(tdir, "file.arrows") con <- file(uncompressed, "wb") writeBin(example_ipc_stream(), con) close(con) local({ wd <- getwd() on.exit(setwd(wd)) setwd(tdir) tryCatch( zip(tf, "file.arrows", extras = "-q"), error = function(...) skip("zip() not supported") ) }) stream <- read_nanoarrow(tf) expect_identical( as.data.frame(stream), data.frame(some_col = c(1L, 2L, 3L)) ) }) test_that("write_nanoarrow() errors for compressed .zip file paths", { tf <- tempfile(fileext = ".zip") on.exit(unlink(tf)) df <- data.frame(letters = letters, stringsAsFactors = FALSE) expect_error( write_nanoarrow(df, tf), "zip compression not supported" ) }) test_that("read_nanoarrow() errors for compressed URL paths", { expect_error( read_nanoarrow("https://something.zip"), "Reading compressed streams from URLs" ) }) test_that("read|write_nanoarrow() errors for input with length != 1", { expect_error( read_nanoarrow(character(0)), "Can't interpret character" ) expect_error( write_nanoarrow(data.frame(), character(0)), "Can't interpret character" ) }) test_that("read_nanoarrow() errors zip archives that contain files != 1", { tf <- tempfile(fileext = ".zip") tdir <- tempfile() on.exit(unlink(c(tf, tdir), recursive = TRUE)) dir.create(tdir) file.create(file.path(tdir, c("file1", "file2"))) local({ wd <- getwd() on.exit(setwd(wd)) setwd(tdir) tryCatch( zip(tf, c("file1", "file2"), extras = "-q"), error = function(...) skip("zip() not supported") ) }) expect_error( read_nanoarrow(tf), "Unzip only supported of archives with exactly one file" ) }) test_that("read_nanoarrow() reports errors from readBin", { tf <- tempfile() on.exit(unlink(tf)) writeLines("this is not a binary file", tf) con <- file(tf, open = "r") on.exit(close(con), add = TRUE) expect_error( read_nanoarrow(con), "R execution error" ) }) test_that("write_nanoarrow() reports errors from writeBin", { tf <- tempfile() on.exit(unlink(tf)) con <- file(tf, open = "w") on.exit(close(con), add = TRUE) expect_error( write_nanoarrow(data.frame(), con), "R execution error" ) }) test_that("read_nanoarrow() respects lazy argument", { expect_error( read_nanoarrow(raw(0), lazy = FALSE), "No data available on stream" ) reader <- read_nanoarrow(raw(0), lazy = TRUE) expect_error( reader$get_next(), "No data available on stream" ) tf <- tempfile() con <- rawConnection(raw(0)) on.exit({ close(con) unlink(tf) }) expect_error( read_nanoarrow(con, lazy = FALSE), "No data available on stream" ) reader <- read_nanoarrow(con, lazy = TRUE) expect_error( reader$get_next(), "No data available on stream" ) file.create(tf) expect_error( read_nanoarrow(tf, lazy = FALSE), "No data available on stream" ) reader <- read_nanoarrow(tf, lazy = TRUE) expect_error( reader$get_next(), "No data available on stream" ) }) test_that("read_nanoarrow() from connection errors when called from another thread", { skip_if_not_installed("arrow") skip_if_not(arrow::arrow_info()$capabilities["dataset"]) skip_if_not_installed("dplyr") tf <- tempfile() tf_out <- tempfile() on.exit(unlink(c(tf, tf_out), recursive = TRUE)) con <- file(tf, "wb") writeBin(example_ipc_stream(), con) close(con) stream <- read_nanoarrow(tf) reader <- arrow::as_record_batch_reader(stream) # There is an internal MakeSafeRecordBatchReader that ensures all read # calls happen on the R thread (used in DuckDB integration), but for now # this should at least error and not crash. expect_error( arrow::write_dataset(reader, tf_out), "Can't read from R connection on a non-R thread" ) }) nanoarrow/tests/testthat/test-as-array.R0000644000176200001440000006646214701301265020116 0ustar liggesusers# 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. test_that("as_nanoarrow_array() works for nanoarrow_array", { array <- as_nanoarrow_array(1:10) expect_identical(as_nanoarrow_array(array), array) array <- as_nanoarrow_array(1:10, schema = na_int32()) expect_identical(as_nanoarrow_array(array), array) skip_if_not_installed("arrow") casted <- as_nanoarrow_array(array, schema = na_int64()) expect_identical(infer_nanoarrow_schema(casted)$format, "l") expect_identical(convert_array(casted), as.double(1:10)) }) test_that("as_nanoarrow_array() works for logical() -> na_bool()", { # Without nulls array <- as_nanoarrow_array(c(TRUE, FALSE, TRUE, FALSE), schema = na_bool()) expect_identical(infer_nanoarrow_schema(array)$format, "b") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(packBits(c(TRUE, FALSE, TRUE, FALSE, rep(FALSE, 4)))) ) # With nulls array <- as_nanoarrow_array(c(TRUE, FALSE, NA), schema = na_bool()) expect_identical(infer_nanoarrow_schema(array)$format, "b") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 2), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(packBits(c(TRUE, FALSE, FALSE, rep(FALSE, 5)))) ) }) test_that("as_nanoarrow_array() errors for bad logical() creation", { skip_if_not_installed("arrow") expect_snapshot_error( as_nanoarrow_array(TRUE, schema = na_string()) ) }) test_that("as_nanoarrow_array() works for logical() -> na_int32()", { # Without nulls array <- as_nanoarrow_array(c(TRUE, FALSE, TRUE, FALSE), schema = na_int32()) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(TRUE, FALSE, TRUE, FALSE))) ) # With nulls array <- as_nanoarrow_array(c(TRUE, FALSE, NA), schema = na_int32()) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 2), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(TRUE, FALSE, NA))) ) }) test_that("as_nanoarrow_array() works for integer() -> na_int32()", { # Without nulls array <- as_nanoarrow_array(1:10) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical(as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(1:10))) # With nulls array <- as_nanoarrow_array(c(1:10, NA)) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(1:10, NA))) ) }) test_that("as_nanoarrow_array() works for integer -> na_int64()", { skip_if_not_installed("arrow") casted <- as_nanoarrow_array(1:10, schema = na_int64()) expect_identical(infer_nanoarrow_schema(casted)$format, "l") expect_identical(convert_array(casted), as.double(1:10)) }) test_that("as_nanoarrow_array() works for double() -> na_double()", { # Without nulls array <- as_nanoarrow_array(as.double(1:10)) expect_identical(infer_nanoarrow_schema(array)$format, "g") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(as.double(1:10))) ) # With nulls array <- as_nanoarrow_array(c(1:10, NA_real_)) expect_identical(infer_nanoarrow_schema(array)$format, "g") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(1:10, NA_real_))) ) }) test_that("as_nanoarrow_array() works for double() -> na_int32()", { # Without nulls array <- as_nanoarrow_array(as.double(1:10), schema = na_int32()) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(1:10)) ) # With nulls array <- as_nanoarrow_array(c(1:10, NA_real_), schema = na_int32()) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) # The last element here is 0 because (int)nan is undefined behaviour expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(1:10, 0L))) ) # With overflow expect_warning( as_nanoarrow_array(.Machine$integer.max + as.double(1:5), schema = na_int32()), class = "nanoarrow_warning_lossy_conversion" ) }) test_that("as_nanoarrow_array() works for double() -> na_int64()", { # Without nulls array <- as_nanoarrow_array(as.double(1:10), schema = na_int64()) expect_identical(infer_nanoarrow_schema(array)$format, "l") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) # This *is* how we create int64 buffers, so just check the roundtrip expect_identical(convert_array(array), as.double(1:10)) # With nulls array <- as_nanoarrow_array(c(1:10, NA_real_), schema = na_int64()) expect_identical(infer_nanoarrow_schema(array)$format, "l") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) expect_identical(convert_array(array), as.double(c(1:10, NA_real_))) }) test_that("as_nanoarrow_array() works for double() -> na_float()", { # Without nulls array <- as_nanoarrow_array(as.double(1:10), schema = na_float()) expect_identical(infer_nanoarrow_schema(array)$format, "f") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical(convert_array(array), as.double(1:10)) # With nulls array <- as_nanoarrow_array(c(1:10, NA_real_), schema = na_float()) expect_identical(infer_nanoarrow_schema(array)$format, "f") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) expect_identical(convert_array(array), c(1:10, NA_real_)) }) test_that("as_nanoarrow_array() works for double() -> na_half_float()", { # Without nulls array <- as_nanoarrow_array(as.double(1:10), schema = na_half_float()) expect_identical(infer_nanoarrow_schema(array)$format, "e") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical(convert_array(array), as.double(1:10)) # With nulls array <- as_nanoarrow_array(c(1:10, NA_real_), schema = na_half_float()) expect_identical(infer_nanoarrow_schema(array)$format, "e") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) expect_identical(convert_array(array), c(1:10, NA_real_)) }) test_that("as_nanoarrow_array() works for integer64() -> na_int32()", { skip_if_not_installed("bit64") # Without nulls array <- as_nanoarrow_array(bit64::as.integer64(1:10), schema = na_int32()) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(1:10)) ) # With nulls array <- as_nanoarrow_array(bit64::as.integer64(c(1:10, NA_real_)), schema = na_int32()) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) # The last element here is 0 because (int)nan is undefined behaviour expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(1:10, 0L))) ) }) test_that("as_nanoarrow_array() works for integer64() -> na_int64()", { skip_if_not_installed("bit64") # Default roundtrip array <- as_nanoarrow_array(bit64::as.integer64(1:10)) expect_identical(convert_array(array, double()), as.double(1:10)) # Without nulls array <- as_nanoarrow_array(bit64::as.integer64(1:10), schema = na_int64()) expect_identical(infer_nanoarrow_schema(array)$format, "l") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) # This *is* how we create int64 buffers, so just check the roundtrip expect_identical(convert_array(array, double()), as.double(1:10)) # With nulls array <- as_nanoarrow_array(bit64::as.integer64(c(1:10, NA_real_)), schema = na_int64()) expect_identical(infer_nanoarrow_schema(array)$format, "l") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 10), FALSE, rep(FALSE, 5))) ) expect_identical(convert_array(array, double()), as.double(c(1:10, NA_real_))) }) test_that("as_nanoarrow_array() works for double -> na_int8()", { skip_if_not_installed("arrow") casted <- as_nanoarrow_array(as.double(1:10), schema = na_int8()) expect_identical(infer_nanoarrow_schema(casted)$format, "c") expect_identical(convert_array(casted), 1:10) }) test_that("as_nanoarrow_array() works for character() -> na_string()", { # Without nulls array <- as_nanoarrow_array(letters) expect_identical(infer_nanoarrow_schema(array)$format, "u") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(0:26)) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) # With nulls array <- as_nanoarrow_array(c(letters, NA)) expect_identical(infer_nanoarrow_schema(array)$format, "u") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(0:26, 26L))) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) }) test_that("as_nanoarrow_array() works for character() -> na_large_string()", { # Without nulls array <- as_nanoarrow_array(letters, schema = na_large_string()) expect_identical(infer_nanoarrow_schema(array)$format, "U") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) # With nulls array <- as_nanoarrow_array(c(letters, NA), schema = na_large_string()) expect_identical(infer_nanoarrow_schema(array)$format, "U") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) }) test_that("as_nanoarrow_array() works for character() -> na_string_view()", { # Without nulls array <- as_nanoarrow_array(letters, schema = na_string_view()) expect_identical(infer_nanoarrow_schema(array)$format, "vu") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) # All these strings are shorter than four characters and thus are all inlined expect_identical(length(array$buffers), 3L) expect_identical(as.vector(array$buffers[[3]]), double()) # With nulls array <- as_nanoarrow_array(c(letters, NA), schema = na_string_view()) expect_identical(infer_nanoarrow_schema(array)$format, "vu") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) # All these strings are shorter than four characters and thus are all inlined expect_identical(length(array$buffers), 3L) expect_identical(as.vector(array$buffers[[3]]), double()) # With non-inlinable strings item <- "this string is longer than 12 bytes" array <- as_nanoarrow_array(item, schema = na_string_view()) expect_identical(length(array$buffers), 4L) expect_identical(as.raw(array$buffers[[3]]), charToRaw(item)) expect_identical(as.vector(array$buffers[[4]]), as.double(nchar(item))) }) test_that("as_nanoarrow_array() works for factor() -> na_dictionary()", { array <- as_nanoarrow_array( factor(letters), schema = na_dictionary(na_string(), na_int32()) ) expect_identical(infer_nanoarrow_schema(array)$format, "i") expect_identical(infer_nanoarrow_schema(array$dictionary)$format, "u") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(0:25)) ) expect_identical( as.raw(array$dictionary$buffers[[3]]), charToRaw(paste0(letters, collapse = "")) ) }) test_that("as_nanoarrow_array() works for factor() -> na_string()", { array <- as_nanoarrow_array( factor(letters), schema = na_string() ) expect_identical(infer_nanoarrow_schema(array)$format, "u") expect_null(array$dictionary) expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(0:26)) ) expect_identical( as.raw(array$buffers[[3]]), charToRaw(paste0(letters, collapse = "")) ) }) test_that("as_nanoarrow_array() works for data.frame() -> na_struct()", { array <- as_nanoarrow_array(data.frame(x = 1:10)) expect_identical(array$length, 10L) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical(infer_nanoarrow_schema(array)$format, "+s") expect_identical(infer_nanoarrow_schema(array$children$x)$format, "i") expect_identical(as.raw(array$children$x$buffers[[2]]), as.raw(as_nanoarrow_buffer(1:10))) }) test_that("as_nanoarrow_array() errors for bad data.frame() -> na_struct()", { expect_error( as_nanoarrow_array(data.frame(x = 1:10), schema = na_struct()), "Expected 1 schema children" ) skip_if_not_installed("arrow") expect_snapshot_error( as_nanoarrow_array(data.frame(x = 1:10), schema = na_int32()) ) }) test_that("as_nanoarrow_array() works for Date -> na_date32()", { array <- as_nanoarrow_array(as.Date(c("2000-01-01", "2023-02-03", NA))) expect_identical(infer_nanoarrow_schema(array)$format, "tdD") expect_identical(array$length, 3L) expect_identical(array$null_count, 1L) expect_identical(as.raw(array$buffers[[1]]), as.raw(0x03)) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(10957L, 19391L, NA))) ) }) test_that("as_nanoarrow_array() works for Date -> na_date64()", { array <- as_nanoarrow_array( as.Date(c("2000-01-01", "2023-02-03", NA)), schema = na_date64() ) expect_identical(infer_nanoarrow_schema(array)$format, "tdm") expect_identical(array$length, 3L) expect_identical(array$null_count, 1L) expect_identical(as.raw(array$buffers[[1]]), as.raw(0x03)) storage <- as_nanoarrow_array( c(10957L, 19391L, NA) * 86400000, schema = na_int64() ) expect_identical( as.raw(array$buffers[[2]]), as.raw(storage$buffers[[2]]) ) }) test_that("as_nanoarrow_array() works for POSIXct -> na_timestamp()", { array <- as_nanoarrow_array( as.POSIXct(c("2000-01-01", "2023-02-03", NA), tz = "UTC"), schema = na_timestamp("ms", timezone = "UTC") ) expect_identical(infer_nanoarrow_schema(array)$format, "tsm:UTC") expect_identical(array$length, 3L) expect_identical(array$null_count, 1L) expect_identical(as.raw(array$buffers[[1]]), as.raw(0x03)) storage <- as_nanoarrow_array( c(10957L, 19391L, NA) * 86400000, schema = na_int64() ) expect_identical( as.raw(array$buffers[[2]]), as.raw(storage$buffers[[2]]) ) }) test_that("as_nanoarrow_array() works for difftime -> na_duration()", { array <- as_nanoarrow_array( as.difftime(c(1:5, NA), units = "secs"), schema = na_duration("ms") ) expect_identical(infer_nanoarrow_schema(array)$format, "tDm") expect_identical(array$length, 6L) expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 5), FALSE, rep(FALSE, 2))) ) storage <- as_nanoarrow_array( c(1:5, NA) * 1000, schema = na_int64() ) expect_identical( as.raw(array$buffers[[2]]), as.raw(storage$buffers[[2]]) ) }) test_that("as_nanoarrow_array() works for blob::blob() -> na_binary()", { skip_if_not_installed("blob") # Without nulls array <- as_nanoarrow_array(blob::as_blob(letters)) expect_identical(infer_nanoarrow_schema(array)$format, "z") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(0:26)) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) # With nulls array <- as_nanoarrow_array(blob::as_blob(c(letters, NA))) expect_identical(infer_nanoarrow_schema(array)$format, "z") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(0:26, 26L))) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) }) test_that("as_nanoarrow_array() works for blob::blob() -> na_fixed_size_binary()", { # Without nulls array <- as_nanoarrow_array(blob::as_blob(letters), schema = na_fixed_size_binary(1)) expect_identical(infer_nanoarrow_schema(array)$format, "w:1") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) # With nulls array <- as_nanoarrow_array( blob::as_blob(c(letters, NA)), schema = na_fixed_size_binary(1) ) expect_identical(infer_nanoarrow_schema(array)$format, "w:1") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), c(as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))), as.raw(0x00)) ) }) test_that("as_nanoarrow_array() works for blob::blob() -> na_large_binary()", { # Without nulls array <- as_nanoarrow_array(blob::as_blob(letters), schema = na_large_binary()) expect_identical(infer_nanoarrow_schema(array)$format, "Z") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) # With nulls array <- as_nanoarrow_array( blob::as_blob(c(letters, NA)), schema = na_large_binary() ) expect_identical(infer_nanoarrow_schema(array)$format, "Z") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) }) test_that("as_nanoarrow_array() works for blob::blob() -> na_binary_view()", { # Without nulls array <- as_nanoarrow_array(blob::as_blob(letters), schema = na_binary_view()) expect_identical(infer_nanoarrow_schema(array)$format, "vz") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) # All these strings are shorter than four characters and thus are all inlined expect_identical(length(array$buffers), 3L) expect_identical(as.vector(array$buffers[[3]]), double()) # With nulls array <- as_nanoarrow_array( blob::as_blob(c(letters, NA)), schema = na_binary_view() ) expect_identical(infer_nanoarrow_schema(array)$format, "vz") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) # All these strings are shorter than four characters and thus are all inlined expect_identical(length(array$buffers), 3L) expect_identical(as.vector(array$buffers[[3]]), double()) # With non-inlinable strings item <- list(charToRaw("this string is longer than 12 bytes")) array <- as_nanoarrow_array(item, schema = na_binary_view()) expect_identical(length(array$buffers), 4L) expect_identical(as.raw(array$buffers[[3]]), item[[1]]) expect_identical(as.vector(array$buffers[[4]]), as.double(length(item[[1]]))) }) test_that("as_nanoarrow_array() works for list(raw()) -> na_binary()", { # Without nulls array <- as_nanoarrow_array(lapply(letters, charToRaw)) expect_identical(infer_nanoarrow_schema(array)$format, "z") expect_identical(as.raw(array$buffers[[1]]), raw()) expect_identical(array$offset, 0L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(0:26)) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) # With nulls array <- as_nanoarrow_array(c(lapply(letters, charToRaw), list(NULL))) expect_identical(infer_nanoarrow_schema(array)$format, "z") expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), packBits(c(rep(TRUE, 26), FALSE, rep(FALSE, 5))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(0:26, 26L))) ) expect_identical( as.raw(array$buffers[[3]]), as.raw(as_nanoarrow_buffer(paste(letters, collapse = ""))) ) }) test_that("as_nanoarrow_array() works for list(NULL) -> na_list(na_na())", { array <- as_nanoarrow_array(list(NULL)) expect_identical(infer_nanoarrow_schema(array)$format, "+l") expect_identical(array$length, 1L) expect_identical(array$null_count, 1L) expect_identical( as.raw(array$buffers[[1]]), as.raw(as_nanoarrow_array(FALSE)$buffers[[2]]) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(0L, 0L))) ) expect_identical(infer_nanoarrow_schema(array$children[[1]])$format, "n") expect_identical(array$children[[1]]$length, 0L) }) test_that("as_nanoarrow_array() works for list(integer()) -> na_list(na_int32())", { array <- as_nanoarrow_array(list(1:5, 6:10), schema = na_list(na_int32())) expect_identical(infer_nanoarrow_schema(array)$format, "+l") expect_identical(array$length, 2L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[1]]), as.raw(as_nanoarrow_array(c(TRUE, TRUE))$buffers[[2]]) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(0L, 5L, 10L))) ) expect_identical(infer_nanoarrow_schema(array$children[[1]])$format, "i") expect_identical(array$children[[1]]$length, 10L) }) test_that("as_nanoarrow_array() works for unspecified() -> na_na()", { skip_if_not_installed("vctrs") array <- as_nanoarrow_array(vctrs::unspecified(5)) expect_identical(infer_nanoarrow_schema(array)$format, "n") expect_identical(array$length, 5L) expect_identical(array$null_count, 5L) }) test_that("as_nanoarrow_array() works for bad unspecified() create", { skip_if_not_installed("vctrs") skip_if_not_installed("arrow") expect_snapshot_error( as_nanoarrow_array(vctrs::unspecified(5), schema = na_interval_day_time()) ) }) test_that("as_nanoarrow_array() can convert data.frame() to sparse_union()", { # Features: At least one element with more than one non-NA value, # one element with all NA values. test_df <- data.frame( lgl = c(TRUE, NA, NA, NA, NA, FALSE), int = c(NA, 123L, NA, NA, NA, NA), dbl = c(NA, NA, 456, NA, NA, NA), chr = c(NA, NA, NA, "789", NA, NA), stringsAsFactors = FALSE ) array <- as_nanoarrow_array( test_df, schema = na_sparse_union(lapply(test_df, infer_nanoarrow_schema)) ) expect_identical(infer_nanoarrow_schema(array)$format, "+us:0,1,2,3") expect_identical(array$length, 6L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[1]]), as.raw(as_nanoarrow_buffer(as.raw(c(0L, 1L, 2L, 3L, 0L, 0L)))) ) expect_identical( lapply(array$children, convert_array), lapply(test_df, identity) ) expect_identical(convert_array(array), test_df) }) test_that("as_nanoarrow_array() can convert data.frame() to sparse_union()", { test_df <- data.frame( lgl = c(TRUE, NA, NA, NA, NA, FALSE), int = c(NA, 123L, NA, NA, NA, NA), dbl = c(NA, NA, 456, NA, NA, NA), chr = c(NA, NA, NA, "789", NA, NA), stringsAsFactors = FALSE ) array <- as_nanoarrow_array( test_df, schema = na_dense_union(lapply(test_df, infer_nanoarrow_schema)) ) expect_identical(infer_nanoarrow_schema(array)$format, "+ud:0,1,2,3") expect_identical(array$length, 6L) expect_identical(array$null_count, 0L) expect_identical( as.raw(array$buffers[[1]]), as.raw(as_nanoarrow_buffer(as.raw(c(0L, 1L, 2L, 3L, 0L, 0L)))) ) expect_identical( as.raw(array$buffers[[2]]), as.raw(as_nanoarrow_buffer(c(0L, 0L, 0L, 0L, 1L, 2L))) ) expect_identical( lapply(array$children, convert_array), list( lgl = c(TRUE, NA, FALSE), int = 123L, dbl = 456, chr = "789" ) ) expect_identical(convert_array(array), test_df) }) test_that("as_nanoarrow_array() for union type errors for unsupported objects", { expect_error( as_nanoarrow_array(data.frame(), schema = na_dense_union()), "Can't convert data frame with 0 columns" ) }) nanoarrow/tests/testthat/test-convert-array-stream.R0000644000176200001440000001307014641555215022460 0ustar liggesusers# 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. test_that("convert array stream works", { stream0 <- basic_array_stream(list(), schema = na_struct(list(x = na_int32()))) expect_identical(convert_array_stream(stream0), data.frame(x = integer())) stream1 <- basic_array_stream(list(data.frame(x = 1:5))) expect_identical(convert_array_stream(stream1), data.frame(x = 1:5)) stream2 <- basic_array_stream( list( data.frame(x = 1:5), data.frame(x = 6:10) ) ) expect_identical(convert_array_stream(stream2), data.frame(x = 1:10)) stream3 <- basic_array_stream(list(), schema = na_int32()) expect_identical(convert_array_stream(stream3), integer()) }) test_that("convert array stream with explicit size works", { stream0 <- basic_array_stream(list(), schema = na_struct(list(x = na_int32()))) expect_identical( convert_array_stream(stream0, size = 0), data.frame(x = integer()) ) stream1 <- basic_array_stream(list(data.frame(x = 1:5))) expect_identical( convert_array_stream(stream1, size = 5), data.frame(x = 1:5) ) stream2 <- basic_array_stream( list( data.frame(x = 1:5), data.frame(x = 6:10) ) ) expect_identical( convert_array_stream(stream2, size = 10), data.frame(x = 1:10) ) }) test_that("convert array stream with functional ptype works", { tibble_or_bust <- function(array, ptype) { if (is.data.frame(ptype)) { ptype <- tibble::as_tibble(ptype) ptype[] <- Map(tibble_or_bust, list(NULL), ptype) } ptype } df_nested_df <- as.data.frame( tibble::tibble(a = 1L, b = "two", c = data.frame(a = 3)) ) stream_nested <- as_nanoarrow_array_stream(df_nested_df) expect_identical( convert_array_stream(stream_nested, tibble_or_bust), tibble::tibble(a = 1L, b = "two", c = tibble::tibble(a = 3)) ) }) test_that("convert array stream works for nested data.frames", { tbl_nested_df <- tibble::tibble(a = 1L, b = "two", c = data.frame(a = 3)) stream_nested <- as_nanoarrow_array_stream(tbl_nested_df) expect_identical( convert_array_stream(stream_nested, tbl_nested_df), tbl_nested_df ) stream_nested <- as_nanoarrow_array_stream(tbl_nested_df) expect_identical( convert_array_stream(stream_nested, size = 1L), as.data.frame(tbl_nested_df) ) stream_nested <- as_nanoarrow_array_stream(tbl_nested_df) expect_identical( convert_array_stream(stream_nested, tbl_nested_df, size = 1L), tbl_nested_df ) }) test_that("convert array stream works for struct-style vectors", { raw_posixlt <- as.data.frame( unclass(as.POSIXlt("2021-01-01", tz = "America/Halifax")), stringsAsFactors = FALSE ) stream <- as_nanoarrow_array_stream(raw_posixlt) expect_identical( convert_array_stream(stream), raw_posixlt ) stream <- as_nanoarrow_array_stream(raw_posixlt) expect_identical( convert_array_stream(stream, as.POSIXlt("2021-01-01", tz = "America/Halifax")), as.POSIXlt("2021-01-01", tz = "America/Halifax") ) # Check with fixed size since this takes a different code path stream <- as_nanoarrow_array_stream(raw_posixlt) expect_identical( convert_array_stream(stream, size = 1L), raw_posixlt ) stream <- as_nanoarrow_array_stream(raw_posixlt) expect_identical( convert_array_stream( stream, as.POSIXlt("2021-01-01", tz = "America/Halifax"), size = 1 ), as.POSIXlt("2021-01-01", tz = "America/Halifax") ) }) test_that("convert array stream respects the value of n", { batches <- list( data.frame(x = 1:5), data.frame(x = 6:10), data.frame(x = 11:15) ) stream3 <- basic_array_stream(batches) expect_identical( convert_array_stream(stream3, n = 0), data.frame(x = integer()) ) stream3 <- basic_array_stream(batches) expect_identical( convert_array_stream(stream3, n = 1), data.frame(x = 1:5) ) stream3 <- basic_array_stream(batches) expect_identical( convert_array_stream(stream3, n = 2), data.frame(x = 1:10) ) }) test_that("fixed-size convert array stream respects the value of n", { batches <- list( data.frame(x = 1:5), data.frame(x = 6:10), data.frame(x = 11:15) ) stream3 <- basic_array_stream(batches) expect_identical( convert_array_stream(stream3, n = 0, size = 0), data.frame(x = integer()) ) stream3 <- basic_array_stream(batches) expect_identical( convert_array_stream(stream3, n = 1, size = 5), data.frame(x = 1:5) ) stream3 <- basic_array_stream(batches) expect_identical( convert_array_stream(stream3, n = 2, size = 10), data.frame(x = 1:10) ) }) test_that("fixed-size stream conversion errors when the output has insufficient size", { stream <- as_nanoarrow_array_stream(data.frame(x = 1:100)) expect_error( convert_array_stream(stream, size = 2), "Expected to materialize 100 values in batch 1 but materialized 2" ) }) nanoarrow/tests/testthat/test-array.R0000644000176200001440000004076114676554240017525 0ustar liggesusers# 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. test_that("nanoarrow_array format, print, and str methods work", { array <- as_nanoarrow_array(1:10) expect_identical(format(array), "") expect_output(expect_identical(str(array), array), "nanoarrow_array") expect_output(expect_identical(print(array), array), "nanoarrow_array") }) test_that("released nanoarrow_array format, print, and str methods work", { array <- nanoarrow_allocate_array() expect_identical(format(array), "") expect_output(expect_identical(str(array), array), "nanoarrow_array") expect_output(expect_identical(print(array), array), "nanoarrow_array") }) test_that("schemaless nanoarrow_array format, print, and str methods work", { array <- as_nanoarrow_array(1:10) nanoarrow_array_set_schema(array, NULL) expect_identical(format(array), "[10]>") expect_output(expect_identical(str(array), array), "nanoarrow_array") expect_output(expect_identical(print(array), array), "nanoarrow_array") }) test_that("string/binary view nanoarrow_array buffers print correctly", { view_array_all_inlined <- as_nanoarrow_array(letters, schema = na_string_view()) expect_snapshot(print(view_array_all_inlined)) view_array_not_all_inlined <- as_nanoarrow_array( "this string is longer than 12 bytes", schema = na_string_view() ) expect_snapshot(print(view_array_not_all_inlined)) }) test_that("as_nanoarrow_array() / convert_array() default method works", { array <- as_nanoarrow_array(1:10) expect_identical(convert_array(array), 1:10) array <- as_nanoarrow_array(as.double(1:10), schema = na_double()) expect_identical(convert_array(array), as.double(1:10)) }) test_that("infer_nanoarrow_schema() works for nanoarrow_array", { array <- as_nanoarrow_array(1:10) schema <- infer_nanoarrow_schema(array) expect_true(nanoarrow_schema_identical(schema, na_int32())) nanoarrow_array_set_schema(array, NULL) expect_error(infer_nanoarrow_schema(array), "has no associated schema") }) test_that("nanoarrow_array_set_schema() errors for invalid schema/array", { array <- as_nanoarrow_array(integer()) schema <- na_string() expect_error( nanoarrow_array_set_schema(array, schema), "Expected array with 3 buffer\\(s\\) but found 2 buffer\\(s\\)" ) }) test_that("as.vector() and as.data.frame() work for array", { array <- as_nanoarrow_array(1:10) expect_identical(as.vector(array), 1:10) struct_array <- as_nanoarrow_array(data.frame(a = 1:10)) expect_identical(as.data.frame(struct_array), data.frame(a = 1:10)) expect_error( as.data.frame(array), "Can't convert array with type int32 to data.frame" ) }) test_that("as_tibble() works for array()", { struct_array <- as_nanoarrow_array(data.frame(a = 1:10)) expect_identical(tibble::as_tibble(struct_array), tibble::tibble(a = 1:10)) }) test_that("schemaless array list interface works for non-nested types", { array <- as_nanoarrow_array(1:10) nanoarrow_array_set_schema(array, NULL) expect_identical(length(array), 6L) expect_identical( names(array), c("length", "null_count", "offset", "buffers", "children", "dictionary") ) expect_identical(array$length, 10L) expect_identical(array$null_count, 0L) expect_identical(array$offset, 0L) expect_length(array$buffers, 2L) expect_s3_class(array$buffers[[1]], "nanoarrow_buffer") expect_s3_class(array$buffers[[2]], "nanoarrow_buffer") expect_null(array$children) expect_null(array$dictionary) }) test_that("schemaless array list interface works for nested types", { array <- as_nanoarrow_array(data.frame(a = 1L, b = "two", stringsAsFactors = FALSE)) nanoarrow_array_set_schema(array, NULL) expect_length(array$children, 2L) expect_length(array$children[[1]]$buffers, 2L) expect_length(array$children[[2]]$buffers, 3L) expect_s3_class(array$children[[1]], "nanoarrow_array") expect_s3_class(array$children[[2]], "nanoarrow_array") info_recursive <- nanoarrow_array_proxy(array, recursive = TRUE) expect_type(info_recursive$children[[1]], "list") expect_length(info_recursive$children[[1]]$buffers, 2L) }) test_that("schemaless array list interface works for dictionary types", { array <- as_nanoarrow_array(factor(letters[1:5])) nanoarrow_array_set_schema(array, NULL) expect_length(array$buffers, 2L) expect_length(array$dictionary$buffers, 3L) expect_s3_class(array$dictionary, "nanoarrow_array") info_recursive <- nanoarrow_array_proxy_safe(array, recursive = TRUE) expect_type(info_recursive$dictionary, "list") expect_length(info_recursive$dictionary$buffers, 3L) }) test_that("array list interface classes data buffers for relevant types", { types <- list( int8 = na_int8(), uint8 = na_uint8(), int16 = na_int16(), uint16 = na_uint16(), int32 = na_int32(), uint32 = na_uint32(), int64 = na_int64(), uint64 = na_uint64(), half_float = na_half_float(), float = na_float(), double = na_double(), decimal128 = na_decimal128(2, 3), decimal256 = na_decimal256(2, 3) ) arrays <- lapply(types, function(x) nanoarrow_array_init(x)) for (nm in names(arrays)) { expect_identical(arrays[[!!nm]]$buffers[[1]]$type, "validity") expect_identical(arrays[[!!nm]]$buffers[[1]]$data_type, "bool") expect_identical(arrays[[!!nm]]$buffers[[2]]$type, "data") expect_identical(arrays[[!!nm]]$buffers[[2]]$data_type, nm) } }) test_that("array list interface classes offset buffers for relevant types", { arr_string <- nanoarrow_array_init(na_string()) expect_identical(arr_string$buffers[[2]]$type, "data_offset") expect_identical(arr_string$buffers[[2]]$data_type, "int32") expect_identical(arr_string$buffers[[3]]$type, "data") expect_identical(arr_string$buffers[[3]]$data_type, "string") arr_large_string <- nanoarrow_array_init(na_large_string()) expect_identical(arr_large_string$buffers[[2]]$type, "data_offset") expect_identical(arr_large_string$buffers[[2]]$data_type, "int64") arr_binary <- nanoarrow_array_init(na_binary()) expect_identical(arr_binary$buffers[[2]]$type, "data_offset") expect_identical(arr_binary$buffers[[2]]$data_type, "int32") arr_large_binary <- nanoarrow_array_init(na_large_binary()) expect_identical(arr_large_binary$buffers[[2]]$type, "data_offset") expect_identical(arr_large_binary$buffers[[2]]$data_type, "int64") }) test_that("array list interface works for nested types", { array <- as_nanoarrow_array(data.frame(a = 1L, b = "two", stringsAsFactors = FALSE)) expect_named(array$children, c("a", "b")) expect_s3_class(array$children[[1]], "nanoarrow_array") expect_s3_class(infer_nanoarrow_schema(array$children[[1]]), "nanoarrow_schema") info_recursive <- nanoarrow_array_proxy_safe(array, recursive = TRUE) expect_type(info_recursive$children, "list") expect_identical( info_recursive$children$a$buffers[[2]]$type, "data" ) expect_identical( info_recursive$children$b$buffers[[2]]$type, "data_offset" ) }) test_that("array list interface works for dictionary types", { array <- as_nanoarrow_array(factor(letters[1:5])) expect_identical(array$buffers[[2]]$type, "data") expect_identical(array$dictionary$buffers[[2]]$type, "data_offset") info_recursive <- nanoarrow_array_proxy_safe(array, recursive = TRUE) expect_type(info_recursive$dictionary, "list") expect_identical(info_recursive$dictionary$buffers[[2]]$type, "data_offset") }) test_that("array modify errors for invalid components", { array <- as_nanoarrow_array(1:5) expect_error( nanoarrow_array_modify(array, list(1, 2, 3)), "`new_values`" ) expect_error( nanoarrow_array_modify(array, list(not_an_item = NULL)), "Can't modify array" ) }) test_that("array modify does not copy if length(new_values) == 0", { array <- as_nanoarrow_array(1:5) expect_identical( nanoarrow_pointer_addr_chr(nanoarrow_array_modify(array, list())), nanoarrow_pointer_addr_chr(array) ) }) test_that("array modify can modify length", { array <- as_nanoarrow_array(1:5) array2 <- nanoarrow_array_modify(array, list(length = 4)) expect_identical(convert_array(array2), 1:4) expect_identical(array$length, 5L) expect_error( nanoarrow_array_modify(array, list(length = NULL)), "array\\$length must be double" ) expect_error( nanoarrow_array_modify(array, list(length = NA_real_)), "array\\$length must be finite" ) expect_error( nanoarrow_array_modify(array, list(length = -1)), "array\\$length must be finite and greater than zero" ) }) test_that("array modify can modify null_count", { array <- as_nanoarrow_array(c(1L, NA, 2L, NA, 3L)) array2 <- nanoarrow_array_modify(array, list(null_count = -1)) expect_identical(array2$null_count, -1L) expect_identical(array$null_count, 2L) expect_error( nanoarrow_array_modify(array, list(null_count = NULL)), "array\\$null_count must be double" ) expect_error( nanoarrow_array_modify(array, list(null_count = NA_real_)), "array\\$null_count must be finite" ) expect_error( nanoarrow_array_modify(array, list(null_count = -2)), "array\\$null_count must be finite and greater than -1" ) }) test_that("array modify can modify offset", { array <- as_nanoarrow_array(1:5) array2 <- nanoarrow_array_modify(array, list(length = 4, offset = 1)) expect_identical(convert_array(array2), 2:5) expect_identical(array$length, 5L) expect_error( nanoarrow_array_modify(array, list(offset = NULL)), "array\\$offset must be double" ) expect_error( nanoarrow_array_modify(array, list(offset = NA_real_)), "array\\$offset must be finite" ) expect_error( nanoarrow_array_modify(array, list(offset = -1)), "array\\$offset must be finite and greater than zero" ) }) test_that("array modify can modify buffers", { array <- as_nanoarrow_array(1:5) # Replace with brand new buffer array2 <- nanoarrow_array_modify(array, list(buffers = list(NULL, 6:10))) expect_identical(convert_array(array2), 6:10) expect_identical(convert_array(array), 1:5) # Re-use buffers from another array array_with_nulls <- as_nanoarrow_array(c(1L, NA, 2L, NA, 3L)) array2 <- nanoarrow_array_modify( array, list( null_count = -1, buffers = list( array_with_nulls$buffers[[1]], array$buffers[[2]] ) ) ) expect_identical(convert_array(array2), c(1L, NA, 3L, NA, 5L)) expect_identical(convert_array(array), 1:5) expect_identical(convert_array(array_with_nulls), c(1L, NA, 2L, NA, 3L)) # Should work even after the source arrays go out of scope array <- NULL array_with_nulls <- NULL gc() expect_identical(convert_array(array2), c(1L, NA, 3L, NA, 5L)) array <- as_nanoarrow_array(1:5) expect_error( nanoarrow_array_modify(array, list(buffers = rep(list(NULL), 4))), "must be <= 3" ) # Check that specifying too few buffers will result in a validation error expect_error( nanoarrow_array_modify(array, list(buffers = list()), validate = TRUE), "Expected 2 buffer" ) }) test_that("array modify checks buffer sizes", { array <- as_nanoarrow_array(1:5) expect_error( nanoarrow_array_modify(array, list(length = 6)), ">= 24 bytes but found buffer with 20 bytes" ) }) test_that("array modify can modify children", { array_with_children <- as_nanoarrow_array(data.frame(x = 1L)) # Children -> no children array2 <- nanoarrow_array_modify(array_with_children, list(children = NULL)) expect_identical( convert_array(array2), new_data_frame(setNames(list(), character()), nrow = 1L) ) # No children -> no children array_without_children <- array2 array2 <- nanoarrow_array_modify(array_with_children, list(children = NULL)) expect_identical( convert_array(array2), new_data_frame(setNames(list(), character()), nrow = 1L) ) # No children -> children array2 <- nanoarrow_array_modify( array_without_children, list(children = list(y = 2L)) ) expect_identical(convert_array(array2), data.frame(y = 2L)) # Replace same number of children array2 <- nanoarrow_array_modify( array_with_children, list(children = list(y = 2L)) ) expect_identical(convert_array(array2), data.frame(y = 2L)) }) test_that("array modify can modify dictionary", { array_without_dictionary <- as_nanoarrow_array(0L) array_with_dictionary <- as_nanoarrow_array(factor("a")) # No dictionary -> no dictionary array2 <- nanoarrow_array_modify( array_without_dictionary, list(dictionary = NULL) ) expect_identical(convert_array(array2), 0L) # No dictionary -> dictionary array2 <- nanoarrow_array_modify( array_without_dictionary, list(dictionary = "a") ) expect_identical(convert_array(array2$dictionary), "a") # Dictionary -> no dictionary array2 <- nanoarrow_array_modify( array_with_dictionary, list(dictionary = NULL) ) expect_identical(convert_array(array2), 0L) # Dictionary -> new dictionary array2 <- nanoarrow_array_modify( array_with_dictionary, list(dictionary = "b") ) expect_identical(convert_array(array2$dictionary), "b") }) test_that("array modify can modify array with no schema attached", { array <- as_nanoarrow_array(1L) nanoarrow_array_set_schema(array, NULL) array2 <- nanoarrow_array_modify(array, list(dictionary = c("a", "b"))) expect_true(!is.null(array2$dictionary)) array2 <- nanoarrow_array_modify(array, list(children = list("x"))) expect_length(array2$children, 1) }) test_that("array modify can skip validation", { array <- as_nanoarrow_array(1L) expect_error( nanoarrow_array_modify(array, list(children = list("x")), validate = TRUE), "Expected schema with 0 children" ) array2 <- nanoarrow_array_modify( array, list(children = list("x")), validate = FALSE ) expect_length(array2$children, 1) }) test_that("[[<- works for array", { array <- as_nanoarrow_array(1L) array[["length"]] <- 0 expect_identical(array$length, 0L) array <- as_nanoarrow_array(1L) array[[1]] <- 0 expect_identical(array$length, 0L) expect_error( array[["not_an_item"]] <- "something", "Can't modify array" ) expect_error( array[[NA_character_]] <- "something", "must be character" ) expect_error( array[[character()]] <- "something", "must be character" ) expect_error( array[[NA_integer_]] <- "something", "must be character" ) expect_error( array[[integer()]] <- "something", "must be character" ) expect_error( array[[12]] <- "something", "must be character" ) }) test_that("$<- works for array", { array <- as_nanoarrow_array(1L) array$length <- 0 expect_identical(array$length, 0L) expect_error( array$not_an_item <- "something", "Can't modify array" ) }) test_that("<- assignment works for array$children", { array <- as_nanoarrow_array( data.frame(col1 = 1L, col2 = "a", stringsAsFactors = FALSE) ) array$children$col1 <- 100 expect_identical( convert_array(array), data.frame(col1 = 100, col2 = "a", stringsAsFactors = FALSE) ) names(array$children)[1] <- "col1_new" expect_identical( convert_array(array), data.frame(col1_new = 100, col2 = "a", stringsAsFactors = FALSE) ) }) test_that("<- assignment works for array$buffers", { array <- as_nanoarrow_array(c(1:7, NA)) array$null_count <- -1 array$buffers[[1]] <- packBits(c(TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE)) expect_identical( convert_array(array), c(1:4, rep(NA, 4)) ) }) test_that("nanoarrow_array_init() creates an array", { array <- nanoarrow_array_init(na_int32()) expect_identical(convert_array(array), integer()) # Check error from init bad_schema <- nanoarrow_schema_modify( na_int32(), list(children = list(na_int32())), validate = FALSE ) expect_error( nanoarrow_array_init(bad_schema), "Expected schema with 0 children" ) }) nanoarrow/tests/testthat/test-nanoarrow-package.R0000644000176200001440000000164414355103326021770 0ustar liggesusers# 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. test_that("nanoarrow_version() works", { expect_identical( nanoarrow_version(runtime = TRUE), nanoarrow_version(runtime = FALSE) ) }) nanoarrow/tests/testthat/test-extension-vctrs.R0000644000176200001440000001046514672342161021551 0ustar liggesusers# 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. test_that("vctrs extension type can roundtrip built-in vector types", { skip_if_not_installed("tibble") skip_if_not_installed("jsonlite") # Lists aren't automatically handled in nanoarrow conversion, so they # aren't listed here yet. vectors <- list( lgl = c(FALSE, TRUE, NA), int = c(0L, 1L, NA_integer_), dbl = c(0, 1, NA_real_), chr = c("a", NA_character_), posixct = as.POSIXct("2000-01-01 12:23", tz = "UTC"), posixlt = as.POSIXlt("2000-01-01 12:23", tz = "UTC"), date = as.Date("2000-01-01"), difftime = as.difftime(123, units = "secs"), data_frame_simple = data.frame(x = 1:5), data_frame_nested = tibble::tibble(x = 1:5, y = tibble::tibble(z = letters[1:5])) ) for (nm in names(vectors)) { vctr <- vectors[[nm]] ptype <- vctrs::vec_ptype(vctr) schema <- na_vctrs(vctr) array <- as_nanoarrow_array(vctr, schema = schema) array_schema <- infer_nanoarrow_schema(array) # Roundtrip through convert_array() expect_true(nanoarrow_schema_identical(array_schema, schema)) expect_identical(infer_nanoarrow_ptype(array), ptype) expect_identical(convert_array(array), vctr) # Roundtrip with an empty array stream stream <- basic_array_stream(list(), schema = schema) expect_identical(convert_array_stream(stream), ptype) # Roundtrip with multiple chunks stream <- basic_array_stream(list(array, array)) expect_identical(convert_array_stream(stream), vctrs::vec_rep(vctr, 2)) } }) test_that("vctrs extension type respects `to` in convert_array()", { skip_if_not_installed("vctrs") vctr <- as.Date("2000-01-01") array <- as_nanoarrow_array(vctr, schema = na_vctrs(vctr)) expect_identical(convert_array(array), vctr) expect_identical( convert_array(array, to = as.POSIXct(character())), vctrs::vec_cast(vctr, as.POSIXct(character())) ) }) test_that("serialize_ptype() can roundtrip R objects", { skip_if_not_installed("jsonlite") vectors <- list( null = NULL, raw = as.raw(c(0x00, 0x01, 0x02)), lgl = c(FALSE, TRUE, NA), int = c(0L, 1L, NA_integer_), dbl = c(0, 1, pi, NA_real_), chr = c("a", NA_character_), cmplx = c(complex(real = 1:3, imaginary = 3:1), NA_complex_), list = list(1, 2, x = 3, NULL), raw0 = raw(), lgl0 = logical(), int0 = integer(), dbl0 = double(), chr0 = character(), cmplx0 = complex(), list0 = list(), posixct = as.POSIXct("2000-01-01 12:23", tz = "UTC"), posixlt = as.POSIXlt("2000-01-01 12:23", tz = "UTC"), date = as.Date("2000-01-01"), difftime = as.difftime(123, units = "secs"), data_frame_simple = data.frame(x = 1:5), data_frame_nested = tibble::tibble(x = 1:5, y = tibble::tibble(z = letters[1:5])) ) for (obj in vectors) { # Check that our serializer/deserializer can roundtrip expect_identical( unserialize_ptype(serialize_ptype(obj)), obj ) # Check that our generated JSON is compatible with jsonlite's serde expect_identical( jsonlite::unserializeJSON(serialize_ptype(obj)), obj ) expect_identical( unserialize_ptype(jsonlite::serializeJSON(obj, digits = 16)), obj ) } }) test_that("serialize_ptype() errors for unsupported R objects", { skip_if_not_installed("jsonlite") expect_error( serialize_ptype(quote(cat("I will eat you"))), "storage 'language' is not supported by serialize_ptype" ) expect_error( unserialize_ptype(jsonlite::serializeJSON(quote(cat("I will eat you")))), "storage 'language' is not supported by unserialize_ptype" ) }) nanoarrow/tests/testthat/_snaps/0000755000176200001440000000000014677134124016556 5ustar liggesusersnanoarrow/tests/testthat/_snaps/array.md0000644000176200001440000000202114677134124020211 0ustar liggesusers# string/binary view nanoarrow_array buffers print correctly Code print(view_array_all_inlined) Output $ length : int 26 $ null_count: int 0 $ offset : int 0 $ buffers :List of 3 ..$ :[null] `` ..$ :[26][416 b]>` ..$ :[null] `` $ dictionary: NULL $ children : list() --- Code print(view_array_not_all_inlined) Output $ length : int 1 $ null_count: int 0 $ offset : int 0 $ buffers :List of 4 ..$ :[null] `` ..$ :[1][16 b]>` ..$ :[35 b]> `this string is longer...` ..$ :[1][8 b]> `35` $ dictionary: NULL $ children : list() nanoarrow/tests/testthat/_snaps/as-array.md0000644000176200001440000000051214676571434020625 0ustar liggesusers# as_nanoarrow_array() errors for bad logical() creation Invalid: Expecting a character vector # as_nanoarrow_array() errors for bad data.frame() -> na_struct() Can't create Array from object of type data.frame # as_nanoarrow_array() works for bad unspecified() create NotImplemented: day_time_interval nanoarrow/tests/testthat/_snaps/buffer.md0000644000176200001440000000136014676571434020361 0ustar liggesusers# buffers can be printed Code str(as_nanoarrow_buffer(1:10)) Output [10][40 b]> `1 2 3 4 5 6 7 8 9 10` --- Code str(as_nanoarrow_buffer(1:10000)) Output [10000][40000 b]> `1 2 3 4 5 6 7 8 9 10 11 12 1...` --- Code str(as_nanoarrow_buffer(strrep("abcdefg", 100))) Output [700 b]> `abcdefgabcdefgabcdefgabcdefgabcdefga...` --- Code str(as_nanoarrow_buffer(charToRaw(strrep("abcdefg", 100)))) Output [700 b]> `61 62 63 64 65 66 67 61 62 63 64 65 ...` --- Code str(array$buffers[[2]]) Output > nanoarrow/tests/testthat/_snaps/array-stream.md0000644000176200001440000000027314676571432021517 0ustar liggesusers# as_nanoarrow_array_stream() works for nanoarrow_array_stream is.null(schema) is not TRUE # as_nanoarrow_array_stream() works for nanoarrow_array is.null(schema) is not TRUE nanoarrow/tests/testthat/test-schema.R0000644000176200001440000004555014555060376017646 0ustar liggesusers# 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. test_that("nanoarrow_schema format, print, and str methods work", { schema <- na_int32() expect_identical(format(schema), "") expect_output(expect_identical(str(schema), schema), "nanoarrow_schema") expect_output(expect_identical(print(schema), schema), "nanoarrow_schema") }) test_that("nanoarrow_schema format, print, and str methods work for invalid pointers", { schema <- nanoarrow_allocate_schema() expect_identical(format(schema), "") expect_output(expect_identical(str(schema), schema), "nanoarrow_schema") expect_output(expect_identical(print(schema), schema), "nanoarrow_schema") }) test_that("as_nanoarrow_schema() works for nanoarrow_schema", { schema <- na_int32() expect_identical(as_nanoarrow_schema(schema), schema) }) test_that("infer_nanoarrow_schema() errors for unsupported types", { expect_error( infer_nanoarrow_schema(environment()), "Can't infer Arrow type" ) }) test_that("infer_nanoarrow_schema() methods work for built-in types", { expect_identical(infer_nanoarrow_schema(raw())$format, "C") expect_identical(infer_nanoarrow_schema(logical())$format, "b") expect_identical(infer_nanoarrow_schema(integer())$format, "i") expect_identical(infer_nanoarrow_schema(double())$format, "g") expect_identical(infer_nanoarrow_schema(character())$format, "u") expect_identical(infer_nanoarrow_schema(Sys.Date())$format, "tdD") expect_identical(infer_nanoarrow_schema(factor())$format, "i") expect_identical(infer_nanoarrow_schema(factor())$dictionary$format, "u") time <- as.POSIXct("2000-01-01", tz = "UTC") expect_identical(infer_nanoarrow_schema(time)$format, "tsu:UTC") # Some systems (mostly Docker images) don't return a value for Sys.timezone() # so set one explicitly to test the Sys.timezone() fallback. withr::with_timezone("America/Halifax", { time <- as.POSIXct("2000-01-01", tz = "") expect_identical( infer_nanoarrow_schema(time)$format, paste0("tsu:", Sys.timezone()) ) }) difftime <- as.difftime(double(), unit = "secs") expect_identical(infer_nanoarrow_schema(difftime)$format, "tDu") df_schema <- infer_nanoarrow_schema(data.frame(x = 1L)) expect_identical(df_schema$format, "+s") expect_identical(df_schema$children$x$format, "i") }) test_that("infer_nanoarrow_schema() methods work for blob type", { skip_if_not_installed("blob") expect_identical(infer_nanoarrow_schema(blob::blob())$format, "z") }) test_that("infer_nanoarrow_schema() methods work for hms type", { skip_if_not_installed("hms") expect_identical(infer_nanoarrow_schema(hms::hms())$format, "ttm") }) test_that("infer_nanoarrow_schema() methods work for vctrs types", { skip_if_not_installed("vctrs") expect_identical(infer_nanoarrow_schema(vctrs::unspecified())$format, "n") list_schema <- infer_nanoarrow_schema(vctrs::list_of(.ptype = integer())) expect_identical(list_schema$format, "+l") expect_identical(list_schema$children[[1]]$format, "i") }) test_that("infer_nanoarrow_schema() method works for integer64()", { skip_if_not_installed("bit64") expect_identical(infer_nanoarrow_schema(bit64::integer64())$format, "l") }) test_that("infer_nanoarrow_schema() method works for AsIs", { expect_identical( infer_nanoarrow_schema(I(integer()))$format, infer_nanoarrow_schema(integer())$format ) }) test_that("infer_nanoarrow_schema() returns list of null for empty or all null list", { expect_identical(infer_nanoarrow_schema(list())$format, "+l") expect_identical(infer_nanoarrow_schema(list())$children[[1]]$format, "n") expect_identical(infer_nanoarrow_schema(list(NULL))$format, "+l") expect_identical(infer_nanoarrow_schema(list())$children[[1]]$format, "n") }) test_that("infer_nanoarrow_schema() returns binary for list of raw", { expect_identical(infer_nanoarrow_schema(list(raw()))$format, "z") expect_identical(infer_nanoarrow_schema(list(raw(), NULL))$format, "z") }) test_that("nanoarrow_schema_parse() works", { simple_info <- nanoarrow_schema_parse(na_int32()) expect_identical(simple_info$type, "int32") expect_identical(simple_info$storage_type, "int32") fixed_size_info <- nanoarrow_schema_parse(na_fixed_size_binary(1234)) expect_identical(fixed_size_info$fixed_size, 1234L) decimal_info <- nanoarrow_schema_parse(na_decimal128(4, 5)) expect_identical(decimal_info$decimal_bitwidth, 128L) expect_identical(decimal_info$decimal_precision, 4L) expect_identical(decimal_info$decimal_scale, 5L) time_unit_info <- nanoarrow_schema_parse(na_time32("s")) expect_identical(time_unit_info$time_unit, "s") timezone_info <- nanoarrow_schema_parse(na_timestamp("s", "America/Halifax")) expect_identical(timezone_info$timezone, "America/Halifax") recursive_info <- nanoarrow_schema_parse( na_struct(list(x = na_int32())), recursive = FALSE ) expect_null(recursive_info$children) recursive_info <- nanoarrow_schema_parse( na_struct(list(x = na_int32())), recursive = TRUE ) expect_length(recursive_info$children, 1L) expect_identical( recursive_info$children$x, nanoarrow_schema_parse(na_int32()) ) }) test_that("nanoarrow_schema_parse() works for extension types", { ext_info <- nanoarrow_schema_parse(na_extension(na_int32(), "ext_name", "ext_meta")) expect_identical(ext_info$type, "int32") expect_identical(ext_info$storage_type, "int32") expect_identical(ext_info$extension_name, "ext_name") expect_identical(ext_info$extension_metadata, charToRaw("ext_meta")) }) test_that("schema list interface works for non-nested types", { schema <- na_int32() expect_identical(length(schema), 6L) expect_identical( names(schema), c("format", "name", "metadata", "flags", "children", "dictionary") ) expect_identical(schema$format, "i") expect_identical(schema$name, "") expect_identical(schema$metadata, list()) expect_identical(schema$flags, 2L) expect_identical(schema$children, list()) expect_identical(schema$dictionary, NULL) }) test_that("schema list interface works for nested types", { schema <- na_struct(list(a = na_int32(), b = na_string())) expect_identical(schema$format, "+s") expect_named(schema$children, c("a", "b")) expect_identical(schema$children$a, schema$children[[1]]) expect_identical(schema$children$a$format, "i") expect_identical(schema$children$b$format, "u") expect_s3_class(schema$children$a, "nanoarrow_schema") expect_s3_class(schema$children$b, "nanoarrow_schema") info_recursive <- nanoarrow_schema_proxy(schema, recursive = TRUE) expect_type(info_recursive$children$a, "list") expect_identical(info_recursive$children$a$format, "i") }) test_that("schema list interface works for dictionary types", { schema <- na_dictionary(na_string(), na_int8()) expect_identical(schema$format, "c") expect_identical(schema$dictionary$format, "u") expect_s3_class(schema$dictionary, "nanoarrow_schema") info_recursive <- nanoarrow_schema_proxy(schema, recursive = TRUE) expect_type(info_recursive$dictionary, "list") expect_identical(info_recursive$dictionary$format, "u") }) test_that("schema list interface works with metadata", { schema <- na_extension(na_int32(), "ext_name", "ext_meta") expect_identical( schema$metadata[["ARROW:extension:name"]], "ext_name" ) expect_identical( schema$metadata[["ARROW:extension:metadata"]], "ext_meta" ) }) test_that("schema modify errors for invalid components", { schema <- na_int32() expect_error( nanoarrow_schema_modify(schema, list(1, 2, 3)), "`new_values`" ) expect_error( nanoarrow_schema_modify(schema, list(not_an_item = NULL)), "Can't modify schema" ) }) test_that("schema modify does not copy if length(new_values) == 0", { schema <- na_int32() expect_identical( nanoarrow_pointer_addr_chr(nanoarrow_schema_modify(schema, list())), nanoarrow_pointer_addr_chr(schema) ) }) test_that("schema modify can modify format", { schema <- na_int32() schema2 <- nanoarrow_schema_modify(schema, list(format = "I")) expect_identical(schema2$format, "I") expect_identical(schema2$name, schema$name) expect_identical(schema2$flags, schema$flags) expect_error( nanoarrow_schema_modify(schema, list(format = NULL)), "schema\\$format must be character" ) expect_error( nanoarrow_schema_modify(schema, list(format = character())), "schema\\$format must be character" ) }) test_that("schema modify can modify name", { schema <- na_int32() schema2 <- nanoarrow_schema_modify(schema, list(name = "new_name")) expect_identical(schema2$name, "new_name") expect_identical(schema2$format, schema$format) expect_identical(schema2$flags, schema$flags) schema2 <- nanoarrow_schema_modify(schema, list(name = NULL)) expect_null(schema2$name) expect_identical(schema2$format, schema$format) expect_identical(schema2$flags, schema$flags) expect_error( nanoarrow_schema_modify(schema, list(name = character())), "schema\\$name must be NULL or character" ) }) test_that("schema modify can modify flags", { schema <- na_int32() expect_identical(schema$flags, 2L) schema2 <- nanoarrow_schema_modify(schema, list(flags = 0)) expect_identical(schema2$flags, 0L) expect_identical(schema2$format, schema$format) expect_identical(schema2$name, schema$name) expect_error( nanoarrow_schema_modify(schema, list(flags = integer())), "schema\\$flags must be integer" ) }) test_that("schema modify can modify metadata", { schema <- na_int32() schema2 <- nanoarrow_schema_modify(schema, list(metadata = list())) expect_identical(schema2$metadata, list()) expect_identical(schema2$format, schema$format) schema3 <- nanoarrow_schema_modify(schema, list(metadata = NULL)) expect_identical(schema3$metadata, list()) expect_identical(schema3$format, schema$format) schema4 <- nanoarrow_schema_modify(schema, list(metadata = list(key = "value"))) expect_identical(schema4$metadata, list(key = "value")) expect_identical(schema4$format, schema$format) schema5 <- nanoarrow_schema_modify( schema, list(metadata = list(new_key = charToRaw("new value"))) ) expect_identical(schema5$metadata, list(new_key = "new value")) expect_identical(schema5$format, schema$format) expect_error( nanoarrow_schema_modify(schema, list(metadata = list(1))), "schema\\$metadata must be named" ) expect_error( nanoarrow_schema_modify(schema, list(metadata = setNames(list(1, 2), c("", "")))), "must be named" ) expect_error( nanoarrow_schema_modify(schema, list(metadata = setNames(list(1), NA_character_))), "must be named" ) expect_error( nanoarrow_schema_modify(schema, list(metadata = list(name = NULL))), "must be character\\(1\\) or raw" ) expect_error( nanoarrow_schema_modify(schema, list(metadata = list(name = character()))), "must be character\\(1\\) or raw" ) expect_error( nanoarrow_schema_modify(schema, list(metadata = list(name = NA_character_))), "must not be NA_character_" ) }) test_that("schema modify can modify children", { schema_without_children <- na_struct() child_to_be <- schema_without_children child_to_be$name <- "should not appear" # NULL children to NULL children schema2 <- nanoarrow_schema_modify( schema_without_children, list(children = NULL) ) expect_identical(schema2$children, list()) expect_identical(schema2$format, schema_without_children$format) # NULL children to zero-size list() children schema2 <- nanoarrow_schema_modify( schema_without_children, list(children = list()) ) expect_identical(schema2$children, list()) expect_identical(schema2$format, schema_without_children$format) # with unnamed child list schema2 <- nanoarrow_schema_modify( schema_without_children, list(children = list(child_to_be)) ) expect_length(schema2$children, 1) expect_named(schema2$children, "") expect_identical(schema2$format, schema_without_children$format) expect_identical(schema2$children[[1]]$format, child_to_be$format) # with another type of unnamed child list schema2 <- nanoarrow_schema_modify( schema_without_children, list(children = setNames(list(child_to_be), "")) ) expect_length(schema2$children, 1) expect_named(schema2$children, "") expect_identical(schema2$format, schema_without_children$format) expect_identical(schema2$children[[1]]$format, child_to_be$format) # with oddly unnamed child list schema2 <- nanoarrow_schema_modify( schema_without_children, list(children = setNames(list(child_to_be), NA_character_)) ) expect_length(schema2$children, 1) expect_named(schema2$children, "") expect_identical(schema2$format, schema_without_children$format) expect_identical(schema2$children[[1]]$format, child_to_be$format) # with a normal named child list schema2 <- nanoarrow_schema_modify( schema_without_children, list(children = list("a new name" = child_to_be)) ) expect_length(schema2$children, 1) expect_named(schema2$children, "a new name") expect_identical(schema2$format, schema_without_children$format) expect_identical(schema2$children[[1]]$format, child_to_be$format) schema_with_children <- na_struct(list(existing_name = na_string())) # some children to NULL children schema2 <- nanoarrow_schema_modify( schema_with_children, list(children = NULL) ) expect_identical(schema2$children, list()) expect_identical(schema2$format, schema_with_children$format) # replace identical number of children schema2 <- nanoarrow_schema_modify( schema_with_children, list(children = list("a new name" = child_to_be)) ) expect_length(schema2$children, 1) expect_named(schema2$children, "a new name") expect_identical(schema2$format, schema_with_children$format) expect_identical(schema2$children[[1]]$format, child_to_be$format) # replace with more children another_child_to_be <- na_bool() schema2 <- nanoarrow_schema_modify( schema_with_children, list( children = list( "a new name" = child_to_be, "another new name" = another_child_to_be ) ) ) expect_length(schema2$children, 2) expect_named(schema2$children, c("a new name", "another new name")) expect_identical(schema2$format, schema_with_children$format) expect_identical(schema2$children[[1]]$format, child_to_be$format) expect_identical(schema2$children[[2]]$format, another_child_to_be$format) }) test_that("schema modify can modify dictionary", { schema_without_dictionary <- na_int32() # NULL -> NULL schema2 <- nanoarrow_schema_modify( schema_without_dictionary, list(dictionary = NULL) ) expect_null(schema2$dictionary) expect_identical(schema2$flags, schema_without_dictionary$flags) expect_identical(schema2$format, schema_without_dictionary$format) expect_identical(schema2$name, schema_without_dictionary$name) # NULL -> non-null schema2 <- nanoarrow_schema_modify( schema_without_dictionary, list(dictionary = na_int32()) ) expect_identical(schema2$dictionary$format, "i") expect_identical(schema2$flags, schema_without_dictionary$flags) expect_identical(schema2$format, schema_without_dictionary$format) expect_identical(schema2$name, schema_without_dictionary$name) # non-null -> NULL schema_with_dictionary <- schema2 schema2 <- nanoarrow_schema_modify( schema_with_dictionary, list(dictionary = NULL) ) expect_null(schema2$dictionary) expect_identical(schema2$flags, schema_with_dictionary$flags) expect_identical(schema2$format, schema_with_dictionary$format) expect_identical(schema2$name, schema_with_dictionary$name) # non-null -> non-null schema2 <- nanoarrow_schema_modify( schema_with_dictionary, list(dictionary = na_string()) ) expect_identical(schema2$dictionary$format, "u") expect_identical(schema2$flags, schema_with_dictionary$flags) expect_identical(schema2$format, schema_with_dictionary$format) expect_identical(schema2$name, schema_with_dictionary$name) }) test_that("schema modify respects the validate flag", { schema <- na_int32() schema2 <- nanoarrow_schema_modify( schema, list(format = "totally invalid"), validate = FALSE ) expect_identical(schema2$format, "totally invalid") expect_error( nanoarrow_schema_modify( schema, list(format = "totally invalid"), validate = TRUE ), "Error parsing schema->format" ) }) test_that("[[<- works for schema", { schema <- na_int32() schema[["name"]] <- "a new name" expect_identical(schema$name, "a new name") schema <- na_int32() schema[[2]] <- "yet a new name" expect_identical(schema$name, "yet a new name") expect_error( schema[["not_an_item"]] <- "something", "Can't modify schema" ) expect_error( schema[[NA_character_]] <- "something", "must be character" ) expect_error( schema[[character()]] <- "something", "must be character" ) expect_error( schema[[NA_integer_]] <- "something", "must be character" ) expect_error( schema[[integer()]] <- "something", "must be character" ) expect_error( schema[[12]] <- "something", "must be character" ) }) test_that("$<- works for schema", { schema <- na_int32() schema$name <- "a new name" expect_identical(schema$name, "a new name") expect_error( schema$not_an_item <- "something", "Can't modify schema" ) }) test_that("<- assignment works for schema$children", { schema <- na_struct(list(col1 = na_int32(), col2 = na_string())) schema$children$col1 <- na_bool() expect_named(schema$children, c("col1", "col2")) expect_identical(schema$children$col1$format, "b") expect_identical(schema$children$col1$name, "col1") names(schema$children)[1] <- "col1_new" expect_named(schema$children, c("col1_new", "col2")) expect_identical(schema$children$col1_new$format, "b") expect_identical(schema$children$col1_new$name, "col1_new") }) test_that("<- assignment works for schema$metadata", { schema <- na_int32() schema$metadata$key <- "value" expect_identical(schema$metadata$key, "value") names(schema$metadata)[1] <- "new_key" expect_identical(schema$metadata$new_key, "value") schema$metadata$new_key <- "new value" expect_identical(schema$metadata$new_key, "new value") }) nanoarrow/tests/testthat/test-pkg-arrow.R0000644000176200001440000003651714672341746020325 0ustar liggesusers# 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. test_that("infer_type() for nanoarrow_array works", { skip_if_not_installed("arrow") array <- as_nanoarrow_array(1:5) expect_true( arrow::infer_type(array)$Equals(arrow::int32()) ) }) test_that("infer_nanoarrow_schema() works for arrow objects", { skip_if_not_installed("arrow") int_schema <- infer_nanoarrow_schema(arrow::Array$create(1:10)) expect_true(arrow::as_data_type(int_schema)$Equals(arrow::int32())) int_schema <- infer_nanoarrow_schema(arrow::Scalar$create(1L)) expect_true(arrow::as_data_type(int_schema)$Equals(arrow::int32())) int_schema <- infer_nanoarrow_schema(arrow::ChunkedArray$create(1:10)) expect_true(arrow::as_data_type(int_schema)$Equals(arrow::int32())) int_schema <- infer_nanoarrow_schema(arrow::Expression$scalar(1L)) expect_true(arrow::as_data_type(int_schema)$Equals(arrow::int32())) tbl_schema_expected <- arrow::schema(x = arrow::int32()) tbl_schema <- infer_nanoarrow_schema(arrow::record_batch(x = 1L)) expect_true(arrow::as_schema(tbl_schema)$Equals(tbl_schema_expected)) tbl_schema <- infer_nanoarrow_schema(arrow::arrow_table(x = 1L)) expect_true(arrow::as_schema(tbl_schema)$Equals(tbl_schema_expected)) tbl_schema <- infer_nanoarrow_schema( arrow::RecordBatchReader$create(arrow::record_batch(x = 1L)) ) expect_true(arrow::as_schema(tbl_schema)$Equals(tbl_schema_expected)) skip_if_not(arrow::arrow_info()$capabilities["dataset"]) tbl_schema <- infer_nanoarrow_schema( arrow::InMemoryDataset$create(arrow::record_batch(x = 1L)) ) expect_true(arrow::as_schema(tbl_schema)$Equals(tbl_schema_expected)) tbl_schema <- infer_nanoarrow_schema( arrow::Scanner$create( arrow::InMemoryDataset$create(arrow::record_batch(x = 1L)) ) ) expect_true(arrow::as_schema(tbl_schema)$Equals(tbl_schema_expected)) }) test_that("nanoarrow_array to Array works", { skip_if_not_installed("arrow") int <- arrow::as_arrow_array(as_nanoarrow_array(1:5)) expect_true(int$Equals(arrow::Array$create(1:5))) dbl <- arrow::as_arrow_array(as_nanoarrow_array(1:5, schema = arrow::float64())) expect_true(dbl$Equals(arrow::Array$create(1:5, type = arrow::float64()))) dbl_casted <- arrow::as_arrow_array(as_nanoarrow_array(1:5), type = arrow::float64()) expect_true(dbl_casted$Equals(arrow::Array$create(1:5, type = arrow::float64()))) chr <- arrow::as_arrow_array(as_nanoarrow_array(c("one", "two"))) expect_true(chr$Equals(arrow::Array$create(c("one", "two")))) }) test_that("nanoarrow_array to Array works for child arrays", { skip_if_not_installed("arrow") df <- data.frame(a = 1, b = "two") batch <- as_nanoarrow_array(df) # This type of export is special because batch$children[[2]] has an SEXP # dependency on the original array. When we export it, we reverse that # dependency such that the exported array and the batch->children[1] array # are shells that call nanoarrow_release_sexp on a common object (i.e., sort of like # a shared pointer). array_from_column <- arrow::as_arrow_array(batch$children[[2]]) # The exported array should be valid expect_null(array_from_column$Validate()) # All the nanoarrow pointers should still be valid expect_true(nanoarrow_pointer_is_valid(batch)) expect_true(nanoarrow_pointer_is_valid(batch$children[[1]])) expect_true(nanoarrow_pointer_is_valid(batch$children[[2]])) # Let the exported arrow::Array go out of scope and maximize the # chance that the exported data release callback is called array_from_column <- NULL gc() Sys.sleep(0.1) # All the nanoarrow pointers should *still* be valid even after that # release callback is called expect_true(nanoarrow_pointer_is_valid(batch)) expect_true(nanoarrow_pointer_is_valid(batch$children[[1]])) expect_true(nanoarrow_pointer_is_valid(batch$children[[2]])) # Export one column again but this time let the `batch` go out of scope array_from_column <- arrow::as_arrow_array(batch$children[[1]]) batch <- NULL gc() Sys.sleep(0.1) # The exported array should still be valid expect_null(array_from_column$Validate()) }) test_that("Array to nanoarrow_array works", { skip_if_not_installed("arrow") int <- arrow::Array$create(1:5) int_array <- as_nanoarrow_array(int) expect_s3_class(int_array, "nanoarrow_array") int_schema <- infer_nanoarrow_schema(int_array) expect_s3_class(int_schema, "nanoarrow_schema") expect_true( arrow::as_arrow_array(int_array)$Equals( arrow::Array$create(1:5) ) ) dbl_array <- as_nanoarrow_array(int, schema = arrow::float64()) expect_s3_class(dbl_array, "nanoarrow_array") dbl_schema <- infer_nanoarrow_schema(dbl_array) expect_s3_class(dbl_schema, "nanoarrow_schema") expect_true( arrow::as_arrow_array(dbl_array)$Equals( arrow::Array$create(1:5, type = arrow::float64()) ) ) }) test_that("nanoarrow_array to ChunkedArray works", { skip_if_not_installed("arrow") int <- arrow::as_chunked_array(as_nanoarrow_array(1:5)) expect_true(int$Equals(arrow::ChunkedArray$create(1:5))) dbl_casted <- arrow::as_chunked_array(as_nanoarrow_array(1:5), type = arrow::float64()) expect_true(dbl_casted$Equals(arrow::ChunkedArray$create(1:5, type = arrow::float64()))) }) test_that("ChunkedArray to nanoarrow_array works", { skip_if_not_installed("arrow") int <- arrow::ChunkedArray$create(1:5) int_array <- as_nanoarrow_array(int) expect_s3_class(int_array, "nanoarrow_array") int_schema <- infer_nanoarrow_schema(int_array) expect_s3_class(int_schema, "nanoarrow_schema") expect_true( arrow::as_chunked_array(int_array)$Equals( arrow::ChunkedArray$create(1:5) ) ) dbl_array <- as_nanoarrow_array(int, schema = arrow::float64()) expect_s3_class(dbl_array, "nanoarrow_array") dbl_schema <- infer_nanoarrow_schema(dbl_array) expect_s3_class(dbl_schema, "nanoarrow_schema") expect_true( arrow::as_chunked_array(dbl_array)$Equals( arrow::ChunkedArray$create(1:5, type = arrow::float64()) ) ) }) test_that("ChunkedArray to nanoarrow_array_stream works", { skip_if_not_installed("arrow") int <- arrow::ChunkedArray$create(1:5) int_array_stream <- as_nanoarrow_array_stream(int) expect_s3_class(int_array_stream, "nanoarrow_array_stream") expect_true( arrow::as_chunked_array(int_array_stream)$Equals( arrow::ChunkedArray$create(1:5) ) ) dbl_array_stream <- as_nanoarrow_array_stream(int, schema = arrow::float64()) expect_s3_class(dbl_array_stream, "nanoarrow_array_stream") expect_true( arrow::as_chunked_array(dbl_array_stream)$Equals( arrow::ChunkedArray$create(1:5, type = arrow::float64()) ) ) }) test_that("Array to nanoarrow_array_stream works", { skip_if_not_installed("arrow") int <- arrow::Array$create(1:5) int_array_stream <- as_nanoarrow_array_stream(int) expect_s3_class(int_array_stream, "nanoarrow_array_stream") expect_true( arrow::as_arrow_array(int_array_stream)$Equals( arrow::Array$create(1:5) ) ) dbl_array_stream <- as_nanoarrow_array_stream(int, schema = arrow::float64()) expect_s3_class(dbl_array_stream, "nanoarrow_array_stream") expect_true( arrow::as_arrow_array(dbl_array_stream)$Equals( arrow::Array$create(1:5, type = arrow::float64()) ) ) empty_array_stream <- basic_array_stream(list(), na_int32()) expect_true( arrow::as_arrow_array(empty_array_stream)$Equals( arrow::concat_arrays(type = arrow::int32()) ) ) }) test_that("nanoarrow_array to RecordBatch works", { skip_if_not_installed("arrow") df <- data.frame(a = 1:5, b = letters[1:5]) batch <- arrow::as_record_batch(as_nanoarrow_array(df)) expect_true( batch$Equals(arrow::record_batch(a = 1:5, b = letters[1:5])) ) batch_casted <- arrow::as_record_batch( as_nanoarrow_array(df), schema = arrow::schema(a = arrow::float64(), b = arrow::string()) ) expect_true( batch_casted$Equals( arrow::record_batch(a = as.double(1:5), b = letters[1:5]) ) ) }) test_that("RecordBatch to nanoarrow_array", { skip_if_not_installed("arrow") batch <- arrow::record_batch(a = 1:5, b = letters[1:5]) struct_array <- as_nanoarrow_array(batch) expect_s3_class(struct_array, "nanoarrow_array") struct_schema <- infer_nanoarrow_schema(struct_array) expect_s3_class(struct_schema, "nanoarrow_schema") expect_true( arrow::as_record_batch(struct_array)$Equals( arrow::record_batch(a = 1:5, b = letters[1:5]) ) ) struct_array_casted <- as_nanoarrow_array( batch, schema = arrow::schema(a = arrow::float64(), b = arrow::string()) ) expect_s3_class(struct_array_casted, "nanoarrow_array") struct_schema_casted <- infer_nanoarrow_schema(struct_array_casted) expect_s3_class(struct_schema_casted, "nanoarrow_schema") expect_true( arrow::as_record_batch(struct_array_casted)$Equals( arrow::record_batch(a = as.double(1:5), b = letters[1:5]) ) ) }) test_that("nanoarrow_array to Table works", { skip_if_not_installed("arrow") df <- data.frame(a = 1:5, b = letters[1:5]) table <- arrow::as_arrow_table(as_nanoarrow_array(df)) expect_true( table$Equals(arrow::arrow_table(a = 1:5, b = letters[1:5])) ) table_casted <- arrow::as_arrow_table( as_nanoarrow_array(df), schema = arrow::schema(a = arrow::float64(), b = arrow::string()) ) expect_true( table_casted$Equals( arrow::arrow_table(a = as.double(1:5), b = letters[1:5]) ) ) }) test_that("Table to nanoarrow_array", { skip_if_not_installed("arrow") table <- arrow::arrow_table(a = 1:5, b = letters[1:5]) struct_array <- as_nanoarrow_array(table) expect_s3_class(struct_array, "nanoarrow_array") struct_schema <- infer_nanoarrow_schema(struct_array) expect_s3_class(struct_schema, "nanoarrow_schema") expect_true( arrow::as_arrow_table(struct_array)$Equals( arrow::arrow_table(a = 1:5, b = letters[1:5]) ) ) struct_array_casted <- as_nanoarrow_array( table, schema = arrow::schema(a = arrow::float64(), b = arrow::string()) ) expect_s3_class(struct_array_casted, "nanoarrow_array") struct_schema_casted <- infer_nanoarrow_schema(struct_array_casted) expect_s3_class(struct_schema_casted, "nanoarrow_schema") expect_true( arrow::as_arrow_table(struct_array_casted)$Equals( arrow::arrow_table(a = as.double(1:5), b = letters[1:5]) ) ) }) test_that("Table to nanoarrow_array_stream works", { skip_if_not_installed("arrow") table <- arrow::arrow_table(a = 1:5, b = letters[1:5]) stream <- as_nanoarrow_array_stream(table) expect_s3_class(stream, "nanoarrow_array_stream") expect_true( arrow::as_arrow_table(stream)$Equals( arrow::arrow_table(a = 1:5, b = letters[1:5]) ) ) # Check cast in the stream -> table direction stream <- as_nanoarrow_array_stream(table) expect_true( arrow::as_arrow_table( stream, schema = arrow::schema(a = arrow::float64(), b = arrow::string()) )$Equals( arrow::arrow_table(a = as.double(1:5), b = letters[1:5]) ) ) # Check cast in the table -> stream direction stream_casted <- as_nanoarrow_array_stream( table, schema = arrow::schema(a = arrow::float64(), b = arrow::string()) ) expect_s3_class(stream_casted, "nanoarrow_array_stream") expect_true( arrow::as_arrow_table(stream_casted)$Equals( arrow::arrow_table(a = as.double(1:5), b = letters[1:5]) ) ) }) test_that("Dataset to nanoarrow_array_stream works", { skip_if_not_installed("arrow") skip_if_not(arrow::arrow_info()$capabilities["dataset"]) dataset <- arrow::InMemoryDataset$create(arrow::arrow_table(a = 1:5, b = letters[1:5])) stream <- as_nanoarrow_array_stream(dataset) expect_s3_class(stream, "nanoarrow_array_stream") expect_true( arrow::as_arrow_table(stream)$Equals( arrow::arrow_table(a = 1:5, b = letters[1:5]) ) ) }) test_that("Scanner to nanoarrow_array_stream works", { skip_if_not_installed("arrow") skip_if_not(arrow::arrow_info()$capabilities["dataset"]) dataset <- arrow::InMemoryDataset$create(arrow::arrow_table(a = 1:5, b = letters[1:5])) scanner <- arrow::Scanner$create(dataset) stream <- as_nanoarrow_array_stream(scanner) expect_s3_class(stream, "nanoarrow_array_stream") expect_true( arrow::as_arrow_table(stream)$Equals( arrow::arrow_table(a = 1:5, b = letters[1:5]) ) ) }) test_that("nanoarrow_schema to DataType works", { skip_if_not_installed("arrow") int_schema <- as_nanoarrow_schema(arrow::int32()) arrow_type <- arrow::as_data_type(int_schema) expect_true(arrow_type$Equals(arrow::int32())) }) test_that("DataType to nanoarrow_schema", { skip_if_not_installed("arrow") schema <- as_nanoarrow_schema(arrow::int32()) expect_s3_class(schema, "nanoarrow_schema") expect_true(arrow::as_data_type(schema)$Equals(arrow::int32())) }) test_that("Field to nanoarrow_schema", { skip_if_not_installed("arrow") schema <- as_nanoarrow_schema(arrow::field("name", arrow::int32())) expect_s3_class(schema, "nanoarrow_schema") expect_true(arrow::as_data_type(schema)$Equals(arrow::int32())) }) test_that("nanoarrow_schema to Schema works", { skip_if_not_installed("arrow") struct_schema <- as_nanoarrow_schema( arrow::struct(a = arrow::int32(), b = arrow::string()) ) arrow_schema <- arrow::as_schema(struct_schema) expect_true(arrow_schema$Equals(arrow::schema(a = arrow::int32(), b = arrow::string()))) }) test_that("Schema to nanoarrow_schema", { skip_if_not_installed("arrow") schema <- as_nanoarrow_schema(arrow::schema(name = arrow::int32())) expect_s3_class(schema, "nanoarrow_schema") expect_true(arrow::as_schema(schema)$Equals(arrow::schema(name = arrow::int32()))) }) test_that("nanoarrow_array_stream to RecordBatchReader works", { skip_if_not_installed("arrow") reader <- arrow::as_record_batch_reader( arrow::record_batch(a = 1:5, b = letters[1:5]) ) array_stream <- as_nanoarrow_array_stream(reader) reader_roundtrip <- arrow::as_record_batch_reader(array_stream) expect_false(nanoarrow_pointer_is_valid(array_stream)) expect_true( reader_roundtrip$read_next_batch()$Equals( arrow::record_batch(a = 1:5, b = letters[1:5]) ) ) expect_null(reader_roundtrip$read_next_batch()) }) test_that("RecordBatchReader to nanoarrow_array_stream works", { skip_if_not_installed("arrow") reader <- arrow::as_record_batch_reader( arrow::record_batch(a = 1:5, b = letters[1:5]) ) array_stream <- as_nanoarrow_array_stream(reader) expect_s3_class(array_stream, "nanoarrow_array_stream") reader_roundtrip <- arrow::as_record_batch_reader(array_stream) expect_true( reader_roundtrip$read_next_batch()$Equals( arrow::record_batch(a = 1:5, b = letters[1:5]) ) ) expect_null(reader_roundtrip$read_next_batch()) }) nanoarrow/tests/testthat/test-util.R0000644000176200001440000000540114502402562017337 0ustar liggesusers# 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. test_that("can set option/env var to pretend the arrow package is not installed", { skip_if_not_installed("arrow") expect_true(arrow_installed()) expect_silent(assert_arrow_installed("life")) withr::with_options(list(nanoarrow.without_arrow = TRUE), { expect_false(arrow_installed()) expect_error( assert_arrow_installed("life"), "Package 'arrow' required for life" ) }) withr::with_envvar(list(R_NANOARROW_WITHOUT_ARROW = "true"), { expect_false(arrow_installed()) }) }) test_that("preserve/release works when release happens on another thread", { some_non_null_sexp <- 1L preserved_empty() expect_identical(preserved_empty(), 0) preserve_and_release_on_other_thread(some_non_null_sexp) # We can't test the exact value of preserved_count() because what the # garbage collector releases and when is not stable. expect_true(preserved_count() > 0) expect_identical(preserved_empty(), 1) expect_identical(preserved_empty(), 0) }) test_that("vector slicer works", { expect_identical(vec_slice2(letters, 1), "a") expect_identical( vec_slice2(data.frame(letters = letters, stringsAsFactors = FALSE), 1), data.frame(letters = "a", stringsAsFactors = FALSE) ) }) test_that("new_data_frame() works", { expect_identical( new_data_frame(list(x = 1, y = 2), nrow = 1), data.frame(x = 1, y = 2) ) }) test_that("vector fuzzers work", { ptype <- data.frame( a = logical(), b = integer(), c = double(), d = character(), stringsAsFactors = FALSE ) df_gen <- vec_gen(ptype, n = 123) expect_identical(nrow(df_gen), 123L) expect_identical(df_gen[integer(), ], ptype) expect_error(vec_gen(environment()), "Don't know how to generate vector") }) test_that("vector shuffler works", { df <- data.frame(letters = letters, stringsAsFactors = FALSE) df_shuffled <- vec_shuffle(df) expect_setequal(df_shuffled$letters, df$letters) letters_shuffled <- vec_shuffle(letters) expect_setequal(letters_shuffled, letters) }) nanoarrow/tests/testthat/test-pointers.R0000644000176200001440000001767114502402506020237 0ustar liggesusers# 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. test_that("nanoarrow_pointer_is_valid() works", { expect_true(nanoarrow_pointer_is_valid(na_int32())) expect_true(nanoarrow_pointer_is_valid(as_nanoarrow_array(integer()))) expect_true(nanoarrow_pointer_is_valid( as_nanoarrow_array_stream(data.frame(a = integer()))) ) expect_false(nanoarrow_pointer_is_valid(nanoarrow_allocate_schema())) expect_false(nanoarrow_pointer_is_valid(nanoarrow_allocate_array())) expect_false(nanoarrow_pointer_is_valid(nanoarrow_allocate_array_stream())) expect_error(nanoarrow_pointer_is_valid(NULL), "must inherit from") }) test_that("nanoarrow_pointer_release() works", { ptr <- na_int32() expect_true(nanoarrow_pointer_is_valid(ptr)) nanoarrow_pointer_release(ptr) expect_false(nanoarrow_pointer_is_valid(ptr)) ptr <- as_nanoarrow_array(integer()) expect_true(nanoarrow_pointer_is_valid(ptr)) nanoarrow_pointer_release(ptr) expect_false(nanoarrow_pointer_is_valid(ptr)) ptr <- as_nanoarrow_array_stream(data.frame(a = integer())) expect_true(nanoarrow_pointer_is_valid(ptr)) nanoarrow_pointer_release(ptr) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_error(nanoarrow_pointer_release(NULL), "must inherit from") }) test_that("nanoarrow_pointer_move() works for schema", { ptr <- na_int32() dst <- nanoarrow_allocate_schema() nanoarrow_pointer_move(ptr, dst) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_true(nanoarrow_schema_identical(dst, na_int32())) expect_error( nanoarrow_pointer_move(ptr, dst), "`ptr_dst` is a valid struct ArrowSchema" ) expect_error( nanoarrow_pointer_move(nanoarrow_allocate_schema(), ptr), "`ptr_src` is not a valid struct ArrowSchema" ) }) test_that("nanoarrow_pointer_move() works for array", { ptr <- as_nanoarrow_array(integer()) dst <- nanoarrow_allocate_array() nanoarrow_pointer_move(ptr, dst) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_identical(convert_array(dst), integer()) expect_error( nanoarrow_pointer_move(ptr, dst), "`ptr_dst` is a valid struct ArrowArray" ) expect_error( nanoarrow_pointer_move(nanoarrow_allocate_array(), ptr), "`ptr_src` is not a valid struct ArrowArray" ) }) test_that("nanoarrow_pointer_move() works for array_stream", { ptr <- as_nanoarrow_array_stream(data.frame(a = integer())) dst <- nanoarrow_allocate_array_stream() nanoarrow_pointer_move(ptr, dst) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_true(nanoarrow_pointer_is_valid(dst)) expect_error( nanoarrow_pointer_move(ptr, dst), "`ptr_dst` is a valid struct ArrowArrayStream" ) expect_error( nanoarrow_pointer_move(nanoarrow_allocate_array_stream(), ptr), "`ptr_src` is not a valid struct ArrowArrayStream" ) }) test_that("nanoarrow_pointer_move() can import from chr address", { ptr <- na_int32() ptr_chr <- nanoarrow_pointer_addr_chr(ptr) dst <- nanoarrow_allocate_schema() nanoarrow_pointer_move(ptr_chr, dst) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_true(nanoarrow_pointer_is_valid(dst)) }) test_that("nanoarrow_pointer_move() can import from dbl address", { ptr <- na_int32() ptr_dbl <- nanoarrow_pointer_addr_dbl(ptr) dst <- nanoarrow_allocate_schema() nanoarrow_pointer_move(ptr_dbl, dst) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_true(nanoarrow_pointer_is_valid(dst)) }) test_that("nanoarrow_pointer_move() errors for bad input", { ptr <- na_int32() dst <- nanoarrow_allocate_schema() expect_error(nanoarrow_pointer_move(ptr, NULL), "`ptr_dst` must inherit from") expect_error( nanoarrow_pointer_move(NULL, dst), "Pointer must be chr\\[1\\], dbl\\[1\\], or external pointer" ) }) test_that("nanoarrow_pointer_export() works for schema", { ptr <- na_int32() dst <- nanoarrow_allocate_schema() nanoarrow_pointer_export(ptr, dst) expect_true(nanoarrow_pointer_is_valid(ptr)) expect_true(nanoarrow_schema_identical(dst, na_int32())) expect_error( nanoarrow_pointer_export(ptr, dst), "`ptr_dst` is a valid struct ArrowSchema" ) expect_error( nanoarrow_pointer_export(nanoarrow_allocate_schema(), nanoarrow_allocate_schema()), "has already been released" ) }) test_that("nanoarrow_pointer_export() works for array", { ptr <- as_nanoarrow_array(integer()) dst <- nanoarrow_allocate_array() nanoarrow_pointer_export(ptr, dst) expect_true(nanoarrow_pointer_is_valid(ptr)) # (when exporting the schema is not included) nanoarrow_array_set_schema(dst, infer_nanoarrow_schema(ptr)) expect_identical(convert_array(dst), integer()) expect_error( nanoarrow_pointer_export(ptr, dst), "`ptr_dst` is a valid struct ArrowArray" ) expect_error( nanoarrow_pointer_export(nanoarrow_allocate_array(), nanoarrow_allocate_array()), "has already been released" ) }) test_that("exported Arrays can have their children released", { ptr <- as_nanoarrow_array(data.frame(a = 1L, b = 2)) dst <- nanoarrow_allocate_array() nanoarrow_pointer_export(ptr, dst) expect_identical(convert_array(ptr), data.frame(a = 1L, b = 2)) nanoarrow_pointer_release(dst$children[[1]]) expect_identical(convert_array(ptr), data.frame(a = 1L, b = 2)) nanoarrow_pointer_release(dst$children[[2]]) expect_identical(convert_array(ptr), data.frame(a = 1L, b = 2)) nanoarrow_pointer_release(dst) expect_identical(convert_array(ptr), data.frame(a = 1L, b = 2)) }) test_that("nanoarrow_pointer_export() works for array_stream", { ptr <- as_nanoarrow_array_stream(data.frame(a = integer())) dst <- nanoarrow_allocate_array_stream() nanoarrow_pointer_export(ptr, dst) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_true(nanoarrow_pointer_is_valid(dst)) expect_identical(convert_array_stream(dst), data.frame(a = integer())) expect_error( nanoarrow_pointer_export(ptr, dst), "`ptr_dst` is a valid struct ArrowArrayStream" ) expect_error( nanoarrow_pointer_export(nanoarrow_allocate_array_stream(), ptr), "has already been released" ) }) test_that("nanoarrow_pointer_export() works for wrapped array_stream", { some_dependent_object <- list() ptr <- as_nanoarrow_array_stream(data.frame(a = integer())) nanoarrow_pointer_set_protected(ptr, some_dependent_object) dst <- nanoarrow_allocate_array_stream() nanoarrow_pointer_export(ptr, dst) expect_false(nanoarrow_pointer_is_valid(ptr)) expect_true(nanoarrow_pointer_is_valid(dst)) expect_identical(convert_array_stream(dst), data.frame(a = integer())) }) test_that("nanoarrow_pointer_set_protected() errors appropriately", { expect_error( nanoarrow_pointer_set_protected(NULL), "must inherit from 'nanoarrow_schema', 'nanoarrow_array', or 'nanoarrow_array_stream'" ) dst <- nanoarrow_allocate_array_stream() nanoarrow_pointer_set_protected(dst, 1234) expect_error( nanoarrow_pointer_set_protected(dst, 5678), "External pointer protected value has already been set" ) }) test_that("nanoarrow_pointer_export() errors for unknown object", { expect_error(nanoarrow_pointer_export(NULL), "must inherit from") }) test_that("pointer address getters work", { schema <- na_int32() expect_match(nanoarrow_pointer_addr_chr(schema), "^[0-9]+$") expect_match(nanoarrow_pointer_addr_pretty(schema), "^(0x)?[0-9a-fA-F]+$") }) nanoarrow/tests/testthat/test-infer-ptype.R0000644000176200001440000000766114567516717020661 0ustar liggesusers# 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. test_that("infer_nanoarrow_ptype() works on arrays, schemas, and streams", { array <- as_nanoarrow_array(logical()) expect_identical(infer_nanoarrow_ptype(array), logical()) schema <- infer_nanoarrow_schema(array) expect_identical(infer_nanoarrow_ptype(schema), logical()) stream <- as_nanoarrow_array_stream(data.frame(x = logical())) expect_identical(infer_nanoarrow_ptype(stream), data.frame(x = logical())) expect_error( infer_nanoarrow_ptype("not valid"), "must be a nanoarrow_schema" ) }) test_that("infer_nanoarrow_ptype() works for basic types", { expect_identical( infer_nanoarrow_ptype(as_nanoarrow_array(vctrs::unspecified())), vctrs::unspecified() ) expect_identical( infer_nanoarrow_ptype(as_nanoarrow_array(logical())), logical() ) expect_identical( infer_nanoarrow_ptype(as_nanoarrow_array(integer())), integer() ) expect_identical( infer_nanoarrow_ptype(as_nanoarrow_array(double())), double() ) expect_identical( infer_nanoarrow_ptype(as_nanoarrow_schema(na_decimal128(2, 3))), double() ) expect_identical( infer_nanoarrow_ptype(as_nanoarrow_array(character())), character() ) expect_identical( infer_nanoarrow_ptype( as_nanoarrow_array(data.frame(x = character(), stringsAsFactors = FALSE)) ), data.frame(x = character(), stringsAsFactors = FALSE) ) }) test_that("infer_nanoarrow_ptype() infers ptypes for date/time types", { array_date <- as_nanoarrow_array(as.Date("2000-01-01")) expect_identical( infer_nanoarrow_ptype(array_date), as.Date(character()) ) array_time <- as_nanoarrow_array(hms::parse_hm("12:34")) expect_identical( infer_nanoarrow_ptype(array_time), hms::hms() ) array_duration <- as_nanoarrow_array(as.difftime(123, units = "secs")) expect_identical( infer_nanoarrow_ptype(array_duration), as.difftime(numeric(), units = "secs") ) array_timestamp <- as_nanoarrow_array( as.POSIXct("2000-01-01 12:33", tz = "America/Halifax") ) expect_identical( infer_nanoarrow_ptype(array_timestamp), as.POSIXct(character(), tz = "America/Halifax") ) }) test_that("infer_nanoarrow_ptype() infers ptypes for nested types", { skip_if_not_installed("arrow") array_list <- as_nanoarrow_array(vctrs::list_of(integer())) expect_identical( infer_nanoarrow_ptype(array_list), vctrs::list_of(.ptype = integer()) ) array_fixed_size <- as_nanoarrow_array( arrow::Array$create( list(1:5), arrow::fixed_size_list_of(arrow::int32(), 5) ) ) expect_identical( infer_nanoarrow_ptype(array_fixed_size), vctrs::list_of(.ptype = integer()) ) }) test_that("infer_nanoarrow_ptype() errors for types it can't infer", { unsupported_array <- nanoarrow_array_init(na_decimal256(3, 4)) expect_error( infer_nanoarrow_ptype(as_nanoarrow_array(unsupported_array)), "Can't infer R vector type for " ) unsupported_struct <- nanoarrow_array_init( na_struct(list(col = na_decimal256(3, 4))) ) expect_error( infer_nanoarrow_ptype(as_nanoarrow_array(unsupported_struct)), "Can't infer R vector type for `col` " ) }) nanoarrow/tests/testthat.R0000644000176200001440000000224214307221533015405 0ustar liggesusers# 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. library(testthat) library(nanoarrow) verbose_test_output <- identical(tolower(Sys.getenv("ARROW_R_DEV", "false")), "true") || identical(tolower(Sys.getenv("ARROW_R_VERBOSE_TEST", "false")), "true") if (verbose_test_output) { reporter <- MultiReporter$new(list(CheckReporter$new(), LocationReporter$new())) } else { reporter <- check_reporter() } test_check("nanoarrow", reporter = reporter) nanoarrow/MD50000644000176200001440000002073014702646313012600 0ustar liggesusers07dab9af8a4d0cc6e28b72b233a55c58 *DESCRIPTION 34e0201fd98a275a08b7bb8e955d5101 *NAMESPACE cb60ceed22cc410ad2ba70e04c3a0b7b *NEWS.md 3f4b9900b02b437eb56d26cbf22466fc *R/altrep.R da959399c29340892a633c8f6a9b4653 *R/array-stream.R 966c63d6fe83a3ab18e488de95d27287 *R/array.R 562dcb1a7487529242f601ab03ff02a4 *R/as-array.R 309a722262b0ba12affd4b3962f0b978 *R/buffer.R 5dfde2e8099afe812764b20250530f9c *R/convert-array-stream.R 152c495203e33bde52483363f0184452 *R/convert-array.R 0668e4c17443c748946aa4ce054151d2 *R/extension-vctrs.R 83c0cc729213d7d3b5d0dac1b2aeb117 *R/extension.R 95055f8c97fa85b44246f05499512c05 *R/infer-ptype.R e647a3c7971eb453960b93646200e420 *R/ipc.R db26ada34d5262762a300cc2a3e26e10 *R/nanoarrow-package.R 529668f91d84dad694c12d75829fe65b *R/pkg-arrow.R 132650b0d3b75350945c6b040b5ce483 *R/pointers.R 3e052f60c0fd58608d65528d76c3ca13 *R/schema.R 833b864512bb3e6de2dd859ceafa38a2 *R/type.R 06270acd344a99cd3d1d06db5514dbfd *R/util.R ae64dcb9e22508ec55d697b6fba67ceb *R/vctr.R 5752b83fec0a385e9c8298c688fa7552 *R/zzz.R ba1490eb4626847a71feac2e1ab6aea3 *README.md 0aa53aae37d4e9fff19d5f281396d292 *inst/include/nanoarrow/r.h 7aaadb46d2e09fe111c89629b92e83af *man/array_stream_set_finalizer.Rd 4d587015438f353cb5b72675ae2ca659 *man/as_nanoarrow_array.Rd bd2f9b6181d29ed93358fb1f2d52e9dc *man/as_nanoarrow_array_stream.Rd d6a23e2f24251d5e404cf2d69b11e4b3 *man/as_nanoarrow_buffer.Rd 64371e8326850178c621394b6941f881 *man/as_nanoarrow_schema.Rd a945c923096965f19498abf7b9378e30 *man/as_nanoarrow_vctr.Rd ab560cd52af1016a5aaccb5623533ec7 *man/basic_array_stream.Rd c8a5455e9c99eedb0532d3d1196880ff *man/convert_array.Rd 6e131087aca590558b26f2a79f30a4d2 *man/convert_array_stream.Rd 46525b8260de44f421c2768dff2f841c *man/infer_nanoarrow_ptype.Rd f07a675b459cdcf282e645af2ac6e524 *man/infer_nanoarrow_ptype_extension.Rd ccf807624af85434673ad4320ddfcf65 *man/na_type.Rd 2f122d625da0ee7c04fc935b25b73003 *man/na_vctrs.Rd b483ecffbb1f2abefd22e1ee96e1023f *man/nanoarrow-package.Rd ea2719b6457c3dc1b270e3ac1d8c445a *man/nanoarrow_array_init.Rd ead3237b06c2e034738de27f68625336 *man/nanoarrow_buffer_init.Rd cad85e570d72538909919fba3aa2de80 *man/nanoarrow_extension_array.Rd c653c8e32b8780d91701e42109565657 *man/nanoarrow_extension_spec.Rd 8c085033c3bfb38aa7e7bb5a2e2eec35 *man/nanoarrow_pointer_is_valid.Rd ad4e8783c1b88a84de24615fef1dd178 *man/nanoarrow_version.Rd e5348e67a79c8db6a39b37bb64ccef68 *man/read_nanoarrow.Rd 48b35feb238829a1a0fce7bb09fa71e0 *src/Makevars f1d9b2458107adf780e435b49aa2c34f *src/altrep.c 2d48b1bb763debda602979c4ef478594 *src/altrep.h 4de101bae9efc6e416bd14eff842afe3 *src/array.c 38269433b1f19a6ee9c93fba69aaab37 *src/array.h c70906d3071ab352b00a2231511e2393 *src/array_stream.c eb4b0c65b3e4210a8e336e4195366748 *src/array_stream.h 9a01a75c2877fcbea0e2a9a68d3ebdeb *src/array_view.c 10f66cefa23bfd607ec8c2f8f18ebafc *src/array_view.h 8aa1f24c0ab92bec6ad5a59260905b8c *src/as_array.c 2993ea1120552e6fa23bd35f8c123d2e *src/buffer.c 68dec2a47008d3ad8adaf3d30ca6b291 *src/buffer.h 87dfa2be2876db08f42f8222f58f46bc *src/convert.c 16f1f979c2e5d79fdfc20ccd07100cc8 *src/convert.h 376f88f291761406c65339af8874762b *src/convert_array.c 7530ee780cb0f1ff25c538e48085cff0 *src/convert_array_stream.c 3595fbad640fe5cd5c40d2391ee34405 *src/flatcc.c 91d1c457fe51f367233682f7334b6a49 *src/flatcc/flatcc_accessors.h 9e874043a381cafee6ed308af0864739 *src/flatcc/flatcc_alloc.h b026b6391eba1cf057c7d777bc4580da *src/flatcc/flatcc_assert.h 5e302d4fd8225eaa9503d1ff66e60cdc *src/flatcc/flatcc_builder.h 5cbbe929f40951bf4680fd893a4215ee *src/flatcc/flatcc_emitter.h 46bfd8e2ac79791b87dae07d74b67906 *src/flatcc/flatcc_endian.h 8f73e0b2b28bdd12c20b6322fd2508e3 *src/flatcc/flatcc_epilogue.h baa0108a0b0578ec9d66941bcedf8430 *src/flatcc/flatcc_flatbuffers.h c1f4b5f7f1c903a2dbc3ce9c5bab6bd8 *src/flatcc/flatcc_identifier.h 97f5b803b5ef369a3311dd67008666c5 *src/flatcc/flatcc_iov.h e286dee5eb7d52175cee234bcd45da91 *src/flatcc/flatcc_portable.h 8a2f78b91806a79dfe514142051b8bec *src/flatcc/flatcc_prologue.h 4005c50fe695208e17949415526204af *src/flatcc/flatcc_refmap.h e6f4d1f98ec01f3b0e2ebca42a19b9f5 *src/flatcc/flatcc_rtconfig.h 85cb9cd0dc67d0d68035139e89cdb9df *src/flatcc/flatcc_types.h 1fc8d83f128080dbe29caa3ee42d8282 *src/flatcc/flatcc_verifier.h e286dee5eb7d52175cee234bcd45da91 *src/flatcc/portable/flatcc_portable.h 956e557e764ac8a6c71a0e609eee495e *src/flatcc/portable/paligned_alloc.h 281ec08cfa98e996e4a97bc64810c2a5 *src/flatcc/portable/pattributes.h 28d1e99d3f4d4538531c7e9a71465b51 *src/flatcc/portable/pdiagnostic.h a2f88d4d4583745554356f9f19af67c2 *src/flatcc/portable/pdiagnostic_pop.h 113641d73df4b2dff5f47a4488704605 *src/flatcc/portable/pdiagnostic_push.h 4531c2936d25ca615553a0fb5e5b4739 *src/flatcc/portable/pendian.h 4786762c61bfedda48ca94de747bfc59 *src/flatcc/portable/pendian_detect.h 4db59aaac682d99d5581789bd1c3ce79 *src/flatcc/portable/pinline.h 864819a928068a43418bb0e1a42712ee *src/flatcc/portable/pinttypes.h e33bedaeb181081c482cc0bfa9e6c60f *src/flatcc/portable/pmemaccess.h d5ef17803712998b54c62b90f9fd8074 *src/flatcc/portable/portable.h b316c5c45e405f14aaf803d17dcddbe3 *src/flatcc/portable/portable_basic.h 5bb7911af7df2171e79bf916510776c0 *src/flatcc/portable/prestrict.h cb088d27f67e8655d7edeb93dd0a4c48 *src/flatcc/portable/pstatic_assert.h c8294e4e09c7c59aea3589b4c883d8c6 *src/flatcc/portable/pstdalign.h a73f400b1ca2a9784ea6bcd8bd2b97a4 *src/flatcc/portable/pstdint.h bac178f7a1251a1c0db0f6f6958ad94b *src/flatcc/portable/punaligned.h a410c5f9028ba64d2c28fa73d267ddf2 *src/flatcc/portable/pversion.h 47afe264db83e9773847e73e7ff13dbf *src/flatcc/portable/pwarnings.h ba439326eccbda99bea259943e08e2e6 *src/infer_ptype.c cd9aa374b2f7936e0bf98cb8e479635c *src/init.c 86dcfce2997a17226a2665ce0c9955ce *src/ipc.c 1f259a560b719316c6c3c4b6d9ebd9e3 *src/materialize.c c27d93240fabfb17ca5e4ada5dc2bab9 *src/materialize.h 707ec6617231fc14525a85d571315cc6 *src/materialize_blob.h c65768fb3d57af8ce3a6128eae726c0f *src/materialize_chr.h 48102a1913c7c22c508e120c3b22f4a9 *src/materialize_common.h e6dd97454fad97df3de78b64a6106f51 *src/materialize_date.h da5a830cbbf5e003710c02f1763e2db1 *src/materialize_dbl.h 69d6d6d23f7794b6b167e6adc24bd866 *src/materialize_difftime.h 76f146bead6bd20aa96a7c94851db7fe *src/materialize_int.h 2937593e010e28b92096616ab8e114d1 *src/materialize_int64.h 2474e0e7f6c4002924b05a44dc4034f3 *src/materialize_lgl.h 9d547b11f10e00f9aff1f6943ffbef91 *src/materialize_posixct.h 04c963c561bab504b00e89efc623a965 *src/materialize_unspecified.h 9c3278e2def1c83e7b713948cbdc6ff1 *src/nanoarrow.c 1c4d353457b1e5e9b36afc50be8f0e78 *src/nanoarrow.h efc511533436f9f64fbb12b253bcba25 *src/nanoarrow_cpp.cc 571da7a9f836f475790de1df70a442a1 *src/nanoarrow_ipc.c 0d44090c6d1c350939356dcee7b7ad18 *src/nanoarrow_ipc.h 5ab019701d0ed5341f2599eb3a30efdb *src/pointers.c d99d1f5474e7f8b1689a0133ba1c4f03 *src/schema.c b6af4a24ba6939fa08e135699e7c0ab4 *src/schema.h 951d574f0799738522f306d640a4743d *src/util.c 9c44d7c3c11b35897ef47cdecd1ef8b0 *src/util.h 7e0e0adcbeb92b0a81787e2eb5f45123 *src/vctr.c bd5ef54bce08c2a12d42a6c6b58f9ffa *src/version.c a78f805c4c8406d9012eb5ad2aada4e4 *tests/testthat.R ce90b02424cadc66f5f5982fc4d94a48 *tests/testthat/_snaps/array-stream.md 69c690c8ab8b48c1879dab9ef0f3706a *tests/testthat/_snaps/array.md 669744f5bd7def919393275a0fa8fa14 *tests/testthat/_snaps/as-array.md 79ad070e5cd671a27d1620c7f4dde40a *tests/testthat/_snaps/buffer.md cdd56d9d91a8dfe2c7b9ae346ed7e1d8 *tests/testthat/test-altrep.R 4fa42c0f13b89d379eeb3e691e7ae05c *tests/testthat/test-array-stream.R b7b24c9adad76861d14107e7bf0ec7c1 *tests/testthat/test-array.R 26fbed8acfa403c918edd212b9a1f261 *tests/testthat/test-as-array.R f92b2ea5c36578736f0502b721ef956f *tests/testthat/test-buffer.R b00603d1d72417d7e17b34ad6ee05455 *tests/testthat/test-convert-array-stream.R 0d5801acd955febbc3e229d12bcc67e2 *tests/testthat/test-convert-array.R cde34d0c7ed9f9a8d79458aed186152d *tests/testthat/test-extension-vctrs.R 1dc05421ee22beaa32d2495d615dd211 *tests/testthat/test-extension.R 2c0761d46c9de72bfcef7379a0ebc8a7 *tests/testthat/test-infer-ptype.R fa3e69248578466f71bba4c4dec9d3fd *tests/testthat/test-ipc.R 5d03084abff7f7f929713b591aa216ee *tests/testthat/test-nanoarrow-package.R 63ad8cb9f19b3c9d259e3c24888b5369 *tests/testthat/test-pkg-arrow.R bef36f06e21dfd2efb40c2432d46db70 *tests/testthat/test-pointers.R 1fd2cabedd6532aca8ee2ed59fbe9e74 *tests/testthat/test-schema.R a02e8d00d0cd68982b4382df40fcd72a *tests/testthat/test-type.R 17a59ff8c36b700a0f9edcfba0d3aa09 *tests/testthat/test-util.R 10b400c5532d64e15cf7e8dace4d28d1 *tests/testthat/test-vctr.R 3d6615b7150f3ce50b8ec9ae3bc957bf *tools/make-callentries.R nanoarrow/R/0000755000176200001440000000000014676554240012476 5ustar liggesusersnanoarrow/R/ipc.R0000644000176200001440000002241314672714403013371 0ustar liggesusers# 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. #' Read/write serialized streams of Arrow data #' #' Reads/writes connections, file paths, URLs, or raw vectors from/to serialized #' Arrow data. Arrow documentation typically refers to this format as "Arrow #' IPC", since its origin was as a means to transmit tables between processes #' (e.g., multiple R sessions). This format can also be written to and read #' from files or URLs and is essentially a high performance equivalent of #' a CSV file that does a better job maintaining types. #' #' The nanoarrow package implements an IPC writer; however, you can also #' use [arrow::write_ipc_stream()] to write data from R, or use #' the equivalent writer from another Arrow implementation in Python, C++, #' Rust, JavaScript, Julia, C#, and beyond. #' #' The media type of an Arrow stream is `application/vnd.apache.arrow.stream` #' and the recommended file extension is `.arrows`. #' #' @param x A `raw()` vector, connection, or file path from which to read #' binary data. Common extensions indicating compression (.gz, .bz2, .zip) #' are automatically uncompressed. #' @param data An object to write as an Arrow IPC stream, converted using #' [as_nanoarrow_array_stream()]. Notably, this includes a [data.frame()]. #' @param lazy By default, `read_nanoarrow()` will read and discard a copy of #' the reader's schema to ensure that invalid streams are discovered as #' soon as possible. Use `lazy = TRUE` to defer this check until the reader #' is actually consumed. #' @param ... Currently unused. #' #' @return A [nanoarrow_array_stream][as_nanoarrow_array_stream] #' @export #' #' @examples #' as.data.frame(read_nanoarrow(example_ipc_stream())) #' read_nanoarrow <- function(x, ..., lazy = FALSE) { UseMethod("read_nanoarrow") } #' @export read_nanoarrow.raw <- function(x, ..., lazy = FALSE) { buffer <- as_nanoarrow_buffer(x) reader <- .Call(nanoarrow_c_ipc_array_reader_buffer, buffer) check_stream_if_requested(reader, lazy) } #' @export read_nanoarrow.character <- function(x, ..., lazy = FALSE) { if (length(x) != 1) { stop(sprintf("Can't interpret character(%d) as file path", length(x))) } con_type <- guess_connection_type(x) if (con_type == "unz") { con <- do.call(con_type, list(x, filename = guess_zip_filename(x))) } else { con <- do.call(con_type, list(x)) } # Helps with error reporting when reading invalid files reader <- read_nanoarrow(con, lazy = TRUE) check_stream_if_requested(reader, lazy) } #' @export read_nanoarrow.connection <- function(x, ..., lazy = FALSE) { if (!isOpen(x)) { # Unopened connections should be opened in binary mode open(x, "rb") stream <- tryCatch( .Call(nanoarrow_c_ipc_array_reader_connection, x), error = function(e) { close(x) stop(e) } ) # Close the connection when the array stream is released stream_finalizer <- function() { close(x) } finalizer_env <- new.env(parent = baseenv()) finalizer_env$x <- x environment(stream_finalizer) <- finalizer_env reader <- array_stream_set_finalizer(stream, stream_finalizer) } else { reader <- .Call(nanoarrow_c_ipc_array_reader_connection, x) } check_stream_if_requested(reader, lazy) } #' @rdname read_nanoarrow #' @export write_nanoarrow <- function(data, x, ...) { UseMethod("write_nanoarrow", x) } #' @export write_nanoarrow.connection <- function(data, x, ...) { if (!isOpen(x)) { open(x, "wb") on.exit(close(x)) } writer <- .Call(nanoarrow_c_ipc_writer_connection, x) stream <- as_nanoarrow_array_stream(data) on.exit(nanoarrow_pointer_release(stream), add = TRUE) .Call(nanoarrow_c_ipc_writer_write_stream, writer, stream) invisible(data) } #' @export write_nanoarrow.character <- function(data, x, ...) { if (length(x) != 1) { stop(sprintf("Can't interpret character(%d) as file path", length(x))) } con_type <- guess_connection_type(x) if (con_type == "unz") { stop("zip compression not supported for write_nanoarrow()") } con <- do.call(con_type, list(x)) write_nanoarrow(data, con) } #' @rdname read_nanoarrow #' @export example_ipc_stream <- function() { # data.frame(some_col = c(1L, 2L, 3L)) as a serialized schema/batch schema <- as.raw(c( 0xff, 0xff, 0xff, 0xff, 0x10, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x05, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x84, 0xff, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x18, 0x00, 0x08, 0x00, 0x06, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x14, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x14, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )) batch <- as.raw(c( 0xff, 0xff, 0xff, 0xff, 0x88, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x16, 0x00, 0x06, 0x00, 0x05, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x18, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )) c(schema, batch) } check_stream_if_requested <- function(reader, lazy) { if (!lazy) { # Report error as coming from read_nanoarrow() always cnd_call <- sys.call(-1) tryCatch( reader$get_schema(), error = function(e) { reader$release() e$call <- cnd_call stop(e) } ) } reader } guess_connection_type <- function(x) { is_url <- grepl("://", x) compressed_con <- switch( tools::file_ext(x), "gz" = "gzfile", "bz2" = "bzfile", "zip" = "unz" ) if (is_url && !is.null(compressed_con)) { stop("Reading compressed streams from URLs is not supported") } if (is_url) { "url" } else if (is.null(compressed_con)) { "file" } else { compressed_con } } guess_zip_filename <- function(x) { files <- utils::unzip(x, list = TRUE)[[1]] if (length(files) != 1) { stop( sprintf( "Unzip only supported of archives with exactly one file (found %d)", length(files) ) ) } files } # The C-level R_tryCatch() does not provide for handling interrupts (or # I couldn't figure out how to make it work), so instead we provide wrappers # around readBin() and writeBin() that convert interrupt conditions to errors # (which the C code does know how to handle). read_bin_wrapper <- function(con, what, n) { withCallingHandlers( readBin(con, what, n), interrupt = function(e) { stop("user interrupt") } ) } write_bin_wrapper <- function(object, con) { withCallingHandlers( writeBin(object, con), interrupt = function(e) { stop("user interrupt") } ) } nanoarrow/R/extension-vctrs.R0000644000176200001440000001413514672342161015771 0ustar liggesusers# 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. #' Vctrs extension type #' #' The Arrow format provides a rich type system that can handle most R #' vector types; however, many R vector types do not roundtrip perfectly #' through Arrow memory. The vctrs extension type uses [vctrs::vec_data()], #' [vctrs::vec_restore()], and [vctrs::vec_ptype()] in calls to #' [as_nanoarrow_array()] and [convert_array()] to ensure roundtrip fidelity. #' #' @param ptype A vctrs prototype as returned by [vctrs::vec_ptype()]. #' The prototype can be of arbitrary size, but a zero-size vector #' is sufficient here. #' @inheritParams na_type #' #' @return A [nanoarrow_schema][as_nanoarrow_schema]. #' @export #' #' @examplesIf requireNamespace("jsonlite", quietly = TRUE) #' vctr <- as.POSIXlt("2000-01-02 03:45", tz = "UTC") #' array <- as_nanoarrow_array(vctr, schema = na_vctrs(vctr)) #' infer_nanoarrow_ptype(array) #' convert_array(array) #' na_vctrs <- function(ptype, storage_type = NULL) { ptype <- vctrs::vec_ptype(ptype) if (is.null(storage_type)) { storage_type <- infer_nanoarrow_schema(vctrs::vec_data(ptype)) } na_extension(storage_type, "arrow.r.vctrs", serialize_ptype(ptype)) } register_vctrs_extension <- function() { register_nanoarrow_extension( "arrow.r.vctrs", nanoarrow_extension_spec(subclass = "nanoarrow_extension_spec_vctrs") ) } #' @export infer_nanoarrow_ptype_extension.nanoarrow_extension_spec_vctrs <- function(extension_spec, x, ...) { parsed <- .Call(nanoarrow_c_schema_parse, x) unserialize_ptype(parsed$extension_metadata) } #' @export convert_array_extension.nanoarrow_extension_spec_vctrs <- function(extension_spec, array, to, ...) { # Restore the vector data to the ptype that is serialized in the type metadata to_r_data <- infer_nanoarrow_ptype(array) to_data <- vctrs::vec_data(to_r_data) data <- convert_array_extension(NULL, array, to_data, warn_unregistered = FALSE) vctr <- vctrs::vec_restore(data, to_r_data) # Cast to `to` if a different ptype was requested if (!is.null(to)) { vctrs::vec_cast(vctr, to) } else { vctr } } #' @export as_nanoarrow_array_extension.nanoarrow_extension_spec_vctrs <- function( extension_spec, x, ..., schema = NULL) { storage_schema <- schema storage_schema$metadata[["ARROW:extension:name"]] <- NULL storage_schema$metadata[["ARROW:extension:metadata"]] <- NULL storage_array <- as_nanoarrow_array( vctrs::vec_data(x), schema = storage_schema ) nanoarrow_extension_array( storage_array, "arrow.r.vctrs", schema$metadata[["ARROW:extension:metadata"]] ) } # The logic for serializing and deserializing prototypes is a subset of # the implementation in jsonlite. Unlike jsonlite, we don't need to handle # arbitrary attributes because vector prototypes typically do not contain # complex information like expression/language objects and environments. serialize_ptype <- function(x) { type <- typeof(x) type_serialized <- sprintf('"type":"%s"', type) attrs <- attributes(x) attributes(x) <- NULL if (!is.null(attrs)) { attr_names_serialized <- paste0('"', gsub('"', '\\"', names(attrs)), '"') attr_values_serialized <- lapply(unname(attrs), serialize_ptype) attrs_serialized <- sprintf( '"attributes":{%s}', paste0(attr_names_serialized, ":", attr_values_serialized, collapse = ",") ) } else { attrs_serialized <- NULL } if (identical(type, "NULL")) { values_serialized <- NULL } else if (identical(type, "raw")) { values_serialized <- sprintf('"value":"%s"', jsonlite::base64_enc(x)) } else if(length(x) == 0) { values_serialized <- '"value":[]' } else { values <- switch( type, character = paste0('"', gsub('"', '\\"', x), '"'), complex = paste0('"', format(x, digits = 16, justify = "none", na.encode = FALSE), '"'), logical = tolower(as.character(x)), integer = , double = format(x, digits = 16, justify = "none", na.encode = FALSE), list = lapply(x, serialize_ptype), stop(sprintf("storage '%s' is not supported by serialize_ptype", type)) ) values[is.na(x)] <- "null" values_serialized <- sprintf( '"value":[%s]', paste(values, collapse = ",") ) } sprintf( "{%s}", paste( c(type_serialized, attrs_serialized, values_serialized), collapse = "," ) ) } unserialize_ptype <- function(x) { if (is.raw(x)) { x <- rawToChar(x) } unserialize_ptype_impl(jsonlite::fromJSON(x, simplifyVector = FALSE)) } unserialize_ptype_impl <- function(x) { if (identical(x$type, "NULL")) { return(NULL) } else if(identical(x$type, "raw")) { return(jsonlite::base64_dec(x$value)) } sanitizer <- switch( x$type, raw = as.raw, complex = as.complex, character = as.character, logical = as.logical, integer = as.integer, double = as.double, list = function(x) list(unserialize_ptype_impl(x)), stop(sprintf("storage '%s' is not supported by unserialize_ptype", x$type)) ) na <- vector(x$type)[1] x$value[vapply(x$value, is.null, logical(1))] <- na x$value[vapply(x$value, identical, logical(1), "NA")] <- na out <- vapply(x$value, sanitizer, na) if (!is.null(x$attributes)) { attributes(out) <- lapply(x$attributes, unserialize_ptype_impl) } out } nanoarrow/R/type.R0000644000176200001440000003307114676554240013606 0ustar liggesusers# 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. #' Create type objects #' #' In nanoarrow, types, fields, and schemas are all represented by a #' [nanoarrow_schema][as_nanoarrow_schema]. These functions are convenience #' constructors to create these objects in a readable way. Use [na_type()] to #' construct types based on the constructor name, which is also the name that #' prints/is returned by [nanoarrow_schema_parse()]. #' #' @param type_name The name of the type (e.g., "int32"). This form of the #' constructor is useful for writing tests that loop over many types. #' @param byte_width For [na_fixed_size_binary()], the number of bytes #' occupied by each item. #' @param list_size The number of elements in each item in a #' [na_fixed_size_list()]. #' @param precision The total number of digits representable by the decimal type #' @param scale The number of digits after the decimal point in a decimal type #' @param unit One of 's' (seconds), 'ms' (milliseconds), 'us' (microseconds), #' or 'ns' (nanoseconds). #' @param timezone A string representing a timezone name. The empty string "" #' represents a naive point in time (i.e., one that has no associated #' timezone). #' @param column_types A `list()` of [nanoarrow_schema][as_nanoarrow_schema]s. #' @param item_type For [na_list()], [na_large_list()], [na_fixed_size_list()], #' and [na_map()], the [nanoarrow_schema][as_nanoarrow_schema] representing #' the item type. #' @param key_type The [nanoarrow_schema][as_nanoarrow_schema] representing the #' [na_map()] key type. #' @param index_type The [nanoarrow_schema][as_nanoarrow_schema] representing the #' [na_dictionary()] index type. #' @param value_type The [nanoarrow_schema][as_nanoarrow_schema] representing the #' [na_dictionary()] or [na_map()] value type. #' @param keys_sorted Use `TRUE` to assert that keys are sorted. #' @param storage_type For [na_extension()], the underlying value type. #' @param extension_name For [na_extension()], the extension name. This is #' typically namespaced separated by dots (e.g., arrow.r.vctrs). #' @param extension_metadata A string or raw vector defining extension metadata. #' Most Arrow extension types define extension metadata as a JSON object. #' @param nullable Use `FALSE` to assert that this field cannot contain #' null values. #' @param ordered Use `TRUE` to assert that the order of values in the #' dictionary are meaningful. #' #' @return A [nanoarrow_schema][as_nanoarrow_schema] #' @export #' #' @examples #' na_int32() #' na_struct(list(col1 = na_int32())) #' na_type <- function(type_name, byte_width = NULL, unit = NULL, timezone = NULL, column_types = NULL, item_type = NULL, key_type = NULL, value_type = NULL, index_type = NULL, ordered = NULL, list_size = NULL, keys_sorted = NULL, storage_type = NULL, extension_name = NULL, extension_metadata = NULL, nullable = NULL) { # Create a call and evaluate it. This leads to reasonable error messages # regarding nonexistent type names and extraneous or missing parameters. args <- list( byte_width = byte_width, unit = unit, timezone = timezone, column_types = column_types, item_type = item_type, key_type = key_type, value_type = value_type, index_type = index_type, ordered = ordered, list_size = list_size, keys_sorted = keys_sorted, storage_type = storage_type, extension_name = extension_name, extension_metadata = extension_metadata, nullable = nullable ) args <- args[!vapply(args, is.null, logical(1))] constructor <- as.symbol(paste0("na_", type_name)) call_obj <- as.call(c(list(constructor), args)) eval(call_obj) } #' @rdname na_type #' @export na_na <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE[["NA"]], isTRUE(nullable)) } #' @rdname na_type #' @export na_bool <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$BOOL, isTRUE(nullable)) } #' @rdname na_type #' @export na_int8 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$INT8, isTRUE(nullable)) } #' @rdname na_type #' @export na_uint8 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$UINT8, isTRUE(nullable)) } #' @rdname na_type #' @export na_int16 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$INT16, isTRUE(nullable)) } #' @rdname na_type #' @export na_uint16 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$UINT16, isTRUE(nullable)) } #' @rdname na_type #' @export na_int32 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$INT32, isTRUE(nullable)) } #' @rdname na_type #' @export na_uint32 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$UINT32, isTRUE(nullable)) } #' @rdname na_type #' @export na_int64 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$INT64, isTRUE(nullable)) } #' @rdname na_type #' @export na_uint64 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$UINT64, isTRUE(nullable)) } #' @rdname na_type #' @export na_half_float <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$HALF_FLOAT, isTRUE(nullable)) } #' @rdname na_type #' @export na_float <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$FLOAT, isTRUE(nullable)) } #' @rdname na_type #' @export na_double <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$DOUBLE, isTRUE(nullable)) } #' @rdname na_type #' @export na_string <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$STRING, isTRUE(nullable)) } #' @rdname na_type #' @export na_large_string <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$LARGE_STRING, isTRUE(nullable)) } #' @rdname na_type #' @export na_string_view <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$STRING_VIEW, isTRUE(nullable)) } #' @rdname na_type #' @export na_binary <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$BINARY, isTRUE(nullable)) } #' @rdname na_type #' @export na_large_binary <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$LARGE_BINARY, isTRUE(nullable)) } #' @rdname na_type #' @export na_fixed_size_binary <- function(byte_width, nullable = TRUE) { .Call( nanoarrow_c_schema_init_fixed_size, NANOARROW_TYPE$FIXED_SIZE_BINARY, as.integer(byte_width)[1], isTRUE(nullable) ) } #' @rdname na_type #' @export na_binary_view <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$BINARY_VIEW, isTRUE(nullable)) } #' @rdname na_type #' @export na_date32 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$DATE32, isTRUE(nullable)) } #' @rdname na_type #' @export na_date64 <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$DATE64, isTRUE(nullable)) } #' @rdname na_type #' @export na_time32 <- function(unit = c("ms", "s"), nullable = TRUE) { unit <- match.arg(unit) .Call( nanoarrow_c_schema_init_date_time, NANOARROW_TYPE$TIME32, time_unit_id(unit), NULL, isTRUE(nullable) ) } #' @rdname na_type #' @export na_time64 <- function(unit = c("us", "ns"), nullable = TRUE) { unit <- match.arg(unit) .Call( nanoarrow_c_schema_init_date_time, NANOARROW_TYPE$TIME64, time_unit_id(unit), NULL, isTRUE(nullable) ) } #' @rdname na_type #' @export na_duration <- function(unit = c("ms", "s", "us", "ns"), nullable = TRUE) { unit <- match.arg(unit) .Call( nanoarrow_c_schema_init_date_time, NANOARROW_TYPE$DURATION, time_unit_id(unit), NULL, isTRUE(nullable) ) } #' @rdname na_type #' @export na_interval_months <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$INTERVAL_MONTHS, isTRUE(nullable)) } #' @rdname na_type #' @export na_interval_day_time <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$INTERVAL_DAY_TIME, isTRUE(nullable)) } #' @rdname na_type #' @export na_interval_month_day_nano <- function(nullable = TRUE) { .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$INTERVAL_MONTH_DAY_NANO, isTRUE(nullable)) } #' @rdname na_type #' @export na_timestamp <- function(unit = c("us", "ns", "s", "ms"), timezone = "", nullable = TRUE) { unit <- match.arg(unit) if (!is.character(timezone) || length(timezone) != 1 || is.na(timezone)) { stop("`timezone` must be character(1)") } .Call( nanoarrow_c_schema_init_date_time, NANOARROW_TYPE$TIMESTAMP, time_unit_id(unit), timezone, isTRUE(nullable) ) } #' @rdname na_type #' @export na_decimal128 <- function(precision, scale, nullable = TRUE) { .Call( nanoarrow_c_schema_init_decimal, NANOARROW_TYPE$DECIMAL128, as.integer(precision)[1], as.integer(scale)[1], isTRUE(nullable) ) } #' @rdname na_type #' @export na_decimal256 <- function(precision, scale, nullable = TRUE) { .Call( nanoarrow_c_schema_init_decimal, NANOARROW_TYPE$DECIMAL256, as.integer(precision)[1], as.integer(scale)[1], isTRUE(nullable) ) } #' @rdname na_type #' @export na_struct <- function(column_types = list(), nullable = FALSE) { schema <- .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$STRUCT, isTRUE(nullable)) schema$children <- column_types schema } #' @rdname na_type #' @export na_sparse_union <- function(column_types = list()) { schema <- na_struct(column_types) schema$format <- paste0("+us:", paste(seq_along(schema$children) - 1L, collapse = ",")) schema } #' @rdname na_type #' @export na_dense_union <- function(column_types = list()) { schema <- na_struct(column_types) schema$format <- paste0("+ud:", paste(seq_along(schema$children) - 1L, collapse = ",")) schema } #' @rdname na_type #' @export na_list <- function(item_type, nullable = TRUE) { schema <- .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$LIST, isTRUE(nullable)) schema$children[[1]] <- item_type schema } #' @rdname na_type #' @export na_large_list <- function(item_type, nullable = TRUE) { schema <- .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$LARGE_LIST, isTRUE(nullable)) schema$children[[1]] <- item_type schema } #' @rdname na_type #' @export na_fixed_size_list <- function(item_type, list_size, nullable = TRUE) { schema <- .Call( nanoarrow_c_schema_init_fixed_size, NANOARROW_TYPE$FIXED_SIZE_LIST, as.integer(list_size)[1], isTRUE(nullable) ) schema$children[[1]] <- item_type schema } #' @rdname na_type #' @export na_map <- function(key_type, item_type, keys_sorted = FALSE, nullable = TRUE) { schema <- .Call(nanoarrow_c_schema_init, NANOARROW_TYPE$MAP, isTRUE(nullable)) schema$children[[1]]$children[[1]] <- key_type schema$children[[1]]$children[[2]] <- item_type schema } #' @rdname na_type #' @export na_dictionary <- function(value_type, index_type = na_int32(), ordered = FALSE) { index_type <- as_nanoarrow_schema(index_type) index_type$dictionary <- value_type if (ordered) { index_type$flags <- bitwOr(index_type$flags, ARROW_FLAG$DICTIONARY_ORDERED) } else { index_type$flags <- bitwAnd( index_type$flags, bitwNot(ARROW_FLAG$DICTIONARY_ORDERED) ) } index_type } #' @rdname na_type #' @export na_extension <- function(storage_type, extension_name, extension_metadata = "") { storage_type <- as_nanoarrow_schema(storage_type) new_metadata <- list( "ARROW:extension:name" = extension_name, "ARROW:extension:metadata" = extension_metadata ) new_metadata <- c(new_metadata, storage_type$metadata) storage_type$metadata <- new_metadata[unique(names(new_metadata))] storage_type } time_unit_id <- function(time_unit) { match(time_unit, c("s", "ms", "us", "ns")) - 1L } # These values aren't guaranteed to stay stable between nanoarrow versions, # so we keep them internal but use them in these functions to simplify the # number of C functions we need to build all the types. NANOARROW_TYPE <- list( UNINITIALIZED = 0, "NA" = 1L, BOOL = 2L, UINT8 = 3L, INT8 = 4L, UINT16 = 5L, INT16 = 6L, UINT32 = 7L, INT32 = 8L, UINT64 = 9L, INT64 = 10L, HALF_FLOAT = 11L, FLOAT = 12L, DOUBLE = 13L, STRING = 14L, BINARY = 15L, FIXED_SIZE_BINARY = 16L, DATE32 = 17L, DATE64 = 18L, TIMESTAMP = 19L, TIME32 = 20L, TIME64 = 21L, INTERVAL_MONTHS = 22L, INTERVAL_DAY_TIME = 23L, DECIMAL128 = 24L, DECIMAL256 = 25L, LIST = 26L, STRUCT = 27L, SPARSE_UNION = 28L, DENSE_UNION = 29L, DICTIONARY = 30L, MAP = 31L, EXTENSION = 32L, FIXED_SIZE_LIST = 33L, DURATION = 34L, LARGE_STRING = 35L, LARGE_BINARY = 36L, LARGE_LIST = 37L, INTERVAL_MONTH_DAY_NANO = 38L, RUN_END_ENCODED = 39L, BINARY_VIEW = 40L, STRING_VIEW = 41L ) ARROW_FLAG <- list( DICTIONARY_ORDERED = 1L, NULLABLE = 2L, MAP_KEYS_SORTED = 4L ) nanoarrow/R/convert-array.R0000644000176200001440000002240514674150567015422 0ustar liggesusers# 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. #' Convert an Array into an R vector #' #' Converts `array` to the type specified by `to`. This is a low-level interface; #' most users should use `as.data.frame()` or `as.vector()` unless finer-grained #' control is needed over the conversion. This function is an S3 generic #' dispatching on `to`: developers may implement their own S3 methods for #' custom vector types. #' #' Note that unregistered extension types will by default issue a warning. #' Use `options(nanoarrow.warn_unregistered_extension = FALSE)` to disable #' this behaviour. #' #' @param array A [nanoarrow_array][as_nanoarrow_array]. #' @param to A target prototype object describing the type to which `array` #' should be converted, or `NULL` to use the default conversion as #' returned by [infer_nanoarrow_ptype()]. Alternatively, a function can be #' passed to perform an alternative calculation of the default ptype as #' a function of `array` and the default inference of the prototype. #' @param ... Passed to S3 methods #' #' @return An R vector of type `to`. #' @export #' #' @details #' Conversions are implemented for the following R vector types: #' #' - [logical()]: Any numeric type can be converted to [logical()] in addition #' to the bool type. For numeric types, any non-zero value is considered `TRUE`. #' - [integer()]: Any numeric type can be converted to [integer()]; however, #' a warning will be signaled if the any value is outside the range of the #' 32-bit integer. #' - [double()]: Any numeric type can be converted to [double()]. This #' conversion currently does not warn for values that may not roundtrip #' through a floating-point double (e.g., very large uint64 and int64 values). #' - [character()]: String and large string types can be converted to #' [character()]. The conversion does not check for valid UTF-8: if you need #' finer-grained control over encodings, use `to = blob::blob()`. #' - [factor()]: Dictionary-encoded arrays of strings can be converted to #' `factor()`; however, this must be specified explicitly (i.e., #' `convert_array(array, factor())`) because arrays arriving #' in chunks can have dictionaries that contain different levels. Use #' `convert_array(array, factor(levels = c(...)))` to materialize an array #' into a vector with known levels. #' - [Date][as.Date()]: Only the date32 type can be converted to an R Date vector. #' - [hms::hms()]: Time32 and time64 types can be converted to [hms::hms()]. #' - [difftime()]: Time32, time64, and duration types can be converted to #' R [difftime()] vectors. The value is converted to match the [units()] #' attribute of `to`. #' - [blob::blob()]: String, large string, binary, and large binary types can #' be converted to [blob::blob()]. #' - [vctrs::list_of()]: List, large list, and fixed-size list types can be #' converted to [vctrs::list_of()]. #' - [data.frame()]: Struct types can be converted to [data.frame()]. #' - [vctrs::unspecified()]: Any type can be converted to [vctrs::unspecified()]; #' however, a warning will be raised if any non-null values are encountered. #' #' In addition to the above conversions, a null array may be converted to any #' target prototype except [data.frame()]. Extension arrays are currently #' converted as their storage type. #' #' @examples #' array <- as_nanoarrow_array(data.frame(x = 1:5)) #' str(convert_array(array)) #' str(convert_array(array, to = data.frame(x = double()))) #' convert_array <- function(array, to = NULL, ...) { stopifnot(inherits(array, "nanoarrow_array")) UseMethod("convert_array", to) } #' @export convert_array.default <- function(array, to = NULL, ..., .from_c = FALSE) { if (.from_c) { # Handle extension conversion # We don't need the user-friendly versions and this is performance-sensitive schema <- .Call(nanoarrow_c_infer_schema_array, array) parsed <- .Call(nanoarrow_c_schema_parse, schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(convert_array_extension(spec, array, to, ...)) } # Handle default dictionary conversion since it's the same for all types dictionary <- array$dictionary if (!is.null(dictionary)) { values <- .Call(nanoarrow_c_convert_array, dictionary, to) array$dictionary <- NULL indices <- .Call(nanoarrow_c_convert_array, array, integer()) return(vec_slice2(values, indices + 1L)) } stop_cant_convert_array(array, to) } if (is.function(to)) { to <- to(array, infer_nanoarrow_ptype(array)) } .Call(nanoarrow_c_convert_array, array, to) } # This is defined because it's verbose to pass named arguments from C. # When converting data frame columns, we try the internal C conversions # first to save R evaluation overhead. When the internal conversions fail, # we call convert_array() to dispatch to conversions defined via S3 # dispatch, making sure to let the default method know that we've already # tried the internal C conversions. convert_fallback_other <- function(array, offset, length, to) { # If we need to modify offset/length, do it using a shallow copy. if (!is.null(offset)) { array <- nanoarrow_array_modify( array, list(offset = offset, length = length), validate = FALSE ) } # Call convert_array() on a single chunk. Use .from_c = TRUE to ensure that # methods do not attempt to pass the same array back to the C conversions. # When the result is passed back to C it is checked enough to avoid segfault # but not necessarily for correctness (e.g., factors with levels that don't # correspond to 'to'). This result may be used as-is or may be copied into # a slice of another vector. convert_array(array, to, .from_c = TRUE) } #' @export convert_array.nanoarrow_vctr <- function(array, to, ...) { schema <- attr(to, "schema", exact = TRUE) if (is.null(schema)) { schema <- infer_nanoarrow_schema(array) } new_nanoarrow_vctr(list(array), schema, class(to)) } #' @export convert_array.double <- function(array, to, ...) { # Handle conversion from decimal128 via arrow schema <- infer_nanoarrow_schema(array) parsed <- nanoarrow_schema_parse(schema) if (parsed$type == "decimal128") { assert_arrow_installed( sprintf( "convert %s array to object of type double", nanoarrow_schema_formatted(schema) ) ) arrow_array <- as_arrow_array.nanoarrow_array(array) arrow_array$as_vector() } else { NextMethod() } } #' @export convert_array.vctrs_partial_frame <- function(array, to, ...) { ptype <- infer_nanoarrow_ptype(array) if (!is.data.frame(ptype)) { stop_cant_convert_array(array, to) } ptype <- vctrs::vec_ptype_common(ptype, to) .Call(nanoarrow_c_convert_array, array, ptype) } #' @export convert_array.factor <- function(array, to, ...) { if (!is.null(array$dictionary)) { levels_final <- levels(to) levels <- convert_array(array$dictionary, character()) array$dictionary <- NULL indices <- convert_array(array, integer()) + 1L # Handle empty factor() as the sentinel for "auto levels" if (identical(levels(to), character())) { levels(to) <- levels } if (identical(levels, levels(to))) { fct_data <- indices } else if (all(levels %in% levels(to))) { level_map <- match(levels, levels(to)) fct_data <- level_map[indices] } else { stop("Error converting to factor: some levels in data do not exist in levels") } } else { strings <- convert_array(array, character()) # Handle empty factor() as the sentinel for "auto levels" if (identical(levels(to), character())) { fct_data <- factor(strings, levels) levels(to) <- levels(fct_data) } else { fct_data <- factor(strings, levels = levels(to)) } } # Restore other attributes (e.g., ordered, labels) attributes(fct_data) <- attributes(to) fct_data } stop_cant_convert_array <- function(array, to, n = 0) { stop_cant_convert_schema(infer_nanoarrow_schema(array), to, n - 1) } stop_cant_convert_schema <- function(schema, to, n = 0) { schema_label <- nanoarrow_schema_formatted(schema) if (is.null(schema$name) || identical(schema$name, "")) { cnd <- simpleError( sprintf( "Can't convert array <%s> to R vector of type %s", schema_label, class(to)[1] ), call = sys.call(n - 1) ) } else { cnd <- simpleError( sprintf( "Can't convert `%s` <%s> to R vector of type %s", schema$name, schema_label, class(to)[1] ), call = sys.call(n - 1) ) } stop(cnd) } nanoarrow/R/altrep.R0000644000176200001440000000232114377444470014107 0ustar liggesusers# 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. # For testing the altrep chr conversion nanoarrow_altrep_chr <- function(array) { .Call(nanoarrow_c_make_altrep_chr, array) } is_nanoarrow_altrep <- function(x) { .Call(nanoarrow_c_is_altrep, x) } nanoarrow_altrep_force_materialize <- function(x, recursive = FALSE) { invisible(.Call(nanoarrow_c_altrep_force_materialize, x, recursive)) } is_nanoarrow_altrep_materialized <- function(x) { .Call(nanoarrow_c_altrep_is_materialized, x) } nanoarrow/R/infer-ptype.R0000644000176200001440000001257514676554240015075 0ustar liggesusers# 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. #' Infer an R vector prototype #' #' Resolves the default `to` value to use in [convert_array()] and #' [convert_array_stream()]. The default conversions are: #' #' - null to [vctrs::unspecified()] #' - boolean to [logical()] #' - int8, uint8, int16, uint16, and int13 to [integer()] #' - uint32, int64, uint64, float, and double to [double()] #' - string and large string to [character()] #' - struct to [data.frame()] #' - binary and large binary to [blob::blob()] #' - list, large_list, and fixed_size_list to [vctrs::list_of()] #' - time32 and time64 to [hms::hms()] #' - duration to [difftime()] #' - date32 to [as.Date()] #' - timestamp to [as.POSIXct()] #' #' Additional conversions are possible by specifying an explicit value for #' `to`. For details of each conversion, see [convert_array()]. #' #' @param x A [nanoarrow_schema][as_nanoarrow_schema], #' [nanoarrow_array][as_nanoarrow_array], or #' [nanoarrow_array_stream][as_nanoarrow_array_stream]. #' #' @return An R vector of zero size describing the target into which #' the array should be materialized. #' @export #' #' @examples #' infer_nanoarrow_ptype(as_nanoarrow_array(1:10)) #' infer_nanoarrow_ptype <- function(x) { if (inherits(x, "nanoarrow_array")) { x <- .Call(nanoarrow_c_infer_schema_array, x) } else if (inherits(x, "nanoarrow_array_stream")) { x <- .Call(nanoarrow_c_array_stream_get_schema, x) } else if (!inherits(x, "nanoarrow_schema")) { stop("`x` must be a nanoarrow_schema(), nanoarrow_array(), or nanoarrow_array_stream()") } .Call(nanoarrow_c_infer_ptype, x) } # This is called from C from nanoarrow_c_infer_ptype when all the C conversions # have been tried. Some of these inferences could be moved to C to be faster # (but are much less verbose to create here) infer_ptype_other <- function(schema) { # We don't need the user-friendly versions and this is performance-sensitive parsed <- .Call(nanoarrow_c_schema_parse, schema) # Give registered extension types a chance to resolve the ptype if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(infer_nanoarrow_ptype_extension(spec, schema)) } switch( parsed$type, "na" = vctrs::unspecified(), "binary" = , "large_binary" = , "binary_view" = new_blob_internal(), "date32" = structure(numeric(), class = "Date"), "time32" = , "time64" = hms::hms(), "duration" = structure(numeric(), class = "difftime", units = "secs"), "date64" = , "timestamp" = { if (is.null(parsed$timezone) || parsed$timezone == "") { # We almost never want to assume the user's timezone here, which is # what would happen if we passed on "". This is consistent with how # readr handles reading timezones (assign "UTC" since it's DST-free # and let the user explicitly set this later) parsed$timezone <- getOption("nanoarrow.timezone_if_unspecified", "UTC") } structure( numeric(0), class = c("POSIXct", "POSIXt"), tzone = parsed$timezone ) }, "map" = , "large_list" = , "list" = , "fixed_size_list" = { ptype <- infer_nanoarrow_ptype(schema$children[[1]]) vctrs::list_of(.ptype = ptype) }, "dictionary" = { # Even though R's 'factor' can handle a dictionary of strings # (perhaps the most common case), an array arriving in chunks may have # different dictionary arrays. Thus, the best type-stable default we can # achieve is to expand dictionaries. infer_nanoarrow_ptype(schema$dictionary) }, stop_cant_infer_ptype(schema, n = -1) ) } stop_cant_infer_ptype <- function(schema, n = 0) { schema_label <- nanoarrow_schema_formatted(schema) if (is.null(schema$name) || identical(schema$name, "")) { cnd <- simpleError( sprintf( "Can't infer R vector type for <%s>", schema_label ), call = sys.call(n - 1) ) } else { cnd <- simpleError( sprintf( "Can't infer R vector type for `%s` <%s>", schema$name, schema_label ), call = sys.call(n - 1) ) } stop(cnd) } # Try to load the blob namespace. If it fails, we still return the correct # ptype object. This is not ideal because the behaviour of the output object # may be slightly different if blob isn't installed; however, we use this # conversion for printing buffers and it's difficult to work around with the # current system for conversion. new_blob_internal <- function() { requireNamespace("blob", quietly = TRUE) structure( list(), ptype = raw(0), class = c("blob", "vctrs_list_of", "vctrs_vctr", "list") ) } nanoarrow/R/array-stream.R0000644000176200001440000002116314547575511015234 0ustar liggesusers# 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. #' Create ArrayStreams from batches #' #' @param batches A [list()] of [nanoarrow_array][as_nanoarrow_array] objects #' or objects that can be coerced via [as_nanoarrow_array()]. #' @param schema A [nanoarrow_schema][as_nanoarrow_schema] or `NULL` to guess #' based on the first schema. #' @param validate Use `FALSE` to skip the validation step (i.e., if you #' know that the arrays are valid). #' #' @return An [nanoarrow_array_stream][as_nanoarrow_array_stream] #' @export #' #' @examples #' (stream <- basic_array_stream(list(data.frame(a = 1, b = 2)))) #' as.data.frame(stream$get_next()) #' stream$get_next() #' basic_array_stream <- function(batches, schema = NULL, validate = TRUE) { # Error for everything except a bare list (e.g., so that calling with # a data.frame() does not unintentionally loop over columns) if (!identical(class(batches), "list")) { stop("`batches` must be an unclassed `list()`") } batches <- lapply(batches, as_nanoarrow_array, schema = schema) if (is.null(schema) && length(batches) > 0) { schema <- infer_nanoarrow_schema(batches[[1]]) } else if (is.null(schema)) { stop("Can't infer schema from first batch if there are zero batches") } .Call(nanoarrow_c_basic_array_stream, batches, schema, validate) } #' Register an array stream finalizer #' #' In some cases, R functions that return a [nanoarrow_array_stream][as_nanoarrow_array_stream] #' may require that the scope of some other object outlive that of the array #' stream. If there is a need for that object to be released deterministically #' (e.g., to close open files), you can register a function to run after the #' stream's release callback is invoked from the R thread. Note that this #' finalizer will **not** be run if the stream's release callback is invoked #' from a **non**-R thread. In this case, the finalizer and its chain of #' environments will be garbage-collected when `nanoarrow:::preserved_empty()` #' is run. #' #' @param array_stream A [nanoarrow_array_stream][as_nanoarrow_array_stream] #' @param finalizer A function that will be called with zero arguments. #' #' @return A newly allocated `array_stream` whose release callback will call #' the supplied finalizer. #' @export #' #' @examples #' stream <- array_stream_set_finalizer( #' basic_array_stream(list(1:5)), #' function() message("All done!") #' ) #' stream$release() #' array_stream_set_finalizer <- function(array_stream, finalizer) { stopifnot(is.function(finalizer)) prot <- new.env(parent = emptyenv()) prot$array_stream_finalizer <- finalizer class(prot) <- "nanoarrow_array_stream_finalizer" nanoarrow_pointer_set_protected(array_stream, prot) out <- nanoarrow_allocate_array_stream() nanoarrow_pointer_export(array_stream, out) out } #' Convert an object to a nanoarrow array_stream #' #' In nanoarrow, an 'array stream' corresponds to the `struct ArrowArrayStream` #' as defined in the Arrow C Stream interface. This object is used to represent #' a stream of [arrays][as_nanoarrow_array] with a common #' [schema][as_nanoarrow_schema]. This is similar to an #' [arrow::RecordBatchReader] except it can be used to represent a stream of #' any type (not just record batches). Note that a stream of record batches #' and a stream of non-nullable struct arrays are represented identically. #' Also note that array streams are mutable objects and are passed by #' reference and not by value. #' #' @param x An object to convert to a array_stream #' @param ... Passed to S3 methods #' @inheritParams as_nanoarrow_array #' #' @return An object of class 'nanoarrow_array_stream' #' @export #' #' @examples #' (stream <- as_nanoarrow_array_stream(data.frame(x = 1:5))) #' stream$get_schema() #' stream$get_next() #' #' # The last batch is returned as NULL #' stream$get_next() #' #' # Release the stream #' stream$release() #' as_nanoarrow_array_stream <- function(x, ..., schema = NULL) { UseMethod("as_nanoarrow_array_stream") } #' @export as_nanoarrow_array_stream.nanoarrow_array_stream <- function(x, ..., schema = NULL) { if (is.null(schema)) { return(x) } inferred_schema <- infer_nanoarrow_schema(x) if (nanoarrow_schema_identical(schema, inferred_schema)) { return(x) } NextMethod() } #' @export as_nanoarrow_array_stream.nanoarrow_array <- function(x, ..., schema = NULL) { if (is.null(schema)) { return(basic_array_stream(list(x), validate = FALSE)) } inferred_schema <- infer_nanoarrow_schema(x) if (nanoarrow_schema_identical(schema, inferred_schema)) { return(basic_array_stream(list(x), validate = FALSE)) } as_nanoarrow_array_stream( as_nanoarrow_array_stream(x), schema = schema ) } #' @export as_nanoarrow_array_stream.default <- function(x, ..., schema = NULL) { assert_arrow_installed("default coerce to nanoarrow_array_stream") as_nanoarrow_array_stream( arrow::as_record_batch_reader(x, ..., schema = arrow::as_schema(schema)), schema = schema ) } #' @export as_nanoarrow_array_stream.data.frame <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } else { schema <- as_nanoarrow_schema(schema) } x <- as_nanoarrow_array(x, schema = schema) basic_array_stream(list(x), schema = schema) } #' @export infer_nanoarrow_schema.nanoarrow_array_stream <- function(x, ...) { x$get_schema() } #' @export as.data.frame.nanoarrow_array_stream <- function(x, ...) { # Always release the input: we are always consuming the entire stream. # For more fine-grained behaviour on error, one can use # convert_array_stream() on.exit(x$release()) to <- infer_nanoarrow_ptype(x$get_schema()) if (!inherits(to, "data.frame")) { stop("Can't convert non-struct array stream to data.frame") } convert_array_stream(x, to) } #' @export as.vector.nanoarrow_array_stream <- function(x, mode) { on.exit(x$release()) convert_array_stream(x) } #' @importFrom utils str #' @export str.nanoarrow_array_stream <- function(object, ...) { cat(sprintf("%s\n", format(object))) if (nanoarrow_pointer_is_valid(object)) { # Use the str() of the list version but remove the first # line of the output ("List of 2") info <- list( get_schema = object$get_schema, get_next = object$get_next, release = object$release ) raw_str_output <- utils::capture.output(str(info, ..., give.attr = FALSE)) cat(paste0(raw_str_output[-1], collapse = "\n")) cat("\n") } invisible(object) } #' @export print.nanoarrow_array_stream <- function(x, ...) { str(x, ...) invisible(x) } #' @export format.nanoarrow_array_stream <- function(x, ...) { if (nanoarrow_pointer_is_valid(x)) { tryCatch( sprintf("", nanoarrow_schema_formatted(x$get_schema())), error = function(...) "" ) } else { "" } } # This is the list()-like interface to nanoarrow_array_stream that allows $ and [[ # to make nice auto-complete when interacting in an IDE #' @export length.nanoarrow_array_stream <- function(x, ...) { 3L } #' @export names.nanoarrow_array_stream <- function(x, ...) { c("get_schema", "get_next", "release") } #' @export `[[.nanoarrow_array_stream` <- function(x, i, ...) { force(x) if (identical(i, "get_schema") || isTRUE(i == 1L)) { function() .Call(nanoarrow_c_array_stream_get_schema, x) } else if (identical(i, "get_next") || isTRUE(i == 2L)) { function(schema = x$get_schema(), validate = TRUE) { array <- .Call(nanoarrow_c_array_stream_get_next, x) if (!nanoarrow_pointer_is_valid(array)) { return(NULL) } nanoarrow_array_set_schema(array, schema, validate = validate) array } } else if (identical(i, "release") || isTRUE(i == 3L)) { function() nanoarrow_pointer_release(x) } else { NULL } } #' @export `$.nanoarrow_array_stream` <- function(x, i, ...) { x[[i]] } nanoarrow/R/zzz.R0000644000176200001440000000643714547061553013465 0ustar liggesusers# 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. # nocov start .onLoad <- function(...) { register_vctrs_extension() s3_register("arrow::infer_type", "nanoarrow_array") s3_register("arrow::as_data_type", "nanoarrow_schema") s3_register("arrow::as_schema", "nanoarrow_schema") s3_register("arrow::as_arrow_array", "nanoarrow_array") s3_register("arrow::as_arrow_array", "nanoarrow_array_stream") s3_register("arrow::as_chunked_array", "nanoarrow_array") s3_register("arrow::as_chunked_array", "nanoarrow_array_stream") s3_register("arrow::as_record_batch", "nanoarrow_array") s3_register("arrow::as_arrow_table", "nanoarrow_array") s3_register("arrow::as_arrow_table", "nanoarrow_array_stream") s3_register("arrow::as_record_batch_reader", "nanoarrow_array_stream") s3_register("tibble::as_tibble", "nanoarrow_array") } # From the `vctrs` package (this function is intended to be copied # without attribution or license requirements to avoid a hard dependency on # vctrs: # https://github.com/r-lib/vctrs/blob/c2a7710fe55e3a2249c4fdfe75bbccbafcf38804/R/register-s3.R#L25-L31 s3_register <- function(generic, class, method = NULL) { stopifnot(is.character(generic), length(generic) == 1) stopifnot(is.character(class), length(class) == 1) pieces <- strsplit(generic, "::")[[1]] stopifnot(length(pieces) == 2) package <- pieces[[1]] generic <- pieces[[2]] caller <- parent.frame() get_method_env <- function() { top <- topenv(caller) if (isNamespace(top)) { asNamespace(environmentName(top)) } else { caller } } get_method <- function(method, env) { if (is.null(method)) { get(paste0(generic, ".", class), envir = get_method_env()) } else { method } } register <- function(...) { envir <- asNamespace(package) # Refresh the method each time, it might have been updated by # `devtools::load_all()` method_fn <- get_method(method) stopifnot(is.function(method_fn)) # Only register if generic can be accessed if (exists(generic, envir)) { registerS3method(generic, class, method_fn, envir = envir) } else if (identical(Sys.getenv("NOT_CRAN"), "true")) { warning(sprintf( "Can't find generic `%s` in package %s to register S3 method.", generic, package )) } } # Always register hook in case package is later unloaded & reloaded setHook(packageEvent(package, "onLoad"), register) # Avoid registration failures during loading (pkgload or regular) if (isNamespaceLoaded(package)) { register() } invisible() } # nocov end nanoarrow/R/schema.R0000644000176200001440000002352414547061553014064 0ustar liggesusers# 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. #' Convert an object to a nanoarrow schema #' #' In nanoarrow a 'schema' refers to a `struct ArrowSchema` as defined in the #' Arrow C Data interface. This data structure can be used to represent an #' [arrow::schema()], an [arrow::field()], or an `arrow::DataType`. Note that #' in nanoarrow, an [arrow::schema()] and a non-nullable [arrow::struct()] #' are represented identically. #' #' @param x An object to convert to a schema #' @param recursive Use `TRUE` to include a `children` member when parsing #' schemas. #' @param new_values New schema component to assign #' @param validate Use `FALSE` to skip schema validation #' @param ... Passed to S3 methods #' #' @return An object of class 'nanoarrow_schema' #' @export #' #' @examples #' infer_nanoarrow_schema(integer()) #' infer_nanoarrow_schema(data.frame(x = integer())) #' as_nanoarrow_schema <- function(x, ...) { UseMethod("as_nanoarrow_schema") } #' @export as_nanoarrow_schema.nanoarrow_schema <- function(x, ...) { x } #' @rdname as_nanoarrow_schema #' @export infer_nanoarrow_schema <- function(x, ...) { UseMethod("infer_nanoarrow_schema") } #' @export infer_nanoarrow_schema.default <- function(x, ...) { cls <- paste(class(x), collapse = "/") stop(sprintf("Can't infer Arrow type for object of class %s", cls)) } #' @export infer_nanoarrow_schema.raw <- function(x, ...) { na_uint8() } #' @export infer_nanoarrow_schema.logical <- function(x, ...) { na_bool() } #' @export infer_nanoarrow_schema.integer <- function(x, ...) { na_int32() } #' @export infer_nanoarrow_schema.double <- function(x, ...) { na_double() } #' @export infer_nanoarrow_schema.character <- function(x, ...) { if (length(x) > 0 && sum(nchar(x, type = "bytes"), na.rm = TRUE) > .Machine$integer.max) { na_large_string() } else { na_string() } } #' @export infer_nanoarrow_schema.integer64 <- function(x, ...) { na_int64() } #' @export infer_nanoarrow_schema.factor <- function(x, ...) { na_dictionary( infer_nanoarrow_schema(levels(x)), na_int32(), ordered = is.ordered(x) ) } #' @export infer_nanoarrow_schema.POSIXct <- function(x, ...) { tz <- attr(x, "tzone") if (is.null(tz) || identical(tz, "")) { tz <- Sys.timezone() } na_timestamp(timezone = tz) } #' @export infer_nanoarrow_schema.POSIXlt <- function(x, ...) { infer_nanoarrow_schema(new_data_frame(x, length(x))) } #' @export infer_nanoarrow_schema.Date <- function(x, ...) { na_date32() } #' @export infer_nanoarrow_schema.difftime <- function(x, ...) { # A balance between safety for large time ranges (not overflowing) # and safety for small time ranges (not truncating) na_duration(unit = "us") } #' @export infer_nanoarrow_schema.data.frame <- function(x, ...) { na_struct(lapply(x, infer_nanoarrow_schema), nullable = FALSE) } #' @export infer_nanoarrow_schema.hms <- function(x, ...) { # As a default, ms is safer than s and less likely to truncate na_time32(unit = "ms") } #' @export infer_nanoarrow_schema.blob <- function(x, ...) { if (length(x) > 0 && sum(lengths(x)) > .Machine$integer.max) { na_large_binary() } else { na_binary() } } #' @export infer_nanoarrow_schema.vctrs_unspecified <- function(x, ...) { na_na() } #' @export infer_nanoarrow_schema.vctrs_list_of <- function(x, ...) { child_type <- infer_nanoarrow_schema(attr(x, "ptype")) if (length(x) > 0 && sum(lengths(x)) > .Machine$integer.max) { na_large_list(child_type) } else { na_list(child_type) } } #' @export infer_nanoarrow_schema.AsIs <- function(x, ...) { # NextMethod() goes directly to `default` class(x) <- class(x)[-1] infer_nanoarrow_schema(x) } #' @export infer_nanoarrow_schema.list <- function(x, ...) { # TODO: Move this to C is_null <- vapply(x, is.null, logical(1)) if (all(is_null)) { return(na_list(na_na())) } is_raw <- vapply(x, is.raw, logical(1)) if (!all(is_raw | is_null)) { return(NextMethod()) } if (length(x) > 0 && sum(lengths(x)) > .Machine$integer.max) { na_large_binary() } else { na_binary() } } #' @rdname as_nanoarrow_schema #' @export nanoarrow_schema_parse <- function(x, recursive = FALSE) { parsed <- .Call(nanoarrow_c_schema_parse, as_nanoarrow_schema(x)) parsed_null <- vapply(parsed, is.null, logical(1)) result <- parsed[!parsed_null] if (recursive && length(x$children) > 0) { result$children <- lapply(x$children, nanoarrow_schema_parse, TRUE) } result } #' @rdname as_nanoarrow_schema #' @export nanoarrow_schema_modify <- function(x, new_values, validate = TRUE) { schema <- as_nanoarrow_schema(x) if (length(new_values) == 0) { return(schema) } # Make sure new_values has names to iterate over new_names <- names(new_values) if (is.null(new_names) || all(new_names == "", na.rm = TRUE)) { stop("`new_values` must be named") } # Make a deep copy and modify it. Possibly not as efficient as it could be # but it's unclear to what degree performance is an issue for R-level # schema modification. schema_deep_copy <- nanoarrow_allocate_schema() nanoarrow_pointer_export(schema, schema_deep_copy) for (i in seq_along(new_values)) { nm <- new_names[i] value <- new_values[[i]] switch( nm, format = .Call( nanoarrow_c_schema_set_format, schema_deep_copy, as.character(value) ), name = { if (!is.null(value)) { value <- as.character(value) } .Call(nanoarrow_c_schema_set_name, schema_deep_copy, value) }, flags = .Call( nanoarrow_c_schema_set_flags, schema_deep_copy, as.integer(value) ), metadata = .Call( nanoarrow_c_schema_set_metadata, schema_deep_copy, as.list(value) ), children = { if (!is.null(value)) { value <- lapply(value, as_nanoarrow_schema) } .Call(nanoarrow_c_schema_set_children, schema_deep_copy, value) }, dictionary = { if (!is.null(value)) { value <- as_nanoarrow_schema(value) } .Call(nanoarrow_c_schema_set_dictionary, schema_deep_copy, value) }, stop(sprintf("Can't modify schema[[%s]]: does not exist", deparse(nm))) ) } if (validate) { nanoarrow_schema_parse(schema_deep_copy, recursive = FALSE) } schema_deep_copy } nanoarrow_schema_identical <- function(x, y) { identical(x, y) || identical( nanoarrow_schema_proxy(x, recursive = TRUE), nanoarrow_schema_proxy(y, recursive = TRUE) ) } #' @importFrom utils str #' @export str.nanoarrow_schema <- function(object, ...) { cat(sprintf("%s\n", format(object, .recursive = FALSE))) if (nanoarrow_pointer_is_valid(object)) { # Use the str() of the list version but remove the first # line of the output ("List of 6") info <- nanoarrow_schema_proxy(object) raw_str_output <- utils::capture.output(str(info, ...)) cat(paste0(raw_str_output[-1], collapse = "\n")) cat("\n") } invisible(object) } #' @export print.nanoarrow_schema <- function(x, ...) { str(x, ...) invisible(x) } #' @export format.nanoarrow_schema <- function(x, ..., .recursive = TRUE) { sprintf( "", nanoarrow_schema_formatted(x, .recursive) ) } # This is the list()-like interface to nanoarrow_schema that allows $ and [[ # to make nice auto-complete for the schema fields #' @export length.nanoarrow_schema <- function(x, ...) { 6L } #' @export names.nanoarrow_schema <- function(x, ...) { c("format", "name", "metadata", "flags", "children", "dictionary") } #' @export `[[.nanoarrow_schema` <- function(x, i, ...) { nanoarrow_schema_proxy(x)[[i]] } #' @export `$.nanoarrow_schema` <- function(x, i, ...) { nanoarrow_schema_proxy(x)[[i]] } #' @export `[[<-.nanoarrow_schema` <- function(x, i, value) { if (is.numeric(i) && isTRUE(i %in% 1:6)) { i <- names.nanoarrow_schema()[[i]] } if (is.character(i) && (length(i) == 1L) && !is.na(i)) { new_values <- list(value) names(new_values) <- i return(nanoarrow_schema_modify(x, new_values)) } stop("`i` must be character(1) or integer(1) %in% 1:6") } #' @export `$<-.nanoarrow_schema` <- function(x, i, value) { new_values <- list(value) names(new_values) <- i nanoarrow_schema_modify(x, new_values) } nanoarrow_schema_formatted <- function(x, recursive = TRUE) { .Call(nanoarrow_c_schema_format, x, as.logical(recursive)[1]) } nanoarrow_schema_proxy <- function(schema, recursive = FALSE) { result <- .Call(nanoarrow_c_schema_to_list, schema) if (recursive && !is.null(schema$children)) { result$children <- lapply( schema$children, nanoarrow_schema_proxy, recursive = TRUE ) } if (recursive && !is.null(schema$dictionary)) { result$dictionary <- nanoarrow_schema_proxy(schema$dictionary, recursive = TRUE) } result$metadata <- list_of_raw_to_metadata(result$metadata) result } list_of_raw_to_metadata <- function(metadata) { lapply(metadata, function(x) { if (is.character(x) || any(x == 0)) { x } else { x_str <- iconv(list(x), from = "UTF-8", to = "UTF-8", mark = TRUE)[[1]] if (is.na(x_str)) x else x_str } }) } nanoarrow/R/as-array.R0000644000176200001440000003001114547061553014330 0ustar liggesusers# 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. #' @export as_nanoarrow_array.default <- function(x, ..., schema = NULL, .from_c = FALSE) { # If we're coming from C it's because we've tried all the internal conversions # and no suitable S3 method was found or the x--schema combination is not # implemented in nanoarrow. Try arrow::as_arrow_array(). if (.from_c) { # Give extension types a chance to handle conversion parsed <- .Call(nanoarrow_c_schema_parse, schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } assert_arrow_installed( sprintf( "create %s array from object of type %s", nanoarrow_schema_formatted(schema), paste0(class(x), collapse = "/") ) ) result <- as_nanoarrow_array( arrow::as_arrow_array( x, type = arrow::as_data_type(schema) ) ) # Skip nanoarrow_pointer_export() for these arrays since we know there # are no external references to them class(result) <- c("nanoarrow_array_dont_export", class(result)) return(result) } if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } else { schema <- as_nanoarrow_schema(schema) } .Call(nanoarrow_c_as_array_default, x, schema) } #' @export as_nanoarrow_array.nanoarrow_array <- function(x, ..., schema = NULL) { if (is.null(schema)) { return(x) } inferred_schema <- infer_nanoarrow_schema(x) if (nanoarrow_schema_identical(schema, inferred_schema)) { return(x) } NextMethod() } #' @export as_nanoarrow_array.integer64 <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } switch( parsed$type, int64 = , uint64 = { if (anyNA(x)) { is_valid_lgl <- is.finite(x) is_valid <- as_nanoarrow_array(is_valid_lgl, schema = na_bool())$buffers[[2]] na_count <- length(x) - sum(is_valid_lgl) } else { is_valid <- NULL na_count <- 0 } array <- nanoarrow_array_init(schema) nanoarrow_array_modify( array, list( length = length(x), null_count = na_count, buffers = list(is_valid, x) ) ) }, as_nanoarrow_array(as.double(x), schema = schema) ) } #' @export as_nanoarrow_array.POSIXct <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } switch( parsed$type, timestamp = , duration = { multipliers <- c(s = 1.0, ms = 1e3, us = 1e6, ns = 1e9) multiplier <- unname(multipliers[parsed$time_unit]) array <- as_nanoarrow_array( as.numeric(x) * multiplier, schema = na_type(parsed$storage_type) ) nanoarrow_array_set_schema(array, schema) array }, NextMethod() ) } #' @export as_nanoarrow_array.difftime <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } src_unit <- attr(x, "units") switch( parsed$type, time32 = , time64 = , duration = { multipliers <- c(s = 1.0, ms = 1e3, us = 1e6, ns = 1e9) src_multipliers <- c( secs = 1.0, mins = 60.0, hours = 3600.0, days = 86400.0, weeks = 604800.0 ) multiplier <- unname(multipliers[parsed$time_unit]) * unname(src_multipliers[src_unit]) array <- as_nanoarrow_array( as.numeric(x) * multiplier, schema = na_type(parsed$storage_type) ) nanoarrow_array_set_schema(array, schema) array }, NextMethod() ) } #' @export as_nanoarrow_array.blob <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } as_nanoarrow_array(unclass(x), schema = schema) } #' @export as_nanoarrow_array.data.frame <- function(x, ..., schema = NULL) { # We need to override this to prevent the list implementation from handling it as_nanoarrow_array.default(x, ..., schema = schema) } #' @export as_nanoarrow_array.list <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name) || parsed$type != "list") { return(NextMethod()) } # This R implementation can't handle complex nesting if (startsWith(schema$children[[1]]$format, "+")) { return(NextMethod()) } array <- nanoarrow_array_init(schema) child <- unlist(x, recursive = FALSE, use.names = FALSE) if (is.null(child)) { child_array <- as_nanoarrow_array.vctrs_unspecified(logical(), schema = na_na()) } else { child_array <- as_nanoarrow_array(child, schema = schema$children[[1]]) } offsets <- c(0L, cumsum(lengths(x))) is_na <- vapply(x, is.null, logical(1)) validity <- as_nanoarrow_array(!is_na)$buffers[[2]] nanoarrow_array_modify( array, list( length = length(x), null_count = sum(is_na), buffers = list( validity, offsets ), children = list( child_array ) ) ) } #' @export as_nanoarrow_array.Date <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } switch( parsed$type, date32 = { storage <- as_nanoarrow_array( as.integer(x), schema = na_type(parsed$storage_type) ) nanoarrow_array_set_schema(storage, schema) storage }, date64 = { storage <- as_nanoarrow_array( as.numeric(x) * 86400000, schema = na_type(parsed$storage_type) ) nanoarrow_array_set_schema(storage, schema) storage }, NextMethod() ) } #' @export as_nanoarrow_array.POSIXlt <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } as_nanoarrow_array(new_data_frame(x, length(x)), schema = schema) } #' @export as_nanoarrow_array.factor <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } if (is.null(schema$dictionary)) { return(as_nanoarrow_array(as.character(x), schema = schema)) } storage <- schema storage$dictionary <- NULL array <- as_nanoarrow_array(unclass(x) - 1L, schema = storage) array$dictionary <- as_nanoarrow_array(levels(x), schema = schema$dictionary) array } #' @export as_nanoarrow_array.vctrs_unspecified <- function(x, ..., schema = NULL) { if (is.null(schema)) { schema <- infer_nanoarrow_schema(x) } else { schema <- as_nanoarrow_schema(schema) } schema <- as_nanoarrow_schema(schema) parsed <- nanoarrow_schema_parse(schema) if (!is.null(parsed$extension_name)) { spec <- resolve_nanoarrow_extension(parsed$extension_name) return(as_nanoarrow_array_extension(spec, x, ..., schema = schema)) } switch( parsed$storage_type, na = { array <- nanoarrow_array_init(schema) array$length <- length(x) array$null_count <- length(x) array }, NextMethod() ) } # Called from C to create a union array when requested. # There are other types of objects that might make sense to # convert to a union but we basically just need enough to # for testing at this point. union_array_from_data_frame <- function(x, schema) { if (length(x) == 0 || length(x) > 127) { stop( sprintf( "Can't convert data frame with %d columns to union array", length(x) ) ) } # Compute NAs x_is_na <- do.call("cbind", lapply(x, is.na)) # Make sure we only have one non-NA value per row to make sure we don't drop # values stopifnot(all(rowSums(!x_is_na) <= 1)) child_index <- rep_len(0L, nrow(x)) seq_x <- seq_along(x) for (i in seq_along(child_index)) { for (j in seq_x) { if (!x_is_na[i, j]) { child_index[i] <- j - 1L break; } } } switch( nanoarrow_schema_parse(schema)$storage_type, "dense_union" = { is_child <- lapply(seq_x - 1L, "==", child_index) child_offset_each <- lapply(is_child, function(x) cumsum(x) - 1L) child_offset <- lapply(seq_along(child_index), function(i) { child_offset_each[[child_index[i] + 1]][i] }) children <- Map("[", x, is_child, drop = FALSE) names(children) <- names(schema$children) array <- nanoarrow_array_init(schema) nanoarrow_array_modify( array, list( length = length(child_index), null_count = 0, buffers = list(as.raw(child_index), as.integer(child_offset)), children = children ) ) }, "sparse_union" = { struct_schema <- na_struct(schema$children) array <- as_nanoarrow_array(x, array = struct_schema) array <- nanoarrow_array_modify( array, list(buffers = list(as.raw(child_index))), validate = FALSE ) nanoarrow_array_set_schema(array, schema, validate = TRUE) array }, stop("Attempt to create union from non-union array type") ) } # This is defined because it's verbose to pass named arguments from C. # When converting data frame columns, we try the internal C conversions # first to save R evaluation overhead. When the internal conversions fail, # we call as_nanoarrow_array() to dispatch to conversions defined via S3 # dispatch, making sure to let the default method know that we've already # tried the internal C conversions. as_nanoarrow_array_from_c <- function(x, schema) { result <- as_nanoarrow_array(x, schema = schema, .from_c = TRUE) # Anything we get from an S3 method we need to validate (even from the # arrow package, which occasionally does not honour the schema argument) nanoarrow_array_set_schema(result, schema, validate = TRUE) result } nanoarrow/R/vctr.R0000644000176200001440000002425714672341746013612 0ustar liggesusers# 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. #' Experimental Arrow encoded arrays as R vectors #' #' This experimental vctr class allows zero or more Arrow arrays to #' present as an R vector without converting them. This is useful for arrays #' with types that do not have a non-lossy R equivalent, and helps provide an #' intermediary object type where the default conversion is prohibitively #' expensive (e.g., a nested list of data frames). These objects will not #' survive many vctr transformations; however, they can be sliced without #' copying the underlying arrays. #' #' The nanoarrow_vctr is currently implemented similarly to `factor()`: its #' storage type is an `integer()` that is a sequence along the total length #' of the vctr and there are attributes that are required to resolve these #' indices to an array + offset. Sequences typically have a very compact #' representation in recent versions of R such that this has a cheap storage #' footprint even for large arrays. The attributes are currently: #' #' - `schema`: The [nanoarrow_schema][as_nanoarrow_schema] shared by each chunk. #' - `chunks`: A `list()` of `nanoarrow_array`. #' - `offsets`: An `integer()` vector beginning with `0` and followed by the #' cumulative length of each chunk. This allows the chunk index + offset #' to be resolved from a logical index with `log(n)` complexity. #' #' This implementation is preliminary and may change; however, the result of #' `as_nanoarrow_array_stream(some_vctr[begin:end])` should remain stable. #' #' @param x An object that works with [as_nanoarrow_array_stream()]. #' @param subclass An optional subclass of nanoarrow_vctr to prepend to the #' final class name. #' @param ... Passed to [as_nanoarrow_array_stream()] #' @param schema An optional `schema` #' #' @return A vctr of class 'nanoarrow_vctr' #' @export #' #' @examples #' array <- as_nanoarrow_array(1:5) #' as_nanoarrow_vctr(array) #' as_nanoarrow_vctr <- function(x, ..., schema = NULL, subclass = character()) { if (inherits(x, "nanoarrow_vctr") && is.null(schema)) { return(x) } stream <- as_nanoarrow_array_stream(x, ..., schema = schema) chunks <- collect_array_stream(stream, validate = FALSE) new_nanoarrow_vctr(chunks, stream$get_schema(), subclass) } #' @rdname as_nanoarrow_vctr #' @export nanoarrow_vctr <- function(schema = NULL, subclass = character()) { if (is.null(schema)) { new_nanoarrow_vctr(list(), NULL, subclass) } else { new_nanoarrow_vctr(list(), as_nanoarrow_schema(schema), subclass) } } new_nanoarrow_vctr <- function(chunks, schema, subclass = character()) { offsets <- .Call(nanoarrow_c_vctr_chunk_offsets, chunks) indices <- seq_len(offsets[length(offsets)]) structure( indices, schema = schema, chunks = chunks, offsets = offsets, class = union(subclass, "nanoarrow_vctr") ) } #' @export `[.nanoarrow_vctr` <- function(x, i) { attrs <- attributes(x) x <- NextMethod() if (is.null(vctr_as_slice(x))) { stop( "Can't subset nanoarrow_vctr with non-slice (e.g., only i:j indexing is supported)" ) } attributes(x) <- attrs x } #' @export `[<-.nanoarrow_vctr` <- function(x, i, value) { stop("subset assignment for nanoarrow_vctr is not supported") } #' @export `[[<-.nanoarrow_vctr` <- function(x, i, value) { stop("subset assignment for nanoarrow_vctr is not supported") } #' @export format.nanoarrow_vctr <- function(x, ...) { if (length(x) == 0) { return(character()) } stream <- as_nanoarrow_array_stream(x) converted <- convert_array_stream(stream) # This needs to be a character() with the same length as x to work with # RStudio's viewer. Data frames need special handling in this case. size_stable_format(converted) } size_stable_format <- function(x, ...) { if (inherits(x, "nanoarrow_vctr")) { # Extension types could have a default convert that gives a nanoarrow_vctr. # If this is the case, they should be returning a subclass with a format # method that ensures we don't get here. rep(sprintf("<%s[%d]>", class(x)[1], seq_along(x))) } else if (inherits(x, "data.frame")) { cols <- lapply(x, size_stable_format, ...) cols <- Map(paste, names(x), cols, sep = ": ") rows <- do.call(paste, c(cols, list(sep = ", "))) paste0("{", rows, "}") } else { format(x, ...) } } #' @export infer_nanoarrow_schema.nanoarrow_vctr <- function(x, ...) { attr(x, "schema", exact = TRUE) } # Because zero-length vctrs are R's way of communicating "type", implement # as_nanoarrow_schema() here so that it works in places that expect a type #' @export as_nanoarrow_schema.nanoarrow_vctr <- function(x, ...) { attr(x, "schema", exact = TRUE) } #' @export as_nanoarrow_array_stream.nanoarrow_vctr <- function(x, ..., schema = NULL) { as_nanoarrow_array_stream.nanoarrow_vctr(x, ..., schema = schema) } #' @export as_nanoarrow_array_stream.nanoarrow_vctr <- function(x, ..., schema = NULL) { if (!is.null(schema)) { # If a schema is passed, first resolve the stream as is and then use # as_nanoarrow_array_stream() to either cast (when this is supported) # or error. stream <- as_nanoarrow_array_stream(x, schema = NULL) return(as_nanoarrow_array_stream(stream, schema = schema)) } # Resolve the indices as c(1-based start, length) slice <- vctr_as_slice(x) if (is.null(slice)) { stop("Can't resolve non-slice nanoarrow_vctr to nanoarrow_array_stream") } x_schema <- attr(x, "schema", exact = TRUE) # Zero-size slice can be an array stream with zero batches if (slice[2] == 0) { return(basic_array_stream(list(), schema = x_schema)) } # Full slice doesn't need slicing logic offsets <- attr(x, "offsets", exact = TRUE) batches <- attr(x, "chunks", exact = TRUE) if (slice[1] == 1 && slice[2] == max(offsets)) { return( basic_array_stream( batches, schema = x_schema, validate = FALSE ) ) } # Calculate first and last slice information first_index <- slice[1] - 1L end_index <- first_index + slice[2] last_index <- end_index - 1L first_chunk_index <- vctr_resolve_chunk(first_index, offsets) last_chunk_index <- vctr_resolve_chunk(last_index, offsets) first_chunk_offset <- first_index - offsets[first_chunk_index + 1L] first_chunk_length <- offsets[first_chunk_index + 2L] - first_index last_chunk_offset <- 0L last_chunk_length <- end_index - offsets[last_chunk_index + 1L] # Calculate first and last slices if (first_chunk_index == last_chunk_index) { batch <- vctr_array_slice( batches[[first_chunk_index + 1L]], first_chunk_offset, last_chunk_length - first_chunk_offset ) return( basic_array_stream( list(batch), schema = x_schema, validate = FALSE ) ) } batch1 <- vctr_array_slice( batches[[first_chunk_index + 1L]], first_chunk_offset, first_chunk_length ) batchn <- vctr_array_slice( batches[[last_chunk_index + 1L]], last_chunk_offset, last_chunk_length ) seq_mid <- seq_len(last_chunk_index - first_chunk_index - 1) batch_mid <- batches[first_chunk_index + seq_mid] basic_array_stream( c( list(batch1), batch_mid, list(batchn) ), schema = x_schema, validate = FALSE ) } #' @export c.nanoarrow_vctr <- function(...) { dots <- list(...) # This one we can do safely if (length(dots) == 1) { return(dots[[1]]) } stop("c() not implemented for nanoarrow_vctr()") } # Ensures that nanoarrow_vctr can fit in a data.frame #' @export as.data.frame.nanoarrow_vctr <- function(x, ..., optional = FALSE) { if (!optional) { stop(sprintf("cannot coerce object of tyoe '%s' to data.frame", class(x)[1])) } else { new_data_frame(list(x), nrow = length(x)) } } #' @export print.nanoarrow_vctr <- function(x, ...) { schema <- attr(x, "schema", exact = TRUE) if (is.null(schema)) { cat(sprintf("<%s >\n", class(x)[1])) return(invisible(x)) } formatted <- nanoarrow_schema_formatted(schema, recursive = FALSE) cat(sprintf("<%s %s[%d]>\n", class(x)[1], formatted, length(x))) n_values <- min(length(x), 20) more_values <- length(x) - n_values stream <- as_nanoarrow_array_stream(utils::head(x, n_values)) converted_head <- convert_array_stream(stream) if (inherits(converted_head, "nanoarrow_vctr")) { converted_head <- format(converted_head) print(converted_head, quote = FALSE) } else { print(converted_head) } if (more_values >= 2) { cat(sprintf("...and %d more values\n", more_values)) } else if (more_values >= 1) { cat(sprintf("...and %d more value\n", more_values)) } invisible(x) } #' @export str.nanoarrow_vctr <- function(object, ...) { schema <- attr(object, "schema", exact = TRUE) if (is.null(schema)) { cat(sprintf("<%s >\n", class(object)[1])) return(invisible(object)) } formatted <- nanoarrow_schema_formatted(schema, recursive = FALSE) cat(sprintf("<%s %s[%d]>\n", class(object)[1], formatted, length(object))) # Prints out the C data interface dump of each chunk with the chunk # index above. str(attr(object, "chunks")) invisible(object) } # Utilities for vctr methods vctr_resolve_chunk <- function(x, offsets) { .Call(nanoarrow_c_vctr_chunk_resolve, x, offsets) } vctr_as_slice <- function(x) { .Call(nanoarrow_c_vctr_as_slice, x) } vctr_array_slice <- function(x, offset, length) { new_offset <- x$offset + offset new_length <- length nanoarrow_array_modify( x, list(offset = new_offset, length = new_length), validate = FALSE ) } nanoarrow/R/pointers.R0000644000176200001440000001523314502402506014451 0ustar liggesusers# 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. #' Danger zone: low-level pointer operations #' #' The [nanoarrow_schema][as_nanoarrow_schema], #' [nanoarrow_array][as_nanoarrow_array], #' and [nanoarrow_array_stream][as_nanoarrow_array_stream] classes are #' represented in R as external pointers (`EXTPTRSXP`). When these objects #' go out of scope (i.e., when they are garbage collected or shortly #' thereafter), the underlying object's `release()` callback is called if #' the underlying pointer is non-null and if the `release()` callback is #' non-null. #' #' When interacting with other C Data Interface implementations, it is #' important to keep in mind that the R object wrapping these pointers is #' always passed by reference (because it is an external pointer) and may #' be referred to by another R object (e.g., an element in a `list()` or as a #' variable assigned in a user's environment). When importing a schema, #' array, or array stream into nanoarrow this is not a problem: the R object #' takes ownership of the lifecycle and memory is released when the R #' object is garbage collected. In this case, one can use #' [nanoarrow_pointer_move()] where `ptr_dst` was created using #' `nanoarrow_allocate_*()`. #' #' The case of exporting is more complicated and as such has a dedicated #' function, [nanoarrow_pointer_export()], that implements different logic #' schemas, arrays, and array streams: #' #' - Schema objects are (deep) copied such that a fresh copy of the schema #' is exported and made the responsibility of some other C data interface #' implementation. #' - Array objects are exported as a shell around the original array that #' preserves a reference to the R object. This ensures that the buffers #' and children pointed to by the array are not copied and that any references #' to the original array are not invalidated. #' - Array stream objects are moved: the responsibility for the object is #' transferred to the other C data interface implementation and any #' references to the original R object are invalidated. Because these #' objects are mutable, this is typically what you want (i.e., you should #' not be pulling arrays from a stream accidentally from two places). #' #' If you know the lifecycle of your object (i.e., you created the R object #' yourself and never passed references to it elsewhere), you can slightly #' more efficiently call [nanoarrow_pointer_move()] for all three pointer #' types. #' #' @param ptr,ptr_src,ptr_dst An external pointer to a `struct ArrowSchema`, #' `struct ArrowArray`, or `struct ArrowArrayStream`. #' @param protected An object whose scope must outlive that of `ptr`. This is #' useful for array streams since at least two specifications involving the #' array stream specify that the stream is only valid for the lifecycle of #' another object (e.g., an AdbcStatement or OGRDataset). #' @return #' - `nanoarrow_pointer_is_valid()` returns TRUE if the pointer is non-null #' and has a non-null release callback. #' - `nanoarrow_pointer_addr_dbl()` and `nanoarrow_pointer_addr_chr()` return #' pointer representations that may be helpful to facilitate moving or #' exporting nanoarrow objects to other libraries. #' - `nanoarrow_pointer_addr_pretty()` gives a pointer representation suitable #' for printing or error messages. #' - `nanoarrow_pointer_release()` returns `ptr`, invisibly. #' - `nanoarrow_pointer_move()` and `nanoarrow_pointer_export()` reeturn #' `ptr_dst`, invisibly. #' - `nanoarrow_allocate_array()`, `nanoarrow_allocate_schema()`, and #' `nanoarrow_allocate_array_stream()` return an #' [array][as_nanoarrow_array], a [schema][as_nanoarrow_schema], and an #' [array stream][as_nanoarrow_array_stream], respectively. #' @export #' nanoarrow_pointer_is_valid <- function(ptr) { .Call(nanoarrow_c_pointer_is_valid, ptr) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_pointer_addr_dbl <- function(ptr) { .Call(nanoarrow_c_pointer_addr_dbl, ptr) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_pointer_addr_chr <- function(ptr) { .Call(nanoarrow_c_pointer_addr_chr, ptr) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_pointer_addr_pretty <- function(ptr) { .Call(nanoarrow_c_pointer_addr_pretty, ptr) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_pointer_release <- function(ptr) { invisible(.Call(nanoarrow_c_pointer_release, ptr)) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_pointer_move <- function(ptr_src, ptr_dst) { invisible(.Call(nanoarrow_c_pointer_move, ptr_src, ptr_dst)) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_pointer_export <- function(ptr_src, ptr_dst) { if (inherits(ptr_src, "nanoarrow_schema")) { .Call(nanoarrow_c_export_schema, ptr_src, ptr_dst) } else if (inherits(ptr_src, "nanoarrow_array")) { .Call(nanoarrow_c_export_array, ptr_src, ptr_dst) } else if (inherits(ptr_src, "nanoarrow_array_stream")) { .Call(nanoarrow_c_export_array_stream, ptr_src, ptr_dst) } else { stop( "`ptr_src` must inherit from 'nanoarrow_schema', 'nanoarrow_array', or 'nanoarrow_array_stream'" ) } invisible(ptr_dst) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_allocate_schema <- function() { .Call(nanoarrow_c_allocate_schema) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_allocate_array <- function() { .Call(nanoarrow_c_allocate_array) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_allocate_array_stream <- function() { .Call(nanoarrow_c_allocate_array_stream) } #' @rdname nanoarrow_pointer_is_valid #' @export nanoarrow_pointer_set_protected <- function(ptr_src, protected) { if (!inherits(ptr_src, c("nanoarrow_schema", "nanoarrow_array", "nanoarrow_array_stream"))) { stop( "`ptr_src` must inherit from 'nanoarrow_schema', 'nanoarrow_array', or 'nanoarrow_array_stream'" ) } .Call(nanoarrow_c_pointer_set_protected, ptr_src, protected) invisible(ptr_src) } nanoarrow/R/pkg-arrow.R0000644000176200001440000002006514635121021014513 0ustar liggesusers# 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. # exported in zzz.R infer_type.nanoarrow_array <- function(x, ...) { arrow::as_data_type(infer_nanoarrow_schema(x, ...)) } as_data_type.nanoarrow_schema <- function(x, ...) { exportable_schema <- nanoarrow_allocate_schema() nanoarrow_pointer_export(x, exportable_schema) getFromNamespace("DataType", "arrow")$import_from_c(exportable_schema) } as_schema.nanoarrow_schema <- function(x, ...) { exportable_schema <- nanoarrow_allocate_schema() nanoarrow_pointer_export(x, exportable_schema) arrow::Schema$import_from_c(exportable_schema) } as_arrow_array.nanoarrow_array <- function(x, ..., type = NULL) { exportable_schema <- nanoarrow_allocate_schema() exportable_array <- nanoarrow_allocate_array() schema <- .Call(nanoarrow_c_infer_schema_array, x) nanoarrow_pointer_export(schema, exportable_schema) nanoarrow_pointer_export(x, exportable_array) result <- arrow::Array$import_from_c(exportable_array, exportable_schema) if (!is.null(type)) { result$cast(arrow::as_data_type(type)) } else { result } } as_arrow_array.nanoarrow_array_stream <- function(x, ..., type = NULL) { chunked <- as_chunked_array.nanoarrow_array_stream(x, ..., type = type) if (chunked$num_chunks == 1) { chunked$chunks[[1]] } else { arrow::as_arrow_array(chunked) } } as_chunked_array.nanoarrow_array <- function(x, ..., type = NULL) { arrow::as_chunked_array(as_arrow_array.nanoarrow_array(x, ..., type = type)) } as_chunked_array.nanoarrow_array_stream <- function(x, ..., type = NULL) { on.exit(x$release()) schema <- infer_nanoarrow_schema(x) chunks <- collect_array_stream(x, validate = FALSE) arrow::ChunkedArray$create(!!!chunks, type = arrow::as_data_type(schema)) } as_record_batch.nanoarrow_array <- function(x, ..., schema = NULL) { exportable_schema <- nanoarrow_allocate_schema() exportable_array <- nanoarrow_allocate_array() nanoarrow_pointer_export( .Call(nanoarrow_c_infer_schema_array, x), exportable_schema ) nanoarrow_pointer_export(x, exportable_array) result <- arrow::RecordBatch$import_from_c(exportable_array, exportable_schema) if (!is.null(schema)) { arrow::as_record_batch(result, schema = schema) } else { result } } as_arrow_table.nanoarrow_array <- function(x, ..., schema = NULL) { arrow::as_arrow_table( as_record_batch.nanoarrow_array(x, schema = schema) ) } as_arrow_table.nanoarrow_array_stream <- function(x, ..., schema = NULL) { on.exit(x$release()) table <- arrow::as_arrow_table(as_record_batch_reader.nanoarrow_array_stream(x)) if (!is.null(schema)) { table$cast(arrow::as_schema(schema)) } else { table } } as_record_batch_reader.nanoarrow_array_stream <- function(x, ..., schema = NULL) { # TODO: not supporting an explicit schema here yet stopifnot(is.null(schema)) # Export stream to ensure self-containedness stream_out <- nanoarrow_allocate_array_stream() nanoarrow_pointer_export(x, stream_out) arrow::RecordBatchReader$import_from_c(stream_out) } #' @export as_nanoarrow_schema.DataType <- function(x, ...) { schema <- nanoarrow_allocate_schema() x$export_to_c(schema) schema } #' @export as_nanoarrow_schema.Field <- function(x, ...) { schema <- nanoarrow_allocate_schema() x$export_to_c(schema) schema } #' @export as_nanoarrow_schema.Schema <- function(x, ...) { schema <- nanoarrow_allocate_schema() x$export_to_c(schema) schema } #' @export infer_nanoarrow_schema.Array <- function(x, ...) { as_nanoarrow_schema.DataType(x$type) } #' @export infer_nanoarrow_schema.Scalar <- function(x, ...) { as_nanoarrow_schema.DataType(x$type) } #' @export infer_nanoarrow_schema.Expression <- function(x, ...) { as_nanoarrow_schema.DataType(x$type()) } #' @export infer_nanoarrow_schema.ChunkedArray <- function(x, ...) { as_nanoarrow_schema.DataType(x$type) } #' @export infer_nanoarrow_schema.ArrowTabular <- function(x, ...) { as_nanoarrow_schema.Schema(x$schema) } #' @export infer_nanoarrow_schema.RecordBatchReader <- function(x, ...) { as_nanoarrow_schema.Schema(x$schema) } #' @export infer_nanoarrow_schema.Dataset <- function(x, ...) { as_nanoarrow_schema.Schema(x$schema) } #' @export infer_nanoarrow_schema.Scanner <- function(x, ...) { as_nanoarrow_schema.Schema(x$schema) } #' @export infer_nanoarrow_schema.arrow_dplyr_query <- function(x, ...) { infer_nanoarrow_schema.RecordBatchReader(arrow::as_record_batch_reader(x)) } #' @export as_nanoarrow_array.Array <- function(x, ..., schema = NULL) { imported_schema <- nanoarrow_allocate_schema() array <- nanoarrow_allocate_array() if (!is.null(schema)) { x <- x$cast(arrow::as_data_type(schema)) } x$export_to_c(array, imported_schema) nanoarrow_array_set_schema(array, imported_schema) array } #' @export as_nanoarrow_array.ChunkedArray <- function(x, ..., schema = NULL) { if (is.null(schema)) { array <- arrow::as_arrow_array(x) } else { array <- arrow::as_arrow_array(x, type = arrow::as_data_type(schema)) } as_nanoarrow_array.Array(array) } #' @export as_nanoarrow_array.RecordBatch <- function(x, ..., schema = NULL) { imported_schema <- nanoarrow_allocate_schema() array <- nanoarrow_allocate_array() if (!is.null(schema)) { x <- x$cast(arrow::as_schema(schema)) } x$export_to_c(array, imported_schema) nanoarrow_array_set_schema(array, imported_schema) array } #' @export as_nanoarrow_array.Table <- function(x, ..., schema = NULL) { if (is.null(schema)) { batch <- arrow::as_record_batch(x) } else { batch <- arrow::as_record_batch(x, schema = arrow::as_schema(schema)) } as_nanoarrow_array.RecordBatch(batch) } #' @export as_nanoarrow_array_stream.RecordBatchReader <- function(x, ..., schema = NULL) { # TODO: not supporting an explicit schema here yet stopifnot(is.null(schema)) array_stream <- nanoarrow_allocate_array_stream() x$export_to_c(array_stream) array_stream } #' @export as_nanoarrow_array_stream.ArrowTabular <- function(x, ..., schema = NULL) { if (!is.null(schema)) { x <- x$cast(arrow::as_schema(schema)) } as_nanoarrow_array_stream.RecordBatchReader(arrow::as_record_batch_reader(x)) } #' @export as_nanoarrow_array_stream.Dataset <- function(x, ..., schema = NULL) { as_nanoarrow_array_stream.RecordBatchReader( arrow::as_record_batch_reader(x), ..., schema = schema ) } #' @export as_nanoarrow_array_stream.arrow_dplyr_query <- function(x, ..., schema = NULL) { as_nanoarrow_array_stream.RecordBatchReader( arrow::as_record_batch_reader(x), ..., schema = schema ) } #' @export as_nanoarrow_array_stream.Scanner <- function(x, ..., schema = NULL) { as_nanoarrow_array_stream.RecordBatchReader( arrow::as_record_batch_reader(x), ..., schema = schema ) } #' @export as_nanoarrow_array_stream.ChunkedArray <- function(x, ..., schema = NULL) { if (!is.null(schema)) { x <- x$cast(arrow::as_data_type(schema)) } schema <- as_nanoarrow_schema.DataType(x$type) # Could be more efficient (involves an S3 dispatch + export for each chunk) basic_array_stream(x$chunks, schema = schema, validate = FALSE) } #' @export as_nanoarrow_array_stream.Array <- function(x, ..., schema = NULL) { if (!is.null(schema)) { x <- x$cast(arrow::as_data_type(schema)) } schema <- as_nanoarrow_schema.DataType(x$type) basic_array_stream(list(x), schema = schema, validate = FALSE) } nanoarrow/R/buffer.R0000644000176200001440000001701714676554240014100 0ustar liggesusers# 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. #' Convert an object to a nanoarrow buffer #' #' @param x An object to convert to a buffer #' @param ... Passed to S3 methods #' #' @return An object of class 'nanoarrow_buffer' #' @export #' #' @examples #' array <- as_nanoarrow_array(c(NA, 1:4)) #' array$buffers #' as.raw(array$buffers[[1]]) #' as.raw(array$buffers[[2]]) #' convert_buffer(array$buffers[[1]]) #' convert_buffer(array$buffers[[2]]) #' as_nanoarrow_buffer <- function(x, ...) { UseMethod("as_nanoarrow_buffer") } #' @export as_nanoarrow_buffer.nanoarrow_buffer <- function(x, ...) { x } #' @export as_nanoarrow_buffer.default <- function(x, ...) { msg <- NULL result <- tryCatch( .Call(nanoarrow_c_as_buffer_default, x), error = function(e) { msg <<- conditionMessage(e) NULL } ) if (is.null(result) && is.null(msg)) { cls <- paste(class(x), collapse = "/") stop(sprintf("Can't convert object of type %s to nanoarrow_buffer", cls)) } else if (is.null(result)) { cls <- paste(class(x), collapse = "/") stop(sprintf("Can't convert object of type %s to nanoarrow_buffer: %s", cls, msg)) } result } #' @importFrom utils str #' @export str.nanoarrow_buffer <- function(object, ..., indent.str = "", width = getOption("width")) { formatted <- format(object) cat(formatted) info <- nanoarrow_buffer_info(object) if (info$data_type == "unknown") { cat("\n") return(invisible(object)) } # Worst case is decimal256, which might occupy 2 output characters per # 256 buffer bytes per element. The actual number isn't too important here, # it's just important to make sure this won't try to format gigabytes of # text. width <- width - nchar(indent.str) - nchar(formatted) - 3 max_print_bytes <- width / 2 * 256 buffer_print <- nanoarrow_buffer_head_bytes(object, max_print_bytes) try({ array <- as_nanoarrow_array.nanoarrow_buffer(buffer_print) vector <- convert_array(array) # binary output here is just '[blob xxb]` which is not all that useful here if (inherits(vector, "blob")) { vector <- vector[[1]] } formatted_data <- paste( format(vector, trim = TRUE), collapse = " " ) cat(" `") if (nchar(formatted_data) > width) { cat(substr(formatted_data, 1, width - 3)) cat("...") } else { cat(formatted_data) } }, silent = TRUE) cat("`\n") invisible(object) } #' @export print.nanoarrow_buffer <- function(x, ...) { str(x, ...) invisible(x) } #' @export format.nanoarrow_buffer <- function(x, ...) { info <- nanoarrow_buffer_info(x) is_null <- identical(nanoarrow_pointer_addr_chr(info$data), "0") if (info$data_type == "unknown") { len <- "" } else if (info$element_size_bits == 0 || info$data_type %in% c("binary", "string")) { len <- sprintf("[%s b]", info$size_bytes) } else { logical_length <- (info$size_bytes * 8) %/% info$element_size_bits len <- sprintf("[%s][%s b]", logical_length, info$size_bytes) } if (is_null) { sprintf("<%s %s<%s>[null]", class(x)[1], info$type, info$data_type) } else { sprintf( "<%s %s<%s>%s>", class(x)[1], info$type, info$data_type, len ) } } #' Create and modify nanoarrow buffers #' #' @param buffer,new_buffer [nanoarrow_buffer][as_nanoarrow_buffer]s. #' @inheritParams convert_array #' #' @return #' - `nanoarrow_buffer_init()`: An object of class 'nanoarrow_buffer' #' - `nanoarrow_buffer_append()`: Returns `buffer`, invisibly. Note that #' `buffer` is modified in place by reference. #' @export #' #' @examples #' buffer <- nanoarrow_buffer_init() #' nanoarrow_buffer_append(buffer, 1:5) #' #' array <- nanoarrow_array_modify( #' nanoarrow_array_init(na_int32()), #' list(length = 5, buffers = list(NULL, buffer)) #' ) #' as.vector(array) #' nanoarrow_buffer_init <- function() { as_nanoarrow_buffer(NULL) } #' @rdname nanoarrow_buffer_init #' @export nanoarrow_buffer_append <- function(buffer, new_buffer) { buffer <- as_nanoarrow_buffer(buffer) new_buffer <- as_nanoarrow_buffer(new_buffer) .Call(nanoarrow_c_buffer_append, buffer, new_buffer) invisible(buffer) } #' @rdname nanoarrow_buffer_init #' @export convert_buffer <- function(buffer, to = NULL) { convert_array(as_nanoarrow_array.nanoarrow_buffer(buffer), to = to) } #' @export as_nanoarrow_array.nanoarrow_buffer <- function(x, ..., schema = NULL) { if (!is.null(schema)) { stop("as_nanoarrow_array() with non-NULL schema is not supported") } info <- nanoarrow_buffer_info(x) if (info$data_type %in% c("binary", "string")) { info$element_size_bits <- 8L } if (info$data_type == "unknown" || info$element_size_bits == 0) { stop("Can't convert buffer with unknown type or unknown element size") } data_type <- info$data_type logical_length <- (info$size_bytes * 8) %/% info$element_size_bits if (data_type %in% c("string", "binary") && logical_length <= .Machine$integer.max) { array <- nanoarrow_array_init(na_type(data_type)) offsets <- as.integer(c(0, logical_length)) nanoarrow_array_modify( array, list( length = 1, null_count = 0, buffers = list(NULL, offsets, x) ) ) } else if (data_type %in% c("string", "binary")) { array <- nanoarrow_array_init(na_type(paste0("large_", data_type))) offsets <- as_nanoarrow_array(c(0, logical_length), schema = na_int64())$buffers[[2]] nanoarrow_array_modify( array, list( length = 1, null_count = 0, buffers = list(NULL, offsets, x) ) ) } else if (data_type %in% c("string_view", "binary_view")) { stop("Can't convert buffer of type string_view or binary_view to array") } else { array <- nanoarrow_array_init(na_type(data_type)) nanoarrow_array_modify( array, list( length = logical_length, null_count = 0, buffers = list(NULL, x) ) ) } } #' @export as.raw.nanoarrow_buffer <- function(x, ...) { .Call(nanoarrow_c_buffer_as_raw, x) } #' @export as.vector.nanoarrow_buffer <- function(x, mode) { convert_buffer(x) } nanoarrow_buffer_info <- function(x) { .Call(nanoarrow_c_buffer_info, x) } nanoarrow_buffer_head_bytes <- function(x, max_bytes) { .Call(nanoarrow_c_buffer_head_bytes, x, as.double(max_bytes)[1]) } # This is the list()-like interface to nanoarrow_buffer that allows $ and [[ # to make nice auto-complete when interacting in an IDE #' @export length.nanoarrow_buffer <- function(x, ...) { 5L } #' @export names.nanoarrow_buffer <- function(x, ...) { c("data", "size_bytes", "capacity_bytes", "type", "data_type", "element_size_bits") } #' @export `[[.nanoarrow_buffer` <- function(x, i, ...) { nanoarrow_buffer_info(x)[[i]] } #' @export `$.nanoarrow_buffer` <- function(x, i, ...) { x[[i]] } nanoarrow/R/nanoarrow-package.R0000644000176200001440000000257214355103326016213 0ustar liggesusers# 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. #' @keywords internal "_PACKAGE" ## usethis namespace: start #' @importFrom utils getFromNamespace #' @useDynLib nanoarrow, .registration = TRUE ## usethis namespace: end NULL #' Underlying 'nanoarrow' C library build #' #' @param runtime Compare TRUE and FALSE values to detect a #' possible ABI mismatch. #' #' @return A string identifying the version of nanoarrow this package #' was compiled against. #' @export #' #' @examples #' nanoarrow_version() #' nanoarrow_version <- function(runtime = TRUE) { if (runtime) { .Call(nanoarrow_c_version_runtime) } else { .Call(nanoarrow_c_version) } } nanoarrow/R/array.R0000644000176200001440000002655314672341746013753 0ustar liggesusers# 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. #' Convert an object to a nanoarrow array #' #' In nanoarrow an 'array' refers to the `struct ArrowArray` definition #' in the Arrow C data interface. At the R level, we attach a #' [schema][as_nanoarrow_schema] such that functionally the nanoarrow_array #' class can be used in a similar way as an `arrow::Array`. Note that in #' nanoarrow an `arrow::RecordBatch` and a non-nullable `arrow::StructArray` #' are represented identically. #' #' @param x An object to convert to a array #' @param schema An optional schema used to enforce conversion to a particular #' type. Defaults to [infer_nanoarrow_schema()]. #' @param ... Passed to S3 methods #' #' @return An object of class 'nanoarrow_array' #' @export #' #' @examples #' (array <- as_nanoarrow_array(1:5)) #' as.vector(array) #' #' (array <- as_nanoarrow_array(data.frame(x = 1:5))) #' as.data.frame(array) #' as_nanoarrow_array <- function(x, ..., schema = NULL) { UseMethod("as_nanoarrow_array") } # See as-array.R for S3 method implementations #' @export as.vector.nanoarrow_array <- function(x, mode = "any") { stopifnot(identical(mode, "any")) convert_array(x, to = infer_nanoarrow_ptype(x)) } #' @export as.data.frame.nanoarrow_array <- function(x, ...) { schema <- infer_nanoarrow_schema(x) if (schema$format != "+s") { stop( sprintf( "Can't convert array with type %s to data.frame()", nanoarrow_schema_formatted(schema) ) ) } .Call(nanoarrow_c_convert_array, x, NULL) } # exported in zzz.R as_tibble.nanoarrow_array <- function(x, ...) { tibble::as_tibble(as.data.frame.nanoarrow_array(x), ...) } #' @export infer_nanoarrow_schema.nanoarrow_array <- function(x, ...) { .Call(nanoarrow_c_infer_schema_array, x) %||% stop("nanoarrow_array() has no associated schema") } #' @importFrom utils str #' @export str.nanoarrow_array <- function(object, ...) { cat(sprintf("%s\n", format(object, .recursive = FALSE))) if (nanoarrow_pointer_is_valid(object)) { # Use the str() of the list version but remove the first # line of the output ("List of 6") info <- nanoarrow_array_proxy_safe(object) raw_str_output <- utils::capture.output(str(info, ...)) cat(paste0(raw_str_output[-1], collapse = "\n")) cat("\n") } invisible(object) } #' @export print.nanoarrow_array <- function(x, ...) { str(x, ...) invisible(x) } #' @export format.nanoarrow_array <- function(x, ..., .recursive = TRUE) { if (nanoarrow_pointer_is_valid(x)) { schema <- .Call(nanoarrow_c_infer_schema_array, x) if (is.null(schema)) { sprintf("[%s]>", x$length) } else { sprintf( "", nanoarrow_schema_formatted(schema, .recursive), x$length ) } } else { "" } } # This is the list()-like interface to nanoarrow_array that allows $ and [[ # to make nice auto-complete for the array fields #' @export length.nanoarrow_array <- function(x, ...) { 6L } #' @export names.nanoarrow_array <- function(x, ...) { c("length", "null_count", "offset", "buffers", "children", "dictionary") } #' @export `[[.nanoarrow_array` <- function(x, i, ...) { nanoarrow_array_proxy_safe(x)[[i]] } #' @export `$.nanoarrow_array` <- function(x, i, ...) { nanoarrow_array_proxy_safe(x)[[i]] } #' @export `[[<-.nanoarrow_array` <- function(x, i, value) { if (is.numeric(i) && isTRUE(i %in% 1:6)) { i <- names.nanoarrow_array()[[i]] } if (is.character(i) && (length(i) == 1L) && !is.na(i)) { new_values <- list(value) names(new_values) <- i return(nanoarrow_array_modify(x, new_values)) } stop("`i` must be character(1) or integer(1) %in% 1:6") } #' @export `$<-.nanoarrow_array` <- function(x, i, value) { new_values <- list(value) names(new_values) <- i nanoarrow_array_modify(x, new_values) } # A version of nanoarrow_array_proxy() that is less likely to error for invalid # arrays and/or schemas nanoarrow_array_proxy_safe <- function(array, recursive = FALSE) { schema <- .Call(nanoarrow_c_infer_schema_array, array) tryCatch( nanoarrow_array_proxy(array, schema = schema, recursive = recursive), error = function(...) nanoarrow_array_proxy(array, recursive = recursive) ) } nanoarrow_array_proxy <- function(array, schema = NULL, recursive = FALSE) { if (!is.null(schema)) { array_view <- .Call(nanoarrow_c_array_view, array, schema) result <- .Call(nanoarrow_c_array_proxy, array, array_view, recursive) names(result$children) <- names(schema$children) if (!recursive) { # Pass on some information from the schema if we have it result$children <- Map( nanoarrow_array_set_schema, result$children, schema$children ) if (!is.null(result$dictionary)) { nanoarrow_array_set_schema(result$dictionary, schema$dictionary) } } } else { result <- .Call(nanoarrow_c_array_proxy, array, NULL, recursive) } result } #' Modify nanoarrow arrays #' #' Create a new array or from an existing array, modify one or more parameters. #' When importing an array from elsewhere, `nanoarrow_array_set_schema()` is #' useful to attach the data type information to the array (without this #' information there is little that nanoarrow can do with the array since its #' content cannot be otherwise interpreted). `nanoarrow_array_modify()` can #' create a shallow copy and modify various parameters to create a new array, #' including setting children and buffers recursively. These functions power the #' `$<-` operator, which can modify one parameter at a time. #' #' @param array A [nanoarrow_array][as_nanoarrow_array]. #' @param schema A [nanoarrow_schema][as_nanoarrow_schema] to attach to this #' `array`. #' @param new_values A named `list()` of values to replace. #' @param validate Use `FALSE` to skip validation. Skipping validation may #' result in creating an array that will crash R. #' #' @return #' - `nanoarrow_array_init()` returns a possibly invalid but initialized #' array with a given `schema`. #' - `nanoarrow_array_set_schema()` returns `array`, invisibly. Note that #' `array` is modified in place by reference. #' - `nanoarrow_array_modify()` returns a shallow copy of `array` with the #' modified parameters such that the original array remains valid. #' @export #' #' @examples #' nanoarrow_array_init(na_string()) #' #' # Modify an array using $ and <- #' array <- as_nanoarrow_array(1:5) #' array$length <- 4 #' as.vector(array) #' #' # Modify potentially more than one component at a time #' array <- as_nanoarrow_array(1:5) #' as.vector(nanoarrow_array_modify(array, list(length = 4))) #' #' # Attach a schema to an array #' array <- as_nanoarrow_array(-1L) #' nanoarrow_array_set_schema(array, na_uint32()) #' as.vector(array) #' nanoarrow_array_init <- function(schema) { .Call(nanoarrow_c_array_init, schema) } #' @rdname nanoarrow_array_init #' @export nanoarrow_array_set_schema <- function(array, schema, validate = TRUE) { .Call(nanoarrow_c_array_set_schema, array, schema, as.logical(validate)[1]) invisible(array) } #' @rdname nanoarrow_array_init #' @export nanoarrow_array_modify <- function(array, new_values, validate = TRUE) { array <- as_nanoarrow_array(array) if (length(new_values) == 0) { return(array) } # Make sure new_values has names to iterate over new_names <- names(new_values) if (is.null(new_names) || all(new_names == "", na.rm = TRUE)) { stop("`new_values` must be named") } # Make a copy and modify it. This is a deep copy in the sense that all # children are modifiable; however, it's a shallow copy in the sense that # none of the buffers are copied. schema <- .Call(nanoarrow_c_infer_schema_array, array) array_copy <- array_shallow_copy(array, schema, validate = validate) for (i in seq_along(new_values)) { nm <- new_names[i] value <- new_values[[i]] switch( nm, length = .Call(nanoarrow_c_array_set_length, array_copy, as.double(value)), null_count = .Call(nanoarrow_c_array_set_null_count, array_copy, as.double(value)), offset = .Call(nanoarrow_c_array_set_offset, array_copy, as.double(value)), buffers = { value <- lapply(value, as_nanoarrow_buffer) .Call(nanoarrow_c_array_set_buffers, array_copy, value) }, children = { value <- lapply(value, as_nanoarrow_array) value_copy <- lapply(value, array_shallow_copy, validate = validate) .Call(nanoarrow_c_array_set_children, array_copy, value_copy) if (!is.null(schema)) { schema <- nanoarrow_schema_modify( schema, list(children = lapply(value, infer_nanoarrow_schema)), validate = validate ) } }, dictionary = { if (!is.null(value)) { value <- as_nanoarrow_array(value) value_copy <- array_shallow_copy(value, validate = validate) } else { value_copy <- NULL } .Call(nanoarrow_c_array_set_dictionary, array_copy, value_copy) if (!is.null(schema) && !is.null(value)) { schema <- nanoarrow_schema_modify( schema, list(dictionary = infer_nanoarrow_schema(value)), validate = validate ) } else if (!is.null(schema)) { schema <- nanoarrow_schema_modify( schema, list(dictionary = NULL), validate = validate ) } }, stop(sprintf("Can't modify array[[%s]]: does not exist", deparse(nm))) ) } if (!is.null(schema) && validate) { array_copy <- .Call(nanoarrow_c_array_validate_after_modify, array_copy, schema) } if (!is.null(schema)) { nanoarrow_array_set_schema(array_copy, schema, validate = validate) } array_copy } array_shallow_copy <- function(array, schema = NULL, validate = TRUE) { array_copy <- nanoarrow_allocate_array() nanoarrow_pointer_export(array, array_copy) schema <- schema %||% .Call(nanoarrow_c_infer_schema_array, array) # For validation, use some of the infrastructure we already have in place # to make sure array_copy knows how long each buffer is if (!is.null(schema) && validate) { copy_buffers_recursive(array, array_copy) } array_copy } copy_buffers_recursive <- function(array, array_copy) { proxy <- nanoarrow_array_proxy_safe(array) proxy_copy <- nanoarrow_array_proxy(array_copy) .Call(nanoarrow_c_array_set_buffers, array_copy, proxy$buffers) for (i in seq_along(proxy$children)) { copy_buffers_recursive(proxy$children[[i]], proxy_copy$children[[i]]) } if (!is.null(proxy$dictionary)) { copy_buffers_recursive(proxy$dictionary, proxy_copy$dictionary) } } nanoarrow/R/extension.R0000644000176200001440000001454314674150567014646 0ustar liggesusers# 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. #' Register Arrow extension types #' #' @param extension_name An Arrow extension type name (e.g., arrow.r.vctrs) #' @param extension_spec An extension specification inheriting from #' 'nanoarrow_extension_spec'. #' @param data Optional data to include in the extension type specification #' @param subclass A subclass for the extension type specification. Extension #' methods will dispatch on this object. #' #' @return #' - `nanoarrow_extension_spec()` returns an object of class #' 'nanoarrow_extension_spec'. #' - `register_nanoarrow_extension()` returns `extension_spec`, invisibly. #' - `unregister_nanoarrow_extension()` returns `extension_name`, invisibly. #' - `resolve_nanoarrow_extension()` returns an object of class #' 'nanoarrow_extension_spec' or NULL if the extension type was not #' registered. #' @export #' #' @examples #' nanoarrow_extension_spec("mynamespace.mytype", subclass = "mypackage_mytype_spec") nanoarrow_extension_spec <- function(data = list(), subclass = character()) { structure( data, class = union(subclass, "nanoarrow_extension_spec") ) } #' @rdname nanoarrow_extension_spec #' @export register_nanoarrow_extension <- function(extension_name, extension_spec) { extension_registry[[extension_name]] <- extension_spec invisible(extension_name) } #' @rdname nanoarrow_extension_spec #' @export unregister_nanoarrow_extension <- function(extension_name) { extension_registry[[extension_name]] <- NULL invisible(extension_name) } #' @rdname nanoarrow_extension_spec #' @export resolve_nanoarrow_extension <- function(extension_name) { extension_registry[[extension_name]] } #' Implement Arrow extension types #' #' @inheritParams nanoarrow_extension_spec #' @param warn_unregistered Use `FALSE` to infer/convert based on the storage #' type without a warning. #' @param x,array,to,schema,... Passed from [infer_nanoarrow_ptype()], #' [convert_array()], [as_nanoarrow_array()], and/or #' [as_nanoarrow_array_stream()]. #' #' @return #' - `infer_nanoarrow_ptype_extension()`: The R vector prototype to be used #' as the default conversion target. #' - `convert_array_extension()`: An R vector of type `to`. #' - `as_nanoarrow_array_extension()`: A [nanoarrow_array][as_nanoarrow_array] #' of type `schema`. #' @export #' infer_nanoarrow_ptype_extension <- function(extension_spec, x, ..., warn_unregistered = TRUE) { UseMethod("infer_nanoarrow_ptype_extension") } #' @rdname infer_nanoarrow_ptype_extension #' @export convert_array_extension <- function(extension_spec, array, to, ..., warn_unregistered = TRUE) { UseMethod("convert_array_extension") } #' @rdname infer_nanoarrow_ptype_extension #' @export as_nanoarrow_array_extension <- function(extension_spec, x, ..., schema = NULL) { UseMethod("as_nanoarrow_array_extension") } #' @export infer_nanoarrow_ptype_extension.default <- function(extension_spec, x, ..., warn_unregistered = TRUE) { if (warn_unregistered) { warn_unregistered_extension_type(x) } x$metadata[["ARROW:extension:name"]] <- NULL infer_nanoarrow_ptype(x) } #' @export convert_array_extension.default <- function(extension_spec, array, to, ..., warn_unregistered = TRUE) { storage <- .Call(nanoarrow_c_infer_schema_array, array) if (warn_unregistered) { warn_unregistered_extension_type(storage) } storage$metadata[["ARROW:extension:name"]] <- NULL array <- array_shallow_copy(array, validate = FALSE) nanoarrow_array_set_schema(array, storage) convert_array(array, to, ...) } #' @export as_nanoarrow_array_extension.default <- function(extension_spec, x, ..., schema = NULL) { stop( sprintf( "as_nanoarrow_array_extension() not implemented for extension %s", nanoarrow_schema_formatted(schema) ) ) } #' Create Arrow extension arrays #' #' @param storage_array A [nanoarrow_array][as_nanoarrow_array]. #' @inheritParams na_type #' #' @return A [nanoarrow_array][as_nanoarrow_array] with attached extension #' schema. #' @export #' #' @examples #' nanoarrow_extension_array(1:10, "some_ext", '{"key": "value"}') #' nanoarrow_extension_array <- function(storage_array, extension_name, extension_metadata = NULL) { storage_array <- as_nanoarrow_array(storage_array) schema <- .Call(nanoarrow_c_infer_schema_array, storage_array) schema$metadata[["ARROW:extension:name"]] <- extension_name schema$metadata[["ARROW:extension:metadata"]] <- extension_metadata shallow_copy <- array_shallow_copy(storage_array) nanoarrow_array_set_schema(shallow_copy, schema) shallow_copy } warn_unregistered_extension_type <- function(x) { # Allow an opt-out of this warning for consumers that don't have # control over their source and want to drop unknown extensions if (!getOption("nanoarrow.warn_unregistered_extension", TRUE)) { return() } # Warn that we're about to ignore an extension type message <- sprintf( paste0( "Converting unknown extension %s as storage type\n", "Disable warning with ", "options(nanoarrow.warn_unregistered_extension = FALSE)" ), nanoarrow_schema_formatted(x) ) # Add the field name if we know it if (!is.null(x$name) && !identical(x$name, "")) { message <- paste0(x$name, ": ", message) } warning(message) } # Mutable registry to look up extension specifications extension_registry <- new.env(parent = emptyenv()) nanoarrow/R/convert-array-stream.R0000644000176200001440000001121214643132461016672 0ustar liggesusers# 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. #' Convert an Array Stream into an R vector #' #' Converts `array_stream` to the type specified by `to`. This is a low-level #' interface; most users should use `as.data.frame()` or `as.vector()` unless #' finer-grained control is needed over the conversion. See [convert_array()] #' for details of the conversion process; see [infer_nanoarrow_ptype()] for #' default inferences of `to`. #' #' @param array_stream A [nanoarrow_array_stream][as_nanoarrow_array_stream]. #' @param size The exact size of the output, if known. If specified, #' slightly more efficient implementation may be used to collect the output. #' @param n The maximum number of batches to pull from the array stream. #' @inheritParams convert_array #' @inheritParams basic_array_stream #' #' @return #' - `convert_array_stream()`: An R vector of type `to`. #' - `collect_array_stream()`: A `list()` of [nanoarrow_array][as_nanoarrow_array] #' @export #' #' @examples #' stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) #' str(convert_array_stream(stream)) #' str(convert_array_stream(stream, to = data.frame(x = double()))) #' #' stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) #' collect_array_stream(stream) #' convert_array_stream <- function(array_stream, to = NULL, size = NULL, n = Inf) { stopifnot( inherits(array_stream, "nanoarrow_array_stream") ) schema <- .Call(nanoarrow_c_array_stream_get_schema, array_stream) if (is.null(to)) { to <- infer_nanoarrow_ptype(schema) } else if (is.function(to)) { to <- to(schema, infer_nanoarrow_ptype(schema)) } n <- as.double(n)[1] if (!is.null(size)) { # The underlying nanoarrow_c_convert_array_stream() currently requires that # the total length of all batches is known in advance. If the caller # provided this we can save a bit of work. .Call( nanoarrow_c_convert_array_stream, array_stream, to, as.double(size)[1], n ) } else { # Otherwise, we need to collect all batches and calculate the total length # before calling nanoarrow_c_convert_array_stream(). batches <- collect_array_stream( array_stream, n, schema = schema, validate = FALSE ) # If there is exactly one batch, use convert_array(). Converting a single # array currently takes a more efficient code path for types that can be # converted as ALTREP (e.g., strings). if (length(batches) == 1L) { return(.Call(nanoarrow_c_convert_array, batches[[1]], to)) } # Otherwise, compute the final size, create another array stream, # and call convert_array_stream() with a known size. Using .Call() # directly because we have already type checked the inputs. size <- .Call(nanoarrow_c_array_list_total_length, batches) basic_stream <- .Call(nanoarrow_c_basic_array_stream, batches, schema, FALSE) .Call( nanoarrow_c_convert_array_stream, basic_stream, to, as.double(size), Inf ) } } #' @rdname convert_array_stream #' @export collect_array_stream <- function(array_stream, n = Inf, schema = NULL, validate = TRUE) { stopifnot( inherits(array_stream, "nanoarrow_array_stream") ) if (is.null(schema)) { schema <- .Call(nanoarrow_c_array_stream_get_schema, array_stream) } batches <- vector("list", 1024L) n_batches <- 0 get_next <- array_stream$get_next while (n_batches < n) { array <- get_next(schema, validate = validate) if (is.null(array)) { break } n_batches <- n_batches + 1 # This assignment has reasonable (but not great) performance when # n_batches > 1024 in recent versions of R because R overallocates vectors # slightly to support this pattern. It may be worth moving this # implementation to C or C++ in the future if the collect step becomes a # bottleneck. batches[[n_batches]] <- array } batches[seq_len(n_batches)] } nanoarrow/R/util.R0000644000176200001440000001034614502402562013565 0ustar liggesusers# 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. arrow_installed <- function() { opt <- Sys.getenv( "R_NANOARROW_WITHOUT_ARROW", getOption("nanoarrow.without_arrow", FALSE) ) if (identical(tolower(opt), "true")) { FALSE } else { requireNamespace("arrow", quietly = TRUE) } } assert_arrow_installed <- function(reason) { if (!arrow_installed()) { stop( sprintf("Package 'arrow' required for %s", reason), call. = FALSE ) } } warn_lossy_conversion <- function(count, msg) { cnd <- simpleWarning( sprintf("%d value(s) %s", count, msg), call = sys.call(-1) ) class(cnd) <- union("nanoarrow_warning_lossy_conversion", class(cnd)) warning(cnd) } # Internally we use R_PreserveObject() and R_ReleaseObject() to manage R objects # that must be kept alive for ArrowArray buffers to stay valid. This count # should be zero after tests have run in a fresh session and both gc() and # preserved_empty() have been run. If this isn't the case, compile with # -DNANOARROW_DEBUG_PRESERVE and run preserved_empty() to get verbose output # about which objects didn't get released (including an R traceback to where # they were preserved). preserved_count <- function() { .Call(nanoarrow_c_preserved_count) } # Most objects are both preserved and released on the R main thread; however # when sending objects into the wild there is no guarantee that they will be # deleted on the R main thread (even though they usually are). The R package # handles this by keeping a list of objects that couldn't be released: calling # this function will release them and return how many were released. preserved_empty <- function() { .Call(nanoarrow_c_preserved_empty) } # To test the "release from another thread" mechanism, this preserves obj, # releases it from another thread and returns. preserve_and_release_on_other_thread <- function(obj) { invisible(.Call(nanoarrow_c_preserve_and_release_on_other_thread, obj)) } # This is used by bookkeeping infrastructure when debugging an imbalance in # preserved/released SEXPs. current_stack_trace_chr <- function() { tb <- rlang::trace_back() paste0(utils::capture.output(print(tb)), collapse = "\n") } # Consolidate places we should call vctrs::vec_slice() # if/when a vctrs dependency is added vec_slice2 <- function(x, i) { if (is.data.frame(x)) { x[i, , drop = FALSE] } else { x[i] } } `%||%` <- function(rhs, lhs) { if (is.null(rhs)) lhs else rhs } new_data_frame <- function(x, nrow) { structure(x, row.names = c(NA, nrow), class = "data.frame") } vec_gen <- function(ptype, n = 1e3, prop_true = 0.5, prop_na = 0, chr_len = function(n) ceiling(25 * stats::runif(n))) { vec <- switch( class(ptype)[1], logical = stats::runif(n) < prop_true, integer = as.integer(stats::runif(n, min = -1, max = 1) * .Machine$integer.max), numeric = stats::runif(n), character = strrep(rep_len(letters, n), chr_len(n)), data.frame = new_data_frame( lapply( ptype, vec_gen, n = n, prop_true = prop_true, prop_na = prop_na, chr_len = chr_len ), n ), stop(sprintf("Don't know how to generate vector for type %s", class(ptype)[1])) ) if (!is.data.frame(vec) && prop_na > 0) { is_na <- stats::runif(n) < prop_na vec[is_na] <- ptype[NA_integer_] } vec } vec_shuffle <- function(x) { if (is.data.frame(x)) { i <- sample(seq_len(nrow(x)), replace = FALSE) } else { i <- sample(seq_along(x), replace = FALSE) } vec_slice2(x, i) } nanoarrow/src/0000755000176200001440000000000014702632113013046 5ustar liggesusersnanoarrow/src/array.c0000644000176200001440000003646714677134124014362 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include #include "array.h" #include "buffer.h" #include "nanoarrow.h" #include "schema.h" #include "util.h" SEXP nanoarrow_c_array_init(SEXP schema_xptr) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); SEXP array_xptr = PROTECT(nanoarrow_array_owning_xptr()); struct ArrowArray* array = nanoarrow_output_array_from_xptr(array_xptr); struct ArrowError error; int result = ArrowArrayInitFromSchema(array, schema, &error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromSchema(): %s", error.message); } array_xptr_set_schema(array_xptr, schema_xptr); UNPROTECT(1); return array_xptr; } SEXP nanoarrow_c_array_set_length(SEXP array_xptr, SEXP length_sexp) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); if (TYPEOF(length_sexp) != REALSXP || Rf_length(length_sexp) != 1) { Rf_error("array$length must be double(1)"); } double length = REAL(length_sexp)[0]; if (ISNA(length) || ISNAN(length) || length < 0) { Rf_error("array$length must be finite and greater than zero"); } array->length = (int64_t)length; return R_NilValue; } SEXP nanoarrow_c_array_set_null_count(SEXP array_xptr, SEXP null_count_sexp) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); if (TYPEOF(null_count_sexp) != REALSXP || Rf_length(null_count_sexp) != 1) { Rf_error("array$null_count must be double(1)"); } double null_count = REAL(null_count_sexp)[0]; if (ISNA(null_count) || ISNAN(null_count) || null_count < -1) { Rf_error("array$null_count must be finite and greater than -1"); } array->null_count = (int64_t)null_count; return R_NilValue; } SEXP nanoarrow_c_array_set_offset(SEXP array_xptr, SEXP offset_sexp) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); if (TYPEOF(offset_sexp) != REALSXP || Rf_length(offset_sexp) != 1) { Rf_error("array$offset must be double(1)"); } double offset = REAL(offset_sexp)[0]; if (ISNA(offset) || ISNAN(offset) || offset < 0) { Rf_error("array$offset must be finite and greater than zero"); } array->offset = (int64_t)offset; return R_NilValue; } SEXP nanoarrow_c_array_set_buffers(SEXP array_xptr, SEXP buffers_sexp) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); int64_t n_buffers = Rf_xlength(buffers_sexp); if (n_buffers > 3) { Rf_error("length(array$buffers) must be <= 3"); } // Release any buffers that aren't about to be replaced for (int64_t i = n_buffers; i < array->n_buffers; i++) { ArrowBufferReset(ArrowArrayBuffer(array, i)); } array->n_buffers = n_buffers; for (int64_t i = 0; i < n_buffers; i++) { SEXP buffer_xptr = VECTOR_ELT(buffers_sexp, i); struct ArrowBuffer* src = buffer_from_xptr(buffer_xptr); // We can't necessarily ArrowBufferMove(src) because that buffer might // have been pointed at by something else. So, we do this slightly awkward // dance to make sure buffer_xptr stays valid after this call. SEXP buffer_xptr_clone = PROTECT(buffer_borrowed_xptr(src->data, src->size_bytes, buffer_xptr)); struct ArrowBuffer* src_clone = (struct ArrowBuffer*)R_ExternalPtrAddr(buffer_xptr_clone); // Release whatever buffer is currently there and replace it with src_clone ArrowBufferReset(ArrowArrayBuffer(array, i)); int result = ArrowArraySetBuffer(array, i, src_clone); if (result != NANOARROW_OK) { Rf_error("ArrowArraySetBuffer() failed"); } UNPROTECT(1); } return R_NilValue; } static void release_all_children(struct ArrowArray* array) { for (int64_t i = 0; i < array->n_children; i++) { if (array->children[i]->release != NULL) { array->children[i]->release(array->children[i]); } } } static void free_all_children(struct ArrowArray* array) { for (int64_t i = 0; i < array->n_children; i++) { if (array->children[i] != NULL) { ArrowFree(array->children[i]); array->children[i] = NULL; } } if (array->children != NULL) { ArrowFree(array->children); array->children = NULL; } array->n_children = 0; } SEXP nanoarrow_c_array_set_children(SEXP array_xptr, SEXP children_sexp) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); release_all_children(array); if (Rf_xlength(children_sexp) == 0) { free_all_children(array); return R_NilValue; } if (Rf_xlength(children_sexp) != array->n_children) { free_all_children(array); int result = ArrowArrayAllocateChildren(array, Rf_xlength(children_sexp)); if (result != NANOARROW_OK) { Rf_error("Error allocating array$children of size %ld", (long)Rf_xlength(children_sexp)); } } for (int64_t i = 0; i < array->n_children; i++) { // The arrays here will be moved, invalidating the arrays in the passed // list (the export step is handled in R) SEXP child_xptr = VECTOR_ELT(children_sexp, i); struct ArrowArray* child = nanoarrow_array_from_xptr(child_xptr); ArrowArrayMove(child, array->children[i]); } return R_NilValue; } SEXP nanoarrow_c_array_set_dictionary(SEXP array_xptr, SEXP dictionary_xptr) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); // If there's already a dictionary, make sure we release it if (array->dictionary != NULL) { if (array->dictionary->release != NULL) { array->dictionary->release(array->dictionary); } } if (dictionary_xptr == R_NilValue) { if (array->dictionary != NULL) { ArrowFree(array->dictionary); array->dictionary = NULL; } } else { if (array->dictionary == NULL) { int result = ArrowArrayAllocateDictionary(array); if (result != NANOARROW_OK) { Rf_error("Error allocating array$dictionary"); } } struct ArrowArray* dictionary = nanoarrow_array_from_xptr(dictionary_xptr); ArrowArrayMove(dictionary, array->dictionary); } return R_NilValue; } static int move_array_buffers(struct ArrowArray* src, struct ArrowArray* dst, struct ArrowSchema* schema, struct ArrowError* error) { error->message[0] = '\0'; dst->length = src->length; dst->null_count = src->null_count; dst->offset = src->offset; if (src->n_buffers != dst->n_buffers) { ArrowErrorSet(error, "Expected %ld buffer(s) but got %ld", (long)dst->n_buffers, (long)src->n_buffers); return EINVAL; } for (int64_t i = 0; i < src->n_buffers; i++) { NANOARROW_RETURN_NOT_OK(ArrowArraySetBuffer(dst, i, ArrowArrayBuffer(src, i))); } if (src->n_children != dst->n_children) { ArrowErrorSet(error, "Expected %ld child(ren) but got %ld", (long)dst->n_children, (long)src->n_children); return EINVAL; } for (int64_t i = 0; i < src->n_children; i++) { NANOARROW_RETURN_NOT_OK(move_array_buffers(src->children[i], dst->children[i], schema->children[i], error)); } if (src->dictionary != NULL) { NANOARROW_RETURN_NOT_OK( move_array_buffers(src->dictionary, dst->dictionary, schema->dictionary, error)); } return NANOARROW_OK; } SEXP nanoarrow_c_array_validate_after_modify(SEXP array_xptr, SEXP schema_xptr) { // A very particular type of validation we can do with the ArrowArray we use // in nanoarrow_array_modify() (which was created using ArrowArrayInit). // At this point we know how long each buffer is (via ArrowArrayBuffer()) // but after we send the array into the wild, that information is lost. // This operation will invalidate array_xptr (but this is OK since we very // specifically just allocated it). struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); struct ArrowError error; // Even though array was initialized using ArrowArrayInit(), it doesn't have // all the information about storage types since it didn't necessarily know // what the storage type would be when it was being constructed. Here we create // a version that does and move buffers recursively into it. SEXP array_dst_xptr = PROTECT(nanoarrow_array_owning_xptr()); struct ArrowArray* array_dst = nanoarrow_output_array_from_xptr(array_dst_xptr); int result = ArrowArrayInitFromSchema(array_dst, schema, &error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromSchema(): %s", error.message); } result = move_array_buffers(array, array_dst, schema, &error); if (result != NANOARROW_OK) { Rf_error("move_array_buffers: %s", error.message); } result = ArrowArrayFinishBuildingDefault(array_dst, &error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayFinishBuildingDefault(): %s", error.message); } UNPROTECT(1); return array_dst_xptr; } SEXP nanoarrow_c_array_set_schema(SEXP array_xptr, SEXP schema_xptr, SEXP validate_sexp) { // Fair game to remove a schema from a pointer if (schema_xptr == R_NilValue) { array_xptr_set_schema(array_xptr, R_NilValue); return R_NilValue; } int validate = LOGICAL(validate_sexp)[0]; if (validate) { // If adding a schema, validate the schema and the pair struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); struct ArrowArrayView array_view; struct ArrowError error; int result = ArrowArrayViewInitFromSchema(&array_view, schema, &error); if (result != NANOARROW_OK) { ArrowArrayViewReset(&array_view); Rf_error("%s", ArrowErrorMessage(&error)); } result = ArrowArrayViewSetArray(&array_view, array, &error); ArrowArrayViewReset(&array_view); if (result != NANOARROW_OK) { Rf_error("%s", ArrowErrorMessage(&error)); } } array_xptr_set_schema(array_xptr, schema_xptr); return R_NilValue; } SEXP nanoarrow_c_infer_schema_array(SEXP array_xptr) { SEXP maybe_schema_xptr = R_ExternalPtrTag(array_xptr); if (Rf_inherits(maybe_schema_xptr, "nanoarrow_schema")) { return maybe_schema_xptr; } else { return R_NilValue; } } static SEXP borrow_array_xptr(struct ArrowArray* array, SEXP shelter) { SEXP array_xptr = PROTECT(R_MakeExternalPtr(array, R_NilValue, shelter)); Rf_setAttrib(array_xptr, R_ClassSymbol, nanoarrow_cls_array); UNPROTECT(1); return array_xptr; } SEXP borrow_array_child_xptr(SEXP array_xptr, int64_t i) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); SEXP schema_xptr = R_ExternalPtrTag(array_xptr); SEXP child_xptr = PROTECT(borrow_array_xptr(array->children[i], array_xptr)); if (schema_xptr != R_NilValue) { array_xptr_set_schema(child_xptr, borrow_schema_child_xptr(schema_xptr, i)); } UNPROTECT(1); return child_xptr; } static SEXP borrow_array_view_child(struct ArrowArrayView* array_view, int64_t i, SEXP shelter) { if (array_view != NULL) { return R_MakeExternalPtr(array_view->children[i], R_NilValue, shelter); } else { return R_NilValue; } } static SEXP borrow_array_view_dictionary(struct ArrowArrayView* array_view, SEXP shelter) { if (array_view != NULL) { return R_MakeExternalPtr(array_view->dictionary, R_NilValue, shelter); } else { return R_NilValue; } } static SEXP borrow_unknown_buffer(struct ArrowArray* array, int64_t i, SEXP shelter) { return buffer_borrowed_xptr(array->buffers[i], 0, shelter); } static SEXP borrow_buffer(struct ArrowArrayView* array_view, int64_t i, SEXP shelter) { SEXP buffer_class = PROTECT(Rf_allocVector(STRSXP, 2)); SET_STRING_ELT(buffer_class, 1, Rf_mkChar("nanoarrow_buffer")); struct ArrowBufferView view = ArrowArrayViewGetBufferView(array_view, i); enum ArrowBufferType buffer_type = ArrowArrayViewGetBufferType(array_view, i); enum ArrowType data_type = ArrowArrayViewGetBufferDataType(array_view, i); int64_t element_size_bits = ArrowArrayViewGetBufferElementSizeBits(array_view, i); SEXP buffer_xptr = PROTECT(buffer_borrowed_xptr(view.data.data, view.size_bytes, shelter)); buffer_borrowed_xptr_set_type(buffer_xptr, buffer_type, data_type, element_size_bits); UNPROTECT(2); return buffer_xptr; } SEXP nanoarrow_c_array_proxy(SEXP array_xptr, SEXP array_view_xptr, SEXP recursive_sexp) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); int recursive = LOGICAL(recursive_sexp)[0]; struct ArrowArrayView* array_view = NULL; if (array_view_xptr != R_NilValue) { array_view = (struct ArrowArrayView*)R_ExternalPtrAddr(array_view_xptr); } const char* names[] = {"length", "null_count", "offset", "buffers", "children", "dictionary", ""}; SEXP array_proxy = PROTECT(Rf_mkNamed(VECSXP, names)); SET_VECTOR_ELT(array_proxy, 0, length_sexp_from_int64(array->length)); SET_VECTOR_ELT(array_proxy, 1, length_sexp_from_int64(array->null_count)); SET_VECTOR_ELT(array_proxy, 2, length_sexp_from_int64(array->offset)); if (array->n_buffers > 0) { SEXP buffers = PROTECT(Rf_allocVector(VECSXP, array->n_buffers)); for (int64_t i = 0; i < array->n_buffers; i++) { if (array_view != NULL) { SET_VECTOR_ELT(buffers, i, borrow_buffer(array_view, i, array_xptr)); } else { SET_VECTOR_ELT(buffers, i, borrow_unknown_buffer(array, i, array_xptr)); } } SET_VECTOR_ELT(array_proxy, 3, buffers); UNPROTECT(1); } if (array->n_children > 0) { SEXP children = PROTECT(Rf_allocVector(VECSXP, array->n_children)); for (int64_t i = 0; i < array->n_children; i++) { SEXP child = PROTECT(borrow_array_xptr(array->children[i], array_xptr)); if (recursive) { SEXP array_view_child = PROTECT(borrow_array_view_child(array_view, i, array_view_xptr)); SET_VECTOR_ELT(children, i, nanoarrow_c_array_proxy(child, array_view_child, recursive_sexp)); UNPROTECT(1); } else { SET_VECTOR_ELT(children, i, child); } UNPROTECT(1); } SET_VECTOR_ELT(array_proxy, 4, children); UNPROTECT(1); } if (array->dictionary != NULL) { SEXP dictionary_xptr = PROTECT(borrow_array_xptr(array->dictionary, array_xptr)); if (recursive) { SEXP dictionary_view_xptr = PROTECT(borrow_array_view_dictionary(array_view, array_view_xptr)); SEXP dictionary_proxy = PROTECT( nanoarrow_c_array_proxy(dictionary_xptr, dictionary_view_xptr, recursive_sexp)); SET_VECTOR_ELT(array_proxy, 5, dictionary_proxy); UNPROTECT(2); } else { SET_VECTOR_ELT(array_proxy, 5, dictionary_xptr); } UNPROTECT(1); } UNPROTECT(1); return array_proxy; } nanoarrow/src/nanoarrow_ipc.c0000644000176200001440000631773414702632113016100 0ustar liggesusers#ifndef FLATBUFFERS_COMMON_READER_H #define FLATBUFFERS_COMMON_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ /* Common FlatBuffers read functionality for C. */ #include "flatcc/flatcc_prologue.h" #include "flatcc/flatcc_flatbuffers.h" #define __flatbuffers_read_scalar_at_byteoffset(N, p, o) N ## _read_from_pe((uint8_t *)(p) + (o)) #define __flatbuffers_read_scalar(N, p) N ## _read_from_pe(p) #define __flatbuffers_read_vt(ID, offset, t)\ flatbuffers_voffset_t offset = 0;\ { flatbuffers_voffset_t id__tmp, *vt__tmp;\ FLATCC_ASSERT(t != 0 && "null pointer table access");\ id__tmp = ID;\ vt__tmp = (flatbuffers_voffset_t *)((uint8_t *)(t) -\ __flatbuffers_soffset_read_from_pe(t));\ if (__flatbuffers_voffset_read_from_pe(vt__tmp) >= sizeof(vt__tmp[0]) * (id__tmp + 3u)) {\ offset = __flatbuffers_voffset_read_from_pe(vt__tmp + id__tmp + 2);\ }\ } #define __flatbuffers_field_present(ID, t) { __flatbuffers_read_vt(ID, offset__tmp, t) return offset__tmp != 0; } #define __flatbuffers_scalar_field(T, ID, t)\ {\ __flatbuffers_read_vt(ID, offset__tmp, t)\ if (offset__tmp) {\ return (const T *)((uint8_t *)(t) + offset__tmp);\ }\ return 0;\ } #define __flatbuffers_define_scalar_field(ID, N, NK, TK, T, V)\ static inline T N ## _ ## NK ## _get(N ## _table_t t__tmp)\ { __flatbuffers_read_vt(ID, offset__tmp, t__tmp)\ return offset__tmp ? __flatbuffers_read_scalar_at_byteoffset(TK, t__tmp, offset__tmp) : V;\ }\ static inline T N ## _ ## NK(N ## _table_t t__tmp)\ { __flatbuffers_read_vt(ID, offset__tmp, t__tmp)\ return offset__tmp ? __flatbuffers_read_scalar_at_byteoffset(TK, t__tmp, offset__tmp) : V;\ }\ static inline const T *N ## _ ## NK ## _get_ptr(N ## _table_t t__tmp)\ __flatbuffers_scalar_field(T, ID, t__tmp)\ static inline int N ## _ ## NK ## _is_present(N ## _table_t t__tmp)\ __flatbuffers_field_present(ID, t__tmp)\ __flatbuffers_define_scan_by_scalar_field(N, NK, T) #define __flatbuffers_define_scalar_optional_field(ID, N, NK, TK, T, V)\ __flatbuffers_define_scalar_field(ID, N, NK, TK, T, V)\ static inline TK ## _option_t N ## _ ## NK ## _option(N ## _table_t t__tmp)\ { TK ## _option_t ret; __flatbuffers_read_vt(ID, offset__tmp, t__tmp)\ ret.is_null = offset__tmp == 0; ret.value = offset__tmp ?\ __flatbuffers_read_scalar_at_byteoffset(TK, t__tmp, offset__tmp) : V;\ return ret; } #define __flatbuffers_struct_field(T, ID, t, r)\ {\ __flatbuffers_read_vt(ID, offset__tmp, t)\ if (offset__tmp) {\ return (T)((uint8_t *)(t) + offset__tmp);\ }\ FLATCC_ASSERT(!(r) && "required field missing");\ return 0;\ } #define __flatbuffers_offset_field(T, ID, t, r, adjust)\ {\ flatbuffers_uoffset_t *elem__tmp;\ __flatbuffers_read_vt(ID, offset__tmp, t)\ if (offset__tmp) {\ elem__tmp = (flatbuffers_uoffset_t *)((uint8_t *)(t) + offset__tmp);\ /* Add sizeof so C api can have raw access past header field. */\ return (T)((uint8_t *)(elem__tmp) + adjust +\ __flatbuffers_uoffset_read_from_pe(elem__tmp));\ }\ FLATCC_ASSERT(!(r) && "required field missing");\ return 0;\ } #define __flatbuffers_vector_field(T, ID, t, r) __flatbuffers_offset_field(T, ID, t, r, sizeof(flatbuffers_uoffset_t)) #define __flatbuffers_table_field(T, ID, t, r) __flatbuffers_offset_field(T, ID, t, r, 0) #define __flatbuffers_define_struct_field(ID, N, NK, T, r)\ static inline T N ## _ ## NK ## _get(N ## _table_t t__tmp)\ __flatbuffers_struct_field(T, ID, t__tmp, r)\ static inline T N ## _ ## NK(N ## _table_t t__tmp)\ __flatbuffers_struct_field(T, ID, t__tmp, r)\ static inline int N ## _ ## NK ## _is_present(N ## _table_t t__tmp)\ __flatbuffers_field_present(ID, t__tmp) #define __flatbuffers_define_vector_field(ID, N, NK, T, r)\ static inline T N ## _ ## NK ## _get(N ## _table_t t__tmp)\ __flatbuffers_vector_field(T, ID, t__tmp, r)\ static inline T N ## _ ## NK(N ## _table_t t__tmp)\ __flatbuffers_vector_field(T, ID, t__tmp, r)\ static inline int N ## _ ## NK ## _is_present(N ## _table_t t__tmp)\ __flatbuffers_field_present(ID, t__tmp) #define __flatbuffers_define_table_field(ID, N, NK, T, r)\ static inline T N ## _ ## NK ## _get(N ## _table_t t__tmp)\ __flatbuffers_table_field(T, ID, t__tmp, r)\ static inline T N ## _ ## NK(N ## _table_t t__tmp)\ __flatbuffers_table_field(T, ID, t__tmp, r)\ static inline int N ## _ ## NK ## _is_present(N ## _table_t t__tmp)\ __flatbuffers_field_present(ID, t__tmp) #define __flatbuffers_define_string_field(ID, N, NK, r)\ static inline flatbuffers_string_t N ## _ ## NK ## _get(N ## _table_t t__tmp)\ __flatbuffers_vector_field(flatbuffers_string_t, ID, t__tmp, r)\ static inline flatbuffers_string_t N ## _ ## NK(N ## _table_t t__tmp)\ __flatbuffers_vector_field(flatbuffers_string_t, ID, t__tmp, r)\ static inline int N ## _ ## NK ## _is_present(N ## _table_t t__tmp)\ __flatbuffers_field_present(ID, t__tmp)\ __flatbuffers_define_scan_by_string_field(N, NK) #define __flatbuffers_vec_len(vec)\ { return (vec) ? (size_t)__flatbuffers_uoffset_read_from_pe((flatbuffers_uoffset_t *)vec - 1) : 0; } #define __flatbuffers_string_len(s) __flatbuffers_vec_len(s) static inline size_t flatbuffers_vec_len(const void *vec) __flatbuffers_vec_len(vec) #define __flatbuffers_scalar_vec_at(N, vec, i)\ { FLATCC_ASSERT(flatbuffers_vec_len(vec) > (i) && "index out of range");\ return __flatbuffers_read_scalar(N, &(vec)[i]); } #define __flatbuffers_struct_vec_at(vec, i)\ { FLATCC_ASSERT(flatbuffers_vec_len(vec) > (i) && "index out of range"); return (vec) + (i); } /* `adjust` skips past the header for string vectors. */ #define __flatbuffers_offset_vec_at(T, vec, i, adjust)\ { const flatbuffers_uoffset_t *elem__tmp = (vec) + (i);\ FLATCC_ASSERT(flatbuffers_vec_len(vec) > (i) && "index out of range");\ return (T)((uint8_t *)(elem__tmp) + (size_t)__flatbuffers_uoffset_read_from_pe(elem__tmp) + (adjust)); } #define __flatbuffers_define_scalar_vec_len(N)\ static inline size_t N ## _vec_len(N ##_vec_t vec__tmp)\ { return flatbuffers_vec_len(vec__tmp); } #define __flatbuffers_define_scalar_vec_at(N, T) \ static inline T N ## _vec_at(N ## _vec_t vec__tmp, size_t i__tmp)\ __flatbuffers_scalar_vec_at(N, vec__tmp, i__tmp) typedef const char *flatbuffers_string_t; static inline size_t flatbuffers_string_len(flatbuffers_string_t s) __flatbuffers_string_len(s) typedef const flatbuffers_uoffset_t *flatbuffers_string_vec_t; typedef flatbuffers_uoffset_t *flatbuffers_string_mutable_vec_t; static inline size_t flatbuffers_string_vec_len(flatbuffers_string_vec_t vec) __flatbuffers_vec_len(vec) static inline flatbuffers_string_t flatbuffers_string_vec_at(flatbuffers_string_vec_t vec, size_t i) __flatbuffers_offset_vec_at(flatbuffers_string_t, vec, i, sizeof(vec[0])) typedef const void *flatbuffers_generic_t; typedef void *flatbuffers_mutable_generic_t; static inline flatbuffers_string_t flatbuffers_string_cast_from_generic(const flatbuffers_generic_t p) { return p ? ((const char *)p) + __flatbuffers_uoffset__size() : 0; } typedef const flatbuffers_uoffset_t *flatbuffers_generic_vec_t; typedef flatbuffers_uoffset_t *flatbuffers_generic_table_mutable_vec_t; static inline size_t flatbuffers_generic_vec_len(flatbuffers_generic_vec_t vec) __flatbuffers_vec_len(vec) static inline flatbuffers_generic_t flatbuffers_generic_vec_at(flatbuffers_generic_vec_t vec, size_t i) __flatbuffers_offset_vec_at(flatbuffers_generic_t, vec, i, 0) static inline flatbuffers_generic_t flatbuffers_generic_vec_at_as_string(flatbuffers_generic_vec_t vec, size_t i) __flatbuffers_offset_vec_at(flatbuffers_generic_t, vec, i, sizeof(vec[0])) typedef struct flatbuffers_union { flatbuffers_union_type_t type; flatbuffers_generic_t value; } flatbuffers_union_t; typedef struct flatbuffers_union_vec { const flatbuffers_union_type_t *type; const flatbuffers_uoffset_t *value; } flatbuffers_union_vec_t; typedef struct flatbuffers_mutable_union { flatbuffers_union_type_t type; flatbuffers_mutable_generic_t value; } flatbuffers_mutable_union_t; typedef struct flatbuffers_mutable_union_vec { flatbuffers_union_type_t *type; flatbuffers_uoffset_t *value; } flatbuffers_mutable_union_vec_t; static inline flatbuffers_mutable_union_t flatbuffers_mutable_union_cast(flatbuffers_union_t u__tmp)\ { flatbuffers_mutable_union_t mu = { u__tmp.type, (flatbuffers_mutable_generic_t)u__tmp.value };\ return mu; } static inline flatbuffers_mutable_union_vec_t flatbuffers_mutable_union_vec_cast(flatbuffers_union_vec_t uv__tmp)\ { flatbuffers_mutable_union_vec_t muv =\ { (flatbuffers_union_type_t *)uv__tmp.type, (flatbuffers_uoffset_t *)uv__tmp.value }; return muv; } #define __flatbuffers_union_type_field(ID, t)\ {\ __flatbuffers_read_vt(ID, offset__tmp, t)\ return offset__tmp ? __flatbuffers_read_scalar_at_byteoffset(__flatbuffers_utype, t, offset__tmp) : 0;\ } static inline flatbuffers_string_t flatbuffers_string_cast_from_union(const flatbuffers_union_t u__tmp)\ { return flatbuffers_string_cast_from_generic(u__tmp.value); } #define __flatbuffers_define_union_field(NS, ID, N, NK, T, r)\ static inline T ## _union_type_t N ## _ ## NK ## _type_get(N ## _table_t t__tmp)\ __## NS ## union_type_field(((ID) - 1), t__tmp)\ static inline NS ## generic_t N ## _ ## NK ## _get(N ## _table_t t__tmp)\ __## NS ## table_field(NS ## generic_t, ID, t__tmp, r)\ static inline T ## _union_type_t N ## _ ## NK ## _type(N ## _table_t t__tmp)\ __## NS ## union_type_field(((ID) - 1), t__tmp)\ static inline NS ## generic_t N ## _ ## NK(N ## _table_t t__tmp)\ __## NS ## table_field(NS ## generic_t, ID, t__tmp, r)\ static inline int N ## _ ## NK ## _is_present(N ## _table_t t__tmp)\ __## NS ## field_present(ID, t__tmp)\ static inline T ## _union_t N ## _ ## NK ## _union(N ## _table_t t__tmp)\ { T ## _union_t u__tmp = { 0, 0 }; u__tmp.type = N ## _ ## NK ## _type_get(t__tmp);\ if (u__tmp.type == 0) return u__tmp; u__tmp.value = N ## _ ## NK ## _get(t__tmp); return u__tmp; }\ static inline NS ## string_t N ## _ ## NK ## _as_string(N ## _table_t t__tmp)\ { return NS ## string_cast_from_generic(N ## _ ## NK ## _get(t__tmp)); }\ #define __flatbuffers_define_union_vector_ops(NS, T)\ static inline size_t T ## _union_vec_len(T ## _union_vec_t uv__tmp)\ { return NS ## vec_len(uv__tmp.type); }\ static inline T ## _union_t T ## _union_vec_at(T ## _union_vec_t uv__tmp, size_t i__tmp)\ { T ## _union_t u__tmp = { 0, 0 }; size_t n__tmp = NS ## vec_len(uv__tmp.type);\ FLATCC_ASSERT(n__tmp > (i__tmp) && "index out of range"); u__tmp.type = uv__tmp.type[i__tmp];\ /* Unknown type is treated as NONE for schema evolution. */\ if (u__tmp.type == 0) return u__tmp;\ u__tmp.value = NS ## generic_vec_at(uv__tmp.value, i__tmp); return u__tmp; }\ static inline NS ## string_t T ## _union_vec_at_as_string(T ## _union_vec_t uv__tmp, size_t i__tmp)\ { return (NS ## string_t) NS ## generic_vec_at_as_string(uv__tmp.value, i__tmp); }\ #define __flatbuffers_define_union_vector(NS, T)\ typedef NS ## union_vec_t T ## _union_vec_t;\ typedef NS ## mutable_union_vec_t T ## _mutable_union_vec_t;\ static inline T ## _mutable_union_vec_t T ## _mutable_union_vec_cast(T ## _union_vec_t u__tmp)\ { return NS ## mutable_union_vec_cast(u__tmp); }\ __## NS ## define_union_vector_ops(NS, T) #define __flatbuffers_define_union(NS, T)\ typedef NS ## union_t T ## _union_t;\ typedef NS ## mutable_union_t T ## _mutable_union_t;\ static inline T ## _mutable_union_t T ## _mutable_union_cast(T ## _union_t u__tmp)\ { return NS ## mutable_union_cast(u__tmp); }\ __## NS ## define_union_vector(NS, T) #define __flatbuffers_define_union_vector_field(NS, ID, N, NK, T, r)\ __## NS ## define_vector_field(ID - 1, N, NK ## _type, T ## _vec_t, r)\ __## NS ## define_vector_field(ID, N, NK, flatbuffers_generic_vec_t, r)\ static inline T ## _union_vec_t N ## _ ## NK ## _union(N ## _table_t t__tmp)\ { T ## _union_vec_t uv__tmp; uv__tmp.type = N ## _ ## NK ## _type_get(t__tmp);\ uv__tmp.value = N ## _ ## NK(t__tmp);\ FLATCC_ASSERT(NS ## vec_len(uv__tmp.type) == NS ## vec_len(uv__tmp.value)\ && "union vector type length mismatch"); return uv__tmp; } #include static const size_t flatbuffers_not_found = (size_t)-1; static const size_t flatbuffers_end = (size_t)-1; #define __flatbuffers_identity(n) (n) #define __flatbuffers_min(a, b) ((a) < (b) ? (a) : (b)) /* Subtraction doesn't work for unsigned types. */ #define __flatbuffers_scalar_cmp(x, y, n) ((x) < (y) ? -1 : (x) > (y)) static inline int __flatbuffers_string_n_cmp(flatbuffers_string_t v, const char *s, size_t n) { size_t nv = flatbuffers_string_len(v); int x = strncmp(v, s, nv < n ? nv : n); return x != 0 ? x : nv < n ? -1 : nv > n; } /* `n` arg unused, but needed by string find macro expansion. */ static inline int __flatbuffers_string_cmp(flatbuffers_string_t v, const char *s, size_t n) { (void)n; return strcmp(v, s); } /* A = identity if searching scalar vectors rather than key fields. */ /* Returns lowest matching index or not_found. */ #define __flatbuffers_find_by_field(A, V, E, L, K, Kn, T, D)\ { T v__tmp; size_t a__tmp = 0, b__tmp, m__tmp; if (!(b__tmp = L(V))) { return flatbuffers_not_found; }\ --b__tmp;\ while (a__tmp < b__tmp) {\ m__tmp = a__tmp + ((b__tmp - a__tmp) >> 1);\ v__tmp = A(E(V, m__tmp));\ if ((D(v__tmp, (K), (Kn))) < 0) {\ a__tmp = m__tmp + 1;\ } else {\ b__tmp = m__tmp;\ }\ }\ if (a__tmp == b__tmp) {\ v__tmp = A(E(V, a__tmp));\ if (D(v__tmp, (K), (Kn)) == 0) {\ return a__tmp;\ }\ }\ return flatbuffers_not_found;\ } #define __flatbuffers_find_by_scalar_field(A, V, E, L, K, T)\ __flatbuffers_find_by_field(A, V, E, L, K, 0, T, __flatbuffers_scalar_cmp) #define __flatbuffers_find_by_string_field(A, V, E, L, K)\ __flatbuffers_find_by_field(A, V, E, L, K, 0, flatbuffers_string_t, __flatbuffers_string_cmp) #define __flatbuffers_find_by_string_n_field(A, V, E, L, K, Kn)\ __flatbuffers_find_by_field(A, V, E, L, K, Kn, flatbuffers_string_t, __flatbuffers_string_n_cmp) #define __flatbuffers_define_find_by_scalar_field(N, NK, TK)\ static inline size_t N ## _vec_find_by_ ## NK(N ## _vec_t vec__tmp, TK key__tmp)\ __flatbuffers_find_by_scalar_field(N ## _ ## NK, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, TK) #define __flatbuffers_define_scalar_find(N, T)\ static inline size_t N ## _vec_find(N ## _vec_t vec__tmp, T key__tmp)\ __flatbuffers_find_by_scalar_field(__flatbuffers_identity, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T) #define __flatbuffers_define_find_by_string_field(N, NK) \ /* Note: find only works on vectors sorted by this field. */\ static inline size_t N ## _vec_find_by_ ## NK(N ## _vec_t vec__tmp, const char *s__tmp)\ __flatbuffers_find_by_string_field(N ## _ ## NK, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp)\ static inline size_t N ## _vec_find_n_by_ ## NK(N ## _vec_t vec__tmp, const char *s__tmp, size_t n__tmp)\ __flatbuffers_find_by_string_n_field(N ## _ ## NK, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp, n__tmp) #define __flatbuffers_define_default_find_by_scalar_field(N, NK, TK)\ static inline size_t N ## _vec_find(N ## _vec_t vec__tmp, TK key__tmp)\ { return N ## _vec_find_by_ ## NK(vec__tmp, key__tmp); } #define __flatbuffers_define_default_find_by_string_field(N, NK) \ static inline size_t N ## _vec_find(N ## _vec_t vec__tmp, const char *s__tmp)\ { return N ## _vec_find_by_ ## NK(vec__tmp, s__tmp); }\ static inline size_t N ## _vec_find_n(N ## _vec_t vec__tmp, const char *s__tmp, size_t n__tmp)\ { return N ## _vec_find_n_by_ ## NK(vec__tmp, s__tmp, n__tmp); } /* A = identity if searching scalar vectors rather than key fields. */ /* Returns lowest matching index or not_found. */ #define __flatbuffers_scan_by_field(b, e, A, V, E, L, K, Kn, T, D)\ { T v__tmp; size_t i__tmp;\ for (i__tmp = b; i__tmp < e; ++i__tmp) {\ v__tmp = A(E(V, i__tmp));\ if (D(v__tmp, (K), (Kn)) == 0) {\ return i__tmp;\ }\ }\ return flatbuffers_not_found;\ } #define __flatbuffers_rscan_by_field(b, e, A, V, E, L, K, Kn, T, D)\ { T v__tmp; size_t i__tmp = e;\ while (i__tmp-- > b) {\ v__tmp = A(E(V, i__tmp));\ if (D(v__tmp, (K), (Kn)) == 0) {\ return i__tmp;\ }\ }\ return flatbuffers_not_found;\ } #define __flatbuffers_scan_by_scalar_field(b, e, A, V, E, L, K, T)\ __flatbuffers_scan_by_field(b, e, A, V, E, L, K, 0, T, __flatbuffers_scalar_cmp) #define __flatbuffers_scan_by_string_field(b, e, A, V, E, L, K)\ __flatbuffers_scan_by_field(b, e, A, V, E, L, K, 0, flatbuffers_string_t, __flatbuffers_string_cmp) #define __flatbuffers_scan_by_string_n_field(b, e, A, V, E, L, K, Kn)\ __flatbuffers_scan_by_field(b, e, A, V, E, L, K, Kn, flatbuffers_string_t, __flatbuffers_string_n_cmp) #define __flatbuffers_rscan_by_scalar_field(b, e, A, V, E, L, K, T)\ __flatbuffers_rscan_by_field(b, e, A, V, E, L, K, 0, T, __flatbuffers_scalar_cmp) #define __flatbuffers_rscan_by_string_field(b, e, A, V, E, L, K)\ __flatbuffers_rscan_by_field(b, e, A, V, E, L, K, 0, flatbuffers_string_t, __flatbuffers_string_cmp) #define __flatbuffers_rscan_by_string_n_field(b, e, A, V, E, L, K, Kn)\ __flatbuffers_rscan_by_field(b, e, A, V, E, L, K, Kn, flatbuffers_string_t, __flatbuffers_string_n_cmp) #define __flatbuffers_define_scan_by_scalar_field(N, NK, T)\ static inline size_t N ## _vec_scan_by_ ## NK(N ## _vec_t vec__tmp, T key__tmp)\ __flatbuffers_scan_by_scalar_field(0, N ## _vec_len(vec__tmp), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T)\ static inline size_t N ## _vec_scan_ex_by_ ## NK(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, T key__tmp)\ __flatbuffers_scan_by_scalar_field(begin__tmp, __flatbuffers_min(end__tmp, N ## _vec_len(vec__tmp)), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T)\ static inline size_t N ## _vec_rscan_by_ ## NK(N ## _vec_t vec__tmp, T key__tmp)\ __flatbuffers_rscan_by_scalar_field(0, N ## _vec_len(vec__tmp), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T)\ static inline size_t N ## _vec_rscan_ex_by_ ## NK(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, T key__tmp)\ __flatbuffers_rscan_by_scalar_field(begin__tmp, __flatbuffers_min(end__tmp, N ## _vec_len(vec__tmp)), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T) #define __flatbuffers_define_scalar_scan(N, T)\ static inline size_t N ## _vec_scan(N ## _vec_t vec__tmp, T key__tmp)\ __flatbuffers_scan_by_scalar_field(0, N ## _vec_len(vec__tmp), __flatbuffers_identity, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T)\ static inline size_t N ## _vec_scan_ex(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, T key__tmp)\ __flatbuffers_scan_by_scalar_field(begin__tmp, __flatbuffers_min(end__tmp, N ## _vec_len(vec__tmp)), __flatbuffers_identity, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T)\ static inline size_t N ## _vec_rscan(N ## _vec_t vec__tmp, T key__tmp)\ __flatbuffers_rscan_by_scalar_field(0, N ## _vec_len(vec__tmp), __flatbuffers_identity, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T)\ static inline size_t N ## _vec_rscan_ex(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, T key__tmp)\ __flatbuffers_rscan_by_scalar_field(begin__tmp, __flatbuffers_min(end__tmp, N ## _vec_len(vec__tmp)), __flatbuffers_identity, vec__tmp, N ## _vec_at, N ## _vec_len, key__tmp, T) #define __flatbuffers_define_scan_by_string_field(N, NK) \ static inline size_t N ## _vec_scan_by_ ## NK(N ## _vec_t vec__tmp, const char *s__tmp)\ __flatbuffers_scan_by_string_field(0, N ## _vec_len(vec__tmp), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp)\ static inline size_t N ## _vec_scan_n_by_ ## NK(N ## _vec_t vec__tmp, const char *s__tmp, size_t n__tmp)\ __flatbuffers_scan_by_string_n_field(0, N ## _vec_len(vec__tmp), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp, n__tmp)\ static inline size_t N ## _vec_scan_ex_by_ ## NK(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp)\ __flatbuffers_scan_by_string_field(begin__tmp, __flatbuffers_min(end__tmp, N ## _vec_len(vec__tmp)), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp)\ static inline size_t N ## _vec_scan_ex_n_by_ ## NK(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp, size_t n__tmp)\ __flatbuffers_scan_by_string_n_field(begin__tmp, __flatbuffers_min( end__tmp, N ## _vec_len(vec__tmp)), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp, n__tmp)\ static inline size_t N ## _vec_rscan_by_ ## NK(N ## _vec_t vec__tmp, const char *s__tmp)\ __flatbuffers_rscan_by_string_field(0, N ## _vec_len(vec__tmp), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp)\ static inline size_t N ## _vec_rscan_n_by_ ## NK(N ## _vec_t vec__tmp, const char *s__tmp, size_t n__tmp)\ __flatbuffers_rscan_by_string_n_field(0, N ## _vec_len(vec__tmp), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp, n__tmp)\ static inline size_t N ## _vec_rscan_ex_by_ ## NK(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp)\ __flatbuffers_rscan_by_string_field(begin__tmp, __flatbuffers_min(end__tmp, N ## _vec_len(vec__tmp)), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp)\ static inline size_t N ## _vec_rscan_ex_n_by_ ## NK(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp, size_t n__tmp)\ __flatbuffers_rscan_by_string_n_field(begin__tmp, __flatbuffers_min( end__tmp, N ## _vec_len(vec__tmp)), N ## _ ## NK ## _get, vec__tmp, N ## _vec_at, N ## _vec_len, s__tmp, n__tmp) #define __flatbuffers_define_default_scan_by_scalar_field(N, NK, TK)\ static inline size_t N ## _vec_scan(N ## _vec_t vec__tmp, TK key__tmp)\ { return N ## _vec_scan_by_ ## NK(vec__tmp, key__tmp); }\ static inline size_t N ## _vec_scan_ex(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, TK key__tmp)\ { return N ## _vec_scan_ex_by_ ## NK(vec__tmp, begin__tmp, end__tmp, key__tmp); }\ static inline size_t N ## _vec_rscan(N ## _vec_t vec__tmp, TK key__tmp)\ { return N ## _vec_rscan_by_ ## NK(vec__tmp, key__tmp); }\ static inline size_t N ## _vec_rscan_ex(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, TK key__tmp)\ { return N ## _vec_rscan_ex_by_ ## NK(vec__tmp, begin__tmp, end__tmp, key__tmp); } #define __flatbuffers_define_default_scan_by_string_field(N, NK) \ static inline size_t N ## _vec_scan(N ## _vec_t vec__tmp, const char *s__tmp)\ { return N ## _vec_scan_by_ ## NK(vec__tmp, s__tmp); }\ static inline size_t N ## _vec_scan_n(N ## _vec_t vec__tmp, const char *s__tmp, size_t n__tmp)\ { return N ## _vec_scan_n_by_ ## NK(vec__tmp, s__tmp, n__tmp); }\ static inline size_t N ## _vec_scan_ex(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp)\ { return N ## _vec_scan_ex_by_ ## NK(vec__tmp, begin__tmp, end__tmp, s__tmp); }\ static inline size_t N ## _vec_scan_ex_n(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp, size_t n__tmp)\ { return N ## _vec_scan_ex_n_by_ ## NK(vec__tmp, begin__tmp, end__tmp, s__tmp, n__tmp); }\ static inline size_t N ## _vec_rscan(N ## _vec_t vec__tmp, const char *s__tmp)\ { return N ## _vec_rscan_by_ ## NK(vec__tmp, s__tmp); }\ static inline size_t N ## _vec_rscan_n(N ## _vec_t vec__tmp, const char *s__tmp, size_t n__tmp)\ { return N ## _vec_rscan_n_by_ ## NK(vec__tmp, s__tmp, n__tmp); }\ static inline size_t N ## _vec_rscan_ex(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp)\ { return N ## _vec_rscan_ex_by_ ## NK(vec__tmp, begin__tmp, end__tmp, s__tmp); }\ static inline size_t N ## _vec_rscan_ex_n(N ## _vec_t vec__tmp, size_t begin__tmp, size_t end__tmp, const char *s__tmp, size_t n__tmp)\ { return N ## _vec_rscan_ex_n_by_ ## NK(vec__tmp, begin__tmp, end__tmp, s__tmp, n__tmp); } #define __flatbuffers_heap_sort(N, X, A, E, L, TK, TE, D, S)\ static inline void __ ## N ## X ## __heap_sift_down(\ N ## _mutable_vec_t vec__tmp, size_t start__tmp, size_t end__tmp)\ { size_t child__tmp, root__tmp; TK v1__tmp, v2__tmp, vroot__tmp;\ root__tmp = start__tmp;\ while ((root__tmp << 1) <= end__tmp) {\ child__tmp = root__tmp << 1;\ if (child__tmp < end__tmp) {\ v1__tmp = A(E(vec__tmp, child__tmp));\ v2__tmp = A(E(vec__tmp, child__tmp + 1));\ if (D(v1__tmp, v2__tmp) < 0) {\ child__tmp++;\ }\ }\ vroot__tmp = A(E(vec__tmp, root__tmp));\ v1__tmp = A(E(vec__tmp, child__tmp));\ if (D(vroot__tmp, v1__tmp) < 0) {\ S(vec__tmp, root__tmp, child__tmp, TE);\ root__tmp = child__tmp;\ } else {\ return;\ }\ }\ }\ static inline void __ ## N ## X ## __heap_sort(N ## _mutable_vec_t vec__tmp)\ { size_t start__tmp, end__tmp, size__tmp;\ size__tmp = L(vec__tmp); if (size__tmp == 0) return; end__tmp = size__tmp - 1; start__tmp = size__tmp >> 1;\ do { __ ## N ## X ## __heap_sift_down(vec__tmp, start__tmp, end__tmp); } while (start__tmp--);\ while (end__tmp > 0) { \ S(vec__tmp, 0, end__tmp, TE);\ __ ## N ## X ## __heap_sift_down(vec__tmp, 0, --end__tmp); } } #define __flatbuffers_define_sort_by_field(N, NK, TK, TE, D, S)\ __flatbuffers_heap_sort(N, _sort_by_ ## NK, N ## _ ## NK ## _get, N ## _vec_at, N ## _vec_len, TK, TE, D, S)\ static inline void N ## _vec_sort_by_ ## NK(N ## _mutable_vec_t vec__tmp)\ { __ ## N ## _sort_by_ ## NK ## __heap_sort(vec__tmp); } #define __flatbuffers_define_sort(N, TK, TE, D, S)\ __flatbuffers_heap_sort(N, , __flatbuffers_identity, N ## _vec_at, N ## _vec_len, TK, TE, D, S)\ static inline void N ## _vec_sort(N ## _mutable_vec_t vec__tmp) { __ ## N ## __heap_sort(vec__tmp); } #define __flatbuffers_scalar_diff(x, y) ((x) < (y) ? -1 : (x) > (y)) #define __flatbuffers_string_diff(x, y) __flatbuffers_string_n_cmp((x), (const char *)(y), flatbuffers_string_len(y)) #define __flatbuffers_value_swap(vec, a, b, TE) { TE x__tmp = vec[b]; vec[b] = vec[a]; vec[a] = x__tmp; } #define __flatbuffers_uoffset_swap(vec, a, b, TE)\ { TE ta__tmp, tb__tmp, d__tmp;\ d__tmp = (TE)((a - b) * sizeof(vec[0]));\ ta__tmp = __flatbuffers_uoffset_read_from_pe(vec + b) - d__tmp;\ tb__tmp = __flatbuffers_uoffset_read_from_pe(vec + a) + d__tmp;\ __flatbuffers_uoffset_write_to_pe(vec + a, ta__tmp);\ __flatbuffers_uoffset_write_to_pe(vec + b, tb__tmp); } #define __flatbuffers_scalar_swap(vec, a, b, TE) __flatbuffers_value_swap(vec, a, b, TE) #define __flatbuffers_string_swap(vec, a, b, TE) __flatbuffers_uoffset_swap(vec, a, b, TE) #define __flatbuffers_struct_swap(vec, a, b, TE) __flatbuffers_value_swap(vec, a, b, TE) #define __flatbuffers_table_swap(vec, a, b, TE) __flatbuffers_uoffset_swap(vec, a, b, TE) #define __flatbuffers_define_struct_sort_by_scalar_field(N, NK, TK, TE)\ __flatbuffers_define_sort_by_field(N, NK, TK, TE, __flatbuffers_scalar_diff, __flatbuffers_struct_swap) #define __flatbuffers_define_table_sort_by_scalar_field(N, NK, TK)\ __flatbuffers_define_sort_by_field(N, NK, TK, flatbuffers_uoffset_t, __flatbuffers_scalar_diff, __flatbuffers_table_swap) #define __flatbuffers_define_table_sort_by_string_field(N, NK)\ __flatbuffers_define_sort_by_field(N, NK, flatbuffers_string_t, flatbuffers_uoffset_t, __flatbuffers_string_diff, __flatbuffers_table_swap) #define __flatbuffers_define_scalar_sort(N, T) __flatbuffers_define_sort(N, T, T, __flatbuffers_scalar_diff, __flatbuffers_scalar_swap) #define __flatbuffers_define_string_sort() __flatbuffers_define_sort(flatbuffers_string, flatbuffers_string_t, flatbuffers_uoffset_t, __flatbuffers_string_diff, __flatbuffers_string_swap) #define __flatbuffers_sort_vector_field(N, NK, T, t)\ { T ## _mutable_vec_t v__tmp = (T ## _mutable_vec_t) N ## _ ## NK ## _get(t);\ if (v__tmp) T ## _vec_sort(v__tmp); } #define __flatbuffers_sort_table_field(N, NK, T, t)\ { T ## _sort((T ## _mutable_table_t)N ## _ ## NK ## _get(t)); } #define __flatbuffers_sort_union_field(N, NK, T, t)\ { T ## _sort(T ## _mutable_union_cast(N ## _ ## NK ## _union(t))); } #define __flatbuffers_sort_table_vector_field_elements(N, NK, T, t)\ { T ## _vec_t v__tmp = N ## _ ## NK ## _get(t); size_t i__tmp, n__tmp;\ n__tmp = T ## _vec_len(v__tmp); for (i__tmp = 0; i__tmp < n__tmp; ++i__tmp) {\ T ## _sort((T ## _mutable_table_t)T ## _vec_at(v__tmp, i__tmp)); }} #define __flatbuffers_sort_union_vector_field_elements(N, NK, T, t)\ { T ## _union_vec_t v__tmp = N ## _ ## NK ## _union(t); size_t i__tmp, n__tmp;\ n__tmp = T ## _union_vec_len(v__tmp); for (i__tmp = 0; i__tmp < n__tmp; ++i__tmp) {\ T ## _sort(T ## _mutable_union_cast(T ## _union_vec_at(v__tmp, i__tmp))); }} #define __flatbuffers_define_scalar_vector(N, T)\ typedef const T *N ## _vec_t;\ typedef T *N ## _mutable_vec_t;\ __flatbuffers_define_scalar_vec_len(N)\ __flatbuffers_define_scalar_vec_at(N, T)\ __flatbuffers_define_scalar_find(N, T)\ __flatbuffers_define_scalar_scan(N, T)\ __flatbuffers_define_scalar_sort(N, T) #define __flatbuffers_define_integer_type(N, T, W)\ __flatcc_define_integer_accessors(N, T, W, flatbuffers_endian)\ __flatbuffers_define_scalar_vector(N, T) __flatbuffers_define_scalar_vector(flatbuffers_bool, flatbuffers_bool_t) __flatbuffers_define_scalar_vector(flatbuffers_char, char) __flatbuffers_define_scalar_vector(flatbuffers_uint8, uint8_t) __flatbuffers_define_scalar_vector(flatbuffers_int8, int8_t) __flatbuffers_define_scalar_vector(flatbuffers_uint16, uint16_t) __flatbuffers_define_scalar_vector(flatbuffers_int16, int16_t) __flatbuffers_define_scalar_vector(flatbuffers_uint32, uint32_t) __flatbuffers_define_scalar_vector(flatbuffers_int32, int32_t) __flatbuffers_define_scalar_vector(flatbuffers_uint64, uint64_t) __flatbuffers_define_scalar_vector(flatbuffers_int64, int64_t) __flatbuffers_define_scalar_vector(flatbuffers_float, float) __flatbuffers_define_scalar_vector(flatbuffers_double, double) __flatbuffers_define_scalar_vector(flatbuffers_union_type, flatbuffers_union_type_t) static inline size_t flatbuffers_string_vec_find(flatbuffers_string_vec_t vec, const char *s) __flatbuffers_find_by_string_field(__flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s) static inline size_t flatbuffers_string_vec_find_n(flatbuffers_string_vec_t vec, const char *s, size_t n) __flatbuffers_find_by_string_n_field(__flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s, n) static inline size_t flatbuffers_string_vec_scan(flatbuffers_string_vec_t vec, const char *s) __flatbuffers_scan_by_string_field(0, flatbuffers_string_vec_len(vec), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s) static inline size_t flatbuffers_string_vec_scan_n(flatbuffers_string_vec_t vec, const char *s, size_t n) __flatbuffers_scan_by_string_n_field(0, flatbuffers_string_vec_len(vec), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s, n) static inline size_t flatbuffers_string_vec_scan_ex(flatbuffers_string_vec_t vec, size_t begin, size_t end, const char *s) __flatbuffers_scan_by_string_field(begin, __flatbuffers_min(end, flatbuffers_string_vec_len(vec)), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s) static inline size_t flatbuffers_string_vec_scan_ex_n(flatbuffers_string_vec_t vec, size_t begin, size_t end, const char *s, size_t n) __flatbuffers_scan_by_string_n_field(begin, __flatbuffers_min(end, flatbuffers_string_vec_len(vec)), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s, n) static inline size_t flatbuffers_string_vec_rscan(flatbuffers_string_vec_t vec, const char *s) __flatbuffers_rscan_by_string_field(0, flatbuffers_string_vec_len(vec), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s) static inline size_t flatbuffers_string_vec_rscan_n(flatbuffers_string_vec_t vec, const char *s, size_t n) __flatbuffers_rscan_by_string_n_field(0, flatbuffers_string_vec_len(vec), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s, n) static inline size_t flatbuffers_string_vec_rscan_ex(flatbuffers_string_vec_t vec, size_t begin, size_t end, const char *s) __flatbuffers_rscan_by_string_field(begin, __flatbuffers_min(end, flatbuffers_string_vec_len(vec)), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s) static inline size_t flatbuffers_string_vec_rscan_ex_n(flatbuffers_string_vec_t vec, size_t begin, size_t end, const char *s, size_t n) __flatbuffers_rscan_by_string_n_field(begin, __flatbuffers_min(end, flatbuffers_string_vec_len(vec)), __flatbuffers_identity, vec, flatbuffers_string_vec_at, flatbuffers_string_vec_len, s, n) __flatbuffers_define_string_sort() #define __flatbuffers_define_struct_scalar_fixed_array_field(N, NK, TK, T, L)\ static inline T N ## _ ## NK ## _get(N ## _struct_t t__tmp, size_t i__tmp)\ { if (!t__tmp || i__tmp >= L) return 0;\ return __flatbuffers_read_scalar(TK, &(t__tmp->NK[i__tmp])); }\ static inline const T *N ## _ ## NK ## _get_ptr(N ## _struct_t t__tmp)\ { return t__tmp ? t__tmp->NK : 0; }\ static inline size_t N ## _ ## NK ## _get_len(void) { return L; }\ static inline T N ## _ ## NK (N ## _struct_t t__tmp, size_t i__tmp)\ { return N ## _ ## NK ## _get(t__tmp, i__tmp); } #define __flatbuffers_define_struct_struct_fixed_array_field(N, NK, T, L)\ static inline T N ## _ ## NK ## _get(N ## _struct_t t__tmp, size_t i__tmp)\ { if (!t__tmp || i__tmp >= L) return 0; return t__tmp->NK + i__tmp; }static inline T N ## _ ## NK ## _get_ptr(N ## _struct_t t__tmp)\ { return t__tmp ? t__tmp->NK : 0; }\ static inline size_t N ## _ ## NK ## _get_len(void) { return L; }\ static inline T N ## _ ## NK(N ## _struct_t t__tmp, size_t i__tmp)\ { if (!t__tmp || i__tmp >= L) return 0; return t__tmp->NK + i__tmp; } #define __flatbuffers_define_struct_scalar_field(N, NK, TK, T)\ static inline T N ## _ ## NK ## _get(N ## _struct_t t__tmp)\ { return t__tmp ? __flatbuffers_read_scalar(TK, &(t__tmp->NK)) : 0; }\ static inline const T *N ## _ ## NK ## _get_ptr(N ## _struct_t t__tmp)\ { return t__tmp ? &(t__tmp->NK) : 0; }\ static inline T N ## _ ## NK (N ## _struct_t t__tmp)\ { return t__tmp ? __flatbuffers_read_scalar(TK, &(t__tmp->NK)) : 0; }\ __flatbuffers_define_scan_by_scalar_field(N, NK, T) #define __flatbuffers_define_struct_struct_field(N, NK, T)\ static inline T N ## _ ## NK ## _get(N ## _struct_t t__tmp) { return t__tmp ? &(t__tmp->NK) : 0; }\ static inline T N ## _ ## NK (N ## _struct_t t__tmp) { return t__tmp ? &(t__tmp->NK) : 0; } /* If fid is null, the function returns true without testing as buffer is not expected to have any id. */ static inline int flatbuffers_has_identifier(const void *buffer, const char *fid) { flatbuffers_thash_t id, id2 = 0; if (fid == 0) { return 1; }; id2 = flatbuffers_type_hash_from_string(fid); id = __flatbuffers_thash_read_from_pe(((flatbuffers_uoffset_t *)buffer) + 1); return id2 == 0 || id == id2; } static inline int flatbuffers_has_type_hash(const void *buffer, flatbuffers_thash_t thash) { return thash == 0 || (__flatbuffers_thash_read_from_pe((flatbuffers_uoffset_t *)buffer + 1) == thash); } static inline flatbuffers_thash_t flatbuffers_get_type_hash(const void *buffer) { return __flatbuffers_thash_read_from_pe((flatbuffers_uoffset_t *)buffer + 1); } #define flatbuffers_verify_endian() flatbuffers_has_identifier("\x00\x00\x00\x00" "1234", "1234") static inline void *flatbuffers_read_size_prefix(void *b, size_t *size_out) { if (size_out) { *size_out = (size_t)__flatbuffers_uoffset_read_from_pe(b); } return (uint8_t *)b + sizeof(flatbuffers_uoffset_t); } /* Null file identifier accepts anything, otherwise fid should be 4 characters. */ #define __flatbuffers_read_root(T, K, buffer, fid)\ ((!buffer || !flatbuffers_has_identifier(buffer, fid)) ? 0 :\ ((T ## _ ## K ## t)(((uint8_t *)buffer) +\ __flatbuffers_uoffset_read_from_pe(buffer)))) #define __flatbuffers_read_typed_root(T, K, buffer, thash)\ ((!buffer || !flatbuffers_has_type_hash(buffer, thash)) ? 0 :\ ((T ## _ ## K ## t)(((uint8_t *)buffer) +\ __flatbuffers_uoffset_read_from_pe(buffer)))) #define __flatbuffers_nested_buffer_as_root(C, N, T, K)\ static inline T ## _ ## K ## t C ## _ ## N ## _as_root_with_identifier(C ## _ ## table_t t__tmp, const char *fid__tmp)\ { const uint8_t *buffer__tmp = C ## _ ## N(t__tmp); return __flatbuffers_read_root(T, K, buffer__tmp, fid__tmp); }\ static inline T ## _ ## K ## t C ## _ ## N ## _as_typed_root(C ## _ ## table_t t__tmp)\ { const uint8_t *buffer__tmp = C ## _ ## N(t__tmp); return __flatbuffers_read_root(T, K, buffer__tmp, C ## _ ## type_identifier); }\ static inline T ## _ ## K ## t C ## _ ## N ## _as_root(C ## _ ## table_t t__tmp)\ { const char *fid__tmp = T ## _file_identifier;\ const uint8_t *buffer__tmp = C ## _ ## N(t__tmp); return __flatbuffers_read_root(T, K, buffer__tmp, fid__tmp); } #define __flatbuffers_buffer_as_root(N, K)\ static inline N ## _ ## K ## t N ## _as_root_with_identifier(const void *buffer__tmp, const char *fid__tmp)\ { return __flatbuffers_read_root(N, K, buffer__tmp, fid__tmp); }\ static inline N ## _ ## K ## t N ## _as_root_with_type_hash(const void *buffer__tmp, flatbuffers_thash_t thash__tmp)\ { return __flatbuffers_read_typed_root(N, K, buffer__tmp, thash__tmp); }\ static inline N ## _ ## K ## t N ## _as_root(const void *buffer__tmp)\ { const char *fid__tmp = N ## _file_identifier;\ return __flatbuffers_read_root(N, K, buffer__tmp, fid__tmp); }\ static inline N ## _ ## K ## t N ## _as_typed_root(const void *buffer__tmp)\ { return __flatbuffers_read_typed_root(N, K, buffer__tmp, N ## _type_hash); } #define __flatbuffers_struct_as_root(N) __flatbuffers_buffer_as_root(N, struct_) #define __flatbuffers_table_as_root(N) __flatbuffers_buffer_as_root(N, table_) #include "flatcc/flatcc_epilogue.h" #endif /* FLATBUFFERS_COMMON_H */ #ifndef FLATBUFFERS_COMMON_BUILDER_H #define FLATBUFFERS_COMMON_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ /* Common FlatBuffers build functionality for C. */ #include "flatcc/flatcc_prologue.h" #ifndef FLATBUILDER_H #include "flatcc/flatcc_builder.h" #endif typedef flatcc_builder_t flatbuffers_builder_t; typedef flatcc_builder_ref_t flatbuffers_ref_t; typedef flatcc_builder_ref_t flatbuffers_vec_ref_t; typedef flatcc_builder_union_ref_t flatbuffers_union_ref_t; typedef flatcc_builder_union_vec_ref_t flatbuffers_union_vec_ref_t; /* integer return code (ref and ptr always fail on 0) */ #define flatbuffers_failed(x) ((x) < 0) typedef flatbuffers_ref_t flatbuffers_root_t; #define flatbuffers_root(ref) ((flatbuffers_root_t)(ref)) #define __flatbuffers_memoize_begin(B, src)\ do { flatcc_builder_ref_t _ref; if ((_ref = flatcc_builder_refmap_find((B), (src)))) return _ref; } while (0) #define __flatbuffers_memoize_end(B, src, op) do { return flatcc_builder_refmap_insert((B), (src), (op)); } while (0) #define __flatbuffers_memoize(B, src, op) do { __flatbuffers_memoize_begin(B, src); __flatbuffers_memoize_end(B, src, op); } while (0) #define __flatbuffers_build_buffer(NS)\ typedef NS ## ref_t NS ## buffer_ref_t;\ static inline int NS ## buffer_start(NS ## builder_t *B, const NS ##fid_t fid)\ { return flatcc_builder_start_buffer(B, fid, 0, 0); }\ static inline int NS ## buffer_start_with_size(NS ## builder_t *B, const NS ##fid_t fid)\ { return flatcc_builder_start_buffer(B, fid, 0, flatcc_builder_with_size); }\ static inline int NS ## buffer_start_aligned(NS ## builder_t *B, NS ##fid_t fid, uint16_t block_align)\ { return flatcc_builder_start_buffer(B, fid, block_align, 0); }\ static inline int NS ## buffer_start_aligned_with_size(NS ## builder_t *B, NS ##fid_t fid, uint16_t block_align)\ { return flatcc_builder_start_buffer(B, fid, block_align, flatcc_builder_with_size); }\ static inline NS ## buffer_ref_t NS ## buffer_end(NS ## builder_t *B, NS ## ref_t root)\ { return flatcc_builder_end_buffer(B, root); } #define __flatbuffers_build_table_root(NS, N, FID, TFID)\ static inline int N ## _start_as_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, FID) ? -1 : N ## _start(B); }\ static inline int N ## _start_as_root_with_size(NS ## builder_t *B)\ { return NS ## buffer_start_with_size(B, FID) ? -1 : N ## _start(B); }\ static inline int N ## _start_as_typed_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, TFID) ? -1 : N ## _start(B); }\ static inline int N ## _start_as_typed_root_with_size(NS ## builder_t *B)\ { return NS ## buffer_start_with_size(B, TFID) ? -1 : N ## _start(B); }\ static inline NS ## buffer_ref_t N ## _end_as_root(NS ## builder_t *B)\ { return NS ## buffer_end(B, N ## _end(B)); }\ static inline NS ## buffer_ref_t N ## _end_as_typed_root(NS ## builder_t *B)\ { return NS ## buffer_end(B, N ## _end(B)); }\ static inline NS ## buffer_ref_t N ## _create_as_root(NS ## builder_t *B __ ## N ## _formal_args)\ { if (NS ## buffer_start(B, FID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }\ static inline NS ## buffer_ref_t N ## _create_as_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\ { if (NS ## buffer_start_with_size(B, FID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }\ static inline NS ## buffer_ref_t N ## _create_as_typed_root(NS ## builder_t *B __ ## N ## _formal_args)\ { if (NS ## buffer_start(B, TFID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }\ static inline NS ## buffer_ref_t N ## _create_as_typed_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\ { if (NS ## buffer_start_with_size(B, TFID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }\ static inline NS ## buffer_ref_t N ## _clone_as_root(NS ## builder_t *B, N ## _table_t t)\ { if (NS ## buffer_start(B, FID)) return 0; return NS ## buffer_end(B, N ## _clone(B, t)); }\ static inline NS ## buffer_ref_t N ## _clone_as_root_with_size(NS ## builder_t *B, N ## _table_t t)\ { if (NS ## buffer_start_with_size(B, FID)) return 0; return NS ## buffer_end(B, N ## _clone(B, t)); }\ static inline NS ## buffer_ref_t N ## _clone_as_typed_root(NS ## builder_t *B, N ## _table_t t)\ { if (NS ## buffer_start(B, TFID)) return 0;return NS ## buffer_end(B, N ## _clone(B, t)); }\ static inline NS ## buffer_ref_t N ## _clone_as_typed_root_with_size(NS ## builder_t *B, N ## _table_t t)\ { if (NS ## buffer_start_with_size(B, TFID)) return 0; return NS ## buffer_end(B, N ## _clone(B, t)); } #define __flatbuffers_build_table_prolog(NS, N, FID, TFID)\ __flatbuffers_build_table_vector_ops(NS, N ## _vec, N)\ __flatbuffers_build_table_root(NS, N, FID, TFID) #define __flatbuffers_build_struct_root(NS, N, A, FID, TFID)\ static inline N ## _t *N ## _start_as_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, FID) ? 0 : N ## _start(B); }\ static inline N ## _t *N ## _start_as_root_with_size(NS ## builder_t *B)\ { return NS ## buffer_start_with_size(B, FID) ? 0 : N ## _start(B); }\ static inline N ## _t *N ## _start_as_typed_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, TFID) ? 0 : N ## _start(B); }\ static inline N ## _t *N ## _start_as_typed_root_with_size(NS ## builder_t *B)\ { return NS ## buffer_start_with_size(B, TFID) ? 0 : N ## _start(B); }\ static inline NS ## buffer_ref_t N ## _end_as_root(NS ## builder_t *B)\ { return NS ## buffer_end(B, N ## _end(B)); }\ static inline NS ## buffer_ref_t N ## _end_as_typed_root(NS ## builder_t *B)\ { return NS ## buffer_end(B, N ## _end(B)); }\ static inline NS ## buffer_ref_t N ## _end_pe_as_root(NS ## builder_t *B)\ { return NS ## buffer_end(B, N ## _end_pe(B)); }\ static inline NS ## buffer_ref_t N ## _end_pe_as_typed_root(NS ## builder_t *B)\ { return NS ## buffer_end(B, N ## _end_pe(B)); }\ static inline NS ## buffer_ref_t N ## _create_as_root(NS ## builder_t *B __ ## N ## _formal_args)\ { return flatcc_builder_create_buffer(B, FID, 0,\ N ## _create(B __ ## N ## _call_args), A, 0); }\ static inline NS ## buffer_ref_t N ## _create_as_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\ { return flatcc_builder_create_buffer(B, FID, 0,\ N ## _create(B __ ## N ## _call_args), A, flatcc_builder_with_size); }\ static inline NS ## buffer_ref_t N ## _create_as_typed_root(NS ## builder_t *B __ ## N ## _formal_args)\ { return flatcc_builder_create_buffer(B, TFID, 0,\ N ## _create(B __ ## N ## _call_args), A, 0); }\ static inline NS ## buffer_ref_t N ## _create_as_typed_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\ { return flatcc_builder_create_buffer(B, TFID, 0,\ N ## _create(B __ ## N ## _call_args), A, flatcc_builder_with_size); }\ static inline NS ## buffer_ref_t N ## _clone_as_root(NS ## builder_t *B, N ## _struct_t p)\ { return flatcc_builder_create_buffer(B, FID, 0, N ## _clone(B, p), A, 0); }\ static inline NS ## buffer_ref_t N ## _clone_as_root_with_size(NS ## builder_t *B, N ## _struct_t p)\ { return flatcc_builder_create_buffer(B, FID, 0, N ## _clone(B, p), A, flatcc_builder_with_size); }\ static inline NS ## buffer_ref_t N ## _clone_as_typed_root(NS ## builder_t *B, N ## _struct_t p)\ { return flatcc_builder_create_buffer(B, TFID, 0, N ## _clone(B, p), A, 0); }\ static inline NS ## buffer_ref_t N ## _clone_as_typed_root_with_size(NS ## builder_t *B, N ## _struct_t p)\ { return flatcc_builder_create_buffer(B, TFID, 0, N ## _clone(B, p), A, flatcc_builder_with_size); } #define __flatbuffers_build_nested_table_root(NS, N, TN, FID, TFID)\ static inline int N ## _start_as_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, FID) ? -1 : TN ## _start(B); }\ static inline int N ## _start_as_typed_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, TFID) ? -1 : TN ## _start(B); }\ static inline int N ## _end_as_root(NS ## builder_t *B)\ { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\ static inline int N ## _end_as_typed_root(NS ## builder_t *B)\ { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\ static inline int N ## _nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\ { return N ## _add(B, flatcc_builder_create_vector(B, data, size, 1,\ align ? align : 8, FLATBUFFERS_COUNT_MAX(1))); }\ static inline int N ## _typed_nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\ { return N ## _add(B, flatcc_builder_create_vector(B, data, size, 1,\ align ? align : 8, FLATBUFFERS_COUNT_MAX(1))); }\ static inline int N ## _clone_as_root(NS ## builder_t *B, TN ## _table_t t)\ { return N ## _add(B, TN ## _clone_as_root(B, t)); }\ static inline int N ## _clone_as_typed_root(NS ## builder_t *B, TN ## _table_t t)\ { return N ## _add(B, TN ## _clone_as_typed_root(B, t)); } #define __flatbuffers_build_nested_struct_root(NS, N, TN, A, FID, TFID)\ static inline TN ## _t *N ## _start_as_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, FID) ? 0 : TN ## _start(B); }\ static inline TN ## _t *N ## _start_as_typed_root(NS ## builder_t *B)\ { return NS ## buffer_start(B, FID) ? 0 : TN ## _start(B); }\ static inline int N ## _end_as_root(NS ## builder_t *B)\ { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\ static inline int N ## _end_as_typed_root(NS ## builder_t *B)\ { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\ static inline int N ## _end_pe_as_root(NS ## builder_t *B)\ { return N ## _add(B, NS ## buffer_end(B, TN ## _end_pe(B))); }\ static inline int N ## _create_as_root(NS ## builder_t *B __ ## TN ## _formal_args)\ { return N ## _add(B, flatcc_builder_create_buffer(B, FID, 0,\ TN ## _create(B __ ## TN ## _call_args), A, flatcc_builder_is_nested)); }\ static inline int N ## _create_as_typed_root(NS ## builder_t *B __ ## TN ## _formal_args)\ { return N ## _add(B, flatcc_builder_create_buffer(B, TFID, 0,\ TN ## _create(B __ ## TN ## _call_args), A, flatcc_builder_is_nested)); }\ static inline int N ## _nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\ { return N ## _add(B, flatcc_builder_create_vector(B, data, size, 1,\ align < A ? A : align, FLATBUFFERS_COUNT_MAX(1))); }\ static inline int N ## _typed_nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\ { return N ## _add(B, flatcc_builder_create_vector(B, data, size, 1,\ align < A ? A : align, FLATBUFFERS_COUNT_MAX(1))); }\ static inline int N ## _clone_as_root(NS ## builder_t *B, TN ## _struct_t p)\ { return N ## _add(B, TN ## _clone_as_root(B, p)); }\ static inline int N ## _clone_as_typed_root(NS ## builder_t *B, TN ## _struct_t p)\ { return N ## _add(B, TN ## _clone_as_typed_root(B, p)); } #define __flatbuffers_build_vector_ops(NS, V, N, TN, T)\ static inline T *V ## _extend(NS ## builder_t *B, size_t len)\ { return (T *)flatcc_builder_extend_vector(B, len); }\ static inline T *V ## _append(NS ## builder_t *B, const T *data, size_t len)\ { return (T *)flatcc_builder_append_vector(B, data, len); }\ static inline int V ## _truncate(NS ## builder_t *B, size_t len)\ { return flatcc_builder_truncate_vector(B, len); }\ static inline T *V ## _edit(NS ## builder_t *B)\ { return (T *)flatcc_builder_vector_edit(B); }\ static inline size_t V ## _reserved_len(NS ## builder_t *B)\ { return flatcc_builder_vector_count(B); }\ static inline T *V ## _push(NS ## builder_t *B, const T *p)\ { T *_p; return (_p = (T *)flatcc_builder_extend_vector(B, 1)) ? (memcpy(_p, p, TN ## __size()), _p) : 0; }\ static inline T *V ## _push_copy(NS ## builder_t *B, const T *p)\ { T *_p; return (_p = (T *)flatcc_builder_extend_vector(B, 1)) ? TN ## _copy(_p, p) : 0; }\ static inline T *V ## _push_clone(NS ## builder_t *B, const T *p)\ { T *_p; return (_p = (T *)flatcc_builder_extend_vector(B, 1)) ? TN ## _copy(_p, p) : 0; }\ static inline T *V ## _push_create(NS ## builder_t *B __ ## TN ## _formal_args)\ { T *_p; return (_p = (T *)flatcc_builder_extend_vector(B, 1)) ? TN ## _assign(_p __ ## TN ## _call_args) : 0; } #define __flatbuffers_build_vector(NS, N, T, S, A)\ typedef NS ## ref_t N ## _vec_ref_t;\ static inline int N ## _vec_start(NS ## builder_t *B)\ { return flatcc_builder_start_vector(B, S, A, FLATBUFFERS_COUNT_MAX(S)); }\ static inline N ## _vec_ref_t N ## _vec_end_pe(NS ## builder_t *B)\ { return flatcc_builder_end_vector(B); }\ static inline N ## _vec_ref_t N ## _vec_end(NS ## builder_t *B)\ { if (!NS ## is_native_pe()) { size_t i, n; T *p = (T *)flatcc_builder_vector_edit(B);\ for (i = 0, n = flatcc_builder_vector_count(B); i < n; ++i)\ { N ## _to_pe(N ## __ptr_add(p, i)); }} return flatcc_builder_end_vector(B); }\ static inline N ## _vec_ref_t N ## _vec_create_pe(NS ## builder_t *B, const T *data, size_t len)\ { return flatcc_builder_create_vector(B, data, len, S, A, FLATBUFFERS_COUNT_MAX(S)); }\ static inline N ## _vec_ref_t N ## _vec_create(NS ## builder_t *B, const T *data, size_t len)\ { if (!NS ## is_native_pe()) { size_t i; T *p; int ret = flatcc_builder_start_vector(B, S, A, FLATBUFFERS_COUNT_MAX(S)); if (ret) { return ret; }\ p = (T *)flatcc_builder_extend_vector(B, len); if (!p) return 0;\ for (i = 0; i < len; ++i) { N ## _copy_to_pe(N ## __ptr_add(p, i), N ## __const_ptr_add(data, i)); }\ return flatcc_builder_end_vector(B); } else return flatcc_builder_create_vector(B, data, len, S, A, FLATBUFFERS_COUNT_MAX(S)); }\ static inline N ## _vec_ref_t N ## _vec_clone(NS ## builder_t *B, N ##_vec_t vec)\ { __flatbuffers_memoize(B, vec, flatcc_builder_create_vector(B, vec, N ## _vec_len(vec), S, A, FLATBUFFERS_COUNT_MAX(S))); }\ static inline N ## _vec_ref_t N ## _vec_slice(NS ## builder_t *B, N ##_vec_t vec, size_t index, size_t len)\ { size_t n = N ## _vec_len(vec); if (index >= n) index = n; n -= index; if (len > n) len = n;\ return flatcc_builder_create_vector(B, N ## __const_ptr_add(vec, index), len, S, A, FLATBUFFERS_COUNT_MAX(S)); }\ __flatbuffers_build_vector_ops(NS, N ## _vec, N, N, T) #define __flatbuffers_build_union_vector_ops(NS, V, N, TN)\ static inline TN ## _union_ref_t *V ## _extend(NS ## builder_t *B, size_t len)\ { return flatcc_builder_extend_union_vector(B, len); }\ static inline TN ## _union_ref_t *V ## _append(NS ## builder_t *B, const TN ## _union_ref_t *data, size_t len)\ { return flatcc_builder_append_union_vector(B, data, len); }\ static inline int V ## _truncate(NS ## builder_t *B, size_t len)\ { return flatcc_builder_truncate_union_vector(B, len); }\ static inline TN ## _union_ref_t *V ## _edit(NS ## builder_t *B)\ { return (TN ## _union_ref_t *) flatcc_builder_union_vector_edit(B); }\ static inline size_t V ## _reserved_len(NS ## builder_t *B)\ { return flatcc_builder_union_vector_count(B); }\ static inline TN ## _union_ref_t *V ## _push(NS ## builder_t *B, const TN ## _union_ref_t ref)\ { return flatcc_builder_union_vector_push(B, ref); }\ static inline TN ## _union_ref_t *V ## _push_clone(NS ## builder_t *B, TN ## _union_t u)\ { return TN ## _vec_push(B, TN ## _clone(B, u)); } #define __flatbuffers_build_union_vector(NS, N)\ static inline int N ## _vec_start(NS ## builder_t *B)\ { return flatcc_builder_start_union_vector(B); }\ static inline N ## _union_vec_ref_t N ## _vec_end(NS ## builder_t *B)\ { return flatcc_builder_end_union_vector(B); }\ static inline N ## _union_vec_ref_t N ## _vec_create(NS ## builder_t *B, const N ## _union_ref_t *data, size_t len)\ { return flatcc_builder_create_union_vector(B, data, len); }\ __flatbuffers_build_union_vector_ops(NS, N ## _vec, N, N)\ /* Preserves DAG structure separately for type and value vector, so a type vector could be shared for many value vectors. */\ static inline N ## _union_vec_ref_t N ## _vec_clone(NS ## builder_t *B, N ##_union_vec_t vec)\ { N ## _union_vec_ref_t _uvref, _ret = { 0, 0 }; NS ## union_ref_t _uref; size_t _i, _len;\ if (vec.type == 0) return _ret;\ _uvref.type = flatcc_builder_refmap_find(B, vec.type); _uvref.value = flatcc_builder_refmap_find(B, vec.value);\ _len = N ## _union_vec_len(vec); if (_uvref.type == 0) {\ _uvref.type = flatcc_builder_refmap_insert(B, vec.type, (flatcc_builder_create_type_vector(B, vec.type, _len))); }\ if (_uvref.type == 0) return _ret; if (_uvref.value == 0) {\ if (flatcc_builder_start_offset_vector(B)) return _ret;\ for (_i = 0; _i < _len; ++_i) { _uref = N ## _clone(B, N ## _union_vec_at(vec, _i));\ if (!_uref.value || !(flatcc_builder_offset_vector_push(B, _uref.value))) return _ret; }\ _uvref.value = flatcc_builder_refmap_insert(B, vec.value, flatcc_builder_end_offset_vector(B));\ if (_uvref.value == 0) return _ret; } return _uvref; } #define __flatbuffers_build_string_vector_ops(NS, N)\ static inline int N ## _push_start(NS ## builder_t *B)\ { return NS ## string_start(B); }\ static inline NS ## string_ref_t *N ## _push_end(NS ## builder_t *B)\ { return NS ## string_vec_push(B, NS ## string_end(B)); }\ static inline NS ## string_ref_t *N ## _push_create(NS ## builder_t *B, const char *s, size_t len)\ { return NS ## string_vec_push(B, NS ## string_create(B, s, len)); }\ static inline NS ## string_ref_t *N ## _push_create_str(NS ## builder_t *B, const char *s)\ { return NS ## string_vec_push(B, NS ## string_create_str(B, s)); }\ static inline NS ## string_ref_t *N ## _push_create_strn(NS ## builder_t *B, const char *s, size_t max_len)\ { return NS ## string_vec_push(B, NS ## string_create_strn(B, s, max_len)); }\ static inline NS ## string_ref_t *N ## _push_clone(NS ## builder_t *B, NS ## string_t string)\ { return NS ## string_vec_push(B, NS ## string_clone(B, string)); }\ static inline NS ## string_ref_t *N ## _push_slice(NS ## builder_t *B, NS ## string_t string, size_t index, size_t len)\ { return NS ## string_vec_push(B, NS ## string_slice(B, string, index, len)); } #define __flatbuffers_build_table_vector_ops(NS, N, TN)\ static inline int N ## _push_start(NS ## builder_t *B)\ { return TN ## _start(B); }\ static inline TN ## _ref_t *N ## _push_end(NS ## builder_t *B)\ { return N ## _push(B, TN ## _end(B)); }\ static inline TN ## _ref_t *N ## _push_create(NS ## builder_t *B __ ## TN ##_formal_args)\ { return N ## _push(B, TN ## _create(B __ ## TN ## _call_args)); } #define __flatbuffers_build_offset_vector_ops(NS, V, N, TN)\ static inline TN ## _ref_t *V ## _extend(NS ## builder_t *B, size_t len)\ { return flatcc_builder_extend_offset_vector(B, len); }\ static inline TN ## _ref_t *V ## _append(NS ## builder_t *B, const TN ## _ref_t *data, size_t len)\ { return flatcc_builder_append_offset_vector(B, data, len); }\ static inline int V ## _truncate(NS ## builder_t *B, size_t len)\ { return flatcc_builder_truncate_offset_vector(B, len); }\ static inline TN ## _ref_t *V ## _edit(NS ## builder_t *B)\ { return (TN ## _ref_t *)flatcc_builder_offset_vector_edit(B); }\ static inline size_t V ## _reserved_len(NS ## builder_t *B)\ { return flatcc_builder_offset_vector_count(B); }\ static inline TN ## _ref_t *V ## _push(NS ## builder_t *B, const TN ## _ref_t ref)\ { return ref ? flatcc_builder_offset_vector_push(B, ref) : 0; } #define __flatbuffers_build_offset_vector(NS, N)\ typedef NS ## ref_t N ## _vec_ref_t;\ static inline int N ## _vec_start(NS ## builder_t *B)\ { return flatcc_builder_start_offset_vector(B); }\ static inline N ## _vec_ref_t N ## _vec_end(NS ## builder_t *B)\ { return flatcc_builder_end_offset_vector(B); }\ static inline N ## _vec_ref_t N ## _vec_create(NS ## builder_t *B, const N ## _ref_t *data, size_t len)\ { return flatcc_builder_create_offset_vector(B, data, len); }\ __flatbuffers_build_offset_vector_ops(NS, N ## _vec, N, N)\ static inline N ## _vec_ref_t N ## _vec_clone(NS ## builder_t *B, N ##_vec_t vec)\ { int _ret; N ## _ref_t _e; size_t _i, _len; __flatbuffers_memoize_begin(B, vec);\ _len = N ## _vec_len(vec); if (flatcc_builder_start_offset_vector(B)) return 0;\ for (_i = 0; _i < _len; ++_i) { if (!(_e = N ## _clone(B, N ## _vec_at(vec, _i)))) return 0;\ if (!flatcc_builder_offset_vector_push(B, _e)) return 0; }\ __flatbuffers_memoize_end(B, vec, flatcc_builder_end_offset_vector(B)); }\ #define __flatbuffers_build_string_ops(NS, N)\ static inline char *N ## _append(NS ## builder_t *B, const char *s, size_t len)\ { return flatcc_builder_append_string(B, s, len); }\ static inline char *N ## _append_str(NS ## builder_t *B, const char *s)\ { return flatcc_builder_append_string_str(B, s); }\ static inline char *N ## _append_strn(NS ## builder_t *B, const char *s, size_t len)\ { return flatcc_builder_append_string_strn(B, s, len); }\ static inline size_t N ## _reserved_len(NS ## builder_t *B)\ { return flatcc_builder_string_len(B); }\ static inline char *N ## _extend(NS ## builder_t *B, size_t len)\ { return flatcc_builder_extend_string(B, len); }\ static inline char *N ## _edit(NS ## builder_t *B)\ { return flatcc_builder_string_edit(B); }\ static inline int N ## _truncate(NS ## builder_t *B, size_t len)\ { return flatcc_builder_truncate_string(B, len); } #define __flatbuffers_build_string(NS)\ typedef NS ## ref_t NS ## string_ref_t;\ static inline int NS ## string_start(NS ## builder_t *B)\ { return flatcc_builder_start_string(B); }\ static inline NS ## string_ref_t NS ## string_end(NS ## builder_t *B)\ { return flatcc_builder_end_string(B); }\ static inline NS ## ref_t NS ## string_create(NS ## builder_t *B, const char *s, size_t len)\ { return flatcc_builder_create_string(B, s, len); }\ static inline NS ## ref_t NS ## string_create_str(NS ## builder_t *B, const char *s)\ { return flatcc_builder_create_string_str(B, s); }\ static inline NS ## ref_t NS ## string_create_strn(NS ## builder_t *B, const char *s, size_t len)\ { return flatcc_builder_create_string_strn(B, s, len); }\ static inline NS ## string_ref_t NS ## string_clone(NS ## builder_t *B, NS ## string_t string)\ { __flatbuffers_memoize(B, string, flatcc_builder_create_string(B, string, NS ## string_len(string))); }\ static inline NS ## string_ref_t NS ## string_slice(NS ## builder_t *B, NS ## string_t string, size_t index, size_t len)\ { size_t n = NS ## string_len(string); if (index >= n) index = n; n -= index; if (len > n) len = n;\ return flatcc_builder_create_string(B, string + index, len); }\ __flatbuffers_build_string_ops(NS, NS ## string)\ __flatbuffers_build_offset_vector(NS, NS ## string) #define __flatbuffers_copy_from_pe(P, P2, N) (*(P) = N ## _read_from_pe(P2), (P)) #define __flatbuffers_from_pe(P, N) (*(P) = N ## _read_from_pe(P), (P)) #define __flatbuffers_copy_to_pe(P, P2, N) (N ## _write_to_pe((P), *(P2)), (P)) #define __flatbuffers_to_pe(P, N) (N ## _write_to_pe((P), *(P)), (P)) #define __flatbuffers_define_fixed_array_primitives(NS, N, T)\ static inline T *N ## _array_copy(T *p, const T *p2, size_t n)\ { memcpy(p, p2, n * sizeof(T)); return p; }\ static inline T *N ## _array_copy_from_pe(T *p, const T *p2, size_t n)\ { size_t i; if (NS ## is_native_pe()) memcpy(p, p2, n * sizeof(T)); else\ for (i = 0; i < n; ++i) N ## _copy_from_pe(&p[i], &p2[i]); return p; }\ static inline T *N ## _array_copy_to_pe(T *p, const T *p2, size_t n)\ { size_t i; if (NS ## is_native_pe()) memcpy(p, p2, n * sizeof(T)); else\ for (i = 0; i < n; ++i) N ## _copy_to_pe(&p[i], &p2[i]); return p; } #define __flatbuffers_define_scalar_primitives(NS, N, T)\ static inline T *N ## _from_pe(T *p) { return __ ## NS ## from_pe(p, N); }\ static inline T *N ## _to_pe(T *p) { return __ ## NS ## to_pe(p, N); }\ static inline T *N ## _copy(T *p, const T *p2) { *p = *p2; return p; }\ static inline T *N ## _copy_from_pe(T *p, const T *p2)\ { return __ ## NS ## copy_from_pe(p, p2, N); }\ static inline T *N ## _copy_to_pe(T *p, const T *p2) \ { return __ ## NS ## copy_to_pe(p, p2, N); }\ static inline T *N ## _assign(T *p, const T v0) { *p = v0; return p; }\ static inline T *N ## _assign_from_pe(T *p, T v0)\ { *p = N ## _read_from_pe(&v0); return p; }\ static inline T *N ## _assign_to_pe(T *p, T v0)\ { N ## _write_to_pe(p, v0); return p; } #define __flatbuffers_build_scalar(NS, N, T)\ __ ## NS ## define_scalar_primitives(NS, N, T)\ __ ## NS ## define_fixed_array_primitives(NS, N, T)\ __ ## NS ## build_vector(NS, N, T, sizeof(T), sizeof(T)) /* Depends on generated copy_to/from_pe functions, and the type. */ #define __flatbuffers_define_struct_primitives(NS, N)\ static inline N ## _t *N ##_to_pe(N ## _t *p)\ { if (!NS ## is_native_pe()) { N ## _copy_to_pe(p, p); }; return p; }\ static inline N ## _t *N ##_from_pe(N ## _t *p)\ { if (!NS ## is_native_pe()) { N ## _copy_from_pe(p, p); }; return p; }\ static inline N ## _t *N ## _clear(N ## _t *p) { return (N ## _t *)memset(p, 0, N ## __size()); } /* Depends on generated copy/assign_to/from_pe functions, and the type. */ #define __flatbuffers_build_struct(NS, N, S, A, FID, TFID)\ __ ## NS ## define_struct_primitives(NS, N)\ typedef NS ## ref_t N ## _ref_t;\ static inline N ## _t *N ## _start(NS ## builder_t *B)\ { return (N ## _t *)flatcc_builder_start_struct(B, S, A); }\ static inline N ## _ref_t N ## _end(NS ## builder_t *B)\ { if (!NS ## is_native_pe()) { N ## _to_pe((N ## _t *)flatcc_builder_struct_edit(B)); }\ return flatcc_builder_end_struct(B); }\ static inline N ## _ref_t N ## _end_pe(NS ## builder_t *B)\ { return flatcc_builder_end_struct(B); }\ static inline N ## _ref_t N ## _create(NS ## builder_t *B __ ## N ## _formal_args)\ { N ## _t *_p = N ## _start(B); if (!_p) return 0; N ##_assign_to_pe(_p __ ## N ## _call_args);\ return N ## _end_pe(B); }\ static inline N ## _ref_t N ## _clone(NS ## builder_t *B, N ## _struct_t p)\ { N ## _t *_p; __flatbuffers_memoize_begin(B, p); _p = N ## _start(B); if (!_p) return 0;\ N ## _copy(_p, p); __flatbuffers_memoize_end(B, p, N ##_end_pe(B)); }\ __flatbuffers_build_vector(NS, N, N ## _t, S, A)\ __flatbuffers_build_struct_root(NS, N, A, FID, TFID)\ #define __flatbuffers_struct_clear_field(p) memset((p), 0, sizeof(*(p))) #define __flatbuffers_build_table(NS, N, K)\ static inline int N ## _start(NS ## builder_t *B)\ { return flatcc_builder_start_table(B, K); }\ static inline N ## _ref_t N ## _end(NS ## builder_t *B)\ { FLATCC_ASSERT(flatcc_builder_check_required(B, __ ## N ## _required,\ sizeof(__ ## N ## _required) / sizeof(__ ## N ## _required[0]) - 1));\ return flatcc_builder_end_table(B); }\ __flatbuffers_build_offset_vector(NS, N) #define __flatbuffers_build_table_field(ID, NS, N, TN, TT)\ static inline int N ## _add(NS ## builder_t *B, TN ## _ref_t ref)\ { TN ## _ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ?\ ((*_p = ref), 0) : -1; }\ static inline int N ## _start(NS ## builder_t *B)\ { return TN ## _start(B); }\ static inline int N ## _end(NS ## builder_t *B)\ { return N ## _add(B, TN ## _end(B)); }\ static inline TN ## _ref_t N ## _create(NS ## builder_t *B __ ## TN ##_formal_args)\ { return N ## _add(B, TN ## _create(B __ ## TN ## _call_args)); }\ static inline int N ## _clone(NS ## builder_t *B, TN ## _table_t p)\ { return N ## _add(B, TN ## _clone(B, p)); }\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { TN ## _table_t _p = N ## _get(t); return _p ? N ## _clone(B, _p) : 0; } #define __flatbuffers_build_union_field(ID, NS, N, TN, TT)\ static inline int N ## _add(NS ## builder_t *B, TN ## _union_ref_t uref)\ { NS ## ref_t *_p; TN ## _union_type_t *_pt; if (uref.type == TN ## _NONE) return 0; if (uref.value == 0) return -1;\ if (!(_pt = (TN ## _union_type_t *)flatcc_builder_table_add(B, ID - 1, sizeof(*_pt), sizeof(*_pt)))) return -1;\ *_pt = uref.type; if (!(_p = flatcc_builder_table_add_offset(B, ID))) return -1; *_p = uref.value; return 0; }\ static inline int N ## _add_type(NS ## builder_t *B, TN ## _union_type_t type)\ { TN ## _union_type_t *_pt; if (type == TN ## _NONE) return 0; return (_pt = (TN ## _union_type_t *)flatcc_builder_table_add(B, ID - 1,\ sizeof(*_pt), sizeof(*_pt))) ? ((*_pt = type), 0) : -1; }\ static inline int N ## _add_value(NS ## builder_t *B, TN ## _union_ref_t uref)\ { NS ## ref_t *p; if (uref.type == TN ## _NONE) return 0; return (p = flatcc_builder_table_add_offset(B, ID)) ?\ ((*p = uref.value), 0) : -1; }\ static inline int N ## _clone(NS ## builder_t *B, TN ## _union_t p)\ { return N ## _add(B, TN ## _clone(B, p)); }\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { TN ## _union_t _p = N ## _union(t); return _p.type ? N ## _clone(B, _p) : 0; } /* M is the union value name and T is its type, i.e. the qualified name. */ #define __flatbuffers_build_union_table_value_field(NS, N, NU, M, T)\ static inline int N ## _ ## M ## _add(NS ## builder_t *B, T ## _ref_t ref)\ { return N ## _add(B, NU ## _as_ ## M (ref)); }\ static inline int N ## _ ## M ## _start(NS ## builder_t *B)\ { return T ## _start(B); }\ static inline int N ## _ ## M ## _end(NS ## builder_t *B)\ { T ## _ref_t ref = T ## _end(B);\ return ref ? N ## _ ## M ## _add(B, ref) : -1; }\ static inline int N ## _ ## M ## _create(NS ## builder_t *B __ ## T ##_formal_args)\ { T ## _ref_t ref = T ## _create(B __ ## T ## _call_args);\ return ref ? N ## _add(B, NU ## _as_ ## M(ref)) : -1; }\ static inline int N ## _ ## M ## _clone(NS ## builder_t *B, T ## _table_t t)\ { T ## _ref_t ref = T ## _clone(B, t);\ return ref ? N ## _add(B, NU ## _as_ ## M(ref)) : -1; } /* M is the union value name and T is its type, i.e. the qualified name. */ #define __flatbuffers_build_union_struct_value_field(NS, N, NU, M, T)\ static inline int N ## _ ## M ## _add(NS ## builder_t *B, T ## _ref_t ref)\ { return N ## _add(B, NU ## _as_ ## M (ref)); }\ static inline T ## _t *N ## _ ## M ## _start(NS ## builder_t *B)\ { return T ## _start(B); }\ static inline int N ## _ ## M ## _end(NS ## builder_t *B)\ { T ## _ref_t ref = T ## _end(B);\ return ref ? N ## _ ## M ## _add(B, ref) : -1; }\ static inline int N ## _ ## M ## _create(NS ## builder_t *B __ ## T ##_formal_args)\ { T ## _ref_t ref = T ## _create(B __ ## T ## _call_args);\ return ref ? N ## _add(B, NU ## _as_ ## M(ref)) : -1; }\ static inline int N ## _ ## M ## _end_pe(NS ## builder_t *B)\ { T ## _ref_t ref = T ## _end_pe(B);\ return ref ? N ## _add(B, NU ## _as_ ## M(ref)) : -1; }\ static inline int N ## _ ## M ## _clone(NS ## builder_t *B, T ## _struct_t p)\ { T ## _ref_t ref = T ## _clone(B, p);\ return ref ? N ## _add(B, NU ## _as_ ## M(ref)) : -1; } #define __flatbuffers_build_union_string_value_field(NS, N, NU, M)\ static inline int N ## _ ## M ## _add(NS ## builder_t *B, NS ## string_ref_t ref)\ { return N ## _add(B, NU ## _as_ ## M (ref)); }\ __flatbuffers_build_string_field_ops(NS, N ## _ ## M) /* NS: common namespace, ID: table field id (not offset), TN: name of type T, TT: name of table type * S: sizeof of scalar type, A: alignment of type T, default value V of type T. */ #define __flatbuffers_build_scalar_field(ID, NS, N, TN, T, S, A, V, TT)\ static inline int N ## _add(NS ## builder_t *B, const T v)\ { T *_p; if (v == V) return 0; if (!(_p = (T *)flatcc_builder_table_add(B, ID, S, A))) return -1;\ TN ## _assign_to_pe(_p, v); return 0; }\ static inline int N ## _force_add(NS ## builder_t *B, const T v)\ { T *_p; if (!(_p = (T *)flatcc_builder_table_add(B, ID, S, A))) return -1;\ TN ## _assign_to_pe(_p, v); return 0; }\ /* Clone does not skip default values and expects pe endian content. */\ static inline int N ## _clone(NS ## builder_t *B, const T *p)\ { return 0 == flatcc_builder_table_add_copy(B, ID, p, S, A) ? -1 : 0; }\ /* Transferring a missing field is a nop success with 0 as result. */\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { const T *_p = N ## _get_ptr(t); return _p ? N ## _clone(B, _p) : 0; } /* NS: common namespace, ID: table field id (not offset), TN: name of type T, TT: name of table type * S: sizeof of scalar type, A: alignment of type T. */ #define __flatbuffers_build_scalar_optional_field(ID, NS, N, TN, T, S, A, TT)\ static inline int N ## _add(NS ## builder_t *B, const T v)\ { T *_p; if (!(_p = (T *)flatcc_builder_table_add(B, ID, S, A))) return -1;\ TN ## _assign_to_pe(_p, v); return 0; }\ /* Clone does not skip default values and expects pe endian content. */\ static inline int N ## _clone(NS ## builder_t *B, const T *p)\ { return 0 == flatcc_builder_table_add_copy(B, ID, p, S, A) ? -1 : 0; }\ /* Transferring a missing field is a nop success with 0 as result. */\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { const T *_p = N ## _get_ptr(t); return _p ? N ## _clone(B, _p) : 0; } #define __flatbuffers_build_struct_field(ID, NS, N, TN, S, A, TT)\ static inline TN ## _t *N ## _start(NS ## builder_t *B)\ { return (TN ## _t *)flatcc_builder_table_add(B, ID, S, A); }\ static inline int N ## _end(NS ## builder_t *B)\ { if (!NS ## is_native_pe()) { TN ## _to_pe((TN ## _t *)flatcc_builder_table_edit(B, S)); } return 0; }\ static inline int N ## _end_pe(NS ## builder_t *B) { return 0; }\ static inline int N ## _create(NS ## builder_t *B __ ## TN ## _formal_args)\ { TN ## _t *_p = N ## _start(B); if (!_p) return -1; TN ##_assign_to_pe(_p __ ## TN ## _call_args);\ return 0; }\ static inline int N ## _add(NS ## builder_t *B, const TN ## _t *p)\ { TN ## _t *_p = N ## _start(B); if (!_p) return -1; TN ##_copy_to_pe(_p, p); return 0; }\ static inline int N ## _clone(NS ## builder_t *B, TN ## _struct_t p)\ { return 0 == flatcc_builder_table_add_copy(B, ID, p, S, A) ? -1 : 0; }\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { TN ## _struct_t _p = N ## _get(t); return _p ? N ## _clone(B, _p) : 0; } #define __flatbuffers_build_vector_field(ID, NS, N, TN, T, TT)\ static inline int N ## _add(NS ## builder_t *B, TN ## _vec_ref_t ref)\ { TN ## _vec_ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ? ((*_p = ref), 0) : -1; }\ static inline int N ## _start(NS ## builder_t *B)\ { return TN ## _vec_start(B); }\ static inline int N ## _end_pe(NS ## builder_t *B)\ { return N ## _add(B, TN ## _vec_end_pe(B)); }\ static inline int N ## _end(NS ## builder_t *B)\ { return N ## _add(B, TN ## _vec_end(B)); }\ static inline int N ## _create_pe(NS ## builder_t *B, const T *data, size_t len)\ { return N ## _add(B, TN ## _vec_create_pe(B, data, len)); }\ static inline int N ## _create(NS ## builder_t *B, const T *data, size_t len)\ { return N ## _add(B, TN ## _vec_create(B, data, len)); }\ static inline int N ## _slice(NS ## builder_t *B, TN ## _vec_t vec, size_t index, size_t len)\ { return N ## _add(B, TN ## _vec_slice(B, vec, index, len)); }\ static inline int N ## _clone(NS ## builder_t *B, TN ## _vec_t vec)\ { return N ## _add(B, TN ## _vec_clone(B, vec)); }\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { TN ## _vec_t _p = N ## _get(t); return _p ? N ## _clone(B, _p) : 0; }\ __flatbuffers_build_vector_ops(NS, N, N, TN, T)\ #define __flatbuffers_build_offset_vector_field(ID, NS, N, TN, TT)\ static inline int N ## _add(NS ## builder_t *B, TN ## _vec_ref_t ref)\ { TN ## _vec_ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ? ((*_p = ref), 0) : -1; }\ static inline int N ## _start(NS ## builder_t *B)\ { return flatcc_builder_start_offset_vector(B); }\ static inline int N ## _end(NS ## builder_t *B)\ { return N ## _add(B, flatcc_builder_end_offset_vector(B)); }\ static inline int N ## _create(NS ## builder_t *B, const TN ## _ref_t *data, size_t len)\ { return N ## _add(B, flatcc_builder_create_offset_vector(B, data, len)); }\ __flatbuffers_build_offset_vector_ops(NS, N, N, TN)\ static inline int N ## _clone(NS ## builder_t *B, TN ## _vec_t vec)\ { return N ## _add(B, TN ## _vec_clone(B, vec)); }\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { TN ## _vec_t _p = N ## _get(t); return _p ? N ## _clone(B, _p) : 0; } /* depends on N ## _add which differs for union member fields and ordinary fields */\ #define __flatbuffers_build_string_field_ops(NS, N)\ static inline int N ## _start(NS ## builder_t *B)\ { return flatcc_builder_start_string(B); }\ static inline int N ## _end(NS ## builder_t *B)\ { return N ## _add(B, flatcc_builder_end_string(B)); }\ static inline int N ## _create(NS ## builder_t *B, const char *s, size_t len)\ { return N ## _add(B, flatcc_builder_create_string(B, s, len)); }\ static inline int N ## _create_str(NS ## builder_t *B, const char *s)\ { return N ## _add(B, flatcc_builder_create_string_str(B, s)); }\ static inline int N ## _create_strn(NS ## builder_t *B, const char *s, size_t max_len)\ { return N ## _add(B, flatcc_builder_create_string_strn(B, s, max_len)); }\ static inline int N ## _clone(NS ## builder_t *B, NS ## string_t string)\ { return N ## _add(B, NS ## string_clone(B, string)); }\ static inline int N ## _slice(NS ## builder_t *B, NS ## string_t string, size_t index, size_t len)\ { return N ## _add(B, NS ## string_slice(B, string, index, len)); }\ __flatbuffers_build_string_ops(NS, N) #define __flatbuffers_build_string_field(ID, NS, N, TT)\ static inline int N ## _add(NS ## builder_t *B, NS ## string_ref_t ref)\ { NS ## string_ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ? ((*_p = ref), 0) : -1; }\ __flatbuffers_build_string_field_ops(NS, N)\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { NS ## string_t _p = N ## _get(t); return _p ? N ## _clone(B, _p) : 0; } #define __flatbuffers_build_table_vector_field(ID, NS, N, TN, TT)\ __flatbuffers_build_offset_vector_field(ID, NS, N, TN, TT)\ __flatbuffers_build_table_vector_ops(NS, N, TN) #define __flatbuffers_build_union_vector_field(ID, NS, N, TN, TT)\ static inline int N ## _add(NS ## builder_t *B, TN ## _union_vec_ref_t uvref)\ { NS ## vec_ref_t *_p; if (!uvref.type || !uvref.value) return uvref.type == uvref.value ? 0 : -1;\ if (!(_p = flatcc_builder_table_add_offset(B, ID - 1))) return -1; *_p = uvref.type;\ if (!(_p = flatcc_builder_table_add_offset(B, ID))) return -1; *_p = uvref.value; return 0; }\ static inline int N ## _start(NS ## builder_t *B)\ { return flatcc_builder_start_union_vector(B); }\ static inline int N ## _end(NS ## builder_t *B)\ { return N ## _add(B, flatcc_builder_end_union_vector(B)); }\ static inline int N ## _create(NS ## builder_t *B, const TN ## _union_ref_t *data, size_t len)\ { return N ## _add(B, flatcc_builder_create_union_vector(B, data, len)); }\ __flatbuffers_build_union_vector_ops(NS, N, N, TN)\ static inline int N ## _clone(NS ## builder_t *B, TN ## _union_vec_t vec)\ { return N ## _add(B, TN ## _vec_clone(B, vec)); }\ static inline int N ## _pick(NS ## builder_t *B, TT ## _table_t t)\ { TN ## _union_vec_t _p = N ## _union(t); return _p.type ? N ## _clone(B, _p) : 0; } #define __flatbuffers_build_union_table_vector_value_field(NS, N, NU, M, T)\ static inline int N ## _ ## M ## _push_start(NS ## builder_t *B)\ { return T ## _start(B); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_end(NS ## builder_t *B)\ { return NU ## _vec_push(B, NU ## _as_ ## M (T ## _end(B))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push(NS ## builder_t *B, T ## _ref_t ref)\ { return NU ## _vec_push(B, NU ## _as_ ## M (ref)); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_create(NS ## builder_t *B __ ## T ##_formal_args)\ { return NU ## _vec_push(B, NU ## _as_ ## M(T ## _create(B __ ## T ## _call_args))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_clone(NS ## builder_t *B, T ## _table_t t)\ { return NU ## _vec_push(B, NU ## _as_ ## M(T ## _clone(B, t))); } #define __flatbuffers_build_union_struct_vector_value_field(NS, N, NU, M, T)\ static inline T ## _t *N ## _ ## M ## _push_start(NS ## builder_t *B)\ { return T ## _start(B); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_end(NS ## builder_t *B)\ { return NU ## _vec_push(B, NU ## _as_ ## M (T ## _end(B))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push(NS ## builder_t *B, T ## _ref_t ref)\ { return NU ## _vec_push(B, NU ## _as_ ## M (ref)); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_create(NS ## builder_t *B __ ## T ##_formal_args)\ { return NU ## _vec_push(B, NU ## _as_ ## M(T ## _create(B __ ## T ## _call_args))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_clone(NS ## builder_t *B, T ## _struct_t p)\ { return NU ## _vec_push(B, NU ## _as_ ## M(T ## _clone(B, p))); } #define __flatbuffers_build_union_string_vector_value_field(NS, N, NU, M)\ static inline NU ## _union_ref_t *N ## _ ## M ## _push(NS ## builder_t *B, NS ## string_ref_t ref)\ { return NU ## _vec_push(B, NU ## _as_ ## M (ref)); }\ static inline int N ## _ ## M ## _push_start(NS ## builder_t *B)\ { return NS ## string_start(B); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_end(NS ## builder_t *B)\ { return NU ## _vec_push(B, NU ## _as_ ## M(NS ## string_end(B))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_create(NS ## builder_t *B, const char *s, size_t len)\ { return NU ## _vec_push(B, NU ## _as_ ## M(NS ## string_create(B, s, len))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_create_str(NS ## builder_t *B, const char *s)\ { return NU ## _vec_push(B, NU ## _as_ ## M(NS ## string_create_str(B, s))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_create_strn(NS ## builder_t *B, const char *s, size_t max_len)\ { return NU ## _vec_push(B, NU ## _as_ ## M(NS ## string_create_strn(B, s, max_len))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_clone(NS ## builder_t *B, NS ## string_t string)\ { return NU ## _vec_push(B, NU ## _as_ ## M(NS ## string_clone(B, string))); }\ static inline NU ## _union_ref_t *N ## _ ## M ## _push_slice(NS ## builder_t *B, NS ## string_t string, size_t index, size_t len)\ { return NU ## _vec_push(B, NU ## _as_ ## M(NS ## string_slice(B, string, index, len))); } #define __flatbuffers_build_string_vector_field(ID, NS, N, TT)\ __flatbuffers_build_offset_vector_field(ID, NS, N, NS ## string, TT)\ __flatbuffers_build_string_vector_ops(NS, N) #define __flatbuffers_char_formal_args , char v0 #define __flatbuffers_char_call_args , v0 #define __flatbuffers_uint8_formal_args , uint8_t v0 #define __flatbuffers_uint8_call_args , v0 #define __flatbuffers_int8_formal_args , int8_t v0 #define __flatbuffers_int8_call_args , v0 #define __flatbuffers_bool_formal_args , flatbuffers_bool_t v0 #define __flatbuffers_bool_call_args , v0 #define __flatbuffers_uint16_formal_args , uint16_t v0 #define __flatbuffers_uint16_call_args , v0 #define __flatbuffers_uint32_formal_args , uint32_t v0 #define __flatbuffers_uint32_call_args , v0 #define __flatbuffers_uint64_formal_args , uint64_t v0 #define __flatbuffers_uint64_call_args , v0 #define __flatbuffers_int16_formal_args , int16_t v0 #define __flatbuffers_int16_call_args , v0 #define __flatbuffers_int32_formal_args , int32_t v0 #define __flatbuffers_int32_call_args , v0 #define __flatbuffers_int64_formal_args , int64_t v0 #define __flatbuffers_int64_call_args , v0 #define __flatbuffers_float_formal_args , float v0 #define __flatbuffers_float_call_args , v0 #define __flatbuffers_double_formal_args , double v0 #define __flatbuffers_double_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint8, uint8_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int8, int8_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_bool, flatbuffers_bool_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint16, uint16_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint32, uint32_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint64, uint64_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int16, int16_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int32, int32_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int64, int64_t) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_float, float) __flatbuffers_build_scalar(flatbuffers_, flatbuffers_double, double) __flatbuffers_build_string(flatbuffers_) __flatbuffers_build_buffer(flatbuffers_) #include "flatcc/flatcc_epilogue.h" #endif /* FLATBUFFERS_COMMON_BUILDER_H */ #ifndef SCHEMA_READER_H #define SCHEMA_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef struct org_apache_arrow_flatbuf_Buffer org_apache_arrow_flatbuf_Buffer_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_struct_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_struct_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_vec_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_table_t; typedef struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__table_t; typedef struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_table_t; typedef struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_table_t; typedef struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_table_t; typedef struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_table_t; typedef struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_table_t; typedef struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_table_t; typedef struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_table_t; typedef struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_table_t; typedef struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_table_t; typedef struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_table_t; typedef struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_table_t; typedef struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_table_t; typedef struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_table_t; typedef struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_table_t; typedef struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_table_t; typedef struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_table_t; typedef struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_table_t; typedef struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_table_t; typedef struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_table_t; typedef struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_table_t; typedef struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_table_t; typedef struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_table_t; typedef struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_table_t; typedef struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_table_t; typedef struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_table_t; typedef struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_table_t; typedef struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_Null_file_identifier #define org_apache_arrow_flatbuf_Null_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Null_file_identifier */ #ifndef org_apache_arrow_flatbuf_Null_identifier #define org_apache_arrow_flatbuf_Null_identifier 0 #endif #define org_apache_arrow_flatbuf_Null_type_hash ((flatbuffers_thash_t)0x7b36a4dd) #define org_apache_arrow_flatbuf_Null_type_identifier "\xdd\xa4\x36\x7b" #ifndef org_apache_arrow_flatbuf_Null_file_extension #define org_apache_arrow_flatbuf_Null_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Struct__file_identifier #define org_apache_arrow_flatbuf_Struct__file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Struct__file_identifier */ #ifndef org_apache_arrow_flatbuf_Struct__identifier #define org_apache_arrow_flatbuf_Struct__identifier 0 #endif #define org_apache_arrow_flatbuf_Struct__type_hash ((flatbuffers_thash_t)0x6310f362) #define org_apache_arrow_flatbuf_Struct__type_identifier "\x62\xf3\x10\x63" #ifndef org_apache_arrow_flatbuf_Struct__file_extension #define org_apache_arrow_flatbuf_Struct__file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_List_file_identifier #define org_apache_arrow_flatbuf_List_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_List_file_identifier */ #ifndef org_apache_arrow_flatbuf_List_identifier #define org_apache_arrow_flatbuf_List_identifier 0 #endif #define org_apache_arrow_flatbuf_List_type_hash ((flatbuffers_thash_t)0xd4ce5878) #define org_apache_arrow_flatbuf_List_type_identifier "\x78\x58\xce\xd4" #ifndef org_apache_arrow_flatbuf_List_file_extension #define org_apache_arrow_flatbuf_List_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeList_file_identifier #define org_apache_arrow_flatbuf_LargeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeList_identifier #define org_apache_arrow_flatbuf_LargeList_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeList_type_hash ((flatbuffers_thash_t)0x38aa7e27) #define org_apache_arrow_flatbuf_LargeList_type_identifier "\x27\x7e\xaa\x38" #ifndef org_apache_arrow_flatbuf_LargeList_file_extension #define org_apache_arrow_flatbuf_LargeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_ListView_file_identifier #define org_apache_arrow_flatbuf_ListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_ListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_ListView_identifier #define org_apache_arrow_flatbuf_ListView_identifier 0 #endif #define org_apache_arrow_flatbuf_ListView_type_hash ((flatbuffers_thash_t)0x23d37919) #define org_apache_arrow_flatbuf_ListView_type_identifier "\x19\x79\xd3\x23" #ifndef org_apache_arrow_flatbuf_ListView_file_extension #define org_apache_arrow_flatbuf_ListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeListView_file_identifier #define org_apache_arrow_flatbuf_LargeListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeListView_identifier #define org_apache_arrow_flatbuf_LargeListView_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeListView_type_hash ((flatbuffers_thash_t)0x28efac02) #define org_apache_arrow_flatbuf_LargeListView_type_identifier "\x02\xac\xef\x28" #ifndef org_apache_arrow_flatbuf_LargeListView_file_extension #define org_apache_arrow_flatbuf_LargeListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_identifier #define org_apache_arrow_flatbuf_FixedSizeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeList_identifier #define org_apache_arrow_flatbuf_FixedSizeList_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeList_type_hash ((flatbuffers_thash_t)0xcef245bb) #define org_apache_arrow_flatbuf_FixedSizeList_type_identifier "\xbb\x45\xf2\xce" #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_extension #define org_apache_arrow_flatbuf_FixedSizeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Map_file_identifier #define org_apache_arrow_flatbuf_Map_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Map_file_identifier */ #ifndef org_apache_arrow_flatbuf_Map_identifier #define org_apache_arrow_flatbuf_Map_identifier 0 #endif #define org_apache_arrow_flatbuf_Map_type_hash ((flatbuffers_thash_t)0xcebef8e6) #define org_apache_arrow_flatbuf_Map_type_identifier "\xe6\xf8\xbe\xce" #ifndef org_apache_arrow_flatbuf_Map_file_extension #define org_apache_arrow_flatbuf_Map_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Union_file_identifier #define org_apache_arrow_flatbuf_Union_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Union_file_identifier */ #ifndef org_apache_arrow_flatbuf_Union_identifier #define org_apache_arrow_flatbuf_Union_identifier 0 #endif #define org_apache_arrow_flatbuf_Union_type_hash ((flatbuffers_thash_t)0x896bda57) #define org_apache_arrow_flatbuf_Union_type_identifier "\x57\xda\x6b\x89" #ifndef org_apache_arrow_flatbuf_Union_file_extension #define org_apache_arrow_flatbuf_Union_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Int_file_identifier #define org_apache_arrow_flatbuf_Int_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Int_file_identifier */ #ifndef org_apache_arrow_flatbuf_Int_identifier #define org_apache_arrow_flatbuf_Int_identifier 0 #endif #define org_apache_arrow_flatbuf_Int_type_hash ((flatbuffers_thash_t)0x30789001) #define org_apache_arrow_flatbuf_Int_type_identifier "\x01\x90\x78\x30" #ifndef org_apache_arrow_flatbuf_Int_file_extension #define org_apache_arrow_flatbuf_Int_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_identifier #define org_apache_arrow_flatbuf_FloatingPoint_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FloatingPoint_file_identifier */ #ifndef org_apache_arrow_flatbuf_FloatingPoint_identifier #define org_apache_arrow_flatbuf_FloatingPoint_identifier 0 #endif #define org_apache_arrow_flatbuf_FloatingPoint_type_hash ((flatbuffers_thash_t)0xf7d06268) #define org_apache_arrow_flatbuf_FloatingPoint_type_identifier "\x68\x62\xd0\xf7" #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_extension #define org_apache_arrow_flatbuf_FloatingPoint_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8_file_identifier #define org_apache_arrow_flatbuf_Utf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8_identifier #define org_apache_arrow_flatbuf_Utf8_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8_type_hash ((flatbuffers_thash_t)0x8fe60d37) #define org_apache_arrow_flatbuf_Utf8_type_identifier "\x37\x0d\xe6\x8f" #ifndef org_apache_arrow_flatbuf_Utf8_file_extension #define org_apache_arrow_flatbuf_Utf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Binary_file_identifier #define org_apache_arrow_flatbuf_Binary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Binary_file_identifier */ #ifndef org_apache_arrow_flatbuf_Binary_identifier #define org_apache_arrow_flatbuf_Binary_identifier 0 #endif #define org_apache_arrow_flatbuf_Binary_type_hash ((flatbuffers_thash_t)0x8e21a795) #define org_apache_arrow_flatbuf_Binary_type_identifier "\x95\xa7\x21\x8e" #ifndef org_apache_arrow_flatbuf_Binary_file_extension #define org_apache_arrow_flatbuf_Binary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_identifier #define org_apache_arrow_flatbuf_LargeUtf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeUtf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeUtf8_identifier #define org_apache_arrow_flatbuf_LargeUtf8_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeUtf8_type_hash ((flatbuffers_thash_t)0x24ed2fb0) #define org_apache_arrow_flatbuf_LargeUtf8_type_identifier "\xb0\x2f\xed\x24" #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_extension #define org_apache_arrow_flatbuf_LargeUtf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeBinary_file_identifier #define org_apache_arrow_flatbuf_LargeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeBinary_identifier #define org_apache_arrow_flatbuf_LargeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeBinary_type_hash ((flatbuffers_thash_t)0xbd437872) #define org_apache_arrow_flatbuf_LargeBinary_type_identifier "\x72\x78\x43\xbd" #ifndef org_apache_arrow_flatbuf_LargeBinary_file_extension #define org_apache_arrow_flatbuf_LargeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8View_file_identifier #define org_apache_arrow_flatbuf_Utf8View_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8View_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8View_identifier #define org_apache_arrow_flatbuf_Utf8View_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8View_type_hash ((flatbuffers_thash_t)0xab7692) #define org_apache_arrow_flatbuf_Utf8View_type_identifier "\x92\x76\xab\x00" #ifndef org_apache_arrow_flatbuf_Utf8View_file_extension #define org_apache_arrow_flatbuf_Utf8View_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_BinaryView_file_identifier #define org_apache_arrow_flatbuf_BinaryView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_BinaryView_file_identifier */ #ifndef org_apache_arrow_flatbuf_BinaryView_identifier #define org_apache_arrow_flatbuf_BinaryView_identifier 0 #endif #define org_apache_arrow_flatbuf_BinaryView_type_hash ((flatbuffers_thash_t)0x18c52428) #define org_apache_arrow_flatbuf_BinaryView_type_identifier "\x28\x24\xc5\x18" #ifndef org_apache_arrow_flatbuf_BinaryView_file_extension #define org_apache_arrow_flatbuf_BinaryView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeBinary_type_hash ((flatbuffers_thash_t)0x80d0f4ce) #define org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier "\xce\xf4\xd0\x80" #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_extension #define org_apache_arrow_flatbuf_FixedSizeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Bool_file_identifier #define org_apache_arrow_flatbuf_Bool_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Bool_file_identifier */ #ifndef org_apache_arrow_flatbuf_Bool_identifier #define org_apache_arrow_flatbuf_Bool_identifier 0 #endif #define org_apache_arrow_flatbuf_Bool_type_hash ((flatbuffers_thash_t)0x96bf83f0) #define org_apache_arrow_flatbuf_Bool_type_identifier "\xf0\x83\xbf\x96" #ifndef org_apache_arrow_flatbuf_Bool_file_extension #define org_apache_arrow_flatbuf_Bool_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_RunEndEncoded_file_identifier */ #ifndef org_apache_arrow_flatbuf_RunEndEncoded_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_identifier 0 #endif #define org_apache_arrow_flatbuf_RunEndEncoded_type_hash ((flatbuffers_thash_t)0x5a98bcc) #define org_apache_arrow_flatbuf_RunEndEncoded_type_identifier "\xcc\x8b\xa9\x05" #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_extension #define org_apache_arrow_flatbuf_RunEndEncoded_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Decimal_file_identifier #define org_apache_arrow_flatbuf_Decimal_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Decimal_file_identifier */ #ifndef org_apache_arrow_flatbuf_Decimal_identifier #define org_apache_arrow_flatbuf_Decimal_identifier 0 #endif #define org_apache_arrow_flatbuf_Decimal_type_hash ((flatbuffers_thash_t)0x91d1beb7) #define org_apache_arrow_flatbuf_Decimal_type_identifier "\xb7\xbe\xd1\x91" #ifndef org_apache_arrow_flatbuf_Decimal_file_extension #define org_apache_arrow_flatbuf_Decimal_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Date_file_identifier #define org_apache_arrow_flatbuf_Date_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Date_file_identifier */ #ifndef org_apache_arrow_flatbuf_Date_identifier #define org_apache_arrow_flatbuf_Date_identifier 0 #endif #define org_apache_arrow_flatbuf_Date_type_hash ((flatbuffers_thash_t)0xe0ccf624) #define org_apache_arrow_flatbuf_Date_type_identifier "\x24\xf6\xcc\xe0" #ifndef org_apache_arrow_flatbuf_Date_file_extension #define org_apache_arrow_flatbuf_Date_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Time_file_identifier #define org_apache_arrow_flatbuf_Time_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Time_file_identifier */ #ifndef org_apache_arrow_flatbuf_Time_identifier #define org_apache_arrow_flatbuf_Time_identifier 0 #endif #define org_apache_arrow_flatbuf_Time_type_hash ((flatbuffers_thash_t)0x2442a489) #define org_apache_arrow_flatbuf_Time_type_identifier "\x89\xa4\x42\x24" #ifndef org_apache_arrow_flatbuf_Time_file_extension #define org_apache_arrow_flatbuf_Time_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Timestamp_file_identifier #define org_apache_arrow_flatbuf_Timestamp_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Timestamp_file_identifier */ #ifndef org_apache_arrow_flatbuf_Timestamp_identifier #define org_apache_arrow_flatbuf_Timestamp_identifier 0 #endif #define org_apache_arrow_flatbuf_Timestamp_type_hash ((flatbuffers_thash_t)0x1fddf080) #define org_apache_arrow_flatbuf_Timestamp_type_identifier "\x80\xf0\xdd\x1f" #ifndef org_apache_arrow_flatbuf_Timestamp_file_extension #define org_apache_arrow_flatbuf_Timestamp_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Interval_file_identifier #define org_apache_arrow_flatbuf_Interval_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Interval_file_identifier */ #ifndef org_apache_arrow_flatbuf_Interval_identifier #define org_apache_arrow_flatbuf_Interval_identifier 0 #endif #define org_apache_arrow_flatbuf_Interval_type_hash ((flatbuffers_thash_t)0x1e2d6809) #define org_apache_arrow_flatbuf_Interval_type_identifier "\x09\x68\x2d\x1e" #ifndef org_apache_arrow_flatbuf_Interval_file_extension #define org_apache_arrow_flatbuf_Interval_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Duration_file_identifier #define org_apache_arrow_flatbuf_Duration_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Duration_file_identifier */ #ifndef org_apache_arrow_flatbuf_Duration_identifier #define org_apache_arrow_flatbuf_Duration_identifier 0 #endif #define org_apache_arrow_flatbuf_Duration_type_hash ((flatbuffers_thash_t)0x1ecea6b0) #define org_apache_arrow_flatbuf_Duration_type_identifier "\xb0\xa6\xce\x1e" #ifndef org_apache_arrow_flatbuf_Duration_file_extension #define org_apache_arrow_flatbuf_Duration_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_KeyValue_file_identifier #define org_apache_arrow_flatbuf_KeyValue_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_KeyValue_file_identifier */ #ifndef org_apache_arrow_flatbuf_KeyValue_identifier #define org_apache_arrow_flatbuf_KeyValue_identifier 0 #endif #define org_apache_arrow_flatbuf_KeyValue_type_hash ((flatbuffers_thash_t)0x3b264744) #define org_apache_arrow_flatbuf_KeyValue_type_identifier "\x44\x47\x26\x3b" #ifndef org_apache_arrow_flatbuf_KeyValue_file_extension #define org_apache_arrow_flatbuf_KeyValue_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier */ #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_identifier 0 #endif #define org_apache_arrow_flatbuf_DictionaryEncoding_type_hash ((flatbuffers_thash_t)0x8c703261) #define org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier "\x61\x32\x70\x8c" #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_extension #define org_apache_arrow_flatbuf_DictionaryEncoding_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Field_file_identifier #define org_apache_arrow_flatbuf_Field_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Field_file_identifier */ #ifndef org_apache_arrow_flatbuf_Field_identifier #define org_apache_arrow_flatbuf_Field_identifier 0 #endif #define org_apache_arrow_flatbuf_Field_type_hash ((flatbuffers_thash_t)0xd981525c) #define org_apache_arrow_flatbuf_Field_type_identifier "\x5c\x52\x81\xd9" #ifndef org_apache_arrow_flatbuf_Field_file_extension #define org_apache_arrow_flatbuf_Field_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Buffer_file_identifier #define org_apache_arrow_flatbuf_Buffer_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Buffer_file_identifier */ #ifndef org_apache_arrow_flatbuf_Buffer_identifier #define org_apache_arrow_flatbuf_Buffer_identifier 0 #endif #define org_apache_arrow_flatbuf_Buffer_type_hash ((flatbuffers_thash_t)0x519d7fea) #define org_apache_arrow_flatbuf_Buffer_type_identifier "\xea\x7f\x9d\x51" #ifndef org_apache_arrow_flatbuf_Buffer_file_extension #define org_apache_arrow_flatbuf_Buffer_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Schema_file_identifier #define org_apache_arrow_flatbuf_Schema_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Schema_file_identifier */ #ifndef org_apache_arrow_flatbuf_Schema_identifier #define org_apache_arrow_flatbuf_Schema_identifier 0 #endif #define org_apache_arrow_flatbuf_Schema_type_hash ((flatbuffers_thash_t)0x406570b) #define org_apache_arrow_flatbuf_Schema_type_identifier "\x0b\x57\x06\x04" #ifndef org_apache_arrow_flatbuf_Schema_file_extension #define org_apache_arrow_flatbuf_Schema_file_extension "bin" #endif typedef int16_t org_apache_arrow_flatbuf_MetadataVersion_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, 16) /** 0.1.0 (October 2016). */ #define org_apache_arrow_flatbuf_MetadataVersion_V1 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_MetadataVersion_V2 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_MetadataVersion_V3 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_MetadataVersion_V4 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(3)) #define org_apache_arrow_flatbuf_MetadataVersion_V5 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(4)) static inline const char *org_apache_arrow_flatbuf_MetadataVersion_name(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return "V1"; case org_apache_arrow_flatbuf_MetadataVersion_V2: return "V2"; case org_apache_arrow_flatbuf_MetadataVersion_V3: return "V3"; case org_apache_arrow_flatbuf_MetadataVersion_V4: return "V4"; case org_apache_arrow_flatbuf_MetadataVersion_V5: return "V5"; default: return ""; } } static inline int org_apache_arrow_flatbuf_MetadataVersion_is_known_value(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V2: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V3: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V4: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V5: return 1; default: return 0; } } /** Represents Arrow Features that might not have full support * within implementations. This is intended to be used in * two scenarios: * 1. A mechanism for readers of Arrow Streams * and files to understand that the stream or file makes * use of a feature that isn't supported or unknown to * the implementation (and therefore can meet the Arrow * forward compatibility guarantees). * 2. A means of negotiating between a client and server * what features a stream is allowed to use. The enums * values here are intented to represent higher level * features, additional details maybe negotiated * with key-value pairs specific to the protocol. * * Enums added to this list should be assigned power-of-two values * to facilitate exchanging and comparing bitmaps for supported * features. */ typedef int64_t org_apache_arrow_flatbuf_Feature_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, 64) /** Needed to make flatbuffers happy. */ #define org_apache_arrow_flatbuf_Feature_UNUSED ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(0)) #define org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(1)) #define org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(2)) static inline const char *org_apache_arrow_flatbuf_Feature_name(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return "UNUSED"; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return "DICTIONARY_REPLACEMENT"; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return "COMPRESSED_BODY"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Feature_is_known_value(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return 1; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return 1; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_UnionMode_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 16) #define org_apache_arrow_flatbuf_UnionMode_Sparse ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_UnionMode_Dense ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_UnionMode_name(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return "Sparse"; case org_apache_arrow_flatbuf_UnionMode_Dense: return "Dense"; default: return ""; } } static inline int org_apache_arrow_flatbuf_UnionMode_is_known_value(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return 1; case org_apache_arrow_flatbuf_UnionMode_Dense: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_Precision_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 16) #define org_apache_arrow_flatbuf_Precision_HALF ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Precision_SINGLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_Precision_DOUBLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_Precision_name(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return "HALF"; case org_apache_arrow_flatbuf_Precision_SINGLE: return "SINGLE"; case org_apache_arrow_flatbuf_Precision_DOUBLE: return "DOUBLE"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Precision_is_known_value(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return 1; case org_apache_arrow_flatbuf_Precision_SINGLE: return 1; case org_apache_arrow_flatbuf_Precision_DOUBLE: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_DateUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 16) #define org_apache_arrow_flatbuf_DateUnit_DAY ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_DateUnit_MILLISECOND ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_DateUnit_name(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return "DAY"; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return "MILLISECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DateUnit_is_known_value(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return 1; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_TimeUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 16) #define org_apache_arrow_flatbuf_TimeUnit_SECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_TimeUnit_MILLISECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_TimeUnit_MICROSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_TimeUnit_NANOSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(3)) static inline const char *org_apache_arrow_flatbuf_TimeUnit_name(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return "SECOND"; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return "MILLISECOND"; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return "MICROSECOND"; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return "NANOSECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_TimeUnit_is_known_value(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_IntervalUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 16) #define org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_IntervalUnit_name(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return "YEAR_MONTH"; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return "DAY_TIME"; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return "MONTH_DAY_NANO"; default: return ""; } } static inline int org_apache_arrow_flatbuf_IntervalUnit_is_known_value(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return 1; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return 1; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Dictionary encoding metadata * Maintained for forwards compatibility, in the future * Dictionaries might be explicit maps between integers and values * allowing for non-contiguous index values */ typedef int16_t org_apache_arrow_flatbuf_DictionaryKind_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 16) #define org_apache_arrow_flatbuf_DictionaryKind_DenseArray ((org_apache_arrow_flatbuf_DictionaryKind_enum_t)INT16_C(0)) static inline const char *org_apache_arrow_flatbuf_DictionaryKind_name(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return "DenseArray"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DictionaryKind_is_known_value(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Endianness of the platform producing the data */ typedef int16_t org_apache_arrow_flatbuf_Endianness_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 16) #define org_apache_arrow_flatbuf_Endianness_Little ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Endianness_Big ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_Endianness_name(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return "Little"; case org_apache_arrow_flatbuf_Endianness_Big: return "Big"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Endianness_is_known_value(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return 1; case org_apache_arrow_flatbuf_Endianness_Big: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * A Buffer represents a single contiguous memory segment */ struct org_apache_arrow_flatbuf_Buffer { /** The relative offset into the shared memory page where the bytes for this * buffer starts */ alignas(8) int64_t offset; /** The absolute length (in bytes) of the memory buffer. The memory is found * from offset (inclusive) to offset + length (non-inclusive). When building * messages using the encapsulated IPC message, padding bytes may be written * after a buffer, but such padding bytes do not need to be accounted for in * the size here. */ alignas(8) int64_t length; }; static_assert(sizeof(org_apache_arrow_flatbuf_Buffer_t) == 16, "struct size mismatch"); static inline const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__const_ptr_add(const org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__ptr_add(org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_struct_t org_apache_arrow_flatbuf_Buffer_vec_at(org_apache_arrow_flatbuf_Buffer_vec_t vec, size_t i) __flatbuffers_struct_vec_at(vec, i) static inline size_t org_apache_arrow_flatbuf_Buffer__size(void) { return 16; } static inline size_t org_apache_arrow_flatbuf_Buffer_vec_len(org_apache_arrow_flatbuf_Buffer_vec_t vec) __flatbuffers_vec_len(vec) __flatbuffers_struct_as_root(org_apache_arrow_flatbuf_Buffer) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, offset, flatbuffers_int64, int64_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, length, flatbuffers_int64, int64_t) /** These are stored in the flatbuffer in the Type union below */ struct org_apache_arrow_flatbuf_Null_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Null_vec_len(org_apache_arrow_flatbuf_Null_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Null_table_t org_apache_arrow_flatbuf_Null_vec_at(org_apache_arrow_flatbuf_Null_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Null_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Null) /** A Struct_ in the flatbuffer metadata is the same as an Arrow Struct * (according to the physical memory layout). We used Struct_ here as * Struct is a reserved word in Flatbuffers */ struct org_apache_arrow_flatbuf_Struct__table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Struct__vec_len(org_apache_arrow_flatbuf_Struct__vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Struct__table_t org_apache_arrow_flatbuf_Struct__vec_at(org_apache_arrow_flatbuf_Struct__vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Struct__table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Struct_) struct org_apache_arrow_flatbuf_List_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_List_vec_len(org_apache_arrow_flatbuf_List_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_List_table_t org_apache_arrow_flatbuf_List_vec_at(org_apache_arrow_flatbuf_List_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_List_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_List) /** Same as List, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeList_vec_len(org_apache_arrow_flatbuf_LargeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeList_table_t org_apache_arrow_flatbuf_LargeList_vec_at(org_apache_arrow_flatbuf_LargeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeList) /** Represents the same logical types that List can, but contains offsets and * sizes allowing for writes in any order and sharing of child values among * list values. */ struct org_apache_arrow_flatbuf_ListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_ListView_vec_len(org_apache_arrow_flatbuf_ListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_ListView_table_t org_apache_arrow_flatbuf_ListView_vec_at(org_apache_arrow_flatbuf_ListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_ListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_ListView) /** Same as ListView, but with 64-bit offsets and sizes, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeListView_vec_len(org_apache_arrow_flatbuf_LargeListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeListView_table_t org_apache_arrow_flatbuf_LargeListView_vec_at(org_apache_arrow_flatbuf_LargeListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeListView) struct org_apache_arrow_flatbuf_FixedSizeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeList_vec_len(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeList_table_t org_apache_arrow_flatbuf_FixedSizeList_vec_at(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeList) /** Number of list items per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeList, listSize, flatbuffers_int32, int32_t, INT32_C(0)) /** A Map is a logical nested type that is represented as * * List> * * In this layout, the keys and values are each respectively contiguous. We do * not constrain the key and value types, so the application is responsible * for ensuring that the keys are hashable and unique. Whether the keys are sorted * may be set in the metadata for this field. * * In a field with Map type, the field has a child Struct field, which then * has two children: key type and the second the value type. The names of the * child fields may be respectively "entries", "key", and "value", but this is * not enforced. * * Map * ```text * - child[0] entries: Struct * - child[0] key: K * - child[1] value: V * ``` * Neither the "entries" field nor the "key" field may be nullable. * * The metadata is structured so that Arrow systems without special handling * for Map can make Map an alias for List. The "layout" attribute for the Map * field must have the same contents as a List. */ struct org_apache_arrow_flatbuf_Map_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Map_vec_len(org_apache_arrow_flatbuf_Map_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Map_table_t org_apache_arrow_flatbuf_Map_vec_at(org_apache_arrow_flatbuf_Map_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Map_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Map) /** Set to true if the keys within each value are sorted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Map, keysSorted, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** A union is a complex type with children in Field * By default ids in the type vector refer to the offsets in the children * optionally typeIds provides an indirection between the child offset and the type id * for each child `typeIds[offset]` is the id used in the type vector */ struct org_apache_arrow_flatbuf_Union_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Union_vec_len(org_apache_arrow_flatbuf_Union_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Union_table_t org_apache_arrow_flatbuf_Union_vec_at(org_apache_arrow_flatbuf_Union_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Union_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Union) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Union, mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Union, typeIds, flatbuffers_int32_vec_t, 0) struct org_apache_arrow_flatbuf_Int_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Int_vec_len(org_apache_arrow_flatbuf_Int_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Int_table_t org_apache_arrow_flatbuf_Int_vec_at(org_apache_arrow_flatbuf_Int_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Int_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Int) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Int, bitWidth, flatbuffers_int32, int32_t, INT32_C(0)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Int, is_signed, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) struct org_apache_arrow_flatbuf_FloatingPoint_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FloatingPoint_vec_len(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FloatingPoint_table_t org_apache_arrow_flatbuf_FloatingPoint_vec_at(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FloatingPoint_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FloatingPoint, precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, INT16_C(0)) /** Unicode with UTF-8 encoding */ struct org_apache_arrow_flatbuf_Utf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8_vec_len(org_apache_arrow_flatbuf_Utf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8_table_t org_apache_arrow_flatbuf_Utf8_vec_at(org_apache_arrow_flatbuf_Utf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8) /** Opaque binary data */ struct org_apache_arrow_flatbuf_Binary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Binary_vec_len(org_apache_arrow_flatbuf_Binary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Binary_table_t org_apache_arrow_flatbuf_Binary_vec_at(org_apache_arrow_flatbuf_Binary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Binary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Binary) /** Same as Utf8, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeUtf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeUtf8_vec_len(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeUtf8_table_t org_apache_arrow_flatbuf_LargeUtf8_vec_at(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeUtf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeUtf8) /** Same as Binary, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeBinary_vec_len(org_apache_arrow_flatbuf_LargeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeBinary_table_t org_apache_arrow_flatbuf_LargeBinary_vec_at(org_apache_arrow_flatbuf_LargeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeBinary) /** Logically the same as Utf8, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_Utf8View_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8View_vec_len(org_apache_arrow_flatbuf_Utf8View_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8View_table_t org_apache_arrow_flatbuf_Utf8View_vec_at(org_apache_arrow_flatbuf_Utf8View_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8View_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8View) /** Logically the same as Binary, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_BinaryView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_BinaryView_vec_len(org_apache_arrow_flatbuf_BinaryView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_BinaryView_table_t org_apache_arrow_flatbuf_BinaryView_vec_at(org_apache_arrow_flatbuf_BinaryView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_BinaryView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_BinaryView) struct org_apache_arrow_flatbuf_FixedSizeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_len(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeBinary_table_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeBinary) /** Number of bytes per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeBinary, byteWidth, flatbuffers_int32, int32_t, INT32_C(0)) struct org_apache_arrow_flatbuf_Bool_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Bool_vec_len(org_apache_arrow_flatbuf_Bool_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Bool_table_t org_apache_arrow_flatbuf_Bool_vec_at(org_apache_arrow_flatbuf_Bool_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Bool_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Bool) /** Contains two child arrays, run_ends and values. * The run_ends child array must be a 16/32/64-bit integer array * which encodes the indices at which the run with the value in * each corresponding index in the values child array ends. * Like list/struct types, the value array can be of any type. */ struct org_apache_arrow_flatbuf_RunEndEncoded_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_RunEndEncoded_vec_len(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_RunEndEncoded_table_t org_apache_arrow_flatbuf_RunEndEncoded_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_RunEndEncoded) /** Exact decimal value represented as an integer value in two's * complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers * are used. The representation uses the endianness indicated * in the Schema. */ struct org_apache_arrow_flatbuf_Decimal_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Decimal_vec_len(org_apache_arrow_flatbuf_Decimal_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Decimal_table_t org_apache_arrow_flatbuf_Decimal_vec_at(org_apache_arrow_flatbuf_Decimal_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Decimal_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Decimal) /** Total number of decimal digits */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Decimal, precision, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of digits after the decimal point "." */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Decimal, scale, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of bits per value. The only accepted widths are 128 and 256. * We use bitWidth for consistency with Int::bitWidth. */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_Decimal, bitWidth, flatbuffers_int32, int32_t, INT32_C(128)) /** Date is either a 32-bit or 64-bit signed integer type representing an * elapsed time since UNIX epoch (1970-01-01), stored in either of two units: * * * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no * leap seconds), where the values are evenly divisible by 86400000 * * Days (32 bits) since the UNIX epoch */ struct org_apache_arrow_flatbuf_Date_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Date_vec_len(org_apache_arrow_flatbuf_Date_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Date_table_t org_apache_arrow_flatbuf_Date_vec_at(org_apache_arrow_flatbuf_Date_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Date_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Date) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Date, unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, INT16_C(1)) /** Time is either a 32-bit or 64-bit signed integer type representing an * elapsed time since midnight, stored in either of four units: seconds, * milliseconds, microseconds or nanoseconds. * * The integer `bitWidth` depends on the `unit` and must be one of the following: * * SECOND and MILLISECOND: 32 bits * * MICROSECOND and NANOSECOND: 64 bits * * The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds * (exclusive), adjusted for the time unit (for example, up to 86400000 * exclusive for the MILLISECOND unit). * This definition doesn't allow for leap seconds. Time values from * measurements with leap seconds will need to be corrected when ingesting * into Arrow (for example by replacing the value 86400 with 86399). */ struct org_apache_arrow_flatbuf_Time_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Time_vec_len(org_apache_arrow_flatbuf_Time_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Time_table_t org_apache_arrow_flatbuf_Time_vec_at(org_apache_arrow_flatbuf_Time_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Time_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Time) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Time, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Time, bitWidth, flatbuffers_int32, int32_t, INT32_C(32)) /** Timestamp is a 64-bit signed integer representing an elapsed time since a * fixed epoch, stored in either of four units: seconds, milliseconds, * microseconds or nanoseconds, and is optionally annotated with a timezone. * * Timestamp values do not include any leap seconds (in other words, all * days are considered 86400 seconds long). * * Timestamps with a non-empty timezone * ------------------------------------ * * If a Timestamp column has a non-empty timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone * (the Unix epoch), regardless of the Timestamp's own timezone. * * Therefore, timestamp values with a non-empty timezone correspond to * physical points in time together with some additional information about * how the data was obtained and/or how to display it (the timezone). * * For example, the timestamp value 0 with the timezone string "Europe/Paris" * corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the * application may prefer to display it as "January 1st 1970, 01h00" in * the Europe/Paris timezone (which is the same physical point in time). * * One consequence is that timestamp values with a non-empty timezone * can be compared and ordered directly, since they all share the same * well-known point of reference (the Unix epoch). * * Timestamps with an unset / empty timezone * ----------------------------------------- * * If a Timestamp column has no timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone. * * Therefore, timestamp values without a timezone cannot be meaningfully * interpreted as physical points in time, but only as calendar / clock * indications ("wall clock time") in an unspecified timezone. * * For example, the timestamp value 0 with an empty timezone string * corresponds to "January 1st 1970, 00h00" in an unknown timezone: there * is not enough information to interpret it as a well-defined physical * point in time. * * One consequence is that timestamp values without a timezone cannot * be reliably compared or ordered, since they may have different points of * reference. In particular, it is *not* possible to interpret an unset * or empty timezone as the same as "UTC". * * Conversion between timezones * ---------------------------- * * If a Timestamp column has a non-empty timezone, changing the timezone * to a different non-empty value is a metadata-only operation: * the timestamp values need not change as their point of reference remains * the same (the Unix epoch). * * However, if a Timestamp column has no timezone value, changing it to a * non-empty value requires to think about the desired semantics. * One possibility is to assume that the original timestamp values are * relative to the epoch of the timezone being set; timestamp values should * then adjusted to the Unix epoch (for example, changing the timezone from * empty to "Europe/Paris" would require converting the timestamp values * from "Europe/Paris" to "UTC", which seems counter-intuitive but is * nevertheless correct). * * Guidelines for encoding data from external libraries * ---------------------------------------------------- * * Date & time libraries often have multiple different data types for temporal * data. In order to ease interoperability between different implementations the * Arrow project has some recommendations for encoding these types into a Timestamp * column. * * An "instant" represents a physical point in time that has no relevant timezone * (for example, astronomical data). To encode an instant, use a Timestamp with * the timezone string set to "UTC", and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * A "zoned date-time" represents a physical point in time annotated with an * informative timezone (for example, the timezone in which the data was * recorded). To encode a zoned date-time, use a Timestamp with the timezone * string set to the name of the timezone, and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * (There is some ambiguity between an instant and a zoned date-time with the * UTC timezone. Both of these are stored the same in Arrow. Typically, * this distinction does not matter. If it does, then an application should * use custom metadata or an extension type to distinguish between the two cases.) * * An "offset date-time" represents a physical point in time combined with an * explicit offset from UTC. To encode an offset date-time, use a Timestamp * with the timezone string set to the numeric timezone offset string * (e.g. "+03:00"), and make sure the Timestamp values are relative to * the UTC epoch (January 1st 1970, midnight). * * A "naive date-time" (also called "local date-time" in some libraries) * represents a wall clock time combined with a calendar date, but with * no indication of how to map this information to a physical point in time. * Naive date-times must be handled with care because of this missing * information, and also because daylight saving time (DST) may make * some values ambiguous or nonexistent. A naive date-time may be * stored as a struct with Date and Time fields. However, it may also be * encoded into a Timestamp column with an empty timezone. The timestamp * values should be computed "as if" the timezone of the date-time values * was UTC; for example, the naive date-time "January 1st 1970, 00h00" would * be encoded as timestamp value 0. */ struct org_apache_arrow_flatbuf_Timestamp_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Timestamp_vec_len(org_apache_arrow_flatbuf_Timestamp_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Timestamp_table_t org_apache_arrow_flatbuf_Timestamp_vec_at(org_apache_arrow_flatbuf_Timestamp_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Timestamp_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Timestamp) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Timestamp, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(0)) /** The timezone is an optional string indicating the name of a timezone, * one of: * * * As used in the Olson timezone database (the "tz database" or * "tzdata"), such as "America/New_York". * * An absolute timezone offset of the form "+XX:XX" or "-XX:XX", * such as "+07:30". * * Whether a timezone string is present indicates different semantics about * the data (see above). */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_Timestamp, timezone, 0) struct org_apache_arrow_flatbuf_Interval_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Interval_vec_len(org_apache_arrow_flatbuf_Interval_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Interval_table_t org_apache_arrow_flatbuf_Interval_vec_at(org_apache_arrow_flatbuf_Interval_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Interval_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Interval) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Interval, unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, INT16_C(0)) struct org_apache_arrow_flatbuf_Duration_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Duration_vec_len(org_apache_arrow_flatbuf_Duration_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Duration_table_t org_apache_arrow_flatbuf_Duration_vec_at(org_apache_arrow_flatbuf_Duration_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Duration_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Duration) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Duration, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) /** ---------------------------------------------------------------------- * Top-level Type value, enabling extensible type-specific metadata. We can * add new logical types to Type without breaking backwards compatibility */ typedef uint8_t org_apache_arrow_flatbuf_Type_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Type_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_Type) /** ---------------------------------------------------------------------- * user defined key value pairs to add custom metadata to arrow * key namespacing is the responsibility of the user */ #define org_apache_arrow_flatbuf_Type_NONE ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_Type_Null ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_Type_Int ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_Type_FloatingPoint ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(3)) #define org_apache_arrow_flatbuf_Type_Binary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(4)) #define org_apache_arrow_flatbuf_Type_Utf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(5)) #define org_apache_arrow_flatbuf_Type_Bool ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(6)) #define org_apache_arrow_flatbuf_Type_Decimal ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(7)) #define org_apache_arrow_flatbuf_Type_Date ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(8)) #define org_apache_arrow_flatbuf_Type_Time ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(9)) #define org_apache_arrow_flatbuf_Type_Timestamp ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(10)) #define org_apache_arrow_flatbuf_Type_Interval ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(11)) #define org_apache_arrow_flatbuf_Type_List ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(12)) #define org_apache_arrow_flatbuf_Type_Struct_ ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(13)) #define org_apache_arrow_flatbuf_Type_Union ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(14)) #define org_apache_arrow_flatbuf_Type_FixedSizeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(15)) #define org_apache_arrow_flatbuf_Type_FixedSizeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(16)) #define org_apache_arrow_flatbuf_Type_Map ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(17)) #define org_apache_arrow_flatbuf_Type_Duration ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(18)) #define org_apache_arrow_flatbuf_Type_LargeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(19)) #define org_apache_arrow_flatbuf_Type_LargeUtf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(20)) #define org_apache_arrow_flatbuf_Type_LargeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(21)) #define org_apache_arrow_flatbuf_Type_RunEndEncoded ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(22)) #define org_apache_arrow_flatbuf_Type_BinaryView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(23)) #define org_apache_arrow_flatbuf_Type_Utf8View ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(24)) #define org_apache_arrow_flatbuf_Type_ListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(25)) #define org_apache_arrow_flatbuf_Type_LargeListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(26)) static inline const char *org_apache_arrow_flatbuf_Type_type_name(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return "NONE"; case org_apache_arrow_flatbuf_Type_Null: return "Null"; case org_apache_arrow_flatbuf_Type_Int: return "Int"; case org_apache_arrow_flatbuf_Type_FloatingPoint: return "FloatingPoint"; case org_apache_arrow_flatbuf_Type_Binary: return "Binary"; case org_apache_arrow_flatbuf_Type_Utf8: return "Utf8"; case org_apache_arrow_flatbuf_Type_Bool: return "Bool"; case org_apache_arrow_flatbuf_Type_Decimal: return "Decimal"; case org_apache_arrow_flatbuf_Type_Date: return "Date"; case org_apache_arrow_flatbuf_Type_Time: return "Time"; case org_apache_arrow_flatbuf_Type_Timestamp: return "Timestamp"; case org_apache_arrow_flatbuf_Type_Interval: return "Interval"; case org_apache_arrow_flatbuf_Type_List: return "List"; case org_apache_arrow_flatbuf_Type_Struct_: return "Struct_"; case org_apache_arrow_flatbuf_Type_Union: return "Union"; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return "FixedSizeBinary"; case org_apache_arrow_flatbuf_Type_FixedSizeList: return "FixedSizeList"; case org_apache_arrow_flatbuf_Type_Map: return "Map"; case org_apache_arrow_flatbuf_Type_Duration: return "Duration"; case org_apache_arrow_flatbuf_Type_LargeBinary: return "LargeBinary"; case org_apache_arrow_flatbuf_Type_LargeUtf8: return "LargeUtf8"; case org_apache_arrow_flatbuf_Type_LargeList: return "LargeList"; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return "RunEndEncoded"; case org_apache_arrow_flatbuf_Type_BinaryView: return "BinaryView"; case org_apache_arrow_flatbuf_Type_Utf8View: return "Utf8View"; case org_apache_arrow_flatbuf_Type_ListView: return "ListView"; case org_apache_arrow_flatbuf_Type_LargeListView: return "LargeListView"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Type_is_known_type(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return 1; case org_apache_arrow_flatbuf_Type_Null: return 1; case org_apache_arrow_flatbuf_Type_Int: return 1; case org_apache_arrow_flatbuf_Type_FloatingPoint: return 1; case org_apache_arrow_flatbuf_Type_Binary: return 1; case org_apache_arrow_flatbuf_Type_Utf8: return 1; case org_apache_arrow_flatbuf_Type_Bool: return 1; case org_apache_arrow_flatbuf_Type_Decimal: return 1; case org_apache_arrow_flatbuf_Type_Date: return 1; case org_apache_arrow_flatbuf_Type_Time: return 1; case org_apache_arrow_flatbuf_Type_Timestamp: return 1; case org_apache_arrow_flatbuf_Type_Interval: return 1; case org_apache_arrow_flatbuf_Type_List: return 1; case org_apache_arrow_flatbuf_Type_Struct_: return 1; case org_apache_arrow_flatbuf_Type_Union: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeList: return 1; case org_apache_arrow_flatbuf_Type_Map: return 1; case org_apache_arrow_flatbuf_Type_Duration: return 1; case org_apache_arrow_flatbuf_Type_LargeBinary: return 1; case org_apache_arrow_flatbuf_Type_LargeUtf8: return 1; case org_apache_arrow_flatbuf_Type_LargeList: return 1; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return 1; case org_apache_arrow_flatbuf_Type_BinaryView: return 1; case org_apache_arrow_flatbuf_Type_Utf8View: return 1; case org_apache_arrow_flatbuf_Type_ListView: return 1; case org_apache_arrow_flatbuf_Type_LargeListView: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_KeyValue_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_KeyValue_vec_len(org_apache_arrow_flatbuf_KeyValue_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_KeyValue_table_t org_apache_arrow_flatbuf_KeyValue_vec_at(org_apache_arrow_flatbuf_KeyValue_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_KeyValue_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_KeyValue) __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_KeyValue, key, 0) __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_KeyValue, value, 0) struct org_apache_arrow_flatbuf_DictionaryEncoding_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_len(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_DictionaryEncoding_table_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_DictionaryEncoding) /** The known dictionary id in the application where this data is used. In * the file or streaming formats, the dictionary ids are found in the * DictionaryBatch messages */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_DictionaryEncoding, id, flatbuffers_int64, int64_t, INT64_C(0)) /** The dictionary indices are constrained to be non-negative integers. If * this field is null, the indices must be signed int32. To maximize * cross-language compatibility and performance, implementations are * recommended to prefer signed integer types over unsigned integer types * and to avoid uint64 indices unless they are required by an application. */ __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_DictionaryEncoding, indexType, org_apache_arrow_flatbuf_Int_table_t, 0) /** By default, dictionaries are not ordered, or the order does not have * semantic meaning. In some statistical, applications, dictionary-encoding * is used to represent ordered categorical data, and we provide a way to * preserve that metadata here */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_DictionaryEncoding, isOrdered, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_DictionaryEncoding, dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, INT16_C(0)) /** ---------------------------------------------------------------------- * A field represents a named column in a record / row batch or child of a * nested type. */ struct org_apache_arrow_flatbuf_Field_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Field_vec_len(org_apache_arrow_flatbuf_Field_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Field_table_t org_apache_arrow_flatbuf_Field_vec_at(org_apache_arrow_flatbuf_Field_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Field_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Field) /** Name is not required, in i.e. a List */ __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_Field, name, 0) /** Whether or not this field can contain nulls. Should be true in general. */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Field, nullable, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** This is the type of the decoded value if the field is dictionary encoded. */ __flatbuffers_define_union_field(flatbuffers_, 3, org_apache_arrow_flatbuf_Field, type, org_apache_arrow_flatbuf_Type, 0) /** Present only if the field is dictionary encoded. */ __flatbuffers_define_table_field(4, org_apache_arrow_flatbuf_Field, dictionary, org_apache_arrow_flatbuf_DictionaryEncoding_table_t, 0) /** children apply only to nested data types like Struct, List and Union. For * primitive types children will have length 0. */ __flatbuffers_define_vector_field(5, org_apache_arrow_flatbuf_Field, children, org_apache_arrow_flatbuf_Field_vec_t, 0) /** User-defined metadata */ __flatbuffers_define_vector_field(6, org_apache_arrow_flatbuf_Field, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** ---------------------------------------------------------------------- * A Schema describes the columns in a row batch */ struct org_apache_arrow_flatbuf_Schema_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Schema_vec_len(org_apache_arrow_flatbuf_Schema_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Schema_table_t org_apache_arrow_flatbuf_Schema_vec_at(org_apache_arrow_flatbuf_Schema_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Schema_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Schema) /** endianness of the buffer * it is Little Endian by default * if endianness doesn't match the underlying system then the vectors need to be converted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Schema, endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Schema, fields, org_apache_arrow_flatbuf_Field_vec_t, 0) __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Schema, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** Features used in the stream/file. */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Schema, features, org_apache_arrow_flatbuf_Feature_vec_t, 0) #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_READER_H */ #ifndef SCHEMA_BUILDER_H #define SCHEMA_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_MetadataVersion_formal_args , org_apache_arrow_flatbuf_MetadataVersion_enum_t v0 #define __org_apache_arrow_flatbuf_MetadataVersion_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t) #define __org_apache_arrow_flatbuf_Feature_formal_args , org_apache_arrow_flatbuf_Feature_enum_t v0 #define __org_apache_arrow_flatbuf_Feature_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t) #define __org_apache_arrow_flatbuf_UnionMode_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0 #define __org_apache_arrow_flatbuf_UnionMode_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t) #define __org_apache_arrow_flatbuf_Precision_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_Precision_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t) #define __org_apache_arrow_flatbuf_DateUnit_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_DateUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t) #define __org_apache_arrow_flatbuf_TimeUnit_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_TimeUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t) #define __org_apache_arrow_flatbuf_IntervalUnit_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_IntervalUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t) #define __org_apache_arrow_flatbuf_DictionaryKind_formal_args , org_apache_arrow_flatbuf_DictionaryKind_enum_t v0 #define __org_apache_arrow_flatbuf_DictionaryKind_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t) #define __org_apache_arrow_flatbuf_Endianness_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0 #define __org_apache_arrow_flatbuf_Endianness_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t) #define __org_apache_arrow_flatbuf_Buffer_formal_args , int64_t v0, int64_t v1 #define __org_apache_arrow_flatbuf_Buffer_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { p->offset = v0; p->length = v1; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { p->offset = p2->offset; p->length = p2->length; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_to_pe(&p->offset, v0); flatbuffers_int64_assign_to_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_to_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_to_pe(&p->length, &p2->length); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_from_pe(&p->offset, v0); flatbuffers_int64_assign_from_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_from_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_from_pe(&p->length, &p2->length); return p; } __flatbuffers_build_struct(flatbuffers_, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Buffer_file_identifier, org_apache_arrow_flatbuf_Buffer_type_identifier) __flatbuffers_define_fixed_array_primitives(flatbuffers_, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_Type_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_Type_union_vec_ref_t; static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Null_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Null_ref_t; static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Null, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Struct__required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Struct__ref_t; static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Struct_, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_List_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_List_ref_t; static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_List, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeList_ref_t; static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeList, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_ListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_ListView_ref_t; static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_ListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeListView_ref_t; static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeList_ref_t; static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Map_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Map_ref_t; static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Map, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Union_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Union_ref_t; static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Union, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Int_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Int_ref_t; static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Int, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FloatingPoint_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FloatingPoint_ref_t; static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8_ref_t; static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Binary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Binary_ref_t; static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Binary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeUtf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeUtf8_ref_t; static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeBinary_ref_t; static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8View_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8View_ref_t; static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_BinaryView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_BinaryView_ref_t; static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_ref_t; static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Bool_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Bool_ref_t; static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Bool, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_RunEndEncoded_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_RunEndEncoded_ref_t; static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Decimal_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Decimal_ref_t; static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Decimal, 3) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Date_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Date_ref_t; static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Date, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Time_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Time_ref_t; static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Time, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Timestamp_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Timestamp_ref_t; static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Interval_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Interval_ref_t; static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Interval, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Duration_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Duration_ref_t; static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Duration, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_KeyValue_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_KeyValue_ref_t; static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_DictionaryEncoding_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_ref_t; static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, 4) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Field_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Field_ref_t; static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Field, 7) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Schema_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Schema_ref_t; static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Schema, 4) #define __org_apache_arrow_flatbuf_Null_formal_args #define __org_apache_arrow_flatbuf_Null_call_args static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Null, org_apache_arrow_flatbuf_Null_file_identifier, org_apache_arrow_flatbuf_Null_type_identifier) #define __org_apache_arrow_flatbuf_Struct__formal_args #define __org_apache_arrow_flatbuf_Struct__call_args static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Struct_, org_apache_arrow_flatbuf_Struct__file_identifier, org_apache_arrow_flatbuf_Struct__type_identifier) #define __org_apache_arrow_flatbuf_List_formal_args #define __org_apache_arrow_flatbuf_List_call_args static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_List, org_apache_arrow_flatbuf_List_file_identifier, org_apache_arrow_flatbuf_List_type_identifier) #define __org_apache_arrow_flatbuf_LargeList_formal_args #define __org_apache_arrow_flatbuf_LargeList_call_args static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeList, org_apache_arrow_flatbuf_LargeList_file_identifier, org_apache_arrow_flatbuf_LargeList_type_identifier) #define __org_apache_arrow_flatbuf_ListView_formal_args #define __org_apache_arrow_flatbuf_ListView_call_args static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_ListView, org_apache_arrow_flatbuf_ListView_file_identifier, org_apache_arrow_flatbuf_ListView_type_identifier) #define __org_apache_arrow_flatbuf_LargeListView_formal_args #define __org_apache_arrow_flatbuf_LargeListView_call_args static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, org_apache_arrow_flatbuf_LargeListView_file_identifier, org_apache_arrow_flatbuf_LargeListView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeList_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeList_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList_file_identifier, org_apache_arrow_flatbuf_FixedSizeList_type_identifier) #define __org_apache_arrow_flatbuf_Map_formal_args , flatbuffers_bool_t v0 #define __org_apache_arrow_flatbuf_Map_call_args , v0 static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Map, org_apache_arrow_flatbuf_Map_file_identifier, org_apache_arrow_flatbuf_Map_type_identifier) #define __org_apache_arrow_flatbuf_Union_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0, flatbuffers_int32_vec_ref_t v1 #define __org_apache_arrow_flatbuf_Union_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Union, org_apache_arrow_flatbuf_Union_file_identifier, org_apache_arrow_flatbuf_Union_type_identifier) #define __org_apache_arrow_flatbuf_Int_formal_args , int32_t v0, flatbuffers_bool_t v1 #define __org_apache_arrow_flatbuf_Int_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_Int_file_identifier, org_apache_arrow_flatbuf_Int_type_identifier) #define __org_apache_arrow_flatbuf_FloatingPoint_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_FloatingPoint_call_args , v0 static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint_file_identifier, org_apache_arrow_flatbuf_FloatingPoint_type_identifier) #define __org_apache_arrow_flatbuf_Utf8_formal_args #define __org_apache_arrow_flatbuf_Utf8_call_args static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8, org_apache_arrow_flatbuf_Utf8_file_identifier, org_apache_arrow_flatbuf_Utf8_type_identifier) #define __org_apache_arrow_flatbuf_Binary_formal_args #define __org_apache_arrow_flatbuf_Binary_call_args static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Binary, org_apache_arrow_flatbuf_Binary_file_identifier, org_apache_arrow_flatbuf_Binary_type_identifier) #define __org_apache_arrow_flatbuf_LargeUtf8_formal_args #define __org_apache_arrow_flatbuf_LargeUtf8_call_args static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8_file_identifier, org_apache_arrow_flatbuf_LargeUtf8_type_identifier) #define __org_apache_arrow_flatbuf_LargeBinary_formal_args #define __org_apache_arrow_flatbuf_LargeBinary_call_args static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, org_apache_arrow_flatbuf_LargeBinary_file_identifier, org_apache_arrow_flatbuf_LargeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Utf8View_formal_args #define __org_apache_arrow_flatbuf_Utf8View_call_args static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, org_apache_arrow_flatbuf_Utf8View_file_identifier, org_apache_arrow_flatbuf_Utf8View_type_identifier) #define __org_apache_arrow_flatbuf_BinaryView_formal_args #define __org_apache_arrow_flatbuf_BinaryView_call_args static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, org_apache_arrow_flatbuf_BinaryView_file_identifier, org_apache_arrow_flatbuf_BinaryView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeBinary_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Bool_formal_args #define __org_apache_arrow_flatbuf_Bool_call_args static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Bool, org_apache_arrow_flatbuf_Bool_file_identifier, org_apache_arrow_flatbuf_Bool_type_identifier) #define __org_apache_arrow_flatbuf_RunEndEncoded_formal_args #define __org_apache_arrow_flatbuf_RunEndEncoded_call_args static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded_file_identifier, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier) #define __org_apache_arrow_flatbuf_Decimal_formal_args , int32_t v0, int32_t v1, int32_t v2 #define __org_apache_arrow_flatbuf_Decimal_call_args , v0, v1, v2 static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Decimal, org_apache_arrow_flatbuf_Decimal_file_identifier, org_apache_arrow_flatbuf_Decimal_type_identifier) #define __org_apache_arrow_flatbuf_Date_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Date_call_args , v0 static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Date, org_apache_arrow_flatbuf_Date_file_identifier, org_apache_arrow_flatbuf_Date_type_identifier) #define __org_apache_arrow_flatbuf_Time_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, int32_t v1 #define __org_apache_arrow_flatbuf_Time_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Time, org_apache_arrow_flatbuf_Time_file_identifier, org_apache_arrow_flatbuf_Time_type_identifier) #define __org_apache_arrow_flatbuf_Timestamp_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_Timestamp_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, org_apache_arrow_flatbuf_Timestamp_file_identifier, org_apache_arrow_flatbuf_Timestamp_type_identifier) #define __org_apache_arrow_flatbuf_Interval_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Interval_call_args , v0 static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Interval, org_apache_arrow_flatbuf_Interval_file_identifier, org_apache_arrow_flatbuf_Interval_type_identifier) #define __org_apache_arrow_flatbuf_Duration_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Duration_call_args , v0 static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Duration, org_apache_arrow_flatbuf_Duration_file_identifier, org_apache_arrow_flatbuf_Duration_type_identifier) #define __org_apache_arrow_flatbuf_KeyValue_formal_args , flatbuffers_string_ref_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_KeyValue_call_args , v0, v1 static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_KeyValue_file_identifier, org_apache_arrow_flatbuf_KeyValue_type_identifier) #define __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args , int64_t v0, org_apache_arrow_flatbuf_Int_ref_t v1, flatbuffers_bool_t v2, org_apache_arrow_flatbuf_DictionaryKind_enum_t v3 #define __org_apache_arrow_flatbuf_DictionaryEncoding_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier) #define __org_apache_arrow_flatbuf_Field_formal_args ,\ flatbuffers_string_ref_t v0, flatbuffers_bool_t v1, org_apache_arrow_flatbuf_Type_union_ref_t v3, org_apache_arrow_flatbuf_DictionaryEncoding_ref_t v4, org_apache_arrow_flatbuf_Field_vec_ref_t v5, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v6 #define __org_apache_arrow_flatbuf_Field_call_args ,\ v0, v1, v3, v4, v5, v6 static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field_file_identifier, org_apache_arrow_flatbuf_Field_type_identifier) #define __org_apache_arrow_flatbuf_Schema_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0, org_apache_arrow_flatbuf_Field_vec_ref_t v1, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v2, org_apache_arrow_flatbuf_Feature_vec_ref_t v3 #define __org_apache_arrow_flatbuf_Schema_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Schema, org_apache_arrow_flatbuf_Schema_file_identifier, org_apache_arrow_flatbuf_Schema_type_identifier) static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_NONE(void) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Null; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Int; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FloatingPoint; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Binary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Bool; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Decimal; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Date; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Time; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Timestamp; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Interval; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_List; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Struct_; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Union; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Map; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Duration; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeUtf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_RunEndEncoded; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_BinaryView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8View; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_ListView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeListView; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_Type) static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_clone(B, (org_apache_arrow_flatbuf_Null_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_clone(B, (org_apache_arrow_flatbuf_Int_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_clone(B, (org_apache_arrow_flatbuf_FloatingPoint_table_t)u.value)); case 4: return org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_clone(B, (org_apache_arrow_flatbuf_Binary_table_t)u.value)); case 5: return org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_clone(B, (org_apache_arrow_flatbuf_Utf8_table_t)u.value)); case 6: return org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_clone(B, (org_apache_arrow_flatbuf_Bool_table_t)u.value)); case 7: return org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_clone(B, (org_apache_arrow_flatbuf_Decimal_table_t)u.value)); case 8: return org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_clone(B, (org_apache_arrow_flatbuf_Date_table_t)u.value)); case 9: return org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_clone(B, (org_apache_arrow_flatbuf_Time_table_t)u.value)); case 10: return org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_clone(B, (org_apache_arrow_flatbuf_Timestamp_table_t)u.value)); case 11: return org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_clone(B, (org_apache_arrow_flatbuf_Interval_table_t)u.value)); case 12: return org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_clone(B, (org_apache_arrow_flatbuf_List_table_t)u.value)); case 13: return org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__clone(B, (org_apache_arrow_flatbuf_Struct__table_t)u.value)); case 14: return org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_clone(B, (org_apache_arrow_flatbuf_Union_table_t)u.value)); case 15: return org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_clone(B, (org_apache_arrow_flatbuf_FixedSizeBinary_table_t)u.value)); case 16: return org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_clone(B, (org_apache_arrow_flatbuf_FixedSizeList_table_t)u.value)); case 17: return org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_clone(B, (org_apache_arrow_flatbuf_Map_table_t)u.value)); case 18: return org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_clone(B, (org_apache_arrow_flatbuf_Duration_table_t)u.value)); case 19: return org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_clone(B, (org_apache_arrow_flatbuf_LargeBinary_table_t)u.value)); case 20: return org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_clone(B, (org_apache_arrow_flatbuf_LargeUtf8_table_t)u.value)); case 21: return org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_clone(B, (org_apache_arrow_flatbuf_LargeList_table_t)u.value)); case 22: return org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_clone(B, (org_apache_arrow_flatbuf_RunEndEncoded_table_t)u.value)); case 23: return org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_clone(B, (org_apache_arrow_flatbuf_BinaryView_table_t)u.value)); case 24: return org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_clone(B, (org_apache_arrow_flatbuf_Utf8View_table_t)u.value)); case 25: return org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_clone(B, (org_apache_arrow_flatbuf_ListView_table_t)u.value)); case 26: return org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_clone(B, (org_apache_arrow_flatbuf_LargeListView_table_t)u.value)); default: return org_apache_arrow_flatbuf_Type_as_NONE(); } } static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args) { if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } return org_apache_arrow_flatbuf_Null_end(B); } static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Null_end(B)); } static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args) { if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } return org_apache_arrow_flatbuf_Struct__end(B); } static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Struct__end(B)); } static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args) { if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } return org_apache_arrow_flatbuf_List_end(B); } static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_List_end(B)); } static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args) { if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeList_end(B); } static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeList_end(B)); } static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args) { if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_ListView_end(B); } static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_ListView_end(B)); } static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args) { if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeListView_end(B); } static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeListView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList_listSize, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeList) static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeList_end(B); } static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeList_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Map_keysSorted, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Map) static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args) { if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Map_end(B); } static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Map_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Union_mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Union) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Union_typeIds, flatbuffers_int32, int32_t, org_apache_arrow_flatbuf_Union) static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args) { if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_add(B, v1) || org_apache_arrow_flatbuf_Union_mode_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Union_end(B); } static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_pick(B, t) || org_apache_arrow_flatbuf_Union_mode_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Union_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Int_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Int) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Int_is_signed, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Int) static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args) { if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_add(B, v0) || org_apache_arrow_flatbuf_Int_is_signed_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_Int_end(B); } static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Int_is_signed_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Int_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint_precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_FloatingPoint) static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args) { if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FloatingPoint_end(B); } static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FloatingPoint_end(B)); } static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args) { if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8_end(B); } static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8_end(B)); } static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args) { if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } return org_apache_arrow_flatbuf_Binary_end(B); } static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Binary_end(B)); } static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args) { if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeUtf8_end(B); } static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeUtf8_end(B)); } static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args) { if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeBinary_end(B); } static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args) { if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8View_end(B); } static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8View_end(B)); } static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args) { if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } return org_apache_arrow_flatbuf_BinaryView_end(B); } static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_BinaryView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeBinary) static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeBinary_end(B); } static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args) { if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } return org_apache_arrow_flatbuf_Bool_end(B); } static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Bool_end(B)); } static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args) { if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } return org_apache_arrow_flatbuf_RunEndEncoded_end(B); } static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_RunEndEncoded_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Decimal_precision, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Decimal_scale, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_Decimal_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(128), org_apache_arrow_flatbuf_Decimal) static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args) { if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_add(B, v0) || org_apache_arrow_flatbuf_Decimal_scale_add(B, v1) || org_apache_arrow_flatbuf_Decimal_bitWidth_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_Decimal_end(B); } static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_pick(B, t) || org_apache_arrow_flatbuf_Decimal_scale_pick(B, t) || org_apache_arrow_flatbuf_Decimal_bitWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Decimal_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Date_unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Date) static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args) { if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Date_end(B); } static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Date_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Time_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Time) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Time_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(32), org_apache_arrow_flatbuf_Time) static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args) { if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_add(B, v1) || org_apache_arrow_flatbuf_Time_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Time_end(B); } static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Time_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Time_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_timezone, org_apache_arrow_flatbuf_Timestamp) static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args) { if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_add(B, v1) || org_apache_arrow_flatbuf_Timestamp_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Timestamp_end(B); } static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_pick(B, t) || org_apache_arrow_flatbuf_Timestamp_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Timestamp_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Interval_unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Interval) static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args) { if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Interval_end(B); } static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Interval_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Duration_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Duration) static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args) { if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Duration_end(B); } static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Duration_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_key, org_apache_arrow_flatbuf_KeyValue) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_value, org_apache_arrow_flatbuf_KeyValue) static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args) { if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_add(B, v0) || org_apache_arrow_flatbuf_KeyValue_value_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_KeyValue_end(B); } static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_pick(B, t) || org_apache_arrow_flatbuf_KeyValue_value_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_KeyValue_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_id, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_indexType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args) { if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_add(B, v0) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_add(B, v1) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_add(B, v3) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_DictionaryEncoding_end(B); } static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_DictionaryEncoding_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_Field_name, org_apache_arrow_flatbuf_Field) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Field_nullable, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_field(3, flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_field(4, flatbuffers_, org_apache_arrow_flatbuf_Field_dictionary, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(5, flatbuffers_, org_apache_arrow_flatbuf_Field_children, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(6, flatbuffers_, org_apache_arrow_flatbuf_Field_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Field) static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args) { if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_add(B, v0) || org_apache_arrow_flatbuf_Field_type_add_value(B, v3) || org_apache_arrow_flatbuf_Field_dictionary_add(B, v4) || org_apache_arrow_flatbuf_Field_children_add(B, v5) || org_apache_arrow_flatbuf_Field_custom_metadata_add(B, v6) || org_apache_arrow_flatbuf_Field_nullable_add(B, v1) || org_apache_arrow_flatbuf_Field_type_add_type(B, v3.type)) { return 0; } return org_apache_arrow_flatbuf_Field_end(B); } static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_pick(B, t) || org_apache_arrow_flatbuf_Field_type_pick(B, t) || org_apache_arrow_flatbuf_Field_dictionary_pick(B, t) || org_apache_arrow_flatbuf_Field_children_pick(B, t) || org_apache_arrow_flatbuf_Field_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Field_nullable_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Field_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Schema_endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Schema_fields, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Schema_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Schema_features, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, org_apache_arrow_flatbuf_Schema) static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args) { if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_add(B, v1) || org_apache_arrow_flatbuf_Schema_custom_metadata_add(B, v2) || org_apache_arrow_flatbuf_Schema_features_add(B, v3) || org_apache_arrow_flatbuf_Schema_endianness_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Schema_end(B); } static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_pick(B, t) || org_apache_arrow_flatbuf_Schema_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Schema_features_pick(B, t) || org_apache_arrow_flatbuf_Schema_endianness_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Schema_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_BUILDER_H */ #ifndef SCHEMA_VERIFIER_H #define SCHEMA_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_verifier.h" #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Type_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Null_verify_table); /* Null */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Int_verify_table); /* Int */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FloatingPoint_verify_table); /* FloatingPoint */ case 4: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Binary_verify_table); /* Binary */ case 5: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8_verify_table); /* Utf8 */ case 6: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Bool_verify_table); /* Bool */ case 7: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Decimal_verify_table); /* Decimal */ case 8: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Date_verify_table); /* Date */ case 9: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Time_verify_table); /* Time */ case 10: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Timestamp_verify_table); /* Timestamp */ case 11: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Interval_verify_table); /* Interval */ case 12: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_List_verify_table); /* List */ case 13: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Struct__verify_table); /* Struct_ */ case 14: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Union_verify_table); /* Union */ case 15: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); /* FixedSizeBinary */ case 16: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeList_verify_table); /* FixedSizeList */ case 17: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Map_verify_table); /* Map */ case 18: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Duration_verify_table); /* Duration */ case 19: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeBinary_verify_table); /* LargeBinary */ case 20: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeUtf8_verify_table); /* LargeUtf8 */ case 21: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeList_verify_table); /* LargeList */ case 22: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_RunEndEncoded_verify_table); /* RunEndEncoded */ case 23: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_BinaryView_verify_table); /* BinaryView */ case 24: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8View_verify_table); /* Utf8View */ case 25: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_ListView_verify_table); /* ListView */ case 26: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeListView_verify_table); /* LargeListView */ default: return flatcc_verify_ok; } } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root(buf, bufsiz, fid, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, fid, 16, 8); } static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Null_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_List_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* listSize */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 1, 1) /* keysSorted */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Map_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* mode */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 4, 4, INT64_C(1073741823)) /* typeIds */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Union_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* bitWidth */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* is_signed */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Int_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* precision */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* byteWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* precision */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* scale */)) return ret; if ((ret = flatcc_verify_field(td, 2, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Date_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Time_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* timezone */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* key */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* value */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* id */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 0, &org_apache_arrow_flatbuf_Int_verify_table) /* indexType */)) return ret; if ((ret = flatcc_verify_field(td, 2, 1, 1) /* isOrdered */)) return ret; if ((ret = flatcc_verify_field(td, 3, 2, 2) /* dictionaryKind */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* name */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* nullable */)) return ret; if ((ret = flatcc_verify_union_field(td, 3, 0, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_field(td, 4, 0, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table) /* dictionary */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 5, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* children */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 6, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Field_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* endianness */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 1, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* fields */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* features */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_VERIFIER_H */ #ifndef FILE_READER_H #define FILE_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef struct org_apache_arrow_flatbuf_Block org_apache_arrow_flatbuf_Block_t; typedef const org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_struct_t; typedef org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_mutable_struct_t; typedef const org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_vec_t; typedef org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Footer_table *org_apache_arrow_flatbuf_Footer_table_t; typedef struct org_apache_arrow_flatbuf_Footer_table *org_apache_arrow_flatbuf_Footer_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Footer_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Footer_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_Footer_file_identifier #define org_apache_arrow_flatbuf_Footer_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Footer_file_identifier */ #ifndef org_apache_arrow_flatbuf_Footer_identifier #define org_apache_arrow_flatbuf_Footer_identifier 0 #endif #define org_apache_arrow_flatbuf_Footer_type_hash ((flatbuffers_thash_t)0x65df4be3) #define org_apache_arrow_flatbuf_Footer_type_identifier "\xe3\x4b\xdf\x65" #ifndef org_apache_arrow_flatbuf_Footer_file_extension #define org_apache_arrow_flatbuf_Footer_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Block_file_identifier #define org_apache_arrow_flatbuf_Block_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Block_file_identifier */ #ifndef org_apache_arrow_flatbuf_Block_identifier #define org_apache_arrow_flatbuf_Block_identifier 0 #endif #define org_apache_arrow_flatbuf_Block_type_hash ((flatbuffers_thash_t)0xdc6d4841) #define org_apache_arrow_flatbuf_Block_type_identifier "\x41\x48\x6d\xdc" #ifndef org_apache_arrow_flatbuf_Block_file_extension #define org_apache_arrow_flatbuf_Block_file_extension "bin" #endif struct org_apache_arrow_flatbuf_Block { /** Index to the start of the RecordBlock (note this is past the Message header) */ alignas(8) int64_t offset; /** Length of the metadata */ alignas(4) int32_t metaDataLength; /** Length of the data (this is aligned so there can be a gap between this and * the metadata). */ alignas(8) int64_t bodyLength; }; static_assert(sizeof(org_apache_arrow_flatbuf_Block_t) == 24, "struct size mismatch"); static inline const org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block__const_ptr_add(const org_apache_arrow_flatbuf_Block_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block__ptr_add(org_apache_arrow_flatbuf_Block_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Block_struct_t org_apache_arrow_flatbuf_Block_vec_at(org_apache_arrow_flatbuf_Block_vec_t vec, size_t i) __flatbuffers_struct_vec_at(vec, i) static inline size_t org_apache_arrow_flatbuf_Block__size(void) { return 24; } static inline size_t org_apache_arrow_flatbuf_Block_vec_len(org_apache_arrow_flatbuf_Block_vec_t vec) __flatbuffers_vec_len(vec) __flatbuffers_struct_as_root(org_apache_arrow_flatbuf_Block) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Block, offset, flatbuffers_int64, int64_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Block, metaDataLength, flatbuffers_int32, int32_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Block, bodyLength, flatbuffers_int64, int64_t) /** ---------------------------------------------------------------------- * Arrow File metadata * */ struct org_apache_arrow_flatbuf_Footer_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Footer_vec_len(org_apache_arrow_flatbuf_Footer_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Footer_table_t org_apache_arrow_flatbuf_Footer_vec_at(org_apache_arrow_flatbuf_Footer_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Footer_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Footer) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Footer, version, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, INT16_C(0)) __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_Footer, schema, org_apache_arrow_flatbuf_Schema_table_t, 0) __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Footer, dictionaries, org_apache_arrow_flatbuf_Block_vec_t, 0) __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Footer, recordBatches, org_apache_arrow_flatbuf_Block_vec_t, 0) /** User-defined metadata */ __flatbuffers_define_vector_field(4, org_apache_arrow_flatbuf_Footer, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) #include "flatcc/flatcc_epilogue.h" #endif /* FILE_READER_H */ #ifndef FILE_BUILDER_H #define FILE_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FILE_READER_H #include "File_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #ifndef SCHEMA_BUILDER_H #include "Schema_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_Block_formal_args , int64_t v0, int32_t v1, int64_t v2 #define __org_apache_arrow_flatbuf_Block_call_args , v0, v1, v2 static inline org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_assign(org_apache_arrow_flatbuf_Block_t *p, int64_t v0, int32_t v1, int64_t v2) { p->offset = v0; p->metaDataLength = v1; p->bodyLength = v2; return p; } static inline org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_copy(org_apache_arrow_flatbuf_Block_t *p, const org_apache_arrow_flatbuf_Block_t *p2) { p->offset = p2->offset; p->metaDataLength = p2->metaDataLength; p->bodyLength = p2->bodyLength; return p; } static inline org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_assign_to_pe(org_apache_arrow_flatbuf_Block_t *p, int64_t v0, int32_t v1, int64_t v2) { flatbuffers_int64_assign_to_pe(&p->offset, v0); flatbuffers_int32_assign_to_pe(&p->metaDataLength, v1); flatbuffers_int64_assign_to_pe(&p->bodyLength, v2); return p; } static inline org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_copy_to_pe(org_apache_arrow_flatbuf_Block_t *p, const org_apache_arrow_flatbuf_Block_t *p2) { flatbuffers_int64_copy_to_pe(&p->offset, &p2->offset); flatbuffers_int32_copy_to_pe(&p->metaDataLength, &p2->metaDataLength); flatbuffers_int64_copy_to_pe(&p->bodyLength, &p2->bodyLength); return p; } static inline org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_assign_from_pe(org_apache_arrow_flatbuf_Block_t *p, int64_t v0, int32_t v1, int64_t v2) { flatbuffers_int64_assign_from_pe(&p->offset, v0); flatbuffers_int32_assign_from_pe(&p->metaDataLength, v1); flatbuffers_int64_assign_from_pe(&p->bodyLength, v2); return p; } static inline org_apache_arrow_flatbuf_Block_t *org_apache_arrow_flatbuf_Block_copy_from_pe(org_apache_arrow_flatbuf_Block_t *p, const org_apache_arrow_flatbuf_Block_t *p2) { flatbuffers_int64_copy_from_pe(&p->offset, &p2->offset); flatbuffers_int32_copy_from_pe(&p->metaDataLength, &p2->metaDataLength); flatbuffers_int64_copy_from_pe(&p->bodyLength, &p2->bodyLength); return p; } __flatbuffers_build_struct(flatbuffers_, org_apache_arrow_flatbuf_Block, 24, 8, org_apache_arrow_flatbuf_Block_file_identifier, org_apache_arrow_flatbuf_Block_type_identifier) __flatbuffers_define_fixed_array_primitives(flatbuffers_, org_apache_arrow_flatbuf_Block, org_apache_arrow_flatbuf_Block_t) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Footer_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Footer_ref_t; static org_apache_arrow_flatbuf_Footer_ref_t org_apache_arrow_flatbuf_Footer_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Footer_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Footer, 5) #define __org_apache_arrow_flatbuf_Footer_formal_args ,\ org_apache_arrow_flatbuf_MetadataVersion_enum_t v0, org_apache_arrow_flatbuf_Schema_ref_t v1, org_apache_arrow_flatbuf_Block_vec_ref_t v2, org_apache_arrow_flatbuf_Block_vec_ref_t v3, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v4 #define __org_apache_arrow_flatbuf_Footer_call_args ,\ v0, v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_Footer_ref_t org_apache_arrow_flatbuf_Footer_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Footer_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Footer, org_apache_arrow_flatbuf_Footer_file_identifier, org_apache_arrow_flatbuf_Footer_type_identifier) __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Footer_version, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Footer) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_Footer_schema, org_apache_arrow_flatbuf_Schema, org_apache_arrow_flatbuf_Footer) __flatbuffers_build_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Footer_dictionaries, org_apache_arrow_flatbuf_Block, org_apache_arrow_flatbuf_Block_t, org_apache_arrow_flatbuf_Footer) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Footer_recordBatches, org_apache_arrow_flatbuf_Block, org_apache_arrow_flatbuf_Block_t, org_apache_arrow_flatbuf_Footer) __flatbuffers_build_table_vector_field(4, flatbuffers_, org_apache_arrow_flatbuf_Footer_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Footer) static inline org_apache_arrow_flatbuf_Footer_ref_t org_apache_arrow_flatbuf_Footer_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Footer_formal_args) { if (org_apache_arrow_flatbuf_Footer_start(B) || org_apache_arrow_flatbuf_Footer_schema_add(B, v1) || org_apache_arrow_flatbuf_Footer_dictionaries_add(B, v2) || org_apache_arrow_flatbuf_Footer_recordBatches_add(B, v3) || org_apache_arrow_flatbuf_Footer_custom_metadata_add(B, v4) || org_apache_arrow_flatbuf_Footer_version_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Footer_end(B); } static org_apache_arrow_flatbuf_Footer_ref_t org_apache_arrow_flatbuf_Footer_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Footer_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Footer_start(B) || org_apache_arrow_flatbuf_Footer_schema_pick(B, t) || org_apache_arrow_flatbuf_Footer_dictionaries_pick(B, t) || org_apache_arrow_flatbuf_Footer_recordBatches_pick(B, t) || org_apache_arrow_flatbuf_Footer_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Footer_version_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Footer_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* FILE_BUILDER_H */ #ifndef FILE_VERIFIER_H #define FILE_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FILE_READER_H #include "File_reader.h" #endif #include "flatcc/flatcc_verifier.h" #ifndef SCHEMA_VERIFIER_H #include "Schema_verifier.h" #endif #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_Footer_verify_table(flatcc_table_verifier_descriptor_t *td); static inline int org_apache_arrow_flatbuf_Block_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Block_identifier, 24, 8); } static inline int org_apache_arrow_flatbuf_Block_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Block_identifier, 24, 8); } static inline int org_apache_arrow_flatbuf_Block_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, org_apache_arrow_flatbuf_Block_type_hash, 24, 8); } static inline int org_apache_arrow_flatbuf_Block_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Block_type_hash, 24, 8); } static inline int org_apache_arrow_flatbuf_Block_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, thash, 24, 8); } static inline int org_apache_arrow_flatbuf_Block_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, thash, 24, 8); } static inline int org_apache_arrow_flatbuf_Block_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root(buf, bufsiz, fid, 24, 8); } static inline int org_apache_arrow_flatbuf_Block_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, fid, 24, 8); } static int org_apache_arrow_flatbuf_Footer_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* version */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 0, &org_apache_arrow_flatbuf_Schema_verify_table) /* schema */)) return ret; if ((ret = flatcc_verify_vector_field(td, 2, 0, 24, 8, INT64_C(178956970)) /* dictionaries */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 24, 8, INT64_C(178956970)) /* recordBatches */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 4, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Footer_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Footer_identifier, &org_apache_arrow_flatbuf_Footer_verify_table); } static inline int org_apache_arrow_flatbuf_Footer_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Footer_identifier, &org_apache_arrow_flatbuf_Footer_verify_table); } static inline int org_apache_arrow_flatbuf_Footer_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Footer_type_identifier, &org_apache_arrow_flatbuf_Footer_verify_table); } static inline int org_apache_arrow_flatbuf_Footer_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Footer_type_identifier, &org_apache_arrow_flatbuf_Footer_verify_table); } static inline int org_apache_arrow_flatbuf_Footer_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Footer_verify_table); } static inline int org_apache_arrow_flatbuf_Footer_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Footer_verify_table); } static inline int org_apache_arrow_flatbuf_Footer_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Footer_verify_table); } static inline int org_apache_arrow_flatbuf_Footer_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Footer_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* FILE_VERIFIER_H */ #ifndef SCHEMA_READER_H #define SCHEMA_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef struct org_apache_arrow_flatbuf_Buffer org_apache_arrow_flatbuf_Buffer_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_struct_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_struct_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_vec_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_table_t; typedef struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__table_t; typedef struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_table_t; typedef struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_table_t; typedef struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_table_t; typedef struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_table_t; typedef struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_table_t; typedef struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_table_t; typedef struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_table_t; typedef struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_table_t; typedef struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_table_t; typedef struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_table_t; typedef struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_table_t; typedef struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_table_t; typedef struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_table_t; typedef struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_table_t; typedef struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_table_t; typedef struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_table_t; typedef struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_table_t; typedef struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_table_t; typedef struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_table_t; typedef struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_table_t; typedef struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_table_t; typedef struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_table_t; typedef struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_table_t; typedef struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_table_t; typedef struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_table_t; typedef struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_table_t; typedef struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_Null_file_identifier #define org_apache_arrow_flatbuf_Null_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Null_file_identifier */ #ifndef org_apache_arrow_flatbuf_Null_identifier #define org_apache_arrow_flatbuf_Null_identifier 0 #endif #define org_apache_arrow_flatbuf_Null_type_hash ((flatbuffers_thash_t)0x7b36a4dd) #define org_apache_arrow_flatbuf_Null_type_identifier "\xdd\xa4\x36\x7b" #ifndef org_apache_arrow_flatbuf_Null_file_extension #define org_apache_arrow_flatbuf_Null_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Struct__file_identifier #define org_apache_arrow_flatbuf_Struct__file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Struct__file_identifier */ #ifndef org_apache_arrow_flatbuf_Struct__identifier #define org_apache_arrow_flatbuf_Struct__identifier 0 #endif #define org_apache_arrow_flatbuf_Struct__type_hash ((flatbuffers_thash_t)0x6310f362) #define org_apache_arrow_flatbuf_Struct__type_identifier "\x62\xf3\x10\x63" #ifndef org_apache_arrow_flatbuf_Struct__file_extension #define org_apache_arrow_flatbuf_Struct__file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_List_file_identifier #define org_apache_arrow_flatbuf_List_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_List_file_identifier */ #ifndef org_apache_arrow_flatbuf_List_identifier #define org_apache_arrow_flatbuf_List_identifier 0 #endif #define org_apache_arrow_flatbuf_List_type_hash ((flatbuffers_thash_t)0xd4ce5878) #define org_apache_arrow_flatbuf_List_type_identifier "\x78\x58\xce\xd4" #ifndef org_apache_arrow_flatbuf_List_file_extension #define org_apache_arrow_flatbuf_List_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeList_file_identifier #define org_apache_arrow_flatbuf_LargeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeList_identifier #define org_apache_arrow_flatbuf_LargeList_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeList_type_hash ((flatbuffers_thash_t)0x38aa7e27) #define org_apache_arrow_flatbuf_LargeList_type_identifier "\x27\x7e\xaa\x38" #ifndef org_apache_arrow_flatbuf_LargeList_file_extension #define org_apache_arrow_flatbuf_LargeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_ListView_file_identifier #define org_apache_arrow_flatbuf_ListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_ListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_ListView_identifier #define org_apache_arrow_flatbuf_ListView_identifier 0 #endif #define org_apache_arrow_flatbuf_ListView_type_hash ((flatbuffers_thash_t)0x23d37919) #define org_apache_arrow_flatbuf_ListView_type_identifier "\x19\x79\xd3\x23" #ifndef org_apache_arrow_flatbuf_ListView_file_extension #define org_apache_arrow_flatbuf_ListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeListView_file_identifier #define org_apache_arrow_flatbuf_LargeListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeListView_identifier #define org_apache_arrow_flatbuf_LargeListView_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeListView_type_hash ((flatbuffers_thash_t)0x28efac02) #define org_apache_arrow_flatbuf_LargeListView_type_identifier "\x02\xac\xef\x28" #ifndef org_apache_arrow_flatbuf_LargeListView_file_extension #define org_apache_arrow_flatbuf_LargeListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_identifier #define org_apache_arrow_flatbuf_FixedSizeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeList_identifier #define org_apache_arrow_flatbuf_FixedSizeList_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeList_type_hash ((flatbuffers_thash_t)0xcef245bb) #define org_apache_arrow_flatbuf_FixedSizeList_type_identifier "\xbb\x45\xf2\xce" #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_extension #define org_apache_arrow_flatbuf_FixedSizeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Map_file_identifier #define org_apache_arrow_flatbuf_Map_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Map_file_identifier */ #ifndef org_apache_arrow_flatbuf_Map_identifier #define org_apache_arrow_flatbuf_Map_identifier 0 #endif #define org_apache_arrow_flatbuf_Map_type_hash ((flatbuffers_thash_t)0xcebef8e6) #define org_apache_arrow_flatbuf_Map_type_identifier "\xe6\xf8\xbe\xce" #ifndef org_apache_arrow_flatbuf_Map_file_extension #define org_apache_arrow_flatbuf_Map_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Union_file_identifier #define org_apache_arrow_flatbuf_Union_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Union_file_identifier */ #ifndef org_apache_arrow_flatbuf_Union_identifier #define org_apache_arrow_flatbuf_Union_identifier 0 #endif #define org_apache_arrow_flatbuf_Union_type_hash ((flatbuffers_thash_t)0x896bda57) #define org_apache_arrow_flatbuf_Union_type_identifier "\x57\xda\x6b\x89" #ifndef org_apache_arrow_flatbuf_Union_file_extension #define org_apache_arrow_flatbuf_Union_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Int_file_identifier #define org_apache_arrow_flatbuf_Int_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Int_file_identifier */ #ifndef org_apache_arrow_flatbuf_Int_identifier #define org_apache_arrow_flatbuf_Int_identifier 0 #endif #define org_apache_arrow_flatbuf_Int_type_hash ((flatbuffers_thash_t)0x30789001) #define org_apache_arrow_flatbuf_Int_type_identifier "\x01\x90\x78\x30" #ifndef org_apache_arrow_flatbuf_Int_file_extension #define org_apache_arrow_flatbuf_Int_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_identifier #define org_apache_arrow_flatbuf_FloatingPoint_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FloatingPoint_file_identifier */ #ifndef org_apache_arrow_flatbuf_FloatingPoint_identifier #define org_apache_arrow_flatbuf_FloatingPoint_identifier 0 #endif #define org_apache_arrow_flatbuf_FloatingPoint_type_hash ((flatbuffers_thash_t)0xf7d06268) #define org_apache_arrow_flatbuf_FloatingPoint_type_identifier "\x68\x62\xd0\xf7" #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_extension #define org_apache_arrow_flatbuf_FloatingPoint_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8_file_identifier #define org_apache_arrow_flatbuf_Utf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8_identifier #define org_apache_arrow_flatbuf_Utf8_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8_type_hash ((flatbuffers_thash_t)0x8fe60d37) #define org_apache_arrow_flatbuf_Utf8_type_identifier "\x37\x0d\xe6\x8f" #ifndef org_apache_arrow_flatbuf_Utf8_file_extension #define org_apache_arrow_flatbuf_Utf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Binary_file_identifier #define org_apache_arrow_flatbuf_Binary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Binary_file_identifier */ #ifndef org_apache_arrow_flatbuf_Binary_identifier #define org_apache_arrow_flatbuf_Binary_identifier 0 #endif #define org_apache_arrow_flatbuf_Binary_type_hash ((flatbuffers_thash_t)0x8e21a795) #define org_apache_arrow_flatbuf_Binary_type_identifier "\x95\xa7\x21\x8e" #ifndef org_apache_arrow_flatbuf_Binary_file_extension #define org_apache_arrow_flatbuf_Binary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_identifier #define org_apache_arrow_flatbuf_LargeUtf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeUtf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeUtf8_identifier #define org_apache_arrow_flatbuf_LargeUtf8_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeUtf8_type_hash ((flatbuffers_thash_t)0x24ed2fb0) #define org_apache_arrow_flatbuf_LargeUtf8_type_identifier "\xb0\x2f\xed\x24" #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_extension #define org_apache_arrow_flatbuf_LargeUtf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeBinary_file_identifier #define org_apache_arrow_flatbuf_LargeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeBinary_identifier #define org_apache_arrow_flatbuf_LargeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeBinary_type_hash ((flatbuffers_thash_t)0xbd437872) #define org_apache_arrow_flatbuf_LargeBinary_type_identifier "\x72\x78\x43\xbd" #ifndef org_apache_arrow_flatbuf_LargeBinary_file_extension #define org_apache_arrow_flatbuf_LargeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8View_file_identifier #define org_apache_arrow_flatbuf_Utf8View_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8View_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8View_identifier #define org_apache_arrow_flatbuf_Utf8View_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8View_type_hash ((flatbuffers_thash_t)0xab7692) #define org_apache_arrow_flatbuf_Utf8View_type_identifier "\x92\x76\xab\x00" #ifndef org_apache_arrow_flatbuf_Utf8View_file_extension #define org_apache_arrow_flatbuf_Utf8View_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_BinaryView_file_identifier #define org_apache_arrow_flatbuf_BinaryView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_BinaryView_file_identifier */ #ifndef org_apache_arrow_flatbuf_BinaryView_identifier #define org_apache_arrow_flatbuf_BinaryView_identifier 0 #endif #define org_apache_arrow_flatbuf_BinaryView_type_hash ((flatbuffers_thash_t)0x18c52428) #define org_apache_arrow_flatbuf_BinaryView_type_identifier "\x28\x24\xc5\x18" #ifndef org_apache_arrow_flatbuf_BinaryView_file_extension #define org_apache_arrow_flatbuf_BinaryView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeBinary_type_hash ((flatbuffers_thash_t)0x80d0f4ce) #define org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier "\xce\xf4\xd0\x80" #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_extension #define org_apache_arrow_flatbuf_FixedSizeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Bool_file_identifier #define org_apache_arrow_flatbuf_Bool_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Bool_file_identifier */ #ifndef org_apache_arrow_flatbuf_Bool_identifier #define org_apache_arrow_flatbuf_Bool_identifier 0 #endif #define org_apache_arrow_flatbuf_Bool_type_hash ((flatbuffers_thash_t)0x96bf83f0) #define org_apache_arrow_flatbuf_Bool_type_identifier "\xf0\x83\xbf\x96" #ifndef org_apache_arrow_flatbuf_Bool_file_extension #define org_apache_arrow_flatbuf_Bool_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_RunEndEncoded_file_identifier */ #ifndef org_apache_arrow_flatbuf_RunEndEncoded_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_identifier 0 #endif #define org_apache_arrow_flatbuf_RunEndEncoded_type_hash ((flatbuffers_thash_t)0x5a98bcc) #define org_apache_arrow_flatbuf_RunEndEncoded_type_identifier "\xcc\x8b\xa9\x05" #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_extension #define org_apache_arrow_flatbuf_RunEndEncoded_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Decimal_file_identifier #define org_apache_arrow_flatbuf_Decimal_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Decimal_file_identifier */ #ifndef org_apache_arrow_flatbuf_Decimal_identifier #define org_apache_arrow_flatbuf_Decimal_identifier 0 #endif #define org_apache_arrow_flatbuf_Decimal_type_hash ((flatbuffers_thash_t)0x91d1beb7) #define org_apache_arrow_flatbuf_Decimal_type_identifier "\xb7\xbe\xd1\x91" #ifndef org_apache_arrow_flatbuf_Decimal_file_extension #define org_apache_arrow_flatbuf_Decimal_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Date_file_identifier #define org_apache_arrow_flatbuf_Date_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Date_file_identifier */ #ifndef org_apache_arrow_flatbuf_Date_identifier #define org_apache_arrow_flatbuf_Date_identifier 0 #endif #define org_apache_arrow_flatbuf_Date_type_hash ((flatbuffers_thash_t)0xe0ccf624) #define org_apache_arrow_flatbuf_Date_type_identifier "\x24\xf6\xcc\xe0" #ifndef org_apache_arrow_flatbuf_Date_file_extension #define org_apache_arrow_flatbuf_Date_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Time_file_identifier #define org_apache_arrow_flatbuf_Time_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Time_file_identifier */ #ifndef org_apache_arrow_flatbuf_Time_identifier #define org_apache_arrow_flatbuf_Time_identifier 0 #endif #define org_apache_arrow_flatbuf_Time_type_hash ((flatbuffers_thash_t)0x2442a489) #define org_apache_arrow_flatbuf_Time_type_identifier "\x89\xa4\x42\x24" #ifndef org_apache_arrow_flatbuf_Time_file_extension #define org_apache_arrow_flatbuf_Time_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Timestamp_file_identifier #define org_apache_arrow_flatbuf_Timestamp_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Timestamp_file_identifier */ #ifndef org_apache_arrow_flatbuf_Timestamp_identifier #define org_apache_arrow_flatbuf_Timestamp_identifier 0 #endif #define org_apache_arrow_flatbuf_Timestamp_type_hash ((flatbuffers_thash_t)0x1fddf080) #define org_apache_arrow_flatbuf_Timestamp_type_identifier "\x80\xf0\xdd\x1f" #ifndef org_apache_arrow_flatbuf_Timestamp_file_extension #define org_apache_arrow_flatbuf_Timestamp_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Interval_file_identifier #define org_apache_arrow_flatbuf_Interval_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Interval_file_identifier */ #ifndef org_apache_arrow_flatbuf_Interval_identifier #define org_apache_arrow_flatbuf_Interval_identifier 0 #endif #define org_apache_arrow_flatbuf_Interval_type_hash ((flatbuffers_thash_t)0x1e2d6809) #define org_apache_arrow_flatbuf_Interval_type_identifier "\x09\x68\x2d\x1e" #ifndef org_apache_arrow_flatbuf_Interval_file_extension #define org_apache_arrow_flatbuf_Interval_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Duration_file_identifier #define org_apache_arrow_flatbuf_Duration_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Duration_file_identifier */ #ifndef org_apache_arrow_flatbuf_Duration_identifier #define org_apache_arrow_flatbuf_Duration_identifier 0 #endif #define org_apache_arrow_flatbuf_Duration_type_hash ((flatbuffers_thash_t)0x1ecea6b0) #define org_apache_arrow_flatbuf_Duration_type_identifier "\xb0\xa6\xce\x1e" #ifndef org_apache_arrow_flatbuf_Duration_file_extension #define org_apache_arrow_flatbuf_Duration_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_KeyValue_file_identifier #define org_apache_arrow_flatbuf_KeyValue_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_KeyValue_file_identifier */ #ifndef org_apache_arrow_flatbuf_KeyValue_identifier #define org_apache_arrow_flatbuf_KeyValue_identifier 0 #endif #define org_apache_arrow_flatbuf_KeyValue_type_hash ((flatbuffers_thash_t)0x3b264744) #define org_apache_arrow_flatbuf_KeyValue_type_identifier "\x44\x47\x26\x3b" #ifndef org_apache_arrow_flatbuf_KeyValue_file_extension #define org_apache_arrow_flatbuf_KeyValue_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier */ #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_identifier 0 #endif #define org_apache_arrow_flatbuf_DictionaryEncoding_type_hash ((flatbuffers_thash_t)0x8c703261) #define org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier "\x61\x32\x70\x8c" #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_extension #define org_apache_arrow_flatbuf_DictionaryEncoding_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Field_file_identifier #define org_apache_arrow_flatbuf_Field_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Field_file_identifier */ #ifndef org_apache_arrow_flatbuf_Field_identifier #define org_apache_arrow_flatbuf_Field_identifier 0 #endif #define org_apache_arrow_flatbuf_Field_type_hash ((flatbuffers_thash_t)0xd981525c) #define org_apache_arrow_flatbuf_Field_type_identifier "\x5c\x52\x81\xd9" #ifndef org_apache_arrow_flatbuf_Field_file_extension #define org_apache_arrow_flatbuf_Field_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Buffer_file_identifier #define org_apache_arrow_flatbuf_Buffer_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Buffer_file_identifier */ #ifndef org_apache_arrow_flatbuf_Buffer_identifier #define org_apache_arrow_flatbuf_Buffer_identifier 0 #endif #define org_apache_arrow_flatbuf_Buffer_type_hash ((flatbuffers_thash_t)0x519d7fea) #define org_apache_arrow_flatbuf_Buffer_type_identifier "\xea\x7f\x9d\x51" #ifndef org_apache_arrow_flatbuf_Buffer_file_extension #define org_apache_arrow_flatbuf_Buffer_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Schema_file_identifier #define org_apache_arrow_flatbuf_Schema_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Schema_file_identifier */ #ifndef org_apache_arrow_flatbuf_Schema_identifier #define org_apache_arrow_flatbuf_Schema_identifier 0 #endif #define org_apache_arrow_flatbuf_Schema_type_hash ((flatbuffers_thash_t)0x406570b) #define org_apache_arrow_flatbuf_Schema_type_identifier "\x0b\x57\x06\x04" #ifndef org_apache_arrow_flatbuf_Schema_file_extension #define org_apache_arrow_flatbuf_Schema_file_extension "bin" #endif typedef int16_t org_apache_arrow_flatbuf_MetadataVersion_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, 16) /** 0.1.0 (October 2016). */ #define org_apache_arrow_flatbuf_MetadataVersion_V1 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_MetadataVersion_V2 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_MetadataVersion_V3 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_MetadataVersion_V4 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(3)) #define org_apache_arrow_flatbuf_MetadataVersion_V5 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(4)) static inline const char *org_apache_arrow_flatbuf_MetadataVersion_name(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return "V1"; case org_apache_arrow_flatbuf_MetadataVersion_V2: return "V2"; case org_apache_arrow_flatbuf_MetadataVersion_V3: return "V3"; case org_apache_arrow_flatbuf_MetadataVersion_V4: return "V4"; case org_apache_arrow_flatbuf_MetadataVersion_V5: return "V5"; default: return ""; } } static inline int org_apache_arrow_flatbuf_MetadataVersion_is_known_value(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V2: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V3: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V4: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V5: return 1; default: return 0; } } /** Represents Arrow Features that might not have full support * within implementations. This is intended to be used in * two scenarios: * 1. A mechanism for readers of Arrow Streams * and files to understand that the stream or file makes * use of a feature that isn't supported or unknown to * the implementation (and therefore can meet the Arrow * forward compatibility guarantees). * 2. A means of negotiating between a client and server * what features a stream is allowed to use. The enums * values here are intented to represent higher level * features, additional details maybe negotiated * with key-value pairs specific to the protocol. * * Enums added to this list should be assigned power-of-two values * to facilitate exchanging and comparing bitmaps for supported * features. */ typedef int64_t org_apache_arrow_flatbuf_Feature_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, 64) /** Needed to make flatbuffers happy. */ #define org_apache_arrow_flatbuf_Feature_UNUSED ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(0)) #define org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(1)) #define org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(2)) static inline const char *org_apache_arrow_flatbuf_Feature_name(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return "UNUSED"; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return "DICTIONARY_REPLACEMENT"; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return "COMPRESSED_BODY"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Feature_is_known_value(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return 1; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return 1; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_UnionMode_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 16) #define org_apache_arrow_flatbuf_UnionMode_Sparse ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_UnionMode_Dense ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_UnionMode_name(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return "Sparse"; case org_apache_arrow_flatbuf_UnionMode_Dense: return "Dense"; default: return ""; } } static inline int org_apache_arrow_flatbuf_UnionMode_is_known_value(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return 1; case org_apache_arrow_flatbuf_UnionMode_Dense: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_Precision_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 16) #define org_apache_arrow_flatbuf_Precision_HALF ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Precision_SINGLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_Precision_DOUBLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_Precision_name(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return "HALF"; case org_apache_arrow_flatbuf_Precision_SINGLE: return "SINGLE"; case org_apache_arrow_flatbuf_Precision_DOUBLE: return "DOUBLE"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Precision_is_known_value(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return 1; case org_apache_arrow_flatbuf_Precision_SINGLE: return 1; case org_apache_arrow_flatbuf_Precision_DOUBLE: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_DateUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 16) #define org_apache_arrow_flatbuf_DateUnit_DAY ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_DateUnit_MILLISECOND ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_DateUnit_name(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return "DAY"; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return "MILLISECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DateUnit_is_known_value(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return 1; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_TimeUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 16) #define org_apache_arrow_flatbuf_TimeUnit_SECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_TimeUnit_MILLISECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_TimeUnit_MICROSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_TimeUnit_NANOSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(3)) static inline const char *org_apache_arrow_flatbuf_TimeUnit_name(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return "SECOND"; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return "MILLISECOND"; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return "MICROSECOND"; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return "NANOSECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_TimeUnit_is_known_value(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_IntervalUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 16) #define org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_IntervalUnit_name(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return "YEAR_MONTH"; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return "DAY_TIME"; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return "MONTH_DAY_NANO"; default: return ""; } } static inline int org_apache_arrow_flatbuf_IntervalUnit_is_known_value(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return 1; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return 1; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Dictionary encoding metadata * Maintained for forwards compatibility, in the future * Dictionaries might be explicit maps between integers and values * allowing for non-contiguous index values */ typedef int16_t org_apache_arrow_flatbuf_DictionaryKind_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 16) #define org_apache_arrow_flatbuf_DictionaryKind_DenseArray ((org_apache_arrow_flatbuf_DictionaryKind_enum_t)INT16_C(0)) static inline const char *org_apache_arrow_flatbuf_DictionaryKind_name(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return "DenseArray"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DictionaryKind_is_known_value(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Endianness of the platform producing the data */ typedef int16_t org_apache_arrow_flatbuf_Endianness_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 16) #define org_apache_arrow_flatbuf_Endianness_Little ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Endianness_Big ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_Endianness_name(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return "Little"; case org_apache_arrow_flatbuf_Endianness_Big: return "Big"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Endianness_is_known_value(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return 1; case org_apache_arrow_flatbuf_Endianness_Big: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * A Buffer represents a single contiguous memory segment */ struct org_apache_arrow_flatbuf_Buffer { /** The relative offset into the shared memory page where the bytes for this * buffer starts */ alignas(8) int64_t offset; /** The absolute length (in bytes) of the memory buffer. The memory is found * from offset (inclusive) to offset + length (non-inclusive). When building * messages using the encapsulated IPC message, padding bytes may be written * after a buffer, but such padding bytes do not need to be accounted for in * the size here. */ alignas(8) int64_t length; }; static_assert(sizeof(org_apache_arrow_flatbuf_Buffer_t) == 16, "struct size mismatch"); static inline const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__const_ptr_add(const org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__ptr_add(org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_struct_t org_apache_arrow_flatbuf_Buffer_vec_at(org_apache_arrow_flatbuf_Buffer_vec_t vec, size_t i) __flatbuffers_struct_vec_at(vec, i) static inline size_t org_apache_arrow_flatbuf_Buffer__size(void) { return 16; } static inline size_t org_apache_arrow_flatbuf_Buffer_vec_len(org_apache_arrow_flatbuf_Buffer_vec_t vec) __flatbuffers_vec_len(vec) __flatbuffers_struct_as_root(org_apache_arrow_flatbuf_Buffer) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, offset, flatbuffers_int64, int64_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, length, flatbuffers_int64, int64_t) /** These are stored in the flatbuffer in the Type union below */ struct org_apache_arrow_flatbuf_Null_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Null_vec_len(org_apache_arrow_flatbuf_Null_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Null_table_t org_apache_arrow_flatbuf_Null_vec_at(org_apache_arrow_flatbuf_Null_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Null_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Null) /** A Struct_ in the flatbuffer metadata is the same as an Arrow Struct * (according to the physical memory layout). We used Struct_ here as * Struct is a reserved word in Flatbuffers */ struct org_apache_arrow_flatbuf_Struct__table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Struct__vec_len(org_apache_arrow_flatbuf_Struct__vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Struct__table_t org_apache_arrow_flatbuf_Struct__vec_at(org_apache_arrow_flatbuf_Struct__vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Struct__table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Struct_) struct org_apache_arrow_flatbuf_List_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_List_vec_len(org_apache_arrow_flatbuf_List_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_List_table_t org_apache_arrow_flatbuf_List_vec_at(org_apache_arrow_flatbuf_List_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_List_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_List) /** Same as List, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeList_vec_len(org_apache_arrow_flatbuf_LargeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeList_table_t org_apache_arrow_flatbuf_LargeList_vec_at(org_apache_arrow_flatbuf_LargeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeList) /** Represents the same logical types that List can, but contains offsets and * sizes allowing for writes in any order and sharing of child values among * list values. */ struct org_apache_arrow_flatbuf_ListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_ListView_vec_len(org_apache_arrow_flatbuf_ListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_ListView_table_t org_apache_arrow_flatbuf_ListView_vec_at(org_apache_arrow_flatbuf_ListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_ListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_ListView) /** Same as ListView, but with 64-bit offsets and sizes, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeListView_vec_len(org_apache_arrow_flatbuf_LargeListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeListView_table_t org_apache_arrow_flatbuf_LargeListView_vec_at(org_apache_arrow_flatbuf_LargeListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeListView) struct org_apache_arrow_flatbuf_FixedSizeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeList_vec_len(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeList_table_t org_apache_arrow_flatbuf_FixedSizeList_vec_at(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeList) /** Number of list items per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeList, listSize, flatbuffers_int32, int32_t, INT32_C(0)) /** A Map is a logical nested type that is represented as * * List> * * In this layout, the keys and values are each respectively contiguous. We do * not constrain the key and value types, so the application is responsible * for ensuring that the keys are hashable and unique. Whether the keys are sorted * may be set in the metadata for this field. * * In a field with Map type, the field has a child Struct field, which then * has two children: key type and the second the value type. The names of the * child fields may be respectively "entries", "key", and "value", but this is * not enforced. * * Map * ```text * - child[0] entries: Struct * - child[0] key: K * - child[1] value: V * ``` * Neither the "entries" field nor the "key" field may be nullable. * * The metadata is structured so that Arrow systems without special handling * for Map can make Map an alias for List. The "layout" attribute for the Map * field must have the same contents as a List. */ struct org_apache_arrow_flatbuf_Map_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Map_vec_len(org_apache_arrow_flatbuf_Map_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Map_table_t org_apache_arrow_flatbuf_Map_vec_at(org_apache_arrow_flatbuf_Map_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Map_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Map) /** Set to true if the keys within each value are sorted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Map, keysSorted, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** A union is a complex type with children in Field * By default ids in the type vector refer to the offsets in the children * optionally typeIds provides an indirection between the child offset and the type id * for each child `typeIds[offset]` is the id used in the type vector */ struct org_apache_arrow_flatbuf_Union_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Union_vec_len(org_apache_arrow_flatbuf_Union_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Union_table_t org_apache_arrow_flatbuf_Union_vec_at(org_apache_arrow_flatbuf_Union_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Union_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Union) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Union, mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Union, typeIds, flatbuffers_int32_vec_t, 0) struct org_apache_arrow_flatbuf_Int_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Int_vec_len(org_apache_arrow_flatbuf_Int_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Int_table_t org_apache_arrow_flatbuf_Int_vec_at(org_apache_arrow_flatbuf_Int_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Int_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Int) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Int, bitWidth, flatbuffers_int32, int32_t, INT32_C(0)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Int, is_signed, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) struct org_apache_arrow_flatbuf_FloatingPoint_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FloatingPoint_vec_len(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FloatingPoint_table_t org_apache_arrow_flatbuf_FloatingPoint_vec_at(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FloatingPoint_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FloatingPoint, precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, INT16_C(0)) /** Unicode with UTF-8 encoding */ struct org_apache_arrow_flatbuf_Utf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8_vec_len(org_apache_arrow_flatbuf_Utf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8_table_t org_apache_arrow_flatbuf_Utf8_vec_at(org_apache_arrow_flatbuf_Utf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8) /** Opaque binary data */ struct org_apache_arrow_flatbuf_Binary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Binary_vec_len(org_apache_arrow_flatbuf_Binary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Binary_table_t org_apache_arrow_flatbuf_Binary_vec_at(org_apache_arrow_flatbuf_Binary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Binary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Binary) /** Same as Utf8, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeUtf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeUtf8_vec_len(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeUtf8_table_t org_apache_arrow_flatbuf_LargeUtf8_vec_at(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeUtf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeUtf8) /** Same as Binary, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeBinary_vec_len(org_apache_arrow_flatbuf_LargeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeBinary_table_t org_apache_arrow_flatbuf_LargeBinary_vec_at(org_apache_arrow_flatbuf_LargeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeBinary) /** Logically the same as Utf8, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_Utf8View_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8View_vec_len(org_apache_arrow_flatbuf_Utf8View_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8View_table_t org_apache_arrow_flatbuf_Utf8View_vec_at(org_apache_arrow_flatbuf_Utf8View_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8View_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8View) /** Logically the same as Binary, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_BinaryView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_BinaryView_vec_len(org_apache_arrow_flatbuf_BinaryView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_BinaryView_table_t org_apache_arrow_flatbuf_BinaryView_vec_at(org_apache_arrow_flatbuf_BinaryView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_BinaryView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_BinaryView) struct org_apache_arrow_flatbuf_FixedSizeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_len(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeBinary_table_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeBinary) /** Number of bytes per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeBinary, byteWidth, flatbuffers_int32, int32_t, INT32_C(0)) struct org_apache_arrow_flatbuf_Bool_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Bool_vec_len(org_apache_arrow_flatbuf_Bool_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Bool_table_t org_apache_arrow_flatbuf_Bool_vec_at(org_apache_arrow_flatbuf_Bool_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Bool_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Bool) /** Contains two child arrays, run_ends and values. * The run_ends child array must be a 16/32/64-bit integer array * which encodes the indices at which the run with the value in * each corresponding index in the values child array ends. * Like list/struct types, the value array can be of any type. */ struct org_apache_arrow_flatbuf_RunEndEncoded_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_RunEndEncoded_vec_len(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_RunEndEncoded_table_t org_apache_arrow_flatbuf_RunEndEncoded_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_RunEndEncoded) /** Exact decimal value represented as an integer value in two's * complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers * are used. The representation uses the endianness indicated * in the Schema. */ struct org_apache_arrow_flatbuf_Decimal_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Decimal_vec_len(org_apache_arrow_flatbuf_Decimal_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Decimal_table_t org_apache_arrow_flatbuf_Decimal_vec_at(org_apache_arrow_flatbuf_Decimal_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Decimal_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Decimal) /** Total number of decimal digits */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Decimal, precision, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of digits after the decimal point "." */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Decimal, scale, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of bits per value. The only accepted widths are 128 and 256. * We use bitWidth for consistency with Int::bitWidth. */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_Decimal, bitWidth, flatbuffers_int32, int32_t, INT32_C(128)) /** Date is either a 32-bit or 64-bit signed integer type representing an * elapsed time since UNIX epoch (1970-01-01), stored in either of two units: * * * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no * leap seconds), where the values are evenly divisible by 86400000 * * Days (32 bits) since the UNIX epoch */ struct org_apache_arrow_flatbuf_Date_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Date_vec_len(org_apache_arrow_flatbuf_Date_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Date_table_t org_apache_arrow_flatbuf_Date_vec_at(org_apache_arrow_flatbuf_Date_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Date_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Date) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Date, unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, INT16_C(1)) /** Time is either a 32-bit or 64-bit signed integer type representing an * elapsed time since midnight, stored in either of four units: seconds, * milliseconds, microseconds or nanoseconds. * * The integer `bitWidth` depends on the `unit` and must be one of the following: * * SECOND and MILLISECOND: 32 bits * * MICROSECOND and NANOSECOND: 64 bits * * The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds * (exclusive), adjusted for the time unit (for example, up to 86400000 * exclusive for the MILLISECOND unit). * This definition doesn't allow for leap seconds. Time values from * measurements with leap seconds will need to be corrected when ingesting * into Arrow (for example by replacing the value 86400 with 86399). */ struct org_apache_arrow_flatbuf_Time_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Time_vec_len(org_apache_arrow_flatbuf_Time_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Time_table_t org_apache_arrow_flatbuf_Time_vec_at(org_apache_arrow_flatbuf_Time_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Time_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Time) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Time, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Time, bitWidth, flatbuffers_int32, int32_t, INT32_C(32)) /** Timestamp is a 64-bit signed integer representing an elapsed time since a * fixed epoch, stored in either of four units: seconds, milliseconds, * microseconds or nanoseconds, and is optionally annotated with a timezone. * * Timestamp values do not include any leap seconds (in other words, all * days are considered 86400 seconds long). * * Timestamps with a non-empty timezone * ------------------------------------ * * If a Timestamp column has a non-empty timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone * (the Unix epoch), regardless of the Timestamp's own timezone. * * Therefore, timestamp values with a non-empty timezone correspond to * physical points in time together with some additional information about * how the data was obtained and/or how to display it (the timezone). * * For example, the timestamp value 0 with the timezone string "Europe/Paris" * corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the * application may prefer to display it as "January 1st 1970, 01h00" in * the Europe/Paris timezone (which is the same physical point in time). * * One consequence is that timestamp values with a non-empty timezone * can be compared and ordered directly, since they all share the same * well-known point of reference (the Unix epoch). * * Timestamps with an unset / empty timezone * ----------------------------------------- * * If a Timestamp column has no timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone. * * Therefore, timestamp values without a timezone cannot be meaningfully * interpreted as physical points in time, but only as calendar / clock * indications ("wall clock time") in an unspecified timezone. * * For example, the timestamp value 0 with an empty timezone string * corresponds to "January 1st 1970, 00h00" in an unknown timezone: there * is not enough information to interpret it as a well-defined physical * point in time. * * One consequence is that timestamp values without a timezone cannot * be reliably compared or ordered, since they may have different points of * reference. In particular, it is *not* possible to interpret an unset * or empty timezone as the same as "UTC". * * Conversion between timezones * ---------------------------- * * If a Timestamp column has a non-empty timezone, changing the timezone * to a different non-empty value is a metadata-only operation: * the timestamp values need not change as their point of reference remains * the same (the Unix epoch). * * However, if a Timestamp column has no timezone value, changing it to a * non-empty value requires to think about the desired semantics. * One possibility is to assume that the original timestamp values are * relative to the epoch of the timezone being set; timestamp values should * then adjusted to the Unix epoch (for example, changing the timezone from * empty to "Europe/Paris" would require converting the timestamp values * from "Europe/Paris" to "UTC", which seems counter-intuitive but is * nevertheless correct). * * Guidelines for encoding data from external libraries * ---------------------------------------------------- * * Date & time libraries often have multiple different data types for temporal * data. In order to ease interoperability between different implementations the * Arrow project has some recommendations for encoding these types into a Timestamp * column. * * An "instant" represents a physical point in time that has no relevant timezone * (for example, astronomical data). To encode an instant, use a Timestamp with * the timezone string set to "UTC", and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * A "zoned date-time" represents a physical point in time annotated with an * informative timezone (for example, the timezone in which the data was * recorded). To encode a zoned date-time, use a Timestamp with the timezone * string set to the name of the timezone, and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * (There is some ambiguity between an instant and a zoned date-time with the * UTC timezone. Both of these are stored the same in Arrow. Typically, * this distinction does not matter. If it does, then an application should * use custom metadata or an extension type to distinguish between the two cases.) * * An "offset date-time" represents a physical point in time combined with an * explicit offset from UTC. To encode an offset date-time, use a Timestamp * with the timezone string set to the numeric timezone offset string * (e.g. "+03:00"), and make sure the Timestamp values are relative to * the UTC epoch (January 1st 1970, midnight). * * A "naive date-time" (also called "local date-time" in some libraries) * represents a wall clock time combined with a calendar date, but with * no indication of how to map this information to a physical point in time. * Naive date-times must be handled with care because of this missing * information, and also because daylight saving time (DST) may make * some values ambiguous or nonexistent. A naive date-time may be * stored as a struct with Date and Time fields. However, it may also be * encoded into a Timestamp column with an empty timezone. The timestamp * values should be computed "as if" the timezone of the date-time values * was UTC; for example, the naive date-time "January 1st 1970, 00h00" would * be encoded as timestamp value 0. */ struct org_apache_arrow_flatbuf_Timestamp_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Timestamp_vec_len(org_apache_arrow_flatbuf_Timestamp_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Timestamp_table_t org_apache_arrow_flatbuf_Timestamp_vec_at(org_apache_arrow_flatbuf_Timestamp_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Timestamp_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Timestamp) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Timestamp, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(0)) /** The timezone is an optional string indicating the name of a timezone, * one of: * * * As used in the Olson timezone database (the "tz database" or * "tzdata"), such as "America/New_York". * * An absolute timezone offset of the form "+XX:XX" or "-XX:XX", * such as "+07:30". * * Whether a timezone string is present indicates different semantics about * the data (see above). */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_Timestamp, timezone, 0) struct org_apache_arrow_flatbuf_Interval_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Interval_vec_len(org_apache_arrow_flatbuf_Interval_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Interval_table_t org_apache_arrow_flatbuf_Interval_vec_at(org_apache_arrow_flatbuf_Interval_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Interval_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Interval) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Interval, unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, INT16_C(0)) struct org_apache_arrow_flatbuf_Duration_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Duration_vec_len(org_apache_arrow_flatbuf_Duration_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Duration_table_t org_apache_arrow_flatbuf_Duration_vec_at(org_apache_arrow_flatbuf_Duration_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Duration_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Duration) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Duration, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) /** ---------------------------------------------------------------------- * Top-level Type value, enabling extensible type-specific metadata. We can * add new logical types to Type without breaking backwards compatibility */ typedef uint8_t org_apache_arrow_flatbuf_Type_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Type_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_Type) /** ---------------------------------------------------------------------- * user defined key value pairs to add custom metadata to arrow * key namespacing is the responsibility of the user */ #define org_apache_arrow_flatbuf_Type_NONE ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_Type_Null ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_Type_Int ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_Type_FloatingPoint ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(3)) #define org_apache_arrow_flatbuf_Type_Binary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(4)) #define org_apache_arrow_flatbuf_Type_Utf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(5)) #define org_apache_arrow_flatbuf_Type_Bool ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(6)) #define org_apache_arrow_flatbuf_Type_Decimal ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(7)) #define org_apache_arrow_flatbuf_Type_Date ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(8)) #define org_apache_arrow_flatbuf_Type_Time ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(9)) #define org_apache_arrow_flatbuf_Type_Timestamp ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(10)) #define org_apache_arrow_flatbuf_Type_Interval ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(11)) #define org_apache_arrow_flatbuf_Type_List ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(12)) #define org_apache_arrow_flatbuf_Type_Struct_ ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(13)) #define org_apache_arrow_flatbuf_Type_Union ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(14)) #define org_apache_arrow_flatbuf_Type_FixedSizeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(15)) #define org_apache_arrow_flatbuf_Type_FixedSizeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(16)) #define org_apache_arrow_flatbuf_Type_Map ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(17)) #define org_apache_arrow_flatbuf_Type_Duration ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(18)) #define org_apache_arrow_flatbuf_Type_LargeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(19)) #define org_apache_arrow_flatbuf_Type_LargeUtf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(20)) #define org_apache_arrow_flatbuf_Type_LargeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(21)) #define org_apache_arrow_flatbuf_Type_RunEndEncoded ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(22)) #define org_apache_arrow_flatbuf_Type_BinaryView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(23)) #define org_apache_arrow_flatbuf_Type_Utf8View ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(24)) #define org_apache_arrow_flatbuf_Type_ListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(25)) #define org_apache_arrow_flatbuf_Type_LargeListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(26)) static inline const char *org_apache_arrow_flatbuf_Type_type_name(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return "NONE"; case org_apache_arrow_flatbuf_Type_Null: return "Null"; case org_apache_arrow_flatbuf_Type_Int: return "Int"; case org_apache_arrow_flatbuf_Type_FloatingPoint: return "FloatingPoint"; case org_apache_arrow_flatbuf_Type_Binary: return "Binary"; case org_apache_arrow_flatbuf_Type_Utf8: return "Utf8"; case org_apache_arrow_flatbuf_Type_Bool: return "Bool"; case org_apache_arrow_flatbuf_Type_Decimal: return "Decimal"; case org_apache_arrow_flatbuf_Type_Date: return "Date"; case org_apache_arrow_flatbuf_Type_Time: return "Time"; case org_apache_arrow_flatbuf_Type_Timestamp: return "Timestamp"; case org_apache_arrow_flatbuf_Type_Interval: return "Interval"; case org_apache_arrow_flatbuf_Type_List: return "List"; case org_apache_arrow_flatbuf_Type_Struct_: return "Struct_"; case org_apache_arrow_flatbuf_Type_Union: return "Union"; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return "FixedSizeBinary"; case org_apache_arrow_flatbuf_Type_FixedSizeList: return "FixedSizeList"; case org_apache_arrow_flatbuf_Type_Map: return "Map"; case org_apache_arrow_flatbuf_Type_Duration: return "Duration"; case org_apache_arrow_flatbuf_Type_LargeBinary: return "LargeBinary"; case org_apache_arrow_flatbuf_Type_LargeUtf8: return "LargeUtf8"; case org_apache_arrow_flatbuf_Type_LargeList: return "LargeList"; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return "RunEndEncoded"; case org_apache_arrow_flatbuf_Type_BinaryView: return "BinaryView"; case org_apache_arrow_flatbuf_Type_Utf8View: return "Utf8View"; case org_apache_arrow_flatbuf_Type_ListView: return "ListView"; case org_apache_arrow_flatbuf_Type_LargeListView: return "LargeListView"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Type_is_known_type(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return 1; case org_apache_arrow_flatbuf_Type_Null: return 1; case org_apache_arrow_flatbuf_Type_Int: return 1; case org_apache_arrow_flatbuf_Type_FloatingPoint: return 1; case org_apache_arrow_flatbuf_Type_Binary: return 1; case org_apache_arrow_flatbuf_Type_Utf8: return 1; case org_apache_arrow_flatbuf_Type_Bool: return 1; case org_apache_arrow_flatbuf_Type_Decimal: return 1; case org_apache_arrow_flatbuf_Type_Date: return 1; case org_apache_arrow_flatbuf_Type_Time: return 1; case org_apache_arrow_flatbuf_Type_Timestamp: return 1; case org_apache_arrow_flatbuf_Type_Interval: return 1; case org_apache_arrow_flatbuf_Type_List: return 1; case org_apache_arrow_flatbuf_Type_Struct_: return 1; case org_apache_arrow_flatbuf_Type_Union: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeList: return 1; case org_apache_arrow_flatbuf_Type_Map: return 1; case org_apache_arrow_flatbuf_Type_Duration: return 1; case org_apache_arrow_flatbuf_Type_LargeBinary: return 1; case org_apache_arrow_flatbuf_Type_LargeUtf8: return 1; case org_apache_arrow_flatbuf_Type_LargeList: return 1; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return 1; case org_apache_arrow_flatbuf_Type_BinaryView: return 1; case org_apache_arrow_flatbuf_Type_Utf8View: return 1; case org_apache_arrow_flatbuf_Type_ListView: return 1; case org_apache_arrow_flatbuf_Type_LargeListView: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_KeyValue_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_KeyValue_vec_len(org_apache_arrow_flatbuf_KeyValue_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_KeyValue_table_t org_apache_arrow_flatbuf_KeyValue_vec_at(org_apache_arrow_flatbuf_KeyValue_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_KeyValue_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_KeyValue) __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_KeyValue, key, 0) __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_KeyValue, value, 0) struct org_apache_arrow_flatbuf_DictionaryEncoding_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_len(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_DictionaryEncoding_table_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_DictionaryEncoding) /** The known dictionary id in the application where this data is used. In * the file or streaming formats, the dictionary ids are found in the * DictionaryBatch messages */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_DictionaryEncoding, id, flatbuffers_int64, int64_t, INT64_C(0)) /** The dictionary indices are constrained to be non-negative integers. If * this field is null, the indices must be signed int32. To maximize * cross-language compatibility and performance, implementations are * recommended to prefer signed integer types over unsigned integer types * and to avoid uint64 indices unless they are required by an application. */ __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_DictionaryEncoding, indexType, org_apache_arrow_flatbuf_Int_table_t, 0) /** By default, dictionaries are not ordered, or the order does not have * semantic meaning. In some statistical, applications, dictionary-encoding * is used to represent ordered categorical data, and we provide a way to * preserve that metadata here */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_DictionaryEncoding, isOrdered, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_DictionaryEncoding, dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, INT16_C(0)) /** ---------------------------------------------------------------------- * A field represents a named column in a record / row batch or child of a * nested type. */ struct org_apache_arrow_flatbuf_Field_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Field_vec_len(org_apache_arrow_flatbuf_Field_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Field_table_t org_apache_arrow_flatbuf_Field_vec_at(org_apache_arrow_flatbuf_Field_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Field_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Field) /** Name is not required, in i.e. a List */ __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_Field, name, 0) /** Whether or not this field can contain nulls. Should be true in general. */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Field, nullable, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** This is the type of the decoded value if the field is dictionary encoded. */ __flatbuffers_define_union_field(flatbuffers_, 3, org_apache_arrow_flatbuf_Field, type, org_apache_arrow_flatbuf_Type, 0) /** Present only if the field is dictionary encoded. */ __flatbuffers_define_table_field(4, org_apache_arrow_flatbuf_Field, dictionary, org_apache_arrow_flatbuf_DictionaryEncoding_table_t, 0) /** children apply only to nested data types like Struct, List and Union. For * primitive types children will have length 0. */ __flatbuffers_define_vector_field(5, org_apache_arrow_flatbuf_Field, children, org_apache_arrow_flatbuf_Field_vec_t, 0) /** User-defined metadata */ __flatbuffers_define_vector_field(6, org_apache_arrow_flatbuf_Field, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** ---------------------------------------------------------------------- * A Schema describes the columns in a row batch */ struct org_apache_arrow_flatbuf_Schema_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Schema_vec_len(org_apache_arrow_flatbuf_Schema_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Schema_table_t org_apache_arrow_flatbuf_Schema_vec_at(org_apache_arrow_flatbuf_Schema_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Schema_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Schema) /** endianness of the buffer * it is Little Endian by default * if endianness doesn't match the underlying system then the vectors need to be converted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Schema, endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Schema, fields, org_apache_arrow_flatbuf_Field_vec_t, 0) __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Schema, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** Features used in the stream/file. */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Schema, features, org_apache_arrow_flatbuf_Feature_vec_t, 0) #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_READER_H */ #ifndef SCHEMA_BUILDER_H #define SCHEMA_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_MetadataVersion_formal_args , org_apache_arrow_flatbuf_MetadataVersion_enum_t v0 #define __org_apache_arrow_flatbuf_MetadataVersion_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t) #define __org_apache_arrow_flatbuf_Feature_formal_args , org_apache_arrow_flatbuf_Feature_enum_t v0 #define __org_apache_arrow_flatbuf_Feature_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t) #define __org_apache_arrow_flatbuf_UnionMode_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0 #define __org_apache_arrow_flatbuf_UnionMode_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t) #define __org_apache_arrow_flatbuf_Precision_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_Precision_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t) #define __org_apache_arrow_flatbuf_DateUnit_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_DateUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t) #define __org_apache_arrow_flatbuf_TimeUnit_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_TimeUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t) #define __org_apache_arrow_flatbuf_IntervalUnit_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_IntervalUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t) #define __org_apache_arrow_flatbuf_DictionaryKind_formal_args , org_apache_arrow_flatbuf_DictionaryKind_enum_t v0 #define __org_apache_arrow_flatbuf_DictionaryKind_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t) #define __org_apache_arrow_flatbuf_Endianness_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0 #define __org_apache_arrow_flatbuf_Endianness_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t) #define __org_apache_arrow_flatbuf_Buffer_formal_args , int64_t v0, int64_t v1 #define __org_apache_arrow_flatbuf_Buffer_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { p->offset = v0; p->length = v1; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { p->offset = p2->offset; p->length = p2->length; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_to_pe(&p->offset, v0); flatbuffers_int64_assign_to_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_to_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_to_pe(&p->length, &p2->length); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_from_pe(&p->offset, v0); flatbuffers_int64_assign_from_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_from_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_from_pe(&p->length, &p2->length); return p; } __flatbuffers_build_struct(flatbuffers_, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Buffer_file_identifier, org_apache_arrow_flatbuf_Buffer_type_identifier) __flatbuffers_define_fixed_array_primitives(flatbuffers_, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_Type_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_Type_union_vec_ref_t; static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Null_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Null_ref_t; static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Null, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Struct__required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Struct__ref_t; static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Struct_, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_List_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_List_ref_t; static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_List, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeList_ref_t; static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeList, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_ListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_ListView_ref_t; static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_ListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeListView_ref_t; static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeList_ref_t; static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Map_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Map_ref_t; static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Map, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Union_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Union_ref_t; static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Union, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Int_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Int_ref_t; static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Int, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FloatingPoint_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FloatingPoint_ref_t; static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8_ref_t; static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Binary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Binary_ref_t; static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Binary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeUtf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeUtf8_ref_t; static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeBinary_ref_t; static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8View_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8View_ref_t; static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_BinaryView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_BinaryView_ref_t; static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_ref_t; static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Bool_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Bool_ref_t; static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Bool, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_RunEndEncoded_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_RunEndEncoded_ref_t; static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Decimal_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Decimal_ref_t; static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Decimal, 3) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Date_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Date_ref_t; static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Date, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Time_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Time_ref_t; static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Time, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Timestamp_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Timestamp_ref_t; static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Interval_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Interval_ref_t; static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Interval, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Duration_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Duration_ref_t; static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Duration, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_KeyValue_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_KeyValue_ref_t; static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_DictionaryEncoding_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_ref_t; static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, 4) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Field_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Field_ref_t; static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Field, 7) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Schema_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Schema_ref_t; static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Schema, 4) #define __org_apache_arrow_flatbuf_Null_formal_args #define __org_apache_arrow_flatbuf_Null_call_args static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Null, org_apache_arrow_flatbuf_Null_file_identifier, org_apache_arrow_flatbuf_Null_type_identifier) #define __org_apache_arrow_flatbuf_Struct__formal_args #define __org_apache_arrow_flatbuf_Struct__call_args static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Struct_, org_apache_arrow_flatbuf_Struct__file_identifier, org_apache_arrow_flatbuf_Struct__type_identifier) #define __org_apache_arrow_flatbuf_List_formal_args #define __org_apache_arrow_flatbuf_List_call_args static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_List, org_apache_arrow_flatbuf_List_file_identifier, org_apache_arrow_flatbuf_List_type_identifier) #define __org_apache_arrow_flatbuf_LargeList_formal_args #define __org_apache_arrow_flatbuf_LargeList_call_args static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeList, org_apache_arrow_flatbuf_LargeList_file_identifier, org_apache_arrow_flatbuf_LargeList_type_identifier) #define __org_apache_arrow_flatbuf_ListView_formal_args #define __org_apache_arrow_flatbuf_ListView_call_args static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_ListView, org_apache_arrow_flatbuf_ListView_file_identifier, org_apache_arrow_flatbuf_ListView_type_identifier) #define __org_apache_arrow_flatbuf_LargeListView_formal_args #define __org_apache_arrow_flatbuf_LargeListView_call_args static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, org_apache_arrow_flatbuf_LargeListView_file_identifier, org_apache_arrow_flatbuf_LargeListView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeList_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeList_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList_file_identifier, org_apache_arrow_flatbuf_FixedSizeList_type_identifier) #define __org_apache_arrow_flatbuf_Map_formal_args , flatbuffers_bool_t v0 #define __org_apache_arrow_flatbuf_Map_call_args , v0 static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Map, org_apache_arrow_flatbuf_Map_file_identifier, org_apache_arrow_flatbuf_Map_type_identifier) #define __org_apache_arrow_flatbuf_Union_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0, flatbuffers_int32_vec_ref_t v1 #define __org_apache_arrow_flatbuf_Union_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Union, org_apache_arrow_flatbuf_Union_file_identifier, org_apache_arrow_flatbuf_Union_type_identifier) #define __org_apache_arrow_flatbuf_Int_formal_args , int32_t v0, flatbuffers_bool_t v1 #define __org_apache_arrow_flatbuf_Int_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_Int_file_identifier, org_apache_arrow_flatbuf_Int_type_identifier) #define __org_apache_arrow_flatbuf_FloatingPoint_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_FloatingPoint_call_args , v0 static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint_file_identifier, org_apache_arrow_flatbuf_FloatingPoint_type_identifier) #define __org_apache_arrow_flatbuf_Utf8_formal_args #define __org_apache_arrow_flatbuf_Utf8_call_args static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8, org_apache_arrow_flatbuf_Utf8_file_identifier, org_apache_arrow_flatbuf_Utf8_type_identifier) #define __org_apache_arrow_flatbuf_Binary_formal_args #define __org_apache_arrow_flatbuf_Binary_call_args static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Binary, org_apache_arrow_flatbuf_Binary_file_identifier, org_apache_arrow_flatbuf_Binary_type_identifier) #define __org_apache_arrow_flatbuf_LargeUtf8_formal_args #define __org_apache_arrow_flatbuf_LargeUtf8_call_args static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8_file_identifier, org_apache_arrow_flatbuf_LargeUtf8_type_identifier) #define __org_apache_arrow_flatbuf_LargeBinary_formal_args #define __org_apache_arrow_flatbuf_LargeBinary_call_args static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, org_apache_arrow_flatbuf_LargeBinary_file_identifier, org_apache_arrow_flatbuf_LargeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Utf8View_formal_args #define __org_apache_arrow_flatbuf_Utf8View_call_args static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, org_apache_arrow_flatbuf_Utf8View_file_identifier, org_apache_arrow_flatbuf_Utf8View_type_identifier) #define __org_apache_arrow_flatbuf_BinaryView_formal_args #define __org_apache_arrow_flatbuf_BinaryView_call_args static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, org_apache_arrow_flatbuf_BinaryView_file_identifier, org_apache_arrow_flatbuf_BinaryView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeBinary_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Bool_formal_args #define __org_apache_arrow_flatbuf_Bool_call_args static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Bool, org_apache_arrow_flatbuf_Bool_file_identifier, org_apache_arrow_flatbuf_Bool_type_identifier) #define __org_apache_arrow_flatbuf_RunEndEncoded_formal_args #define __org_apache_arrow_flatbuf_RunEndEncoded_call_args static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded_file_identifier, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier) #define __org_apache_arrow_flatbuf_Decimal_formal_args , int32_t v0, int32_t v1, int32_t v2 #define __org_apache_arrow_flatbuf_Decimal_call_args , v0, v1, v2 static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Decimal, org_apache_arrow_flatbuf_Decimal_file_identifier, org_apache_arrow_flatbuf_Decimal_type_identifier) #define __org_apache_arrow_flatbuf_Date_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Date_call_args , v0 static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Date, org_apache_arrow_flatbuf_Date_file_identifier, org_apache_arrow_flatbuf_Date_type_identifier) #define __org_apache_arrow_flatbuf_Time_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, int32_t v1 #define __org_apache_arrow_flatbuf_Time_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Time, org_apache_arrow_flatbuf_Time_file_identifier, org_apache_arrow_flatbuf_Time_type_identifier) #define __org_apache_arrow_flatbuf_Timestamp_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_Timestamp_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, org_apache_arrow_flatbuf_Timestamp_file_identifier, org_apache_arrow_flatbuf_Timestamp_type_identifier) #define __org_apache_arrow_flatbuf_Interval_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Interval_call_args , v0 static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Interval, org_apache_arrow_flatbuf_Interval_file_identifier, org_apache_arrow_flatbuf_Interval_type_identifier) #define __org_apache_arrow_flatbuf_Duration_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Duration_call_args , v0 static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Duration, org_apache_arrow_flatbuf_Duration_file_identifier, org_apache_arrow_flatbuf_Duration_type_identifier) #define __org_apache_arrow_flatbuf_KeyValue_formal_args , flatbuffers_string_ref_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_KeyValue_call_args , v0, v1 static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_KeyValue_file_identifier, org_apache_arrow_flatbuf_KeyValue_type_identifier) #define __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args , int64_t v0, org_apache_arrow_flatbuf_Int_ref_t v1, flatbuffers_bool_t v2, org_apache_arrow_flatbuf_DictionaryKind_enum_t v3 #define __org_apache_arrow_flatbuf_DictionaryEncoding_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier) #define __org_apache_arrow_flatbuf_Field_formal_args ,\ flatbuffers_string_ref_t v0, flatbuffers_bool_t v1, org_apache_arrow_flatbuf_Type_union_ref_t v3, org_apache_arrow_flatbuf_DictionaryEncoding_ref_t v4, org_apache_arrow_flatbuf_Field_vec_ref_t v5, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v6 #define __org_apache_arrow_flatbuf_Field_call_args ,\ v0, v1, v3, v4, v5, v6 static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field_file_identifier, org_apache_arrow_flatbuf_Field_type_identifier) #define __org_apache_arrow_flatbuf_Schema_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0, org_apache_arrow_flatbuf_Field_vec_ref_t v1, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v2, org_apache_arrow_flatbuf_Feature_vec_ref_t v3 #define __org_apache_arrow_flatbuf_Schema_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Schema, org_apache_arrow_flatbuf_Schema_file_identifier, org_apache_arrow_flatbuf_Schema_type_identifier) static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_NONE(void) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Null; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Int; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FloatingPoint; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Binary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Bool; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Decimal; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Date; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Time; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Timestamp; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Interval; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_List; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Struct_; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Union; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Map; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Duration; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeUtf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_RunEndEncoded; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_BinaryView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8View; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_ListView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeListView; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_Type) static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_clone(B, (org_apache_arrow_flatbuf_Null_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_clone(B, (org_apache_arrow_flatbuf_Int_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_clone(B, (org_apache_arrow_flatbuf_FloatingPoint_table_t)u.value)); case 4: return org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_clone(B, (org_apache_arrow_flatbuf_Binary_table_t)u.value)); case 5: return org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_clone(B, (org_apache_arrow_flatbuf_Utf8_table_t)u.value)); case 6: return org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_clone(B, (org_apache_arrow_flatbuf_Bool_table_t)u.value)); case 7: return org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_clone(B, (org_apache_arrow_flatbuf_Decimal_table_t)u.value)); case 8: return org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_clone(B, (org_apache_arrow_flatbuf_Date_table_t)u.value)); case 9: return org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_clone(B, (org_apache_arrow_flatbuf_Time_table_t)u.value)); case 10: return org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_clone(B, (org_apache_arrow_flatbuf_Timestamp_table_t)u.value)); case 11: return org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_clone(B, (org_apache_arrow_flatbuf_Interval_table_t)u.value)); case 12: return org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_clone(B, (org_apache_arrow_flatbuf_List_table_t)u.value)); case 13: return org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__clone(B, (org_apache_arrow_flatbuf_Struct__table_t)u.value)); case 14: return org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_clone(B, (org_apache_arrow_flatbuf_Union_table_t)u.value)); case 15: return org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_clone(B, (org_apache_arrow_flatbuf_FixedSizeBinary_table_t)u.value)); case 16: return org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_clone(B, (org_apache_arrow_flatbuf_FixedSizeList_table_t)u.value)); case 17: return org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_clone(B, (org_apache_arrow_flatbuf_Map_table_t)u.value)); case 18: return org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_clone(B, (org_apache_arrow_flatbuf_Duration_table_t)u.value)); case 19: return org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_clone(B, (org_apache_arrow_flatbuf_LargeBinary_table_t)u.value)); case 20: return org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_clone(B, (org_apache_arrow_flatbuf_LargeUtf8_table_t)u.value)); case 21: return org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_clone(B, (org_apache_arrow_flatbuf_LargeList_table_t)u.value)); case 22: return org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_clone(B, (org_apache_arrow_flatbuf_RunEndEncoded_table_t)u.value)); case 23: return org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_clone(B, (org_apache_arrow_flatbuf_BinaryView_table_t)u.value)); case 24: return org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_clone(B, (org_apache_arrow_flatbuf_Utf8View_table_t)u.value)); case 25: return org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_clone(B, (org_apache_arrow_flatbuf_ListView_table_t)u.value)); case 26: return org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_clone(B, (org_apache_arrow_flatbuf_LargeListView_table_t)u.value)); default: return org_apache_arrow_flatbuf_Type_as_NONE(); } } static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args) { if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } return org_apache_arrow_flatbuf_Null_end(B); } static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Null_end(B)); } static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args) { if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } return org_apache_arrow_flatbuf_Struct__end(B); } static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Struct__end(B)); } static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args) { if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } return org_apache_arrow_flatbuf_List_end(B); } static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_List_end(B)); } static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args) { if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeList_end(B); } static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeList_end(B)); } static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args) { if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_ListView_end(B); } static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_ListView_end(B)); } static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args) { if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeListView_end(B); } static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeListView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList_listSize, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeList) static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeList_end(B); } static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeList_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Map_keysSorted, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Map) static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args) { if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Map_end(B); } static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Map_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Union_mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Union) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Union_typeIds, flatbuffers_int32, int32_t, org_apache_arrow_flatbuf_Union) static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args) { if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_add(B, v1) || org_apache_arrow_flatbuf_Union_mode_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Union_end(B); } static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_pick(B, t) || org_apache_arrow_flatbuf_Union_mode_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Union_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Int_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Int) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Int_is_signed, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Int) static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args) { if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_add(B, v0) || org_apache_arrow_flatbuf_Int_is_signed_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_Int_end(B); } static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Int_is_signed_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Int_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint_precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_FloatingPoint) static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args) { if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FloatingPoint_end(B); } static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FloatingPoint_end(B)); } static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args) { if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8_end(B); } static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8_end(B)); } static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args) { if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } return org_apache_arrow_flatbuf_Binary_end(B); } static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Binary_end(B)); } static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args) { if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeUtf8_end(B); } static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeUtf8_end(B)); } static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args) { if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeBinary_end(B); } static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args) { if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8View_end(B); } static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8View_end(B)); } static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args) { if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } return org_apache_arrow_flatbuf_BinaryView_end(B); } static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_BinaryView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeBinary) static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeBinary_end(B); } static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args) { if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } return org_apache_arrow_flatbuf_Bool_end(B); } static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Bool_end(B)); } static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args) { if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } return org_apache_arrow_flatbuf_RunEndEncoded_end(B); } static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_RunEndEncoded_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Decimal_precision, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Decimal_scale, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_Decimal_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(128), org_apache_arrow_flatbuf_Decimal) static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args) { if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_add(B, v0) || org_apache_arrow_flatbuf_Decimal_scale_add(B, v1) || org_apache_arrow_flatbuf_Decimal_bitWidth_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_Decimal_end(B); } static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_pick(B, t) || org_apache_arrow_flatbuf_Decimal_scale_pick(B, t) || org_apache_arrow_flatbuf_Decimal_bitWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Decimal_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Date_unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Date) static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args) { if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Date_end(B); } static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Date_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Time_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Time) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Time_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(32), org_apache_arrow_flatbuf_Time) static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args) { if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_add(B, v1) || org_apache_arrow_flatbuf_Time_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Time_end(B); } static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Time_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Time_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_timezone, org_apache_arrow_flatbuf_Timestamp) static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args) { if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_add(B, v1) || org_apache_arrow_flatbuf_Timestamp_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Timestamp_end(B); } static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_pick(B, t) || org_apache_arrow_flatbuf_Timestamp_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Timestamp_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Interval_unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Interval) static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args) { if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Interval_end(B); } static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Interval_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Duration_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Duration) static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args) { if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Duration_end(B); } static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Duration_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_key, org_apache_arrow_flatbuf_KeyValue) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_value, org_apache_arrow_flatbuf_KeyValue) static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args) { if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_add(B, v0) || org_apache_arrow_flatbuf_KeyValue_value_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_KeyValue_end(B); } static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_pick(B, t) || org_apache_arrow_flatbuf_KeyValue_value_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_KeyValue_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_id, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_indexType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args) { if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_add(B, v0) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_add(B, v1) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_add(B, v3) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_DictionaryEncoding_end(B); } static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_DictionaryEncoding_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_Field_name, org_apache_arrow_flatbuf_Field) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Field_nullable, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_field(3, flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_field(4, flatbuffers_, org_apache_arrow_flatbuf_Field_dictionary, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(5, flatbuffers_, org_apache_arrow_flatbuf_Field_children, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(6, flatbuffers_, org_apache_arrow_flatbuf_Field_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Field) static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args) { if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_add(B, v0) || org_apache_arrow_flatbuf_Field_type_add_value(B, v3) || org_apache_arrow_flatbuf_Field_dictionary_add(B, v4) || org_apache_arrow_flatbuf_Field_children_add(B, v5) || org_apache_arrow_flatbuf_Field_custom_metadata_add(B, v6) || org_apache_arrow_flatbuf_Field_nullable_add(B, v1) || org_apache_arrow_flatbuf_Field_type_add_type(B, v3.type)) { return 0; } return org_apache_arrow_flatbuf_Field_end(B); } static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_pick(B, t) || org_apache_arrow_flatbuf_Field_type_pick(B, t) || org_apache_arrow_flatbuf_Field_dictionary_pick(B, t) || org_apache_arrow_flatbuf_Field_children_pick(B, t) || org_apache_arrow_flatbuf_Field_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Field_nullable_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Field_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Schema_endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Schema_fields, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Schema_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Schema_features, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, org_apache_arrow_flatbuf_Schema) static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args) { if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_add(B, v1) || org_apache_arrow_flatbuf_Schema_custom_metadata_add(B, v2) || org_apache_arrow_flatbuf_Schema_features_add(B, v3) || org_apache_arrow_flatbuf_Schema_endianness_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Schema_end(B); } static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_pick(B, t) || org_apache_arrow_flatbuf_Schema_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Schema_features_pick(B, t) || org_apache_arrow_flatbuf_Schema_endianness_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Schema_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_BUILDER_H */ #ifndef SCHEMA_VERIFIER_H #define SCHEMA_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_verifier.h" #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Type_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Null_verify_table); /* Null */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Int_verify_table); /* Int */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FloatingPoint_verify_table); /* FloatingPoint */ case 4: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Binary_verify_table); /* Binary */ case 5: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8_verify_table); /* Utf8 */ case 6: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Bool_verify_table); /* Bool */ case 7: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Decimal_verify_table); /* Decimal */ case 8: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Date_verify_table); /* Date */ case 9: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Time_verify_table); /* Time */ case 10: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Timestamp_verify_table); /* Timestamp */ case 11: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Interval_verify_table); /* Interval */ case 12: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_List_verify_table); /* List */ case 13: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Struct__verify_table); /* Struct_ */ case 14: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Union_verify_table); /* Union */ case 15: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); /* FixedSizeBinary */ case 16: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeList_verify_table); /* FixedSizeList */ case 17: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Map_verify_table); /* Map */ case 18: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Duration_verify_table); /* Duration */ case 19: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeBinary_verify_table); /* LargeBinary */ case 20: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeUtf8_verify_table); /* LargeUtf8 */ case 21: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeList_verify_table); /* LargeList */ case 22: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_RunEndEncoded_verify_table); /* RunEndEncoded */ case 23: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_BinaryView_verify_table); /* BinaryView */ case 24: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8View_verify_table); /* Utf8View */ case 25: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_ListView_verify_table); /* ListView */ case 26: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeListView_verify_table); /* LargeListView */ default: return flatcc_verify_ok; } } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root(buf, bufsiz, fid, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, fid, 16, 8); } static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Null_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_List_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* listSize */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 1, 1) /* keysSorted */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Map_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* mode */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 4, 4, INT64_C(1073741823)) /* typeIds */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Union_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* bitWidth */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* is_signed */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Int_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* precision */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* byteWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* precision */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* scale */)) return ret; if ((ret = flatcc_verify_field(td, 2, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Date_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Time_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* timezone */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* key */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* value */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* id */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 0, &org_apache_arrow_flatbuf_Int_verify_table) /* indexType */)) return ret; if ((ret = flatcc_verify_field(td, 2, 1, 1) /* isOrdered */)) return ret; if ((ret = flatcc_verify_field(td, 3, 2, 2) /* dictionaryKind */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* name */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* nullable */)) return ret; if ((ret = flatcc_verify_union_field(td, 3, 0, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_field(td, 4, 0, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table) /* dictionary */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 5, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* children */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 6, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Field_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* endianness */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 1, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* fields */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* features */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_VERIFIER_H */ #ifndef TENSOR_READER_H #define TENSOR_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef const struct org_apache_arrow_flatbuf_TensorDim_table *org_apache_arrow_flatbuf_TensorDim_table_t; typedef struct org_apache_arrow_flatbuf_TensorDim_table *org_apache_arrow_flatbuf_TensorDim_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_TensorDim_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_TensorDim_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Tensor_table *org_apache_arrow_flatbuf_Tensor_table_t; typedef struct org_apache_arrow_flatbuf_Tensor_table *org_apache_arrow_flatbuf_Tensor_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Tensor_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Tensor_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_TensorDim_file_identifier #define org_apache_arrow_flatbuf_TensorDim_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_TensorDim_file_identifier */ #ifndef org_apache_arrow_flatbuf_TensorDim_identifier #define org_apache_arrow_flatbuf_TensorDim_identifier 0 #endif #define org_apache_arrow_flatbuf_TensorDim_type_hash ((flatbuffers_thash_t)0xbc6d7b25) #define org_apache_arrow_flatbuf_TensorDim_type_identifier "\x25\x7b\x6d\xbc" #ifndef org_apache_arrow_flatbuf_TensorDim_file_extension #define org_apache_arrow_flatbuf_TensorDim_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Tensor_file_identifier #define org_apache_arrow_flatbuf_Tensor_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Tensor_file_identifier */ #ifndef org_apache_arrow_flatbuf_Tensor_identifier #define org_apache_arrow_flatbuf_Tensor_identifier 0 #endif #define org_apache_arrow_flatbuf_Tensor_type_hash ((flatbuffers_thash_t)0x1764df19) #define org_apache_arrow_flatbuf_Tensor_type_identifier "\x19\xdf\x64\x17" #ifndef org_apache_arrow_flatbuf_Tensor_file_extension #define org_apache_arrow_flatbuf_Tensor_file_extension "bin" #endif /** ---------------------------------------------------------------------- * Data structures for dense tensors * Shape data for a single axis in a tensor */ struct org_apache_arrow_flatbuf_TensorDim_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_TensorDim_vec_len(org_apache_arrow_flatbuf_TensorDim_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_TensorDim_table_t org_apache_arrow_flatbuf_TensorDim_vec_at(org_apache_arrow_flatbuf_TensorDim_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_TensorDim_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_TensorDim) /** Length of dimension */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_TensorDim, size, flatbuffers_int64, int64_t, INT64_C(0)) /** Name of the dimension, optional */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_TensorDim, name, 0) struct org_apache_arrow_flatbuf_Tensor_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Tensor_vec_len(org_apache_arrow_flatbuf_Tensor_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Tensor_table_t org_apache_arrow_flatbuf_Tensor_vec_at(org_apache_arrow_flatbuf_Tensor_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Tensor_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Tensor) /** The type of data contained in a value cell. Currently only fixed-width * value types are supported, no strings or nested types */ __flatbuffers_define_union_field(flatbuffers_, 1, org_apache_arrow_flatbuf_Tensor, type, org_apache_arrow_flatbuf_Type, 1) /** The dimensions of the tensor, optionally named */ __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Tensor, shape, org_apache_arrow_flatbuf_TensorDim_vec_t, 1) /** Non-negative byte offsets to advance one value cell along each dimension * If omitted, default to row-major order (C-like). */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Tensor, strides, flatbuffers_int64_vec_t, 0) /** The location and size of the tensor's data */ __flatbuffers_define_struct_field(4, org_apache_arrow_flatbuf_Tensor, data, org_apache_arrow_flatbuf_Buffer_struct_t, 1) #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_READER_H */ #ifndef TENSOR_BUILDER_H #define TENSOR_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #ifndef SCHEMA_BUILDER_H #include "Schema_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_TensorDim_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_TensorDim_ref_t; static org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_TensorDim_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_TensorDim, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Tensor_required[] = { 1, 2, 4, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Tensor_ref_t; static org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Tensor_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Tensor, 5) #define __org_apache_arrow_flatbuf_TensorDim_formal_args , int64_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_TensorDim_call_args , v0, v1 static inline org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_TensorDim_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_TensorDim_file_identifier, org_apache_arrow_flatbuf_TensorDim_type_identifier) #define __org_apache_arrow_flatbuf_Tensor_formal_args , org_apache_arrow_flatbuf_Type_union_ref_t v1, org_apache_arrow_flatbuf_TensorDim_vec_ref_t v2, flatbuffers_int64_vec_ref_t v3, org_apache_arrow_flatbuf_Buffer_t *v4 #define __org_apache_arrow_flatbuf_Tensor_call_args , v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Tensor_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Tensor, org_apache_arrow_flatbuf_Tensor_file_identifier, org_apache_arrow_flatbuf_Tensor_type_identifier) __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_TensorDim_size, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_TensorDim) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_TensorDim_name, org_apache_arrow_flatbuf_TensorDim) static inline org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_TensorDim_formal_args) { if (org_apache_arrow_flatbuf_TensorDim_start(B) || org_apache_arrow_flatbuf_TensorDim_size_add(B, v0) || org_apache_arrow_flatbuf_TensorDim_name_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_TensorDim_end(B); } static org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_TensorDim_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_TensorDim_start(B) || org_apache_arrow_flatbuf_TensorDim_size_pick(B, t) || org_apache_arrow_flatbuf_TensorDim_name_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_TensorDim_end(B)); } __flatbuffers_build_union_field(1, flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Tensor_shape, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Tensor_strides, flatbuffers_int64, int64_t, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_struct_field(4, flatbuffers_, org_apache_arrow_flatbuf_Tensor_data, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Tensor) static inline org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Tensor_formal_args) { if (org_apache_arrow_flatbuf_Tensor_start(B) || org_apache_arrow_flatbuf_Tensor_data_add(B, v4) || org_apache_arrow_flatbuf_Tensor_type_add_value(B, v1) || org_apache_arrow_flatbuf_Tensor_shape_add(B, v2) || org_apache_arrow_flatbuf_Tensor_strides_add(B, v3) || org_apache_arrow_flatbuf_Tensor_type_add_type(B, v1.type)) { return 0; } return org_apache_arrow_flatbuf_Tensor_end(B); } static org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Tensor_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Tensor_start(B) || org_apache_arrow_flatbuf_Tensor_data_pick(B, t) || org_apache_arrow_flatbuf_Tensor_type_pick(B, t) || org_apache_arrow_flatbuf_Tensor_shape_pick(B, t) || org_apache_arrow_flatbuf_Tensor_strides_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Tensor_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_BUILDER_H */ #ifndef TENSOR_VERIFIER_H #define TENSOR_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #include "flatcc/flatcc_verifier.h" #ifndef SCHEMA_VERIFIER_H #include "Schema_verifier.h" #endif #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_TensorDim_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Tensor_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_TensorDim_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* size */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* name */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_type_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_type_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static int org_apache_arrow_flatbuf_Tensor_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_union_field(td, 1, 1, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 1, &org_apache_arrow_flatbuf_TensorDim_verify_table) /* shape */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* strides */)) return ret; if ((ret = flatcc_verify_field(td, 4, 16, 8) /* data */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_type_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_type_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Tensor_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_VERIFIER_H */ #ifndef SPARSETENSOR_READER_H #define SPARSETENSOR_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef const struct org_apache_arrow_flatbuf_SparseTensorIndexCOO_table *org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t; typedef struct org_apache_arrow_flatbuf_SparseTensorIndexCOO_table *org_apache_arrow_flatbuf_SparseTensorIndexCOO_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCOO_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t; typedef struct org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_SparseTensorIndexCSF_table *org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t; typedef struct org_apache_arrow_flatbuf_SparseTensorIndexCSF_table *org_apache_arrow_flatbuf_SparseTensorIndexCSF_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCSF_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_SparseTensor_table *org_apache_arrow_flatbuf_SparseTensor_table_t; typedef struct org_apache_arrow_flatbuf_SparseTensor_table *org_apache_arrow_flatbuf_SparseTensor_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensor_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensor_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_hash ((flatbuffers_thash_t)0x3b31385a) #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier "\x5a\x38\x31\x3b" #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_extension #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_hash ((flatbuffers_thash_t)0xec57ea87) #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier "\x87\xea\x57\xec" #ifndef org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_extension #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_hash ((flatbuffers_thash_t)0xf44edda9) #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier "\xa9\xdd\x4e\xf4" #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_extension #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_SparseTensor_file_identifier #define org_apache_arrow_flatbuf_SparseTensor_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseTensor_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseTensor_identifier #define org_apache_arrow_flatbuf_SparseTensor_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseTensor_type_hash ((flatbuffers_thash_t)0xae6f7239) #define org_apache_arrow_flatbuf_SparseTensor_type_identifier "\x39\x72\x6f\xae" #ifndef org_apache_arrow_flatbuf_SparseTensor_file_extension #define org_apache_arrow_flatbuf_SparseTensor_file_extension "bin" #endif typedef int16_t org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t, 16) #define org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Row ((org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Column ((org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_name(org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Row: return "Row"; case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Column: return "Column"; default: return ""; } } static inline int org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_is_known_value(org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Row: return 1; case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Column: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * EXPERIMENTAL: Data structures for sparse tensors * Coordinate (COO) format of sparse tensor index. * * COO's index list are represented as a NxM matrix, * where N is the number of non-zero values, * and M is the number of dimensions of a sparse tensor. * * indicesBuffer stores the location and size of the data of this indices * matrix. The value type and the stride of the indices matrix is * specified in indicesType and indicesStrides fields. * * For example, let X be a 2x3x4x5 tensor, and it has the following * 6 non-zero values: * ```text * X[0, 1, 2, 0] := 1 * X[1, 1, 2, 3] := 2 * X[0, 2, 1, 0] := 3 * X[0, 1, 3, 0] := 4 * X[0, 1, 2, 1] := 5 * X[1, 2, 0, 4] := 6 * ``` * In COO format, the index matrix of X is the following 4x6 matrix: * ```text * [[0, 0, 0, 0, 1, 1], * [1, 1, 1, 2, 1, 2], * [2, 2, 3, 1, 2, 0], * [0, 1, 0, 0, 3, 4]] * ``` * When isCanonical is true, the indices is sorted in lexicographical order * (row-major order), and it does not have duplicated entries. Otherwise, * the indices may not be sorted, or may have duplicated entries. */ struct org_apache_arrow_flatbuf_SparseTensorIndexCOO_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_len(org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseTensorIndexCOO) /** The type of values in indicesBuffer */ __flatbuffers_define_table_field(0, org_apache_arrow_flatbuf_SparseTensorIndexCOO, indicesType, org_apache_arrow_flatbuf_Int_table_t, 1) /** Non-negative byte offsets to advance one value cell along each dimension * If omitted, default to row-major order (C-like). */ __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_SparseTensorIndexCOO, indicesStrides, flatbuffers_int64_vec_t, 0) /** The location and size of the indices matrix's data */ __flatbuffers_define_struct_field(2, org_apache_arrow_flatbuf_SparseTensorIndexCOO, indicesBuffer, org_apache_arrow_flatbuf_Buffer_struct_t, 1) /** This flag is true if and only if the indices matrix is sorted in * row-major order, and does not have duplicated entries. * This sort order is the same as of Tensorflow's SparseTensor, * but it is inverse order of SciPy's canonical coo_matrix * (SciPy employs column-major order for its coo_matrix). */ __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_SparseTensorIndexCOO, isCanonical, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** Compressed Sparse format, that is matrix-specific. */ struct org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_len(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_at(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseMatrixIndexCSX) /** Which axis, row or column, is compressed */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, compressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t, INT16_C(0)) /** The type of values in indptrBuffer */ __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indptrType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indptrBuffer stores the location and size of indptr array that * represents the range of the rows. * The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data. * The length of this array is 1 + (the number of rows), and the type * of index value is long. * * For example, let X be the following 6x4 matrix: * ```text * X := [[0, 1, 2, 0], * [0, 0, 3, 0], * [0, 4, 0, 5], * [0, 0, 0, 0], * [6, 0, 7, 8], * [0, 9, 0, 0]]. * ``` * The array of non-zero values in X is: * ```text * values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. * ``` * And the indptr of X is: * ```text * indptr(X) = [0, 2, 3, 5, 5, 8, 10]. * ``` */ __flatbuffers_define_struct_field(2, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indptrBuffer, org_apache_arrow_flatbuf_Buffer_struct_t, 1) /** The type of values in indicesBuffer */ __flatbuffers_define_table_field(3, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indicesType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indicesBuffer stores the location and size of the array that * contains the column indices of the corresponding non-zero values. * The type of index value is long. * * For example, the indices of the above X is: * ```text * indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. * ``` * Note that the indices are sorted in lexicographical order for each row. */ __flatbuffers_define_struct_field(4, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indicesBuffer, org_apache_arrow_flatbuf_Buffer_struct_t, 1) /** Compressed Sparse Fiber (CSF) sparse tensor index. */ struct org_apache_arrow_flatbuf_SparseTensorIndexCSF_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_len(org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseTensorIndexCSF) /** CSF is a generalization of compressed sparse row (CSR) index. * See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) * * CSF index recursively compresses each dimension of a tensor into a set * of prefix trees. Each path from a root to leaf forms one tensor * non-zero index. CSF is implemented with two arrays of buffers and one * arrays of integers. * * For example, let X be a 2x3x4x5 tensor and let it have the following * 8 non-zero values: * ```text * X[0, 0, 0, 1] := 1 * X[0, 0, 0, 2] := 2 * X[0, 1, 0, 0] := 3 * X[0, 1, 0, 2] := 4 * X[0, 1, 1, 0] := 5 * X[1, 1, 1, 0] := 6 * X[1, 1, 1, 1] := 7 * X[1, 1, 1, 2] := 8 * ``` * As a prefix tree this would be represented as: * ```text * 0 1 * / \ | * 0 1 1 * / / \ | * 0 0 1 1 * /| /| | /| | * 1 2 0 2 0 0 1 2 * ``` * The type of values in indptrBuffers */ __flatbuffers_define_table_field(0, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indptrType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indptrBuffers stores the sparsity structure. * Each two consecutive dimensions in a tensor correspond to a buffer in * indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` * and `indptrBuffers[dim][i + 1]` signify a range of nodes in * `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. * * For example, the indptrBuffers for the above X is: * ```text * indptrBuffer(X) = [ * [0, 2, 3], * [0, 1, 3, 4], * [0, 2, 4, 5, 8] * ]. * ``` */ __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indptrBuffers, org_apache_arrow_flatbuf_Buffer_vec_t, 1) /** The type of values in indicesBuffers */ __flatbuffers_define_table_field(2, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indicesType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indicesBuffers stores values of nodes. * Each tensor dimension corresponds to a buffer in indicesBuffers. * For example, the indicesBuffers for the above X is: * ```text * indicesBuffer(X) = [ * [0, 1], * [0, 1, 1], * [0, 0, 1, 1], * [1, 2, 0, 2, 0, 0, 1, 2] * ]. * ``` */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indicesBuffers, org_apache_arrow_flatbuf_Buffer_vec_t, 1) /** axisOrder stores the sequence in which dimensions were traversed to * produce the prefix tree. * For example, the axisOrder for the above X is: * ```text * axisOrder(X) = [0, 1, 2, 3]. * ``` */ __flatbuffers_define_vector_field(4, org_apache_arrow_flatbuf_SparseTensorIndexCSF, axisOrder, flatbuffers_int32_vec_t, 1) typedef uint8_t org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_SparseTensorIndex, org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndex) #define org_apache_arrow_flatbuf_SparseTensorIndex_NONE ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(3)) static inline const char *org_apache_arrow_flatbuf_SparseTensorIndex_type_name(org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_SparseTensorIndex_NONE: return "NONE"; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO: return "SparseTensorIndexCOO"; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX: return "SparseMatrixIndexCSX"; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF: return "SparseTensorIndexCSF"; default: return ""; } } static inline int org_apache_arrow_flatbuf_SparseTensorIndex_is_known_type(org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_SparseTensorIndex_NONE: return 1; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO: return 1; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX: return 1; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_SparseTensor_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseTensor_vec_len(org_apache_arrow_flatbuf_SparseTensor_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseTensor_table_t org_apache_arrow_flatbuf_SparseTensor_vec_at(org_apache_arrow_flatbuf_SparseTensor_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseTensor_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseTensor) /** The type of data contained in a value cell. * Currently only fixed-width value types are supported, * no strings or nested types. */ __flatbuffers_define_union_field(flatbuffers_, 1, org_apache_arrow_flatbuf_SparseTensor, type, org_apache_arrow_flatbuf_Type, 1) /** The dimensions of the tensor, optionally named. */ __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_SparseTensor, shape, org_apache_arrow_flatbuf_TensorDim_vec_t, 1) /** The number of non-zero values in a sparse tensor. */ __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_SparseTensor, non_zero_length, flatbuffers_int64, int64_t, INT64_C(0)) /** Sparse tensor index */ __flatbuffers_define_union_field(flatbuffers_, 5, org_apache_arrow_flatbuf_SparseTensor, sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, 1) /** The location and size of the tensor's data */ __flatbuffers_define_struct_field(6, org_apache_arrow_flatbuf_SparseTensor, data, org_apache_arrow_flatbuf_Buffer_struct_t, 1) #include "flatcc/flatcc_epilogue.h" #endif /* SPARSETENSOR_READER_H */ #ifndef SPARSETENSOR_BUILDER_H #define SPARSETENSOR_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SPARSETENSOR_READER_H #include "SparseTensor_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #ifndef TENSOR_BUILDER_H #include "Tensor_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_formal_args , org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t v0 #define __org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_union_vec_ref_t; static org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndex_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseTensorIndexCOO_required[] = { 0, 2, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t; static org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO, 4) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_required[] = { 1, 2, 3, 4, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t; static org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, 5) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseTensorIndexCSF_required[] = { 0, 1, 2, 3, 4, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t; static org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF, 5) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseTensor_required[] = { 1, 2, 5, 6, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseTensor_ref_t; static org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensor_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor, 7) #define __org_apache_arrow_flatbuf_SparseTensorIndexCOO_formal_args , org_apache_arrow_flatbuf_Int_ref_t v0, flatbuffers_int64_vec_ref_t v1, org_apache_arrow_flatbuf_Buffer_t *v2, flatbuffers_bool_t v3 #define __org_apache_arrow_flatbuf_SparseTensorIndexCOO_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCOO_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO, org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier, org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier) #define __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_formal_args ,\ org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t v0, org_apache_arrow_flatbuf_Int_ref_t v1, org_apache_arrow_flatbuf_Buffer_t *v2, org_apache_arrow_flatbuf_Int_ref_t v3, org_apache_arrow_flatbuf_Buffer_t *v4 #define __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_call_args ,\ v0, v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier) #define __org_apache_arrow_flatbuf_SparseTensorIndexCSF_formal_args ,\ org_apache_arrow_flatbuf_Int_ref_t v0, org_apache_arrow_flatbuf_Buffer_vec_ref_t v1, org_apache_arrow_flatbuf_Int_ref_t v2, org_apache_arrow_flatbuf_Buffer_vec_ref_t v3, flatbuffers_int32_vec_ref_t v4 #define __org_apache_arrow_flatbuf_SparseTensorIndexCSF_call_args ,\ v0, v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCSF_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF, org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier, org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier) #define __org_apache_arrow_flatbuf_SparseTensor_formal_args ,\ org_apache_arrow_flatbuf_Type_union_ref_t v1, org_apache_arrow_flatbuf_TensorDim_vec_ref_t v2, int64_t v3, org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t v5, org_apache_arrow_flatbuf_Buffer_t *v6 #define __org_apache_arrow_flatbuf_SparseTensor_call_args ,\ v1, v2, v3, v5, v6 static inline org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensor_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor, org_apache_arrow_flatbuf_SparseTensor_file_identifier, org_apache_arrow_flatbuf_SparseTensor_type_identifier) static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_NONE(void) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCOO(org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t ref) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseMatrixIndexCSX(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t ref) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCSF(org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t ref) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndex) static org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndex_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCOO(org_apache_arrow_flatbuf_SparseTensorIndexCOO_clone(B, (org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseMatrixIndexCSX(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_clone(B, (org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCSF(org_apache_arrow_flatbuf_SparseTensorIndexCSF_clone(B, (org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t)u.value)); default: return org_apache_arrow_flatbuf_SparseTensorIndex_as_NONE(); } } __flatbuffers_build_table_field(0, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesStrides, flatbuffers_int64, int64_t, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_struct_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesBuffer, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_isCanonical, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_SparseTensorIndexCOO) static inline org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCOO_formal_args) { if (org_apache_arrow_flatbuf_SparseTensorIndexCOO_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesBuffer_add(B, v2) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesType_add(B, v0) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesStrides_add(B, v1) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_isCanonical_add(B, v3)) { return 0; } return org_apache_arrow_flatbuf_SparseTensorIndexCOO_end(B); } static org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseTensorIndexCOO_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesBuffer_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesType_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesStrides_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_isCanonical_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseTensorIndexCOO_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_compressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_struct_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrBuffer, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_table_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_struct_field(4, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesBuffer, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) static inline org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_formal_args) { if (org_apache_arrow_flatbuf_SparseMatrixIndexCSX_start(B) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrBuffer_add(B, v2) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesBuffer_add(B, v4) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrType_add(B, v1) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesType_add(B, v3) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_compressedAxis_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_SparseMatrixIndexCSX_end(B); } static org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseMatrixIndexCSX_start(B) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrBuffer_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesBuffer_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrType_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesType_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_compressedAxis_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_end(B)); } __flatbuffers_build_table_field(0, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrBuffers, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_table_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesBuffers, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_vector_field(4, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_axisOrder, flatbuffers_int32, int32_t, org_apache_arrow_flatbuf_SparseTensorIndexCSF) static inline org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCSF_formal_args) { if (org_apache_arrow_flatbuf_SparseTensorIndexCSF_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrType_add(B, v0) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrBuffers_add(B, v1) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesType_add(B, v2) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesBuffers_add(B, v3) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_axisOrder_add(B, v4)) { return 0; } return org_apache_arrow_flatbuf_SparseTensorIndexCSF_end(B); } static org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseTensorIndexCSF_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrType_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrBuffers_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesType_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesBuffers_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_axisOrder_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseTensorIndexCSF_end(B)); } __flatbuffers_build_union_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_shape, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_non_zero_length, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_union_field(5, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, SparseTensorIndexCOO, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, SparseMatrixIndexCSX, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, SparseTensorIndexCSF, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_struct_field(6, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_data, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseTensor) static inline org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensor_formal_args) { if (org_apache_arrow_flatbuf_SparseTensor_start(B) || org_apache_arrow_flatbuf_SparseTensor_non_zero_length_add(B, v3) || org_apache_arrow_flatbuf_SparseTensor_data_add(B, v6) || org_apache_arrow_flatbuf_SparseTensor_type_add_value(B, v1) || org_apache_arrow_flatbuf_SparseTensor_shape_add(B, v2) || org_apache_arrow_flatbuf_SparseTensor_sparseIndex_add_value(B, v5) || org_apache_arrow_flatbuf_SparseTensor_type_add_type(B, v1.type) || org_apache_arrow_flatbuf_SparseTensor_sparseIndex_add_type(B, v5.type)) { return 0; } return org_apache_arrow_flatbuf_SparseTensor_end(B); } static org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensor_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseTensor_start(B) || org_apache_arrow_flatbuf_SparseTensor_non_zero_length_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_data_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_type_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_shape_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_sparseIndex_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseTensor_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* SPARSETENSOR_BUILDER_H */ #ifndef SPARSETENSOR_VERIFIER_H #define SPARSETENSOR_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SPARSETENSOR_READER_H #include "SparseTensor_reader.h" #endif #include "flatcc/flatcc_verifier.h" #ifndef TENSOR_VERIFIER_H #include "Tensor_verifier.h" #endif #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseTensor_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseTensorIndex_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); /* SparseTensorIndexCOO */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); /* SparseMatrixIndexCSX */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); /* SparseTensorIndexCSF */ default: return flatcc_verify_ok; } } static int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_table_field(td, 0, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indicesType */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 8, 8, INT64_C(536870911)) /* indicesStrides */)) return ret; if ((ret = flatcc_verify_field(td, 2, 16, 8) /* indicesBuffer */)) return ret; if ((ret = flatcc_verify_field(td, 3, 1, 1) /* isCanonical */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* compressedAxis */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indptrType */)) return ret; if ((ret = flatcc_verify_field(td, 2, 16, 8) /* indptrBuffer */)) return ret; if ((ret = flatcc_verify_table_field(td, 3, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indicesType */)) return ret; if ((ret = flatcc_verify_field(td, 4, 16, 8) /* indicesBuffer */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_table_field(td, 0, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indptrType */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 1, 16, 8, INT64_C(268435455)) /* indptrBuffers */)) return ret; if ((ret = flatcc_verify_table_field(td, 2, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indicesType */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 1, 16, 8, INT64_C(268435455)) /* indicesBuffers */)) return ret; if ((ret = flatcc_verify_vector_field(td, 4, 1, 4, 4, INT64_C(1073741823)) /* axisOrder */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static int org_apache_arrow_flatbuf_SparseTensor_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_union_field(td, 1, 1, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 1, &org_apache_arrow_flatbuf_TensorDim_verify_table) /* shape */)) return ret; if ((ret = flatcc_verify_field(td, 3, 8, 8) /* non_zero_length */)) return ret; if ((ret = flatcc_verify_union_field(td, 5, 1, &org_apache_arrow_flatbuf_SparseTensorIndex_union_verifier) /* sparseIndex */)) return ret; if ((ret = flatcc_verify_field(td, 6, 16, 8) /* data */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_type_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_type_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* SPARSETENSOR_VERIFIER_H */ #ifndef MESSAGE_READER_H #define MESSAGE_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #ifndef SPARSETENSOR_READER_H #include "SparseTensor_reader.h" #endif #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef struct org_apache_arrow_flatbuf_FieldNode org_apache_arrow_flatbuf_FieldNode_t; typedef const org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_struct_t; typedef org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_mutable_struct_t; typedef const org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_vec_t; typedef org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_BodyCompression_table *org_apache_arrow_flatbuf_BodyCompression_table_t; typedef struct org_apache_arrow_flatbuf_BodyCompression_table *org_apache_arrow_flatbuf_BodyCompression_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BodyCompression_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BodyCompression_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_RecordBatch_table *org_apache_arrow_flatbuf_RecordBatch_table_t; typedef struct org_apache_arrow_flatbuf_RecordBatch_table *org_apache_arrow_flatbuf_RecordBatch_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RecordBatch_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RecordBatch_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_DictionaryBatch_table *org_apache_arrow_flatbuf_DictionaryBatch_table_t; typedef struct org_apache_arrow_flatbuf_DictionaryBatch_table *org_apache_arrow_flatbuf_DictionaryBatch_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryBatch_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryBatch_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Message_table *org_apache_arrow_flatbuf_Message_table_t; typedef struct org_apache_arrow_flatbuf_Message_table *org_apache_arrow_flatbuf_Message_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Message_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Message_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_FieldNode_file_identifier #define org_apache_arrow_flatbuf_FieldNode_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FieldNode_file_identifier */ #ifndef org_apache_arrow_flatbuf_FieldNode_identifier #define org_apache_arrow_flatbuf_FieldNode_identifier 0 #endif #define org_apache_arrow_flatbuf_FieldNode_type_hash ((flatbuffers_thash_t)0x931857b8) #define org_apache_arrow_flatbuf_FieldNode_type_identifier "\xb8\x57\x18\x93" #ifndef org_apache_arrow_flatbuf_FieldNode_file_extension #define org_apache_arrow_flatbuf_FieldNode_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_BodyCompression_file_identifier #define org_apache_arrow_flatbuf_BodyCompression_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_BodyCompression_file_identifier */ #ifndef org_apache_arrow_flatbuf_BodyCompression_identifier #define org_apache_arrow_flatbuf_BodyCompression_identifier 0 #endif #define org_apache_arrow_flatbuf_BodyCompression_type_hash ((flatbuffers_thash_t)0xbc821116) #define org_apache_arrow_flatbuf_BodyCompression_type_identifier "\x16\x11\x82\xbc" #ifndef org_apache_arrow_flatbuf_BodyCompression_file_extension #define org_apache_arrow_flatbuf_BodyCompression_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_RecordBatch_file_identifier #define org_apache_arrow_flatbuf_RecordBatch_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_RecordBatch_file_identifier */ #ifndef org_apache_arrow_flatbuf_RecordBatch_identifier #define org_apache_arrow_flatbuf_RecordBatch_identifier 0 #endif #define org_apache_arrow_flatbuf_RecordBatch_type_hash ((flatbuffers_thash_t)0x43c558b) #define org_apache_arrow_flatbuf_RecordBatch_type_identifier "\x8b\x55\x3c\x04" #ifndef org_apache_arrow_flatbuf_RecordBatch_file_extension #define org_apache_arrow_flatbuf_RecordBatch_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_DictionaryBatch_file_identifier #define org_apache_arrow_flatbuf_DictionaryBatch_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_DictionaryBatch_file_identifier */ #ifndef org_apache_arrow_flatbuf_DictionaryBatch_identifier #define org_apache_arrow_flatbuf_DictionaryBatch_identifier 0 #endif #define org_apache_arrow_flatbuf_DictionaryBatch_type_hash ((flatbuffers_thash_t)0x5c6da7bc) #define org_apache_arrow_flatbuf_DictionaryBatch_type_identifier "\xbc\xa7\x6d\x5c" #ifndef org_apache_arrow_flatbuf_DictionaryBatch_file_extension #define org_apache_arrow_flatbuf_DictionaryBatch_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Message_file_identifier #define org_apache_arrow_flatbuf_Message_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Message_file_identifier */ #ifndef org_apache_arrow_flatbuf_Message_identifier #define org_apache_arrow_flatbuf_Message_identifier 0 #endif #define org_apache_arrow_flatbuf_Message_type_hash ((flatbuffers_thash_t)0xc3efd227) #define org_apache_arrow_flatbuf_Message_type_identifier "\x27\xd2\xef\xc3" #ifndef org_apache_arrow_flatbuf_Message_file_extension #define org_apache_arrow_flatbuf_Message_file_extension "bin" #endif typedef int8_t org_apache_arrow_flatbuf_CompressionType_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_CompressionType, org_apache_arrow_flatbuf_CompressionType_enum_t, 8) #define org_apache_arrow_flatbuf_CompressionType_LZ4_FRAME ((org_apache_arrow_flatbuf_CompressionType_enum_t)INT8_C(0)) #define org_apache_arrow_flatbuf_CompressionType_ZSTD ((org_apache_arrow_flatbuf_CompressionType_enum_t)INT8_C(1)) static inline const char *org_apache_arrow_flatbuf_CompressionType_name(org_apache_arrow_flatbuf_CompressionType_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_CompressionType_LZ4_FRAME: return "LZ4_FRAME"; case org_apache_arrow_flatbuf_CompressionType_ZSTD: return "ZSTD"; default: return ""; } } static inline int org_apache_arrow_flatbuf_CompressionType_is_known_value(org_apache_arrow_flatbuf_CompressionType_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_CompressionType_LZ4_FRAME: return 1; case org_apache_arrow_flatbuf_CompressionType_ZSTD: return 1; default: return 0; } } /** Provided for forward compatibility in case we need to support different * strategies for compressing the IPC message body (like whole-body * compression rather than buffer-level) in the future */ typedef int8_t org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_BodyCompressionMethod, org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t, 8) /** Each constituent buffer is first compressed with the indicated * compressor, and then written with the uncompressed length in the first 8 * bytes as a 64-bit little-endian signed integer followed by the compressed * buffer bytes (and then padding as required by the protocol). The * uncompressed length may be set to -1 to indicate that the data that * follows is not compressed, which can be useful for cases where * compression does not yield appreciable savings. */ #define org_apache_arrow_flatbuf_BodyCompressionMethod_BUFFER ((org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t)INT8_C(0)) static inline const char *org_apache_arrow_flatbuf_BodyCompressionMethod_name(org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_BodyCompressionMethod_BUFFER: return "BUFFER"; default: return ""; } } static inline int org_apache_arrow_flatbuf_BodyCompressionMethod_is_known_value(org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_BodyCompressionMethod_BUFFER: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Data structures for describing a table row batch (a collection of * equal-length Arrow arrays) * Metadata about a field at some level of a nested type tree (but not * its children). * * For example, a List with values `[[1, 2, 3], null, [4], [5, 6], null]` * would have {length: 5, null_count: 2} for its List node, and {length: 6, * null_count: 0} for its Int16 node, as separate FieldNode structs */ struct org_apache_arrow_flatbuf_FieldNode { /** The number of value slots in the Arrow array at this level of a nested * tree */ alignas(8) int64_t length; /** The number of observed nulls. Fields with null_count == 0 may choose not * to write their physical validity bitmap out as a materialized buffer, * instead setting the length of the bitmap buffer to 0. */ alignas(8) int64_t null_count; }; static_assert(sizeof(org_apache_arrow_flatbuf_FieldNode_t) == 16, "struct size mismatch"); static inline const org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode__const_ptr_add(const org_apache_arrow_flatbuf_FieldNode_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode__ptr_add(org_apache_arrow_flatbuf_FieldNode_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_FieldNode_struct_t org_apache_arrow_flatbuf_FieldNode_vec_at(org_apache_arrow_flatbuf_FieldNode_vec_t vec, size_t i) __flatbuffers_struct_vec_at(vec, i) static inline size_t org_apache_arrow_flatbuf_FieldNode__size(void) { return 16; } static inline size_t org_apache_arrow_flatbuf_FieldNode_vec_len(org_apache_arrow_flatbuf_FieldNode_vec_t vec) __flatbuffers_vec_len(vec) __flatbuffers_struct_as_root(org_apache_arrow_flatbuf_FieldNode) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_FieldNode, length, flatbuffers_int64, int64_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_FieldNode, null_count, flatbuffers_int64, int64_t) /** Optional compression for the memory buffers constituting IPC message * bodies. Intended for use with RecordBatch but could be used for other * message types */ struct org_apache_arrow_flatbuf_BodyCompression_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_BodyCompression_vec_len(org_apache_arrow_flatbuf_BodyCompression_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_BodyCompression_table_t org_apache_arrow_flatbuf_BodyCompression_vec_at(org_apache_arrow_flatbuf_BodyCompression_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_BodyCompression_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_BodyCompression) /** Compressor library. * For LZ4_FRAME, each compressed buffer must consist of a single frame. */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_BodyCompression, codec, org_apache_arrow_flatbuf_CompressionType, org_apache_arrow_flatbuf_CompressionType_enum_t, INT8_C(0)) /** Indicates the way the record batch body was compressed */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_BodyCompression, method, org_apache_arrow_flatbuf_BodyCompressionMethod, org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t, INT8_C(0)) /** A data header describing the shared memory layout of a "record" or "row" * batch. Some systems call this a "row batch" internally and others a "record * batch". */ struct org_apache_arrow_flatbuf_RecordBatch_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_RecordBatch_vec_len(org_apache_arrow_flatbuf_RecordBatch_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_RecordBatch_table_t org_apache_arrow_flatbuf_RecordBatch_vec_at(org_apache_arrow_flatbuf_RecordBatch_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_RecordBatch_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_RecordBatch) /** number of records / rows. The arrays in the batch should all have this * length */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_RecordBatch, length, flatbuffers_int64, int64_t, INT64_C(0)) /** Nodes correspond to the pre-ordered flattened logical schema */ __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_RecordBatch, nodes, org_apache_arrow_flatbuf_FieldNode_vec_t, 0) /** Buffers correspond to the pre-ordered flattened buffer tree * * The number of buffers appended to this list depends on the schema. For * example, most primitive arrays will have 2 buffers, 1 for the validity * bitmap and 1 for the values. For struct arrays, there will only be a * single buffer for the validity (nulls) bitmap */ __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_RecordBatch, buffers, org_apache_arrow_flatbuf_Buffer_vec_t, 0) /** Optional compression of the message body */ __flatbuffers_define_table_field(3, org_apache_arrow_flatbuf_RecordBatch, compression, org_apache_arrow_flatbuf_BodyCompression_table_t, 0) /** Some types such as Utf8View are represented using a variable number of buffers. * For each such Field in the pre-ordered flattened logical schema, there will be * an entry in variadicBufferCounts to indicate the number of number of variadic * buffers which belong to that Field in the current RecordBatch. * * For example, the schema * col1: Struct * col2: Utf8View * contains two Fields with variadic buffers so variadicBufferCounts will have * two entries, the first counting the variadic buffers of `col1.beta` and the * second counting `col2`'s. * * This field may be omitted if and only if the schema contains no Fields with * a variable number of buffers, such as BinaryView and Utf8View. */ __flatbuffers_define_vector_field(4, org_apache_arrow_flatbuf_RecordBatch, variadicBufferCounts, flatbuffers_int64_vec_t, 0) /** For sending dictionary encoding information. Any Field can be * dictionary-encoded, but in this case none of its children may be * dictionary-encoded. * There is one vector / column per dictionary, but that vector / column * may be spread across multiple dictionary batches by using the isDelta * flag */ struct org_apache_arrow_flatbuf_DictionaryBatch_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_DictionaryBatch_vec_len(org_apache_arrow_flatbuf_DictionaryBatch_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_DictionaryBatch_table_t org_apache_arrow_flatbuf_DictionaryBatch_vec_at(org_apache_arrow_flatbuf_DictionaryBatch_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_DictionaryBatch_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_DictionaryBatch) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_DictionaryBatch, id, flatbuffers_int64, int64_t, INT64_C(0)) __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_DictionaryBatch, data, org_apache_arrow_flatbuf_RecordBatch_table_t, 0) /** If isDelta is true the values in the dictionary are to be appended to a * dictionary with the indicated id. If isDelta is false this dictionary * should replace the existing dictionary. */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_DictionaryBatch, isDelta, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** ---------------------------------------------------------------------- * The root Message type * This union enables us to easily send different message types without * redundant storage, and in the future we can easily add new message types. * * Arrow implementations do not need to implement all of the message types, * which may include experimental metadata types. For maximum compatibility, * it is best to send data using RecordBatch */ typedef uint8_t org_apache_arrow_flatbuf_MessageHeader_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_MessageHeader, org_apache_arrow_flatbuf_MessageHeader_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_MessageHeader) #define org_apache_arrow_flatbuf_MessageHeader_NONE ((org_apache_arrow_flatbuf_MessageHeader_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_MessageHeader_Schema ((org_apache_arrow_flatbuf_MessageHeader_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_MessageHeader_DictionaryBatch ((org_apache_arrow_flatbuf_MessageHeader_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_MessageHeader_RecordBatch ((org_apache_arrow_flatbuf_MessageHeader_union_type_t)UINT8_C(3)) #define org_apache_arrow_flatbuf_MessageHeader_Tensor ((org_apache_arrow_flatbuf_MessageHeader_union_type_t)UINT8_C(4)) #define org_apache_arrow_flatbuf_MessageHeader_SparseTensor ((org_apache_arrow_flatbuf_MessageHeader_union_type_t)UINT8_C(5)) static inline const char *org_apache_arrow_flatbuf_MessageHeader_type_name(org_apache_arrow_flatbuf_MessageHeader_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_MessageHeader_NONE: return "NONE"; case org_apache_arrow_flatbuf_MessageHeader_Schema: return "Schema"; case org_apache_arrow_flatbuf_MessageHeader_DictionaryBatch: return "DictionaryBatch"; case org_apache_arrow_flatbuf_MessageHeader_RecordBatch: return "RecordBatch"; case org_apache_arrow_flatbuf_MessageHeader_Tensor: return "Tensor"; case org_apache_arrow_flatbuf_MessageHeader_SparseTensor: return "SparseTensor"; default: return ""; } } static inline int org_apache_arrow_flatbuf_MessageHeader_is_known_type(org_apache_arrow_flatbuf_MessageHeader_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_MessageHeader_NONE: return 1; case org_apache_arrow_flatbuf_MessageHeader_Schema: return 1; case org_apache_arrow_flatbuf_MessageHeader_DictionaryBatch: return 1; case org_apache_arrow_flatbuf_MessageHeader_RecordBatch: return 1; case org_apache_arrow_flatbuf_MessageHeader_Tensor: return 1; case org_apache_arrow_flatbuf_MessageHeader_SparseTensor: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_Message_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Message_vec_len(org_apache_arrow_flatbuf_Message_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Message_table_t org_apache_arrow_flatbuf_Message_vec_at(org_apache_arrow_flatbuf_Message_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Message_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Message) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Message, version, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, INT16_C(0)) __flatbuffers_define_union_field(flatbuffers_, 2, org_apache_arrow_flatbuf_Message, header, org_apache_arrow_flatbuf_MessageHeader, 0) __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_Message, bodyLength, flatbuffers_int64, int64_t, INT64_C(0)) __flatbuffers_define_vector_field(4, org_apache_arrow_flatbuf_Message, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) #include "flatcc/flatcc_epilogue.h" #endif /* MESSAGE_READER_H */ #ifndef MESSAGE_BUILDER_H #define MESSAGE_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef MESSAGE_READER_H #include "Message_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #ifndef TENSOR_BUILDER_H #include "Tensor_builder.h" #endif #ifndef SPARSETENSOR_BUILDER_H #include "SparseTensor_builder.h" #endif #ifndef SCHEMA_BUILDER_H #include "Schema_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_CompressionType_formal_args , org_apache_arrow_flatbuf_CompressionType_enum_t v0 #define __org_apache_arrow_flatbuf_CompressionType_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_CompressionType, org_apache_arrow_flatbuf_CompressionType_enum_t) #define __org_apache_arrow_flatbuf_BodyCompressionMethod_formal_args , org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t v0 #define __org_apache_arrow_flatbuf_BodyCompressionMethod_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_BodyCompressionMethod, org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t) #define __org_apache_arrow_flatbuf_FieldNode_formal_args , int64_t v0, int64_t v1 #define __org_apache_arrow_flatbuf_FieldNode_call_args , v0, v1 static inline org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_assign(org_apache_arrow_flatbuf_FieldNode_t *p, int64_t v0, int64_t v1) { p->length = v0; p->null_count = v1; return p; } static inline org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_copy(org_apache_arrow_flatbuf_FieldNode_t *p, const org_apache_arrow_flatbuf_FieldNode_t *p2) { p->length = p2->length; p->null_count = p2->null_count; return p; } static inline org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_assign_to_pe(org_apache_arrow_flatbuf_FieldNode_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_to_pe(&p->length, v0); flatbuffers_int64_assign_to_pe(&p->null_count, v1); return p; } static inline org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_copy_to_pe(org_apache_arrow_flatbuf_FieldNode_t *p, const org_apache_arrow_flatbuf_FieldNode_t *p2) { flatbuffers_int64_copy_to_pe(&p->length, &p2->length); flatbuffers_int64_copy_to_pe(&p->null_count, &p2->null_count); return p; } static inline org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_assign_from_pe(org_apache_arrow_flatbuf_FieldNode_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_from_pe(&p->length, v0); flatbuffers_int64_assign_from_pe(&p->null_count, v1); return p; } static inline org_apache_arrow_flatbuf_FieldNode_t *org_apache_arrow_flatbuf_FieldNode_copy_from_pe(org_apache_arrow_flatbuf_FieldNode_t *p, const org_apache_arrow_flatbuf_FieldNode_t *p2) { flatbuffers_int64_copy_from_pe(&p->length, &p2->length); flatbuffers_int64_copy_from_pe(&p->null_count, &p2->null_count); return p; } __flatbuffers_build_struct(flatbuffers_, org_apache_arrow_flatbuf_FieldNode, 16, 8, org_apache_arrow_flatbuf_FieldNode_file_identifier, org_apache_arrow_flatbuf_FieldNode_type_identifier) __flatbuffers_define_fixed_array_primitives(flatbuffers_, org_apache_arrow_flatbuf_FieldNode, org_apache_arrow_flatbuf_FieldNode_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_MessageHeader_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_MessageHeader_union_vec_ref_t; static org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_MessageHeader_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_BodyCompression_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_BodyCompression_ref_t; static org_apache_arrow_flatbuf_BodyCompression_ref_t org_apache_arrow_flatbuf_BodyCompression_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BodyCompression_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_BodyCompression, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_RecordBatch_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_RecordBatch_ref_t; static org_apache_arrow_flatbuf_RecordBatch_ref_t org_apache_arrow_flatbuf_RecordBatch_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RecordBatch_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_RecordBatch, 5) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_DictionaryBatch_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_DictionaryBatch_ref_t; static org_apache_arrow_flatbuf_DictionaryBatch_ref_t org_apache_arrow_flatbuf_DictionaryBatch_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryBatch_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_DictionaryBatch, 3) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Message_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Message_ref_t; static org_apache_arrow_flatbuf_Message_ref_t org_apache_arrow_flatbuf_Message_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Message_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Message, 5) #define __org_apache_arrow_flatbuf_BodyCompression_formal_args , org_apache_arrow_flatbuf_CompressionType_enum_t v0, org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t v1 #define __org_apache_arrow_flatbuf_BodyCompression_call_args , v0, v1 static inline org_apache_arrow_flatbuf_BodyCompression_ref_t org_apache_arrow_flatbuf_BodyCompression_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BodyCompression_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_BodyCompression, org_apache_arrow_flatbuf_BodyCompression_file_identifier, org_apache_arrow_flatbuf_BodyCompression_type_identifier) #define __org_apache_arrow_flatbuf_RecordBatch_formal_args ,\ int64_t v0, org_apache_arrow_flatbuf_FieldNode_vec_ref_t v1, org_apache_arrow_flatbuf_Buffer_vec_ref_t v2, org_apache_arrow_flatbuf_BodyCompression_ref_t v3, flatbuffers_int64_vec_ref_t v4 #define __org_apache_arrow_flatbuf_RecordBatch_call_args ,\ v0, v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_RecordBatch_ref_t org_apache_arrow_flatbuf_RecordBatch_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RecordBatch_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_RecordBatch, org_apache_arrow_flatbuf_RecordBatch_file_identifier, org_apache_arrow_flatbuf_RecordBatch_type_identifier) #define __org_apache_arrow_flatbuf_DictionaryBatch_formal_args , int64_t v0, org_apache_arrow_flatbuf_RecordBatch_ref_t v1, flatbuffers_bool_t v2 #define __org_apache_arrow_flatbuf_DictionaryBatch_call_args , v0, v1, v2 static inline org_apache_arrow_flatbuf_DictionaryBatch_ref_t org_apache_arrow_flatbuf_DictionaryBatch_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryBatch_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_DictionaryBatch, org_apache_arrow_flatbuf_DictionaryBatch_file_identifier, org_apache_arrow_flatbuf_DictionaryBatch_type_identifier) #define __org_apache_arrow_flatbuf_Message_formal_args , org_apache_arrow_flatbuf_MetadataVersion_enum_t v0, org_apache_arrow_flatbuf_MessageHeader_union_ref_t v2, int64_t v3, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v4 #define __org_apache_arrow_flatbuf_Message_call_args , v0, v2, v3, v4 static inline org_apache_arrow_flatbuf_Message_ref_t org_apache_arrow_flatbuf_Message_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Message_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Message, org_apache_arrow_flatbuf_Message_file_identifier, org_apache_arrow_flatbuf_Message_type_identifier) static inline org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_as_NONE(void) { org_apache_arrow_flatbuf_MessageHeader_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_MessageHeader_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_as_Schema(org_apache_arrow_flatbuf_Schema_ref_t ref) { org_apache_arrow_flatbuf_MessageHeader_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_MessageHeader_Schema; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_as_DictionaryBatch(org_apache_arrow_flatbuf_DictionaryBatch_ref_t ref) { org_apache_arrow_flatbuf_MessageHeader_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_MessageHeader_DictionaryBatch; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_as_RecordBatch(org_apache_arrow_flatbuf_RecordBatch_ref_t ref) { org_apache_arrow_flatbuf_MessageHeader_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_MessageHeader_RecordBatch; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_as_Tensor(org_apache_arrow_flatbuf_Tensor_ref_t ref) { org_apache_arrow_flatbuf_MessageHeader_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_MessageHeader_Tensor; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_as_SparseTensor(org_apache_arrow_flatbuf_SparseTensor_ref_t ref) { org_apache_arrow_flatbuf_MessageHeader_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_MessageHeader_SparseTensor; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_MessageHeader) static org_apache_arrow_flatbuf_MessageHeader_union_ref_t org_apache_arrow_flatbuf_MessageHeader_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_MessageHeader_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_MessageHeader_as_Schema(org_apache_arrow_flatbuf_Schema_clone(B, (org_apache_arrow_flatbuf_Schema_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_MessageHeader_as_DictionaryBatch(org_apache_arrow_flatbuf_DictionaryBatch_clone(B, (org_apache_arrow_flatbuf_DictionaryBatch_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_MessageHeader_as_RecordBatch(org_apache_arrow_flatbuf_RecordBatch_clone(B, (org_apache_arrow_flatbuf_RecordBatch_table_t)u.value)); case 4: return org_apache_arrow_flatbuf_MessageHeader_as_Tensor(org_apache_arrow_flatbuf_Tensor_clone(B, (org_apache_arrow_flatbuf_Tensor_table_t)u.value)); case 5: return org_apache_arrow_flatbuf_MessageHeader_as_SparseTensor(org_apache_arrow_flatbuf_SparseTensor_clone(B, (org_apache_arrow_flatbuf_SparseTensor_table_t)u.value)); default: return org_apache_arrow_flatbuf_MessageHeader_as_NONE(); } } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_BodyCompression_codec, org_apache_arrow_flatbuf_CompressionType, org_apache_arrow_flatbuf_CompressionType_enum_t, 1, 1, INT8_C(0), org_apache_arrow_flatbuf_BodyCompression) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_BodyCompression_method, org_apache_arrow_flatbuf_BodyCompressionMethod, org_apache_arrow_flatbuf_BodyCompressionMethod_enum_t, 1, 1, INT8_C(0), org_apache_arrow_flatbuf_BodyCompression) static inline org_apache_arrow_flatbuf_BodyCompression_ref_t org_apache_arrow_flatbuf_BodyCompression_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BodyCompression_formal_args) { if (org_apache_arrow_flatbuf_BodyCompression_start(B) || org_apache_arrow_flatbuf_BodyCompression_codec_add(B, v0) || org_apache_arrow_flatbuf_BodyCompression_method_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_BodyCompression_end(B); } static org_apache_arrow_flatbuf_BodyCompression_ref_t org_apache_arrow_flatbuf_BodyCompression_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BodyCompression_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_BodyCompression_start(B) || org_apache_arrow_flatbuf_BodyCompression_codec_pick(B, t) || org_apache_arrow_flatbuf_BodyCompression_method_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_BodyCompression_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_RecordBatch_length, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_RecordBatch) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_RecordBatch_nodes, org_apache_arrow_flatbuf_FieldNode, org_apache_arrow_flatbuf_FieldNode_t, org_apache_arrow_flatbuf_RecordBatch) __flatbuffers_build_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_RecordBatch_buffers, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t, org_apache_arrow_flatbuf_RecordBatch) __flatbuffers_build_table_field(3, flatbuffers_, org_apache_arrow_flatbuf_RecordBatch_compression, org_apache_arrow_flatbuf_BodyCompression, org_apache_arrow_flatbuf_RecordBatch) __flatbuffers_build_vector_field(4, flatbuffers_, org_apache_arrow_flatbuf_RecordBatch_variadicBufferCounts, flatbuffers_int64, int64_t, org_apache_arrow_flatbuf_RecordBatch) static inline org_apache_arrow_flatbuf_RecordBatch_ref_t org_apache_arrow_flatbuf_RecordBatch_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RecordBatch_formal_args) { if (org_apache_arrow_flatbuf_RecordBatch_start(B) || org_apache_arrow_flatbuf_RecordBatch_length_add(B, v0) || org_apache_arrow_flatbuf_RecordBatch_nodes_add(B, v1) || org_apache_arrow_flatbuf_RecordBatch_buffers_add(B, v2) || org_apache_arrow_flatbuf_RecordBatch_compression_add(B, v3) || org_apache_arrow_flatbuf_RecordBatch_variadicBufferCounts_add(B, v4)) { return 0; } return org_apache_arrow_flatbuf_RecordBatch_end(B); } static org_apache_arrow_flatbuf_RecordBatch_ref_t org_apache_arrow_flatbuf_RecordBatch_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RecordBatch_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_RecordBatch_start(B) || org_apache_arrow_flatbuf_RecordBatch_length_pick(B, t) || org_apache_arrow_flatbuf_RecordBatch_nodes_pick(B, t) || org_apache_arrow_flatbuf_RecordBatch_buffers_pick(B, t) || org_apache_arrow_flatbuf_RecordBatch_compression_pick(B, t) || org_apache_arrow_flatbuf_RecordBatch_variadicBufferCounts_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_RecordBatch_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_DictionaryBatch_id, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_DictionaryBatch) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_DictionaryBatch_data, org_apache_arrow_flatbuf_RecordBatch, org_apache_arrow_flatbuf_DictionaryBatch) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_DictionaryBatch_isDelta, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_DictionaryBatch) static inline org_apache_arrow_flatbuf_DictionaryBatch_ref_t org_apache_arrow_flatbuf_DictionaryBatch_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryBatch_formal_args) { if (org_apache_arrow_flatbuf_DictionaryBatch_start(B) || org_apache_arrow_flatbuf_DictionaryBatch_id_add(B, v0) || org_apache_arrow_flatbuf_DictionaryBatch_data_add(B, v1) || org_apache_arrow_flatbuf_DictionaryBatch_isDelta_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_DictionaryBatch_end(B); } static org_apache_arrow_flatbuf_DictionaryBatch_ref_t org_apache_arrow_flatbuf_DictionaryBatch_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryBatch_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_DictionaryBatch_start(B) || org_apache_arrow_flatbuf_DictionaryBatch_id_pick(B, t) || org_apache_arrow_flatbuf_DictionaryBatch_data_pick(B, t) || org_apache_arrow_flatbuf_DictionaryBatch_isDelta_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_DictionaryBatch_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Message_version, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Message) __flatbuffers_build_union_field(2, flatbuffers_, org_apache_arrow_flatbuf_Message_header, org_apache_arrow_flatbuf_MessageHeader, org_apache_arrow_flatbuf_Message) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Message_header, org_apache_arrow_flatbuf_MessageHeader, Schema, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Message_header, org_apache_arrow_flatbuf_MessageHeader, DictionaryBatch, org_apache_arrow_flatbuf_DictionaryBatch) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Message_header, org_apache_arrow_flatbuf_MessageHeader, RecordBatch, org_apache_arrow_flatbuf_RecordBatch) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Message_header, org_apache_arrow_flatbuf_MessageHeader, Tensor, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Message_header, org_apache_arrow_flatbuf_MessageHeader, SparseTensor, org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_Message_bodyLength, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_Message) __flatbuffers_build_table_vector_field(4, flatbuffers_, org_apache_arrow_flatbuf_Message_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Message) static inline org_apache_arrow_flatbuf_Message_ref_t org_apache_arrow_flatbuf_Message_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Message_formal_args) { if (org_apache_arrow_flatbuf_Message_start(B) || org_apache_arrow_flatbuf_Message_bodyLength_add(B, v3) || org_apache_arrow_flatbuf_Message_header_add_value(B, v2) || org_apache_arrow_flatbuf_Message_custom_metadata_add(B, v4) || org_apache_arrow_flatbuf_Message_version_add(B, v0) || org_apache_arrow_flatbuf_Message_header_add_type(B, v2.type)) { return 0; } return org_apache_arrow_flatbuf_Message_end(B); } static org_apache_arrow_flatbuf_Message_ref_t org_apache_arrow_flatbuf_Message_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Message_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Message_start(B) || org_apache_arrow_flatbuf_Message_bodyLength_pick(B, t) || org_apache_arrow_flatbuf_Message_header_pick(B, t) || org_apache_arrow_flatbuf_Message_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Message_version_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Message_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* MESSAGE_BUILDER_H */ #ifndef MESSAGE_VERIFIER_H #define MESSAGE_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef MESSAGE_READER_H #include "Message_reader.h" #endif #include "flatcc/flatcc_verifier.h" #ifndef TENSOR_VERIFIER_H #include "Tensor_verifier.h" #endif #ifndef SPARSETENSOR_VERIFIER_H #include "SparseTensor_verifier.h" #endif #ifndef SCHEMA_VERIFIER_H #include "Schema_verifier.h" #endif #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_BodyCompression_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_RecordBatch_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_DictionaryBatch_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Message_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_MessageHeader_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Schema_verify_table); /* Schema */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_DictionaryBatch_verify_table); /* DictionaryBatch */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_RecordBatch_verify_table); /* RecordBatch */ case 4: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Tensor_verify_table); /* Tensor */ case 5: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_SparseTensor_verify_table); /* SparseTensor */ default: return flatcc_verify_ok; } } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FieldNode_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FieldNode_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, org_apache_arrow_flatbuf_FieldNode_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FieldNode_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root(buf, bufsiz, fid, 16, 8); } static inline int org_apache_arrow_flatbuf_FieldNode_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, fid, 16, 8); } static int org_apache_arrow_flatbuf_BodyCompression_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 1, 1) /* codec */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* method */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BodyCompression_identifier, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BodyCompression_identifier, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BodyCompression_type_identifier, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BodyCompression_type_identifier, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static inline int org_apache_arrow_flatbuf_BodyCompression_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BodyCompression_verify_table); } static int org_apache_arrow_flatbuf_RecordBatch_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* length */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 16, 8, INT64_C(268435455)) /* nodes */)) return ret; if ((ret = flatcc_verify_vector_field(td, 2, 0, 16, 8, INT64_C(268435455)) /* buffers */)) return ret; if ((ret = flatcc_verify_table_field(td, 3, 0, &org_apache_arrow_flatbuf_BodyCompression_verify_table) /* compression */)) return ret; if ((ret = flatcc_verify_vector_field(td, 4, 0, 8, 8, INT64_C(536870911)) /* variadicBufferCounts */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RecordBatch_identifier, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RecordBatch_identifier, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RecordBatch_type_identifier, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RecordBatch_type_identifier, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static inline int org_apache_arrow_flatbuf_RecordBatch_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RecordBatch_verify_table); } static int org_apache_arrow_flatbuf_DictionaryBatch_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* id */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 0, &org_apache_arrow_flatbuf_RecordBatch_verify_table) /* data */)) return ret; if ((ret = flatcc_verify_field(td, 2, 1, 1) /* isDelta */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryBatch_identifier, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryBatch_identifier, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryBatch_type_identifier, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryBatch_type_identifier, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryBatch_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryBatch_verify_table); } static int org_apache_arrow_flatbuf_Message_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* version */)) return ret; if ((ret = flatcc_verify_union_field(td, 2, 0, &org_apache_arrow_flatbuf_MessageHeader_union_verifier) /* header */)) return ret; if ((ret = flatcc_verify_field(td, 3, 8, 8) /* bodyLength */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 4, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Message_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Message_identifier, &org_apache_arrow_flatbuf_Message_verify_table); } static inline int org_apache_arrow_flatbuf_Message_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Message_identifier, &org_apache_arrow_flatbuf_Message_verify_table); } static inline int org_apache_arrow_flatbuf_Message_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Message_type_identifier, &org_apache_arrow_flatbuf_Message_verify_table); } static inline int org_apache_arrow_flatbuf_Message_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Message_type_identifier, &org_apache_arrow_flatbuf_Message_verify_table); } static inline int org_apache_arrow_flatbuf_Message_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Message_verify_table); } static inline int org_apache_arrow_flatbuf_Message_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Message_verify_table); } static inline int org_apache_arrow_flatbuf_Message_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Message_verify_table); } static inline int org_apache_arrow_flatbuf_Message_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Message_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* MESSAGE_VERIFIER_H */ #ifndef SCHEMA_READER_H #define SCHEMA_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef struct org_apache_arrow_flatbuf_Buffer org_apache_arrow_flatbuf_Buffer_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_struct_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_struct_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_vec_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_table_t; typedef struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__table_t; typedef struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_table_t; typedef struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_table_t; typedef struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_table_t; typedef struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_table_t; typedef struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_table_t; typedef struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_table_t; typedef struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_table_t; typedef struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_table_t; typedef struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_table_t; typedef struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_table_t; typedef struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_table_t; typedef struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_table_t; typedef struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_table_t; typedef struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_table_t; typedef struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_table_t; typedef struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_table_t; typedef struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_table_t; typedef struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_table_t; typedef struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_table_t; typedef struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_table_t; typedef struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_table_t; typedef struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_table_t; typedef struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_table_t; typedef struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_table_t; typedef struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_table_t; typedef struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_table_t; typedef struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_Null_file_identifier #define org_apache_arrow_flatbuf_Null_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Null_file_identifier */ #ifndef org_apache_arrow_flatbuf_Null_identifier #define org_apache_arrow_flatbuf_Null_identifier 0 #endif #define org_apache_arrow_flatbuf_Null_type_hash ((flatbuffers_thash_t)0x7b36a4dd) #define org_apache_arrow_flatbuf_Null_type_identifier "\xdd\xa4\x36\x7b" #ifndef org_apache_arrow_flatbuf_Null_file_extension #define org_apache_arrow_flatbuf_Null_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Struct__file_identifier #define org_apache_arrow_flatbuf_Struct__file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Struct__file_identifier */ #ifndef org_apache_arrow_flatbuf_Struct__identifier #define org_apache_arrow_flatbuf_Struct__identifier 0 #endif #define org_apache_arrow_flatbuf_Struct__type_hash ((flatbuffers_thash_t)0x6310f362) #define org_apache_arrow_flatbuf_Struct__type_identifier "\x62\xf3\x10\x63" #ifndef org_apache_arrow_flatbuf_Struct__file_extension #define org_apache_arrow_flatbuf_Struct__file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_List_file_identifier #define org_apache_arrow_flatbuf_List_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_List_file_identifier */ #ifndef org_apache_arrow_flatbuf_List_identifier #define org_apache_arrow_flatbuf_List_identifier 0 #endif #define org_apache_arrow_flatbuf_List_type_hash ((flatbuffers_thash_t)0xd4ce5878) #define org_apache_arrow_flatbuf_List_type_identifier "\x78\x58\xce\xd4" #ifndef org_apache_arrow_flatbuf_List_file_extension #define org_apache_arrow_flatbuf_List_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeList_file_identifier #define org_apache_arrow_flatbuf_LargeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeList_identifier #define org_apache_arrow_flatbuf_LargeList_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeList_type_hash ((flatbuffers_thash_t)0x38aa7e27) #define org_apache_arrow_flatbuf_LargeList_type_identifier "\x27\x7e\xaa\x38" #ifndef org_apache_arrow_flatbuf_LargeList_file_extension #define org_apache_arrow_flatbuf_LargeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_ListView_file_identifier #define org_apache_arrow_flatbuf_ListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_ListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_ListView_identifier #define org_apache_arrow_flatbuf_ListView_identifier 0 #endif #define org_apache_arrow_flatbuf_ListView_type_hash ((flatbuffers_thash_t)0x23d37919) #define org_apache_arrow_flatbuf_ListView_type_identifier "\x19\x79\xd3\x23" #ifndef org_apache_arrow_flatbuf_ListView_file_extension #define org_apache_arrow_flatbuf_ListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeListView_file_identifier #define org_apache_arrow_flatbuf_LargeListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeListView_identifier #define org_apache_arrow_flatbuf_LargeListView_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeListView_type_hash ((flatbuffers_thash_t)0x28efac02) #define org_apache_arrow_flatbuf_LargeListView_type_identifier "\x02\xac\xef\x28" #ifndef org_apache_arrow_flatbuf_LargeListView_file_extension #define org_apache_arrow_flatbuf_LargeListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_identifier #define org_apache_arrow_flatbuf_FixedSizeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeList_identifier #define org_apache_arrow_flatbuf_FixedSizeList_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeList_type_hash ((flatbuffers_thash_t)0xcef245bb) #define org_apache_arrow_flatbuf_FixedSizeList_type_identifier "\xbb\x45\xf2\xce" #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_extension #define org_apache_arrow_flatbuf_FixedSizeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Map_file_identifier #define org_apache_arrow_flatbuf_Map_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Map_file_identifier */ #ifndef org_apache_arrow_flatbuf_Map_identifier #define org_apache_arrow_flatbuf_Map_identifier 0 #endif #define org_apache_arrow_flatbuf_Map_type_hash ((flatbuffers_thash_t)0xcebef8e6) #define org_apache_arrow_flatbuf_Map_type_identifier "\xe6\xf8\xbe\xce" #ifndef org_apache_arrow_flatbuf_Map_file_extension #define org_apache_arrow_flatbuf_Map_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Union_file_identifier #define org_apache_arrow_flatbuf_Union_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Union_file_identifier */ #ifndef org_apache_arrow_flatbuf_Union_identifier #define org_apache_arrow_flatbuf_Union_identifier 0 #endif #define org_apache_arrow_flatbuf_Union_type_hash ((flatbuffers_thash_t)0x896bda57) #define org_apache_arrow_flatbuf_Union_type_identifier "\x57\xda\x6b\x89" #ifndef org_apache_arrow_flatbuf_Union_file_extension #define org_apache_arrow_flatbuf_Union_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Int_file_identifier #define org_apache_arrow_flatbuf_Int_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Int_file_identifier */ #ifndef org_apache_arrow_flatbuf_Int_identifier #define org_apache_arrow_flatbuf_Int_identifier 0 #endif #define org_apache_arrow_flatbuf_Int_type_hash ((flatbuffers_thash_t)0x30789001) #define org_apache_arrow_flatbuf_Int_type_identifier "\x01\x90\x78\x30" #ifndef org_apache_arrow_flatbuf_Int_file_extension #define org_apache_arrow_flatbuf_Int_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_identifier #define org_apache_arrow_flatbuf_FloatingPoint_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FloatingPoint_file_identifier */ #ifndef org_apache_arrow_flatbuf_FloatingPoint_identifier #define org_apache_arrow_flatbuf_FloatingPoint_identifier 0 #endif #define org_apache_arrow_flatbuf_FloatingPoint_type_hash ((flatbuffers_thash_t)0xf7d06268) #define org_apache_arrow_flatbuf_FloatingPoint_type_identifier "\x68\x62\xd0\xf7" #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_extension #define org_apache_arrow_flatbuf_FloatingPoint_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8_file_identifier #define org_apache_arrow_flatbuf_Utf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8_identifier #define org_apache_arrow_flatbuf_Utf8_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8_type_hash ((flatbuffers_thash_t)0x8fe60d37) #define org_apache_arrow_flatbuf_Utf8_type_identifier "\x37\x0d\xe6\x8f" #ifndef org_apache_arrow_flatbuf_Utf8_file_extension #define org_apache_arrow_flatbuf_Utf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Binary_file_identifier #define org_apache_arrow_flatbuf_Binary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Binary_file_identifier */ #ifndef org_apache_arrow_flatbuf_Binary_identifier #define org_apache_arrow_flatbuf_Binary_identifier 0 #endif #define org_apache_arrow_flatbuf_Binary_type_hash ((flatbuffers_thash_t)0x8e21a795) #define org_apache_arrow_flatbuf_Binary_type_identifier "\x95\xa7\x21\x8e" #ifndef org_apache_arrow_flatbuf_Binary_file_extension #define org_apache_arrow_flatbuf_Binary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_identifier #define org_apache_arrow_flatbuf_LargeUtf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeUtf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeUtf8_identifier #define org_apache_arrow_flatbuf_LargeUtf8_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeUtf8_type_hash ((flatbuffers_thash_t)0x24ed2fb0) #define org_apache_arrow_flatbuf_LargeUtf8_type_identifier "\xb0\x2f\xed\x24" #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_extension #define org_apache_arrow_flatbuf_LargeUtf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeBinary_file_identifier #define org_apache_arrow_flatbuf_LargeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeBinary_identifier #define org_apache_arrow_flatbuf_LargeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeBinary_type_hash ((flatbuffers_thash_t)0xbd437872) #define org_apache_arrow_flatbuf_LargeBinary_type_identifier "\x72\x78\x43\xbd" #ifndef org_apache_arrow_flatbuf_LargeBinary_file_extension #define org_apache_arrow_flatbuf_LargeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8View_file_identifier #define org_apache_arrow_flatbuf_Utf8View_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8View_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8View_identifier #define org_apache_arrow_flatbuf_Utf8View_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8View_type_hash ((flatbuffers_thash_t)0xab7692) #define org_apache_arrow_flatbuf_Utf8View_type_identifier "\x92\x76\xab\x00" #ifndef org_apache_arrow_flatbuf_Utf8View_file_extension #define org_apache_arrow_flatbuf_Utf8View_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_BinaryView_file_identifier #define org_apache_arrow_flatbuf_BinaryView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_BinaryView_file_identifier */ #ifndef org_apache_arrow_flatbuf_BinaryView_identifier #define org_apache_arrow_flatbuf_BinaryView_identifier 0 #endif #define org_apache_arrow_flatbuf_BinaryView_type_hash ((flatbuffers_thash_t)0x18c52428) #define org_apache_arrow_flatbuf_BinaryView_type_identifier "\x28\x24\xc5\x18" #ifndef org_apache_arrow_flatbuf_BinaryView_file_extension #define org_apache_arrow_flatbuf_BinaryView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeBinary_type_hash ((flatbuffers_thash_t)0x80d0f4ce) #define org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier "\xce\xf4\xd0\x80" #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_extension #define org_apache_arrow_flatbuf_FixedSizeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Bool_file_identifier #define org_apache_arrow_flatbuf_Bool_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Bool_file_identifier */ #ifndef org_apache_arrow_flatbuf_Bool_identifier #define org_apache_arrow_flatbuf_Bool_identifier 0 #endif #define org_apache_arrow_flatbuf_Bool_type_hash ((flatbuffers_thash_t)0x96bf83f0) #define org_apache_arrow_flatbuf_Bool_type_identifier "\xf0\x83\xbf\x96" #ifndef org_apache_arrow_flatbuf_Bool_file_extension #define org_apache_arrow_flatbuf_Bool_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_RunEndEncoded_file_identifier */ #ifndef org_apache_arrow_flatbuf_RunEndEncoded_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_identifier 0 #endif #define org_apache_arrow_flatbuf_RunEndEncoded_type_hash ((flatbuffers_thash_t)0x5a98bcc) #define org_apache_arrow_flatbuf_RunEndEncoded_type_identifier "\xcc\x8b\xa9\x05" #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_extension #define org_apache_arrow_flatbuf_RunEndEncoded_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Decimal_file_identifier #define org_apache_arrow_flatbuf_Decimal_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Decimal_file_identifier */ #ifndef org_apache_arrow_flatbuf_Decimal_identifier #define org_apache_arrow_flatbuf_Decimal_identifier 0 #endif #define org_apache_arrow_flatbuf_Decimal_type_hash ((flatbuffers_thash_t)0x91d1beb7) #define org_apache_arrow_flatbuf_Decimal_type_identifier "\xb7\xbe\xd1\x91" #ifndef org_apache_arrow_flatbuf_Decimal_file_extension #define org_apache_arrow_flatbuf_Decimal_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Date_file_identifier #define org_apache_arrow_flatbuf_Date_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Date_file_identifier */ #ifndef org_apache_arrow_flatbuf_Date_identifier #define org_apache_arrow_flatbuf_Date_identifier 0 #endif #define org_apache_arrow_flatbuf_Date_type_hash ((flatbuffers_thash_t)0xe0ccf624) #define org_apache_arrow_flatbuf_Date_type_identifier "\x24\xf6\xcc\xe0" #ifndef org_apache_arrow_flatbuf_Date_file_extension #define org_apache_arrow_flatbuf_Date_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Time_file_identifier #define org_apache_arrow_flatbuf_Time_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Time_file_identifier */ #ifndef org_apache_arrow_flatbuf_Time_identifier #define org_apache_arrow_flatbuf_Time_identifier 0 #endif #define org_apache_arrow_flatbuf_Time_type_hash ((flatbuffers_thash_t)0x2442a489) #define org_apache_arrow_flatbuf_Time_type_identifier "\x89\xa4\x42\x24" #ifndef org_apache_arrow_flatbuf_Time_file_extension #define org_apache_arrow_flatbuf_Time_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Timestamp_file_identifier #define org_apache_arrow_flatbuf_Timestamp_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Timestamp_file_identifier */ #ifndef org_apache_arrow_flatbuf_Timestamp_identifier #define org_apache_arrow_flatbuf_Timestamp_identifier 0 #endif #define org_apache_arrow_flatbuf_Timestamp_type_hash ((flatbuffers_thash_t)0x1fddf080) #define org_apache_arrow_flatbuf_Timestamp_type_identifier "\x80\xf0\xdd\x1f" #ifndef org_apache_arrow_flatbuf_Timestamp_file_extension #define org_apache_arrow_flatbuf_Timestamp_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Interval_file_identifier #define org_apache_arrow_flatbuf_Interval_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Interval_file_identifier */ #ifndef org_apache_arrow_flatbuf_Interval_identifier #define org_apache_arrow_flatbuf_Interval_identifier 0 #endif #define org_apache_arrow_flatbuf_Interval_type_hash ((flatbuffers_thash_t)0x1e2d6809) #define org_apache_arrow_flatbuf_Interval_type_identifier "\x09\x68\x2d\x1e" #ifndef org_apache_arrow_flatbuf_Interval_file_extension #define org_apache_arrow_flatbuf_Interval_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Duration_file_identifier #define org_apache_arrow_flatbuf_Duration_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Duration_file_identifier */ #ifndef org_apache_arrow_flatbuf_Duration_identifier #define org_apache_arrow_flatbuf_Duration_identifier 0 #endif #define org_apache_arrow_flatbuf_Duration_type_hash ((flatbuffers_thash_t)0x1ecea6b0) #define org_apache_arrow_flatbuf_Duration_type_identifier "\xb0\xa6\xce\x1e" #ifndef org_apache_arrow_flatbuf_Duration_file_extension #define org_apache_arrow_flatbuf_Duration_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_KeyValue_file_identifier #define org_apache_arrow_flatbuf_KeyValue_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_KeyValue_file_identifier */ #ifndef org_apache_arrow_flatbuf_KeyValue_identifier #define org_apache_arrow_flatbuf_KeyValue_identifier 0 #endif #define org_apache_arrow_flatbuf_KeyValue_type_hash ((flatbuffers_thash_t)0x3b264744) #define org_apache_arrow_flatbuf_KeyValue_type_identifier "\x44\x47\x26\x3b" #ifndef org_apache_arrow_flatbuf_KeyValue_file_extension #define org_apache_arrow_flatbuf_KeyValue_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier */ #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_identifier 0 #endif #define org_apache_arrow_flatbuf_DictionaryEncoding_type_hash ((flatbuffers_thash_t)0x8c703261) #define org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier "\x61\x32\x70\x8c" #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_extension #define org_apache_arrow_flatbuf_DictionaryEncoding_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Field_file_identifier #define org_apache_arrow_flatbuf_Field_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Field_file_identifier */ #ifndef org_apache_arrow_flatbuf_Field_identifier #define org_apache_arrow_flatbuf_Field_identifier 0 #endif #define org_apache_arrow_flatbuf_Field_type_hash ((flatbuffers_thash_t)0xd981525c) #define org_apache_arrow_flatbuf_Field_type_identifier "\x5c\x52\x81\xd9" #ifndef org_apache_arrow_flatbuf_Field_file_extension #define org_apache_arrow_flatbuf_Field_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Buffer_file_identifier #define org_apache_arrow_flatbuf_Buffer_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Buffer_file_identifier */ #ifndef org_apache_arrow_flatbuf_Buffer_identifier #define org_apache_arrow_flatbuf_Buffer_identifier 0 #endif #define org_apache_arrow_flatbuf_Buffer_type_hash ((flatbuffers_thash_t)0x519d7fea) #define org_apache_arrow_flatbuf_Buffer_type_identifier "\xea\x7f\x9d\x51" #ifndef org_apache_arrow_flatbuf_Buffer_file_extension #define org_apache_arrow_flatbuf_Buffer_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Schema_file_identifier #define org_apache_arrow_flatbuf_Schema_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Schema_file_identifier */ #ifndef org_apache_arrow_flatbuf_Schema_identifier #define org_apache_arrow_flatbuf_Schema_identifier 0 #endif #define org_apache_arrow_flatbuf_Schema_type_hash ((flatbuffers_thash_t)0x406570b) #define org_apache_arrow_flatbuf_Schema_type_identifier "\x0b\x57\x06\x04" #ifndef org_apache_arrow_flatbuf_Schema_file_extension #define org_apache_arrow_flatbuf_Schema_file_extension "bin" #endif typedef int16_t org_apache_arrow_flatbuf_MetadataVersion_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, 16) /** 0.1.0 (October 2016). */ #define org_apache_arrow_flatbuf_MetadataVersion_V1 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_MetadataVersion_V2 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_MetadataVersion_V3 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_MetadataVersion_V4 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(3)) #define org_apache_arrow_flatbuf_MetadataVersion_V5 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(4)) static inline const char *org_apache_arrow_flatbuf_MetadataVersion_name(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return "V1"; case org_apache_arrow_flatbuf_MetadataVersion_V2: return "V2"; case org_apache_arrow_flatbuf_MetadataVersion_V3: return "V3"; case org_apache_arrow_flatbuf_MetadataVersion_V4: return "V4"; case org_apache_arrow_flatbuf_MetadataVersion_V5: return "V5"; default: return ""; } } static inline int org_apache_arrow_flatbuf_MetadataVersion_is_known_value(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V2: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V3: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V4: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V5: return 1; default: return 0; } } /** Represents Arrow Features that might not have full support * within implementations. This is intended to be used in * two scenarios: * 1. A mechanism for readers of Arrow Streams * and files to understand that the stream or file makes * use of a feature that isn't supported or unknown to * the implementation (and therefore can meet the Arrow * forward compatibility guarantees). * 2. A means of negotiating between a client and server * what features a stream is allowed to use. The enums * values here are intented to represent higher level * features, additional details maybe negotiated * with key-value pairs specific to the protocol. * * Enums added to this list should be assigned power-of-two values * to facilitate exchanging and comparing bitmaps for supported * features. */ typedef int64_t org_apache_arrow_flatbuf_Feature_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, 64) /** Needed to make flatbuffers happy. */ #define org_apache_arrow_flatbuf_Feature_UNUSED ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(0)) #define org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(1)) #define org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(2)) static inline const char *org_apache_arrow_flatbuf_Feature_name(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return "UNUSED"; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return "DICTIONARY_REPLACEMENT"; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return "COMPRESSED_BODY"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Feature_is_known_value(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return 1; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return 1; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_UnionMode_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 16) #define org_apache_arrow_flatbuf_UnionMode_Sparse ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_UnionMode_Dense ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_UnionMode_name(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return "Sparse"; case org_apache_arrow_flatbuf_UnionMode_Dense: return "Dense"; default: return ""; } } static inline int org_apache_arrow_flatbuf_UnionMode_is_known_value(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return 1; case org_apache_arrow_flatbuf_UnionMode_Dense: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_Precision_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 16) #define org_apache_arrow_flatbuf_Precision_HALF ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Precision_SINGLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_Precision_DOUBLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_Precision_name(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return "HALF"; case org_apache_arrow_flatbuf_Precision_SINGLE: return "SINGLE"; case org_apache_arrow_flatbuf_Precision_DOUBLE: return "DOUBLE"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Precision_is_known_value(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return 1; case org_apache_arrow_flatbuf_Precision_SINGLE: return 1; case org_apache_arrow_flatbuf_Precision_DOUBLE: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_DateUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 16) #define org_apache_arrow_flatbuf_DateUnit_DAY ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_DateUnit_MILLISECOND ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_DateUnit_name(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return "DAY"; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return "MILLISECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DateUnit_is_known_value(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return 1; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_TimeUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 16) #define org_apache_arrow_flatbuf_TimeUnit_SECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_TimeUnit_MILLISECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_TimeUnit_MICROSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_TimeUnit_NANOSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(3)) static inline const char *org_apache_arrow_flatbuf_TimeUnit_name(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return "SECOND"; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return "MILLISECOND"; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return "MICROSECOND"; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return "NANOSECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_TimeUnit_is_known_value(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_IntervalUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 16) #define org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_IntervalUnit_name(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return "YEAR_MONTH"; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return "DAY_TIME"; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return "MONTH_DAY_NANO"; default: return ""; } } static inline int org_apache_arrow_flatbuf_IntervalUnit_is_known_value(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return 1; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return 1; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Dictionary encoding metadata * Maintained for forwards compatibility, in the future * Dictionaries might be explicit maps between integers and values * allowing for non-contiguous index values */ typedef int16_t org_apache_arrow_flatbuf_DictionaryKind_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 16) #define org_apache_arrow_flatbuf_DictionaryKind_DenseArray ((org_apache_arrow_flatbuf_DictionaryKind_enum_t)INT16_C(0)) static inline const char *org_apache_arrow_flatbuf_DictionaryKind_name(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return "DenseArray"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DictionaryKind_is_known_value(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Endianness of the platform producing the data */ typedef int16_t org_apache_arrow_flatbuf_Endianness_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 16) #define org_apache_arrow_flatbuf_Endianness_Little ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Endianness_Big ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_Endianness_name(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return "Little"; case org_apache_arrow_flatbuf_Endianness_Big: return "Big"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Endianness_is_known_value(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return 1; case org_apache_arrow_flatbuf_Endianness_Big: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * A Buffer represents a single contiguous memory segment */ struct org_apache_arrow_flatbuf_Buffer { /** The relative offset into the shared memory page where the bytes for this * buffer starts */ alignas(8) int64_t offset; /** The absolute length (in bytes) of the memory buffer. The memory is found * from offset (inclusive) to offset + length (non-inclusive). When building * messages using the encapsulated IPC message, padding bytes may be written * after a buffer, but such padding bytes do not need to be accounted for in * the size here. */ alignas(8) int64_t length; }; static_assert(sizeof(org_apache_arrow_flatbuf_Buffer_t) == 16, "struct size mismatch"); static inline const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__const_ptr_add(const org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__ptr_add(org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_struct_t org_apache_arrow_flatbuf_Buffer_vec_at(org_apache_arrow_flatbuf_Buffer_vec_t vec, size_t i) __flatbuffers_struct_vec_at(vec, i) static inline size_t org_apache_arrow_flatbuf_Buffer__size(void) { return 16; } static inline size_t org_apache_arrow_flatbuf_Buffer_vec_len(org_apache_arrow_flatbuf_Buffer_vec_t vec) __flatbuffers_vec_len(vec) __flatbuffers_struct_as_root(org_apache_arrow_flatbuf_Buffer) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, offset, flatbuffers_int64, int64_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, length, flatbuffers_int64, int64_t) /** These are stored in the flatbuffer in the Type union below */ struct org_apache_arrow_flatbuf_Null_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Null_vec_len(org_apache_arrow_flatbuf_Null_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Null_table_t org_apache_arrow_flatbuf_Null_vec_at(org_apache_arrow_flatbuf_Null_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Null_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Null) /** A Struct_ in the flatbuffer metadata is the same as an Arrow Struct * (according to the physical memory layout). We used Struct_ here as * Struct is a reserved word in Flatbuffers */ struct org_apache_arrow_flatbuf_Struct__table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Struct__vec_len(org_apache_arrow_flatbuf_Struct__vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Struct__table_t org_apache_arrow_flatbuf_Struct__vec_at(org_apache_arrow_flatbuf_Struct__vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Struct__table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Struct_) struct org_apache_arrow_flatbuf_List_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_List_vec_len(org_apache_arrow_flatbuf_List_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_List_table_t org_apache_arrow_flatbuf_List_vec_at(org_apache_arrow_flatbuf_List_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_List_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_List) /** Same as List, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeList_vec_len(org_apache_arrow_flatbuf_LargeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeList_table_t org_apache_arrow_flatbuf_LargeList_vec_at(org_apache_arrow_flatbuf_LargeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeList) /** Represents the same logical types that List can, but contains offsets and * sizes allowing for writes in any order and sharing of child values among * list values. */ struct org_apache_arrow_flatbuf_ListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_ListView_vec_len(org_apache_arrow_flatbuf_ListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_ListView_table_t org_apache_arrow_flatbuf_ListView_vec_at(org_apache_arrow_flatbuf_ListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_ListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_ListView) /** Same as ListView, but with 64-bit offsets and sizes, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeListView_vec_len(org_apache_arrow_flatbuf_LargeListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeListView_table_t org_apache_arrow_flatbuf_LargeListView_vec_at(org_apache_arrow_flatbuf_LargeListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeListView) struct org_apache_arrow_flatbuf_FixedSizeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeList_vec_len(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeList_table_t org_apache_arrow_flatbuf_FixedSizeList_vec_at(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeList) /** Number of list items per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeList, listSize, flatbuffers_int32, int32_t, INT32_C(0)) /** A Map is a logical nested type that is represented as * * List> * * In this layout, the keys and values are each respectively contiguous. We do * not constrain the key and value types, so the application is responsible * for ensuring that the keys are hashable and unique. Whether the keys are sorted * may be set in the metadata for this field. * * In a field with Map type, the field has a child Struct field, which then * has two children: key type and the second the value type. The names of the * child fields may be respectively "entries", "key", and "value", but this is * not enforced. * * Map * ```text * - child[0] entries: Struct * - child[0] key: K * - child[1] value: V * ``` * Neither the "entries" field nor the "key" field may be nullable. * * The metadata is structured so that Arrow systems without special handling * for Map can make Map an alias for List. The "layout" attribute for the Map * field must have the same contents as a List. */ struct org_apache_arrow_flatbuf_Map_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Map_vec_len(org_apache_arrow_flatbuf_Map_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Map_table_t org_apache_arrow_flatbuf_Map_vec_at(org_apache_arrow_flatbuf_Map_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Map_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Map) /** Set to true if the keys within each value are sorted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Map, keysSorted, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** A union is a complex type with children in Field * By default ids in the type vector refer to the offsets in the children * optionally typeIds provides an indirection between the child offset and the type id * for each child `typeIds[offset]` is the id used in the type vector */ struct org_apache_arrow_flatbuf_Union_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Union_vec_len(org_apache_arrow_flatbuf_Union_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Union_table_t org_apache_arrow_flatbuf_Union_vec_at(org_apache_arrow_flatbuf_Union_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Union_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Union) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Union, mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Union, typeIds, flatbuffers_int32_vec_t, 0) struct org_apache_arrow_flatbuf_Int_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Int_vec_len(org_apache_arrow_flatbuf_Int_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Int_table_t org_apache_arrow_flatbuf_Int_vec_at(org_apache_arrow_flatbuf_Int_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Int_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Int) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Int, bitWidth, flatbuffers_int32, int32_t, INT32_C(0)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Int, is_signed, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) struct org_apache_arrow_flatbuf_FloatingPoint_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FloatingPoint_vec_len(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FloatingPoint_table_t org_apache_arrow_flatbuf_FloatingPoint_vec_at(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FloatingPoint_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FloatingPoint, precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, INT16_C(0)) /** Unicode with UTF-8 encoding */ struct org_apache_arrow_flatbuf_Utf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8_vec_len(org_apache_arrow_flatbuf_Utf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8_table_t org_apache_arrow_flatbuf_Utf8_vec_at(org_apache_arrow_flatbuf_Utf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8) /** Opaque binary data */ struct org_apache_arrow_flatbuf_Binary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Binary_vec_len(org_apache_arrow_flatbuf_Binary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Binary_table_t org_apache_arrow_flatbuf_Binary_vec_at(org_apache_arrow_flatbuf_Binary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Binary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Binary) /** Same as Utf8, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeUtf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeUtf8_vec_len(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeUtf8_table_t org_apache_arrow_flatbuf_LargeUtf8_vec_at(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeUtf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeUtf8) /** Same as Binary, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeBinary_vec_len(org_apache_arrow_flatbuf_LargeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeBinary_table_t org_apache_arrow_flatbuf_LargeBinary_vec_at(org_apache_arrow_flatbuf_LargeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeBinary) /** Logically the same as Utf8, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_Utf8View_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8View_vec_len(org_apache_arrow_flatbuf_Utf8View_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8View_table_t org_apache_arrow_flatbuf_Utf8View_vec_at(org_apache_arrow_flatbuf_Utf8View_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8View_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8View) /** Logically the same as Binary, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_BinaryView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_BinaryView_vec_len(org_apache_arrow_flatbuf_BinaryView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_BinaryView_table_t org_apache_arrow_flatbuf_BinaryView_vec_at(org_apache_arrow_flatbuf_BinaryView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_BinaryView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_BinaryView) struct org_apache_arrow_flatbuf_FixedSizeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_len(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeBinary_table_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeBinary) /** Number of bytes per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeBinary, byteWidth, flatbuffers_int32, int32_t, INT32_C(0)) struct org_apache_arrow_flatbuf_Bool_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Bool_vec_len(org_apache_arrow_flatbuf_Bool_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Bool_table_t org_apache_arrow_flatbuf_Bool_vec_at(org_apache_arrow_flatbuf_Bool_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Bool_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Bool) /** Contains two child arrays, run_ends and values. * The run_ends child array must be a 16/32/64-bit integer array * which encodes the indices at which the run with the value in * each corresponding index in the values child array ends. * Like list/struct types, the value array can be of any type. */ struct org_apache_arrow_flatbuf_RunEndEncoded_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_RunEndEncoded_vec_len(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_RunEndEncoded_table_t org_apache_arrow_flatbuf_RunEndEncoded_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_RunEndEncoded) /** Exact decimal value represented as an integer value in two's * complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers * are used. The representation uses the endianness indicated * in the Schema. */ struct org_apache_arrow_flatbuf_Decimal_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Decimal_vec_len(org_apache_arrow_flatbuf_Decimal_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Decimal_table_t org_apache_arrow_flatbuf_Decimal_vec_at(org_apache_arrow_flatbuf_Decimal_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Decimal_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Decimal) /** Total number of decimal digits */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Decimal, precision, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of digits after the decimal point "." */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Decimal, scale, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of bits per value. The only accepted widths are 128 and 256. * We use bitWidth for consistency with Int::bitWidth. */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_Decimal, bitWidth, flatbuffers_int32, int32_t, INT32_C(128)) /** Date is either a 32-bit or 64-bit signed integer type representing an * elapsed time since UNIX epoch (1970-01-01), stored in either of two units: * * * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no * leap seconds), where the values are evenly divisible by 86400000 * * Days (32 bits) since the UNIX epoch */ struct org_apache_arrow_flatbuf_Date_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Date_vec_len(org_apache_arrow_flatbuf_Date_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Date_table_t org_apache_arrow_flatbuf_Date_vec_at(org_apache_arrow_flatbuf_Date_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Date_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Date) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Date, unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, INT16_C(1)) /** Time is either a 32-bit or 64-bit signed integer type representing an * elapsed time since midnight, stored in either of four units: seconds, * milliseconds, microseconds or nanoseconds. * * The integer `bitWidth` depends on the `unit` and must be one of the following: * * SECOND and MILLISECOND: 32 bits * * MICROSECOND and NANOSECOND: 64 bits * * The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds * (exclusive), adjusted for the time unit (for example, up to 86400000 * exclusive for the MILLISECOND unit). * This definition doesn't allow for leap seconds. Time values from * measurements with leap seconds will need to be corrected when ingesting * into Arrow (for example by replacing the value 86400 with 86399). */ struct org_apache_arrow_flatbuf_Time_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Time_vec_len(org_apache_arrow_flatbuf_Time_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Time_table_t org_apache_arrow_flatbuf_Time_vec_at(org_apache_arrow_flatbuf_Time_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Time_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Time) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Time, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Time, bitWidth, flatbuffers_int32, int32_t, INT32_C(32)) /** Timestamp is a 64-bit signed integer representing an elapsed time since a * fixed epoch, stored in either of four units: seconds, milliseconds, * microseconds or nanoseconds, and is optionally annotated with a timezone. * * Timestamp values do not include any leap seconds (in other words, all * days are considered 86400 seconds long). * * Timestamps with a non-empty timezone * ------------------------------------ * * If a Timestamp column has a non-empty timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone * (the Unix epoch), regardless of the Timestamp's own timezone. * * Therefore, timestamp values with a non-empty timezone correspond to * physical points in time together with some additional information about * how the data was obtained and/or how to display it (the timezone). * * For example, the timestamp value 0 with the timezone string "Europe/Paris" * corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the * application may prefer to display it as "January 1st 1970, 01h00" in * the Europe/Paris timezone (which is the same physical point in time). * * One consequence is that timestamp values with a non-empty timezone * can be compared and ordered directly, since they all share the same * well-known point of reference (the Unix epoch). * * Timestamps with an unset / empty timezone * ----------------------------------------- * * If a Timestamp column has no timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone. * * Therefore, timestamp values without a timezone cannot be meaningfully * interpreted as physical points in time, but only as calendar / clock * indications ("wall clock time") in an unspecified timezone. * * For example, the timestamp value 0 with an empty timezone string * corresponds to "January 1st 1970, 00h00" in an unknown timezone: there * is not enough information to interpret it as a well-defined physical * point in time. * * One consequence is that timestamp values without a timezone cannot * be reliably compared or ordered, since they may have different points of * reference. In particular, it is *not* possible to interpret an unset * or empty timezone as the same as "UTC". * * Conversion between timezones * ---------------------------- * * If a Timestamp column has a non-empty timezone, changing the timezone * to a different non-empty value is a metadata-only operation: * the timestamp values need not change as their point of reference remains * the same (the Unix epoch). * * However, if a Timestamp column has no timezone value, changing it to a * non-empty value requires to think about the desired semantics. * One possibility is to assume that the original timestamp values are * relative to the epoch of the timezone being set; timestamp values should * then adjusted to the Unix epoch (for example, changing the timezone from * empty to "Europe/Paris" would require converting the timestamp values * from "Europe/Paris" to "UTC", which seems counter-intuitive but is * nevertheless correct). * * Guidelines for encoding data from external libraries * ---------------------------------------------------- * * Date & time libraries often have multiple different data types for temporal * data. In order to ease interoperability between different implementations the * Arrow project has some recommendations for encoding these types into a Timestamp * column. * * An "instant" represents a physical point in time that has no relevant timezone * (for example, astronomical data). To encode an instant, use a Timestamp with * the timezone string set to "UTC", and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * A "zoned date-time" represents a physical point in time annotated with an * informative timezone (for example, the timezone in which the data was * recorded). To encode a zoned date-time, use a Timestamp with the timezone * string set to the name of the timezone, and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * (There is some ambiguity between an instant and a zoned date-time with the * UTC timezone. Both of these are stored the same in Arrow. Typically, * this distinction does not matter. If it does, then an application should * use custom metadata or an extension type to distinguish between the two cases.) * * An "offset date-time" represents a physical point in time combined with an * explicit offset from UTC. To encode an offset date-time, use a Timestamp * with the timezone string set to the numeric timezone offset string * (e.g. "+03:00"), and make sure the Timestamp values are relative to * the UTC epoch (January 1st 1970, midnight). * * A "naive date-time" (also called "local date-time" in some libraries) * represents a wall clock time combined with a calendar date, but with * no indication of how to map this information to a physical point in time. * Naive date-times must be handled with care because of this missing * information, and also because daylight saving time (DST) may make * some values ambiguous or nonexistent. A naive date-time may be * stored as a struct with Date and Time fields. However, it may also be * encoded into a Timestamp column with an empty timezone. The timestamp * values should be computed "as if" the timezone of the date-time values * was UTC; for example, the naive date-time "January 1st 1970, 00h00" would * be encoded as timestamp value 0. */ struct org_apache_arrow_flatbuf_Timestamp_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Timestamp_vec_len(org_apache_arrow_flatbuf_Timestamp_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Timestamp_table_t org_apache_arrow_flatbuf_Timestamp_vec_at(org_apache_arrow_flatbuf_Timestamp_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Timestamp_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Timestamp) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Timestamp, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(0)) /** The timezone is an optional string indicating the name of a timezone, * one of: * * * As used in the Olson timezone database (the "tz database" or * "tzdata"), such as "America/New_York". * * An absolute timezone offset of the form "+XX:XX" or "-XX:XX", * such as "+07:30". * * Whether a timezone string is present indicates different semantics about * the data (see above). */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_Timestamp, timezone, 0) struct org_apache_arrow_flatbuf_Interval_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Interval_vec_len(org_apache_arrow_flatbuf_Interval_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Interval_table_t org_apache_arrow_flatbuf_Interval_vec_at(org_apache_arrow_flatbuf_Interval_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Interval_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Interval) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Interval, unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, INT16_C(0)) struct org_apache_arrow_flatbuf_Duration_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Duration_vec_len(org_apache_arrow_flatbuf_Duration_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Duration_table_t org_apache_arrow_flatbuf_Duration_vec_at(org_apache_arrow_flatbuf_Duration_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Duration_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Duration) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Duration, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) /** ---------------------------------------------------------------------- * Top-level Type value, enabling extensible type-specific metadata. We can * add new logical types to Type without breaking backwards compatibility */ typedef uint8_t org_apache_arrow_flatbuf_Type_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Type_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_Type) /** ---------------------------------------------------------------------- * user defined key value pairs to add custom metadata to arrow * key namespacing is the responsibility of the user */ #define org_apache_arrow_flatbuf_Type_NONE ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_Type_Null ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_Type_Int ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_Type_FloatingPoint ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(3)) #define org_apache_arrow_flatbuf_Type_Binary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(4)) #define org_apache_arrow_flatbuf_Type_Utf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(5)) #define org_apache_arrow_flatbuf_Type_Bool ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(6)) #define org_apache_arrow_flatbuf_Type_Decimal ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(7)) #define org_apache_arrow_flatbuf_Type_Date ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(8)) #define org_apache_arrow_flatbuf_Type_Time ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(9)) #define org_apache_arrow_flatbuf_Type_Timestamp ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(10)) #define org_apache_arrow_flatbuf_Type_Interval ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(11)) #define org_apache_arrow_flatbuf_Type_List ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(12)) #define org_apache_arrow_flatbuf_Type_Struct_ ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(13)) #define org_apache_arrow_flatbuf_Type_Union ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(14)) #define org_apache_arrow_flatbuf_Type_FixedSizeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(15)) #define org_apache_arrow_flatbuf_Type_FixedSizeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(16)) #define org_apache_arrow_flatbuf_Type_Map ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(17)) #define org_apache_arrow_flatbuf_Type_Duration ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(18)) #define org_apache_arrow_flatbuf_Type_LargeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(19)) #define org_apache_arrow_flatbuf_Type_LargeUtf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(20)) #define org_apache_arrow_flatbuf_Type_LargeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(21)) #define org_apache_arrow_flatbuf_Type_RunEndEncoded ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(22)) #define org_apache_arrow_flatbuf_Type_BinaryView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(23)) #define org_apache_arrow_flatbuf_Type_Utf8View ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(24)) #define org_apache_arrow_flatbuf_Type_ListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(25)) #define org_apache_arrow_flatbuf_Type_LargeListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(26)) static inline const char *org_apache_arrow_flatbuf_Type_type_name(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return "NONE"; case org_apache_arrow_flatbuf_Type_Null: return "Null"; case org_apache_arrow_flatbuf_Type_Int: return "Int"; case org_apache_arrow_flatbuf_Type_FloatingPoint: return "FloatingPoint"; case org_apache_arrow_flatbuf_Type_Binary: return "Binary"; case org_apache_arrow_flatbuf_Type_Utf8: return "Utf8"; case org_apache_arrow_flatbuf_Type_Bool: return "Bool"; case org_apache_arrow_flatbuf_Type_Decimal: return "Decimal"; case org_apache_arrow_flatbuf_Type_Date: return "Date"; case org_apache_arrow_flatbuf_Type_Time: return "Time"; case org_apache_arrow_flatbuf_Type_Timestamp: return "Timestamp"; case org_apache_arrow_flatbuf_Type_Interval: return "Interval"; case org_apache_arrow_flatbuf_Type_List: return "List"; case org_apache_arrow_flatbuf_Type_Struct_: return "Struct_"; case org_apache_arrow_flatbuf_Type_Union: return "Union"; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return "FixedSizeBinary"; case org_apache_arrow_flatbuf_Type_FixedSizeList: return "FixedSizeList"; case org_apache_arrow_flatbuf_Type_Map: return "Map"; case org_apache_arrow_flatbuf_Type_Duration: return "Duration"; case org_apache_arrow_flatbuf_Type_LargeBinary: return "LargeBinary"; case org_apache_arrow_flatbuf_Type_LargeUtf8: return "LargeUtf8"; case org_apache_arrow_flatbuf_Type_LargeList: return "LargeList"; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return "RunEndEncoded"; case org_apache_arrow_flatbuf_Type_BinaryView: return "BinaryView"; case org_apache_arrow_flatbuf_Type_Utf8View: return "Utf8View"; case org_apache_arrow_flatbuf_Type_ListView: return "ListView"; case org_apache_arrow_flatbuf_Type_LargeListView: return "LargeListView"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Type_is_known_type(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return 1; case org_apache_arrow_flatbuf_Type_Null: return 1; case org_apache_arrow_flatbuf_Type_Int: return 1; case org_apache_arrow_flatbuf_Type_FloatingPoint: return 1; case org_apache_arrow_flatbuf_Type_Binary: return 1; case org_apache_arrow_flatbuf_Type_Utf8: return 1; case org_apache_arrow_flatbuf_Type_Bool: return 1; case org_apache_arrow_flatbuf_Type_Decimal: return 1; case org_apache_arrow_flatbuf_Type_Date: return 1; case org_apache_arrow_flatbuf_Type_Time: return 1; case org_apache_arrow_flatbuf_Type_Timestamp: return 1; case org_apache_arrow_flatbuf_Type_Interval: return 1; case org_apache_arrow_flatbuf_Type_List: return 1; case org_apache_arrow_flatbuf_Type_Struct_: return 1; case org_apache_arrow_flatbuf_Type_Union: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeList: return 1; case org_apache_arrow_flatbuf_Type_Map: return 1; case org_apache_arrow_flatbuf_Type_Duration: return 1; case org_apache_arrow_flatbuf_Type_LargeBinary: return 1; case org_apache_arrow_flatbuf_Type_LargeUtf8: return 1; case org_apache_arrow_flatbuf_Type_LargeList: return 1; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return 1; case org_apache_arrow_flatbuf_Type_BinaryView: return 1; case org_apache_arrow_flatbuf_Type_Utf8View: return 1; case org_apache_arrow_flatbuf_Type_ListView: return 1; case org_apache_arrow_flatbuf_Type_LargeListView: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_KeyValue_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_KeyValue_vec_len(org_apache_arrow_flatbuf_KeyValue_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_KeyValue_table_t org_apache_arrow_flatbuf_KeyValue_vec_at(org_apache_arrow_flatbuf_KeyValue_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_KeyValue_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_KeyValue) __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_KeyValue, key, 0) __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_KeyValue, value, 0) struct org_apache_arrow_flatbuf_DictionaryEncoding_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_len(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_DictionaryEncoding_table_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_DictionaryEncoding) /** The known dictionary id in the application where this data is used. In * the file or streaming formats, the dictionary ids are found in the * DictionaryBatch messages */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_DictionaryEncoding, id, flatbuffers_int64, int64_t, INT64_C(0)) /** The dictionary indices are constrained to be non-negative integers. If * this field is null, the indices must be signed int32. To maximize * cross-language compatibility and performance, implementations are * recommended to prefer signed integer types over unsigned integer types * and to avoid uint64 indices unless they are required by an application. */ __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_DictionaryEncoding, indexType, org_apache_arrow_flatbuf_Int_table_t, 0) /** By default, dictionaries are not ordered, or the order does not have * semantic meaning. In some statistical, applications, dictionary-encoding * is used to represent ordered categorical data, and we provide a way to * preserve that metadata here */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_DictionaryEncoding, isOrdered, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_DictionaryEncoding, dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, INT16_C(0)) /** ---------------------------------------------------------------------- * A field represents a named column in a record / row batch or child of a * nested type. */ struct org_apache_arrow_flatbuf_Field_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Field_vec_len(org_apache_arrow_flatbuf_Field_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Field_table_t org_apache_arrow_flatbuf_Field_vec_at(org_apache_arrow_flatbuf_Field_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Field_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Field) /** Name is not required, in i.e. a List */ __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_Field, name, 0) /** Whether or not this field can contain nulls. Should be true in general. */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Field, nullable, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** This is the type of the decoded value if the field is dictionary encoded. */ __flatbuffers_define_union_field(flatbuffers_, 3, org_apache_arrow_flatbuf_Field, type, org_apache_arrow_flatbuf_Type, 0) /** Present only if the field is dictionary encoded. */ __flatbuffers_define_table_field(4, org_apache_arrow_flatbuf_Field, dictionary, org_apache_arrow_flatbuf_DictionaryEncoding_table_t, 0) /** children apply only to nested data types like Struct, List and Union. For * primitive types children will have length 0. */ __flatbuffers_define_vector_field(5, org_apache_arrow_flatbuf_Field, children, org_apache_arrow_flatbuf_Field_vec_t, 0) /** User-defined metadata */ __flatbuffers_define_vector_field(6, org_apache_arrow_flatbuf_Field, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** ---------------------------------------------------------------------- * A Schema describes the columns in a row batch */ struct org_apache_arrow_flatbuf_Schema_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Schema_vec_len(org_apache_arrow_flatbuf_Schema_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Schema_table_t org_apache_arrow_flatbuf_Schema_vec_at(org_apache_arrow_flatbuf_Schema_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Schema_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Schema) /** endianness of the buffer * it is Little Endian by default * if endianness doesn't match the underlying system then the vectors need to be converted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Schema, endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Schema, fields, org_apache_arrow_flatbuf_Field_vec_t, 0) __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Schema, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** Features used in the stream/file. */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Schema, features, org_apache_arrow_flatbuf_Feature_vec_t, 0) #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_READER_H */ #ifndef SCHEMA_BUILDER_H #define SCHEMA_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_MetadataVersion_formal_args , org_apache_arrow_flatbuf_MetadataVersion_enum_t v0 #define __org_apache_arrow_flatbuf_MetadataVersion_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t) #define __org_apache_arrow_flatbuf_Feature_formal_args , org_apache_arrow_flatbuf_Feature_enum_t v0 #define __org_apache_arrow_flatbuf_Feature_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t) #define __org_apache_arrow_flatbuf_UnionMode_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0 #define __org_apache_arrow_flatbuf_UnionMode_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t) #define __org_apache_arrow_flatbuf_Precision_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_Precision_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t) #define __org_apache_arrow_flatbuf_DateUnit_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_DateUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t) #define __org_apache_arrow_flatbuf_TimeUnit_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_TimeUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t) #define __org_apache_arrow_flatbuf_IntervalUnit_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_IntervalUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t) #define __org_apache_arrow_flatbuf_DictionaryKind_formal_args , org_apache_arrow_flatbuf_DictionaryKind_enum_t v0 #define __org_apache_arrow_flatbuf_DictionaryKind_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t) #define __org_apache_arrow_flatbuf_Endianness_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0 #define __org_apache_arrow_flatbuf_Endianness_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t) #define __org_apache_arrow_flatbuf_Buffer_formal_args , int64_t v0, int64_t v1 #define __org_apache_arrow_flatbuf_Buffer_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { p->offset = v0; p->length = v1; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { p->offset = p2->offset; p->length = p2->length; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_to_pe(&p->offset, v0); flatbuffers_int64_assign_to_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_to_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_to_pe(&p->length, &p2->length); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_from_pe(&p->offset, v0); flatbuffers_int64_assign_from_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_from_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_from_pe(&p->length, &p2->length); return p; } __flatbuffers_build_struct(flatbuffers_, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Buffer_file_identifier, org_apache_arrow_flatbuf_Buffer_type_identifier) __flatbuffers_define_fixed_array_primitives(flatbuffers_, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_Type_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_Type_union_vec_ref_t; static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Null_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Null_ref_t; static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Null, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Struct__required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Struct__ref_t; static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Struct_, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_List_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_List_ref_t; static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_List, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeList_ref_t; static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeList, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_ListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_ListView_ref_t; static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_ListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeListView_ref_t; static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeList_ref_t; static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Map_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Map_ref_t; static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Map, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Union_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Union_ref_t; static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Union, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Int_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Int_ref_t; static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Int, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FloatingPoint_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FloatingPoint_ref_t; static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8_ref_t; static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Binary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Binary_ref_t; static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Binary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeUtf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeUtf8_ref_t; static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeBinary_ref_t; static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8View_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8View_ref_t; static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_BinaryView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_BinaryView_ref_t; static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_ref_t; static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Bool_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Bool_ref_t; static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Bool, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_RunEndEncoded_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_RunEndEncoded_ref_t; static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Decimal_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Decimal_ref_t; static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Decimal, 3) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Date_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Date_ref_t; static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Date, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Time_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Time_ref_t; static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Time, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Timestamp_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Timestamp_ref_t; static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Interval_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Interval_ref_t; static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Interval, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Duration_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Duration_ref_t; static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Duration, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_KeyValue_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_KeyValue_ref_t; static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_DictionaryEncoding_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_ref_t; static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, 4) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Field_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Field_ref_t; static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Field, 7) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Schema_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Schema_ref_t; static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Schema, 4) #define __org_apache_arrow_flatbuf_Null_formal_args #define __org_apache_arrow_flatbuf_Null_call_args static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Null, org_apache_arrow_flatbuf_Null_file_identifier, org_apache_arrow_flatbuf_Null_type_identifier) #define __org_apache_arrow_flatbuf_Struct__formal_args #define __org_apache_arrow_flatbuf_Struct__call_args static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Struct_, org_apache_arrow_flatbuf_Struct__file_identifier, org_apache_arrow_flatbuf_Struct__type_identifier) #define __org_apache_arrow_flatbuf_List_formal_args #define __org_apache_arrow_flatbuf_List_call_args static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_List, org_apache_arrow_flatbuf_List_file_identifier, org_apache_arrow_flatbuf_List_type_identifier) #define __org_apache_arrow_flatbuf_LargeList_formal_args #define __org_apache_arrow_flatbuf_LargeList_call_args static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeList, org_apache_arrow_flatbuf_LargeList_file_identifier, org_apache_arrow_flatbuf_LargeList_type_identifier) #define __org_apache_arrow_flatbuf_ListView_formal_args #define __org_apache_arrow_flatbuf_ListView_call_args static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_ListView, org_apache_arrow_flatbuf_ListView_file_identifier, org_apache_arrow_flatbuf_ListView_type_identifier) #define __org_apache_arrow_flatbuf_LargeListView_formal_args #define __org_apache_arrow_flatbuf_LargeListView_call_args static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, org_apache_arrow_flatbuf_LargeListView_file_identifier, org_apache_arrow_flatbuf_LargeListView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeList_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeList_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList_file_identifier, org_apache_arrow_flatbuf_FixedSizeList_type_identifier) #define __org_apache_arrow_flatbuf_Map_formal_args , flatbuffers_bool_t v0 #define __org_apache_arrow_flatbuf_Map_call_args , v0 static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Map, org_apache_arrow_flatbuf_Map_file_identifier, org_apache_arrow_flatbuf_Map_type_identifier) #define __org_apache_arrow_flatbuf_Union_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0, flatbuffers_int32_vec_ref_t v1 #define __org_apache_arrow_flatbuf_Union_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Union, org_apache_arrow_flatbuf_Union_file_identifier, org_apache_arrow_flatbuf_Union_type_identifier) #define __org_apache_arrow_flatbuf_Int_formal_args , int32_t v0, flatbuffers_bool_t v1 #define __org_apache_arrow_flatbuf_Int_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_Int_file_identifier, org_apache_arrow_flatbuf_Int_type_identifier) #define __org_apache_arrow_flatbuf_FloatingPoint_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_FloatingPoint_call_args , v0 static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint_file_identifier, org_apache_arrow_flatbuf_FloatingPoint_type_identifier) #define __org_apache_arrow_flatbuf_Utf8_formal_args #define __org_apache_arrow_flatbuf_Utf8_call_args static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8, org_apache_arrow_flatbuf_Utf8_file_identifier, org_apache_arrow_flatbuf_Utf8_type_identifier) #define __org_apache_arrow_flatbuf_Binary_formal_args #define __org_apache_arrow_flatbuf_Binary_call_args static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Binary, org_apache_arrow_flatbuf_Binary_file_identifier, org_apache_arrow_flatbuf_Binary_type_identifier) #define __org_apache_arrow_flatbuf_LargeUtf8_formal_args #define __org_apache_arrow_flatbuf_LargeUtf8_call_args static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8_file_identifier, org_apache_arrow_flatbuf_LargeUtf8_type_identifier) #define __org_apache_arrow_flatbuf_LargeBinary_formal_args #define __org_apache_arrow_flatbuf_LargeBinary_call_args static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, org_apache_arrow_flatbuf_LargeBinary_file_identifier, org_apache_arrow_flatbuf_LargeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Utf8View_formal_args #define __org_apache_arrow_flatbuf_Utf8View_call_args static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, org_apache_arrow_flatbuf_Utf8View_file_identifier, org_apache_arrow_flatbuf_Utf8View_type_identifier) #define __org_apache_arrow_flatbuf_BinaryView_formal_args #define __org_apache_arrow_flatbuf_BinaryView_call_args static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, org_apache_arrow_flatbuf_BinaryView_file_identifier, org_apache_arrow_flatbuf_BinaryView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeBinary_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Bool_formal_args #define __org_apache_arrow_flatbuf_Bool_call_args static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Bool, org_apache_arrow_flatbuf_Bool_file_identifier, org_apache_arrow_flatbuf_Bool_type_identifier) #define __org_apache_arrow_flatbuf_RunEndEncoded_formal_args #define __org_apache_arrow_flatbuf_RunEndEncoded_call_args static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded_file_identifier, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier) #define __org_apache_arrow_flatbuf_Decimal_formal_args , int32_t v0, int32_t v1, int32_t v2 #define __org_apache_arrow_flatbuf_Decimal_call_args , v0, v1, v2 static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Decimal, org_apache_arrow_flatbuf_Decimal_file_identifier, org_apache_arrow_flatbuf_Decimal_type_identifier) #define __org_apache_arrow_flatbuf_Date_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Date_call_args , v0 static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Date, org_apache_arrow_flatbuf_Date_file_identifier, org_apache_arrow_flatbuf_Date_type_identifier) #define __org_apache_arrow_flatbuf_Time_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, int32_t v1 #define __org_apache_arrow_flatbuf_Time_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Time, org_apache_arrow_flatbuf_Time_file_identifier, org_apache_arrow_flatbuf_Time_type_identifier) #define __org_apache_arrow_flatbuf_Timestamp_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_Timestamp_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, org_apache_arrow_flatbuf_Timestamp_file_identifier, org_apache_arrow_flatbuf_Timestamp_type_identifier) #define __org_apache_arrow_flatbuf_Interval_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Interval_call_args , v0 static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Interval, org_apache_arrow_flatbuf_Interval_file_identifier, org_apache_arrow_flatbuf_Interval_type_identifier) #define __org_apache_arrow_flatbuf_Duration_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Duration_call_args , v0 static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Duration, org_apache_arrow_flatbuf_Duration_file_identifier, org_apache_arrow_flatbuf_Duration_type_identifier) #define __org_apache_arrow_flatbuf_KeyValue_formal_args , flatbuffers_string_ref_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_KeyValue_call_args , v0, v1 static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_KeyValue_file_identifier, org_apache_arrow_flatbuf_KeyValue_type_identifier) #define __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args , int64_t v0, org_apache_arrow_flatbuf_Int_ref_t v1, flatbuffers_bool_t v2, org_apache_arrow_flatbuf_DictionaryKind_enum_t v3 #define __org_apache_arrow_flatbuf_DictionaryEncoding_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier) #define __org_apache_arrow_flatbuf_Field_formal_args ,\ flatbuffers_string_ref_t v0, flatbuffers_bool_t v1, org_apache_arrow_flatbuf_Type_union_ref_t v3, org_apache_arrow_flatbuf_DictionaryEncoding_ref_t v4, org_apache_arrow_flatbuf_Field_vec_ref_t v5, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v6 #define __org_apache_arrow_flatbuf_Field_call_args ,\ v0, v1, v3, v4, v5, v6 static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field_file_identifier, org_apache_arrow_flatbuf_Field_type_identifier) #define __org_apache_arrow_flatbuf_Schema_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0, org_apache_arrow_flatbuf_Field_vec_ref_t v1, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v2, org_apache_arrow_flatbuf_Feature_vec_ref_t v3 #define __org_apache_arrow_flatbuf_Schema_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Schema, org_apache_arrow_flatbuf_Schema_file_identifier, org_apache_arrow_flatbuf_Schema_type_identifier) static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_NONE(void) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Null; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Int; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FloatingPoint; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Binary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Bool; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Decimal; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Date; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Time; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Timestamp; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Interval; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_List; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Struct_; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Union; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Map; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Duration; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeUtf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_RunEndEncoded; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_BinaryView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8View; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_ListView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeListView; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_Type) static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_clone(B, (org_apache_arrow_flatbuf_Null_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_clone(B, (org_apache_arrow_flatbuf_Int_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_clone(B, (org_apache_arrow_flatbuf_FloatingPoint_table_t)u.value)); case 4: return org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_clone(B, (org_apache_arrow_flatbuf_Binary_table_t)u.value)); case 5: return org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_clone(B, (org_apache_arrow_flatbuf_Utf8_table_t)u.value)); case 6: return org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_clone(B, (org_apache_arrow_flatbuf_Bool_table_t)u.value)); case 7: return org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_clone(B, (org_apache_arrow_flatbuf_Decimal_table_t)u.value)); case 8: return org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_clone(B, (org_apache_arrow_flatbuf_Date_table_t)u.value)); case 9: return org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_clone(B, (org_apache_arrow_flatbuf_Time_table_t)u.value)); case 10: return org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_clone(B, (org_apache_arrow_flatbuf_Timestamp_table_t)u.value)); case 11: return org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_clone(B, (org_apache_arrow_flatbuf_Interval_table_t)u.value)); case 12: return org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_clone(B, (org_apache_arrow_flatbuf_List_table_t)u.value)); case 13: return org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__clone(B, (org_apache_arrow_flatbuf_Struct__table_t)u.value)); case 14: return org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_clone(B, (org_apache_arrow_flatbuf_Union_table_t)u.value)); case 15: return org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_clone(B, (org_apache_arrow_flatbuf_FixedSizeBinary_table_t)u.value)); case 16: return org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_clone(B, (org_apache_arrow_flatbuf_FixedSizeList_table_t)u.value)); case 17: return org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_clone(B, (org_apache_arrow_flatbuf_Map_table_t)u.value)); case 18: return org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_clone(B, (org_apache_arrow_flatbuf_Duration_table_t)u.value)); case 19: return org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_clone(B, (org_apache_arrow_flatbuf_LargeBinary_table_t)u.value)); case 20: return org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_clone(B, (org_apache_arrow_flatbuf_LargeUtf8_table_t)u.value)); case 21: return org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_clone(B, (org_apache_arrow_flatbuf_LargeList_table_t)u.value)); case 22: return org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_clone(B, (org_apache_arrow_flatbuf_RunEndEncoded_table_t)u.value)); case 23: return org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_clone(B, (org_apache_arrow_flatbuf_BinaryView_table_t)u.value)); case 24: return org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_clone(B, (org_apache_arrow_flatbuf_Utf8View_table_t)u.value)); case 25: return org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_clone(B, (org_apache_arrow_flatbuf_ListView_table_t)u.value)); case 26: return org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_clone(B, (org_apache_arrow_flatbuf_LargeListView_table_t)u.value)); default: return org_apache_arrow_flatbuf_Type_as_NONE(); } } static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args) { if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } return org_apache_arrow_flatbuf_Null_end(B); } static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Null_end(B)); } static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args) { if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } return org_apache_arrow_flatbuf_Struct__end(B); } static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Struct__end(B)); } static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args) { if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } return org_apache_arrow_flatbuf_List_end(B); } static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_List_end(B)); } static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args) { if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeList_end(B); } static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeList_end(B)); } static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args) { if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_ListView_end(B); } static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_ListView_end(B)); } static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args) { if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeListView_end(B); } static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeListView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList_listSize, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeList) static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeList_end(B); } static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeList_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Map_keysSorted, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Map) static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args) { if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Map_end(B); } static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Map_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Union_mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Union) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Union_typeIds, flatbuffers_int32, int32_t, org_apache_arrow_flatbuf_Union) static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args) { if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_add(B, v1) || org_apache_arrow_flatbuf_Union_mode_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Union_end(B); } static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_pick(B, t) || org_apache_arrow_flatbuf_Union_mode_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Union_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Int_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Int) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Int_is_signed, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Int) static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args) { if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_add(B, v0) || org_apache_arrow_flatbuf_Int_is_signed_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_Int_end(B); } static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Int_is_signed_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Int_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint_precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_FloatingPoint) static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args) { if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FloatingPoint_end(B); } static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FloatingPoint_end(B)); } static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args) { if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8_end(B); } static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8_end(B)); } static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args) { if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } return org_apache_arrow_flatbuf_Binary_end(B); } static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Binary_end(B)); } static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args) { if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeUtf8_end(B); } static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeUtf8_end(B)); } static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args) { if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeBinary_end(B); } static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args) { if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8View_end(B); } static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8View_end(B)); } static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args) { if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } return org_apache_arrow_flatbuf_BinaryView_end(B); } static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_BinaryView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeBinary) static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeBinary_end(B); } static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args) { if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } return org_apache_arrow_flatbuf_Bool_end(B); } static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Bool_end(B)); } static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args) { if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } return org_apache_arrow_flatbuf_RunEndEncoded_end(B); } static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_RunEndEncoded_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Decimal_precision, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Decimal_scale, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_Decimal_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(128), org_apache_arrow_flatbuf_Decimal) static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args) { if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_add(B, v0) || org_apache_arrow_flatbuf_Decimal_scale_add(B, v1) || org_apache_arrow_flatbuf_Decimal_bitWidth_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_Decimal_end(B); } static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_pick(B, t) || org_apache_arrow_flatbuf_Decimal_scale_pick(B, t) || org_apache_arrow_flatbuf_Decimal_bitWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Decimal_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Date_unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Date) static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args) { if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Date_end(B); } static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Date_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Time_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Time) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Time_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(32), org_apache_arrow_flatbuf_Time) static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args) { if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_add(B, v1) || org_apache_arrow_flatbuf_Time_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Time_end(B); } static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Time_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Time_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_timezone, org_apache_arrow_flatbuf_Timestamp) static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args) { if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_add(B, v1) || org_apache_arrow_flatbuf_Timestamp_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Timestamp_end(B); } static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_pick(B, t) || org_apache_arrow_flatbuf_Timestamp_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Timestamp_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Interval_unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Interval) static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args) { if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Interval_end(B); } static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Interval_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Duration_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Duration) static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args) { if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Duration_end(B); } static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Duration_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_key, org_apache_arrow_flatbuf_KeyValue) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_value, org_apache_arrow_flatbuf_KeyValue) static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args) { if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_add(B, v0) || org_apache_arrow_flatbuf_KeyValue_value_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_KeyValue_end(B); } static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_pick(B, t) || org_apache_arrow_flatbuf_KeyValue_value_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_KeyValue_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_id, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_indexType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args) { if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_add(B, v0) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_add(B, v1) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_add(B, v3) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_DictionaryEncoding_end(B); } static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_DictionaryEncoding_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_Field_name, org_apache_arrow_flatbuf_Field) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Field_nullable, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_field(3, flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_field(4, flatbuffers_, org_apache_arrow_flatbuf_Field_dictionary, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(5, flatbuffers_, org_apache_arrow_flatbuf_Field_children, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(6, flatbuffers_, org_apache_arrow_flatbuf_Field_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Field) static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args) { if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_add(B, v0) || org_apache_arrow_flatbuf_Field_type_add_value(B, v3) || org_apache_arrow_flatbuf_Field_dictionary_add(B, v4) || org_apache_arrow_flatbuf_Field_children_add(B, v5) || org_apache_arrow_flatbuf_Field_custom_metadata_add(B, v6) || org_apache_arrow_flatbuf_Field_nullable_add(B, v1) || org_apache_arrow_flatbuf_Field_type_add_type(B, v3.type)) { return 0; } return org_apache_arrow_flatbuf_Field_end(B); } static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_pick(B, t) || org_apache_arrow_flatbuf_Field_type_pick(B, t) || org_apache_arrow_flatbuf_Field_dictionary_pick(B, t) || org_apache_arrow_flatbuf_Field_children_pick(B, t) || org_apache_arrow_flatbuf_Field_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Field_nullable_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Field_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Schema_endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Schema_fields, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Schema_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Schema_features, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, org_apache_arrow_flatbuf_Schema) static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args) { if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_add(B, v1) || org_apache_arrow_flatbuf_Schema_custom_metadata_add(B, v2) || org_apache_arrow_flatbuf_Schema_features_add(B, v3) || org_apache_arrow_flatbuf_Schema_endianness_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Schema_end(B); } static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_pick(B, t) || org_apache_arrow_flatbuf_Schema_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Schema_features_pick(B, t) || org_apache_arrow_flatbuf_Schema_endianness_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Schema_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_BUILDER_H */ #ifndef SCHEMA_VERIFIER_H #define SCHEMA_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_verifier.h" #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Type_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Null_verify_table); /* Null */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Int_verify_table); /* Int */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FloatingPoint_verify_table); /* FloatingPoint */ case 4: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Binary_verify_table); /* Binary */ case 5: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8_verify_table); /* Utf8 */ case 6: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Bool_verify_table); /* Bool */ case 7: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Decimal_verify_table); /* Decimal */ case 8: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Date_verify_table); /* Date */ case 9: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Time_verify_table); /* Time */ case 10: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Timestamp_verify_table); /* Timestamp */ case 11: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Interval_verify_table); /* Interval */ case 12: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_List_verify_table); /* List */ case 13: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Struct__verify_table); /* Struct_ */ case 14: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Union_verify_table); /* Union */ case 15: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); /* FixedSizeBinary */ case 16: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeList_verify_table); /* FixedSizeList */ case 17: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Map_verify_table); /* Map */ case 18: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Duration_verify_table); /* Duration */ case 19: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeBinary_verify_table); /* LargeBinary */ case 20: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeUtf8_verify_table); /* LargeUtf8 */ case 21: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeList_verify_table); /* LargeList */ case 22: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_RunEndEncoded_verify_table); /* RunEndEncoded */ case 23: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_BinaryView_verify_table); /* BinaryView */ case 24: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8View_verify_table); /* Utf8View */ case 25: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_ListView_verify_table); /* ListView */ case 26: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeListView_verify_table); /* LargeListView */ default: return flatcc_verify_ok; } } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root(buf, bufsiz, fid, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, fid, 16, 8); } static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Null_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_List_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* listSize */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 1, 1) /* keysSorted */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Map_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* mode */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 4, 4, INT64_C(1073741823)) /* typeIds */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Union_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* bitWidth */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* is_signed */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Int_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* precision */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* byteWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* precision */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* scale */)) return ret; if ((ret = flatcc_verify_field(td, 2, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Date_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Time_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* timezone */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* key */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* value */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* id */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 0, &org_apache_arrow_flatbuf_Int_verify_table) /* indexType */)) return ret; if ((ret = flatcc_verify_field(td, 2, 1, 1) /* isOrdered */)) return ret; if ((ret = flatcc_verify_field(td, 3, 2, 2) /* dictionaryKind */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* name */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* nullable */)) return ret; if ((ret = flatcc_verify_union_field(td, 3, 0, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_field(td, 4, 0, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table) /* dictionary */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 5, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* children */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 6, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Field_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* endianness */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 1, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* fields */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* features */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_VERIFIER_H */ #ifndef SCHEMA_READER_H #define SCHEMA_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef struct org_apache_arrow_flatbuf_Buffer org_apache_arrow_flatbuf_Buffer_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_struct_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_struct_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_vec_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_table_t; typedef struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__table_t; typedef struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_table_t; typedef struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_table_t; typedef struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_table_t; typedef struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_table_t; typedef struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_table_t; typedef struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_table_t; typedef struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_table_t; typedef struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_table_t; typedef struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_table_t; typedef struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_table_t; typedef struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_table_t; typedef struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_table_t; typedef struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_table_t; typedef struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_table_t; typedef struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_table_t; typedef struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_table_t; typedef struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_table_t; typedef struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_table_t; typedef struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_table_t; typedef struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_table_t; typedef struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_table_t; typedef struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_table_t; typedef struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_table_t; typedef struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_table_t; typedef struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_table_t; typedef struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_table_t; typedef struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_Null_file_identifier #define org_apache_arrow_flatbuf_Null_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Null_file_identifier */ #ifndef org_apache_arrow_flatbuf_Null_identifier #define org_apache_arrow_flatbuf_Null_identifier 0 #endif #define org_apache_arrow_flatbuf_Null_type_hash ((flatbuffers_thash_t)0x7b36a4dd) #define org_apache_arrow_flatbuf_Null_type_identifier "\xdd\xa4\x36\x7b" #ifndef org_apache_arrow_flatbuf_Null_file_extension #define org_apache_arrow_flatbuf_Null_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Struct__file_identifier #define org_apache_arrow_flatbuf_Struct__file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Struct__file_identifier */ #ifndef org_apache_arrow_flatbuf_Struct__identifier #define org_apache_arrow_flatbuf_Struct__identifier 0 #endif #define org_apache_arrow_flatbuf_Struct__type_hash ((flatbuffers_thash_t)0x6310f362) #define org_apache_arrow_flatbuf_Struct__type_identifier "\x62\xf3\x10\x63" #ifndef org_apache_arrow_flatbuf_Struct__file_extension #define org_apache_arrow_flatbuf_Struct__file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_List_file_identifier #define org_apache_arrow_flatbuf_List_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_List_file_identifier */ #ifndef org_apache_arrow_flatbuf_List_identifier #define org_apache_arrow_flatbuf_List_identifier 0 #endif #define org_apache_arrow_flatbuf_List_type_hash ((flatbuffers_thash_t)0xd4ce5878) #define org_apache_arrow_flatbuf_List_type_identifier "\x78\x58\xce\xd4" #ifndef org_apache_arrow_flatbuf_List_file_extension #define org_apache_arrow_flatbuf_List_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeList_file_identifier #define org_apache_arrow_flatbuf_LargeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeList_identifier #define org_apache_arrow_flatbuf_LargeList_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeList_type_hash ((flatbuffers_thash_t)0x38aa7e27) #define org_apache_arrow_flatbuf_LargeList_type_identifier "\x27\x7e\xaa\x38" #ifndef org_apache_arrow_flatbuf_LargeList_file_extension #define org_apache_arrow_flatbuf_LargeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_ListView_file_identifier #define org_apache_arrow_flatbuf_ListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_ListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_ListView_identifier #define org_apache_arrow_flatbuf_ListView_identifier 0 #endif #define org_apache_arrow_flatbuf_ListView_type_hash ((flatbuffers_thash_t)0x23d37919) #define org_apache_arrow_flatbuf_ListView_type_identifier "\x19\x79\xd3\x23" #ifndef org_apache_arrow_flatbuf_ListView_file_extension #define org_apache_arrow_flatbuf_ListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeListView_file_identifier #define org_apache_arrow_flatbuf_LargeListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeListView_identifier #define org_apache_arrow_flatbuf_LargeListView_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeListView_type_hash ((flatbuffers_thash_t)0x28efac02) #define org_apache_arrow_flatbuf_LargeListView_type_identifier "\x02\xac\xef\x28" #ifndef org_apache_arrow_flatbuf_LargeListView_file_extension #define org_apache_arrow_flatbuf_LargeListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_identifier #define org_apache_arrow_flatbuf_FixedSizeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeList_identifier #define org_apache_arrow_flatbuf_FixedSizeList_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeList_type_hash ((flatbuffers_thash_t)0xcef245bb) #define org_apache_arrow_flatbuf_FixedSizeList_type_identifier "\xbb\x45\xf2\xce" #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_extension #define org_apache_arrow_flatbuf_FixedSizeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Map_file_identifier #define org_apache_arrow_flatbuf_Map_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Map_file_identifier */ #ifndef org_apache_arrow_flatbuf_Map_identifier #define org_apache_arrow_flatbuf_Map_identifier 0 #endif #define org_apache_arrow_flatbuf_Map_type_hash ((flatbuffers_thash_t)0xcebef8e6) #define org_apache_arrow_flatbuf_Map_type_identifier "\xe6\xf8\xbe\xce" #ifndef org_apache_arrow_flatbuf_Map_file_extension #define org_apache_arrow_flatbuf_Map_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Union_file_identifier #define org_apache_arrow_flatbuf_Union_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Union_file_identifier */ #ifndef org_apache_arrow_flatbuf_Union_identifier #define org_apache_arrow_flatbuf_Union_identifier 0 #endif #define org_apache_arrow_flatbuf_Union_type_hash ((flatbuffers_thash_t)0x896bda57) #define org_apache_arrow_flatbuf_Union_type_identifier "\x57\xda\x6b\x89" #ifndef org_apache_arrow_flatbuf_Union_file_extension #define org_apache_arrow_flatbuf_Union_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Int_file_identifier #define org_apache_arrow_flatbuf_Int_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Int_file_identifier */ #ifndef org_apache_arrow_flatbuf_Int_identifier #define org_apache_arrow_flatbuf_Int_identifier 0 #endif #define org_apache_arrow_flatbuf_Int_type_hash ((flatbuffers_thash_t)0x30789001) #define org_apache_arrow_flatbuf_Int_type_identifier "\x01\x90\x78\x30" #ifndef org_apache_arrow_flatbuf_Int_file_extension #define org_apache_arrow_flatbuf_Int_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_identifier #define org_apache_arrow_flatbuf_FloatingPoint_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FloatingPoint_file_identifier */ #ifndef org_apache_arrow_flatbuf_FloatingPoint_identifier #define org_apache_arrow_flatbuf_FloatingPoint_identifier 0 #endif #define org_apache_arrow_flatbuf_FloatingPoint_type_hash ((flatbuffers_thash_t)0xf7d06268) #define org_apache_arrow_flatbuf_FloatingPoint_type_identifier "\x68\x62\xd0\xf7" #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_extension #define org_apache_arrow_flatbuf_FloatingPoint_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8_file_identifier #define org_apache_arrow_flatbuf_Utf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8_identifier #define org_apache_arrow_flatbuf_Utf8_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8_type_hash ((flatbuffers_thash_t)0x8fe60d37) #define org_apache_arrow_flatbuf_Utf8_type_identifier "\x37\x0d\xe6\x8f" #ifndef org_apache_arrow_flatbuf_Utf8_file_extension #define org_apache_arrow_flatbuf_Utf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Binary_file_identifier #define org_apache_arrow_flatbuf_Binary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Binary_file_identifier */ #ifndef org_apache_arrow_flatbuf_Binary_identifier #define org_apache_arrow_flatbuf_Binary_identifier 0 #endif #define org_apache_arrow_flatbuf_Binary_type_hash ((flatbuffers_thash_t)0x8e21a795) #define org_apache_arrow_flatbuf_Binary_type_identifier "\x95\xa7\x21\x8e" #ifndef org_apache_arrow_flatbuf_Binary_file_extension #define org_apache_arrow_flatbuf_Binary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_identifier #define org_apache_arrow_flatbuf_LargeUtf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeUtf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeUtf8_identifier #define org_apache_arrow_flatbuf_LargeUtf8_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeUtf8_type_hash ((flatbuffers_thash_t)0x24ed2fb0) #define org_apache_arrow_flatbuf_LargeUtf8_type_identifier "\xb0\x2f\xed\x24" #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_extension #define org_apache_arrow_flatbuf_LargeUtf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeBinary_file_identifier #define org_apache_arrow_flatbuf_LargeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeBinary_identifier #define org_apache_arrow_flatbuf_LargeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeBinary_type_hash ((flatbuffers_thash_t)0xbd437872) #define org_apache_arrow_flatbuf_LargeBinary_type_identifier "\x72\x78\x43\xbd" #ifndef org_apache_arrow_flatbuf_LargeBinary_file_extension #define org_apache_arrow_flatbuf_LargeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8View_file_identifier #define org_apache_arrow_flatbuf_Utf8View_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8View_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8View_identifier #define org_apache_arrow_flatbuf_Utf8View_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8View_type_hash ((flatbuffers_thash_t)0xab7692) #define org_apache_arrow_flatbuf_Utf8View_type_identifier "\x92\x76\xab\x00" #ifndef org_apache_arrow_flatbuf_Utf8View_file_extension #define org_apache_arrow_flatbuf_Utf8View_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_BinaryView_file_identifier #define org_apache_arrow_flatbuf_BinaryView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_BinaryView_file_identifier */ #ifndef org_apache_arrow_flatbuf_BinaryView_identifier #define org_apache_arrow_flatbuf_BinaryView_identifier 0 #endif #define org_apache_arrow_flatbuf_BinaryView_type_hash ((flatbuffers_thash_t)0x18c52428) #define org_apache_arrow_flatbuf_BinaryView_type_identifier "\x28\x24\xc5\x18" #ifndef org_apache_arrow_flatbuf_BinaryView_file_extension #define org_apache_arrow_flatbuf_BinaryView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeBinary_type_hash ((flatbuffers_thash_t)0x80d0f4ce) #define org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier "\xce\xf4\xd0\x80" #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_extension #define org_apache_arrow_flatbuf_FixedSizeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Bool_file_identifier #define org_apache_arrow_flatbuf_Bool_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Bool_file_identifier */ #ifndef org_apache_arrow_flatbuf_Bool_identifier #define org_apache_arrow_flatbuf_Bool_identifier 0 #endif #define org_apache_arrow_flatbuf_Bool_type_hash ((flatbuffers_thash_t)0x96bf83f0) #define org_apache_arrow_flatbuf_Bool_type_identifier "\xf0\x83\xbf\x96" #ifndef org_apache_arrow_flatbuf_Bool_file_extension #define org_apache_arrow_flatbuf_Bool_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_RunEndEncoded_file_identifier */ #ifndef org_apache_arrow_flatbuf_RunEndEncoded_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_identifier 0 #endif #define org_apache_arrow_flatbuf_RunEndEncoded_type_hash ((flatbuffers_thash_t)0x5a98bcc) #define org_apache_arrow_flatbuf_RunEndEncoded_type_identifier "\xcc\x8b\xa9\x05" #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_extension #define org_apache_arrow_flatbuf_RunEndEncoded_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Decimal_file_identifier #define org_apache_arrow_flatbuf_Decimal_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Decimal_file_identifier */ #ifndef org_apache_arrow_flatbuf_Decimal_identifier #define org_apache_arrow_flatbuf_Decimal_identifier 0 #endif #define org_apache_arrow_flatbuf_Decimal_type_hash ((flatbuffers_thash_t)0x91d1beb7) #define org_apache_arrow_flatbuf_Decimal_type_identifier "\xb7\xbe\xd1\x91" #ifndef org_apache_arrow_flatbuf_Decimal_file_extension #define org_apache_arrow_flatbuf_Decimal_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Date_file_identifier #define org_apache_arrow_flatbuf_Date_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Date_file_identifier */ #ifndef org_apache_arrow_flatbuf_Date_identifier #define org_apache_arrow_flatbuf_Date_identifier 0 #endif #define org_apache_arrow_flatbuf_Date_type_hash ((flatbuffers_thash_t)0xe0ccf624) #define org_apache_arrow_flatbuf_Date_type_identifier "\x24\xf6\xcc\xe0" #ifndef org_apache_arrow_flatbuf_Date_file_extension #define org_apache_arrow_flatbuf_Date_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Time_file_identifier #define org_apache_arrow_flatbuf_Time_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Time_file_identifier */ #ifndef org_apache_arrow_flatbuf_Time_identifier #define org_apache_arrow_flatbuf_Time_identifier 0 #endif #define org_apache_arrow_flatbuf_Time_type_hash ((flatbuffers_thash_t)0x2442a489) #define org_apache_arrow_flatbuf_Time_type_identifier "\x89\xa4\x42\x24" #ifndef org_apache_arrow_flatbuf_Time_file_extension #define org_apache_arrow_flatbuf_Time_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Timestamp_file_identifier #define org_apache_arrow_flatbuf_Timestamp_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Timestamp_file_identifier */ #ifndef org_apache_arrow_flatbuf_Timestamp_identifier #define org_apache_arrow_flatbuf_Timestamp_identifier 0 #endif #define org_apache_arrow_flatbuf_Timestamp_type_hash ((flatbuffers_thash_t)0x1fddf080) #define org_apache_arrow_flatbuf_Timestamp_type_identifier "\x80\xf0\xdd\x1f" #ifndef org_apache_arrow_flatbuf_Timestamp_file_extension #define org_apache_arrow_flatbuf_Timestamp_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Interval_file_identifier #define org_apache_arrow_flatbuf_Interval_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Interval_file_identifier */ #ifndef org_apache_arrow_flatbuf_Interval_identifier #define org_apache_arrow_flatbuf_Interval_identifier 0 #endif #define org_apache_arrow_flatbuf_Interval_type_hash ((flatbuffers_thash_t)0x1e2d6809) #define org_apache_arrow_flatbuf_Interval_type_identifier "\x09\x68\x2d\x1e" #ifndef org_apache_arrow_flatbuf_Interval_file_extension #define org_apache_arrow_flatbuf_Interval_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Duration_file_identifier #define org_apache_arrow_flatbuf_Duration_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Duration_file_identifier */ #ifndef org_apache_arrow_flatbuf_Duration_identifier #define org_apache_arrow_flatbuf_Duration_identifier 0 #endif #define org_apache_arrow_flatbuf_Duration_type_hash ((flatbuffers_thash_t)0x1ecea6b0) #define org_apache_arrow_flatbuf_Duration_type_identifier "\xb0\xa6\xce\x1e" #ifndef org_apache_arrow_flatbuf_Duration_file_extension #define org_apache_arrow_flatbuf_Duration_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_KeyValue_file_identifier #define org_apache_arrow_flatbuf_KeyValue_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_KeyValue_file_identifier */ #ifndef org_apache_arrow_flatbuf_KeyValue_identifier #define org_apache_arrow_flatbuf_KeyValue_identifier 0 #endif #define org_apache_arrow_flatbuf_KeyValue_type_hash ((flatbuffers_thash_t)0x3b264744) #define org_apache_arrow_flatbuf_KeyValue_type_identifier "\x44\x47\x26\x3b" #ifndef org_apache_arrow_flatbuf_KeyValue_file_extension #define org_apache_arrow_flatbuf_KeyValue_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier */ #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_identifier 0 #endif #define org_apache_arrow_flatbuf_DictionaryEncoding_type_hash ((flatbuffers_thash_t)0x8c703261) #define org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier "\x61\x32\x70\x8c" #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_extension #define org_apache_arrow_flatbuf_DictionaryEncoding_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Field_file_identifier #define org_apache_arrow_flatbuf_Field_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Field_file_identifier */ #ifndef org_apache_arrow_flatbuf_Field_identifier #define org_apache_arrow_flatbuf_Field_identifier 0 #endif #define org_apache_arrow_flatbuf_Field_type_hash ((flatbuffers_thash_t)0xd981525c) #define org_apache_arrow_flatbuf_Field_type_identifier "\x5c\x52\x81\xd9" #ifndef org_apache_arrow_flatbuf_Field_file_extension #define org_apache_arrow_flatbuf_Field_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Buffer_file_identifier #define org_apache_arrow_flatbuf_Buffer_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Buffer_file_identifier */ #ifndef org_apache_arrow_flatbuf_Buffer_identifier #define org_apache_arrow_flatbuf_Buffer_identifier 0 #endif #define org_apache_arrow_flatbuf_Buffer_type_hash ((flatbuffers_thash_t)0x519d7fea) #define org_apache_arrow_flatbuf_Buffer_type_identifier "\xea\x7f\x9d\x51" #ifndef org_apache_arrow_flatbuf_Buffer_file_extension #define org_apache_arrow_flatbuf_Buffer_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Schema_file_identifier #define org_apache_arrow_flatbuf_Schema_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Schema_file_identifier */ #ifndef org_apache_arrow_flatbuf_Schema_identifier #define org_apache_arrow_flatbuf_Schema_identifier 0 #endif #define org_apache_arrow_flatbuf_Schema_type_hash ((flatbuffers_thash_t)0x406570b) #define org_apache_arrow_flatbuf_Schema_type_identifier "\x0b\x57\x06\x04" #ifndef org_apache_arrow_flatbuf_Schema_file_extension #define org_apache_arrow_flatbuf_Schema_file_extension "bin" #endif typedef int16_t org_apache_arrow_flatbuf_MetadataVersion_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, 16) /** 0.1.0 (October 2016). */ #define org_apache_arrow_flatbuf_MetadataVersion_V1 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_MetadataVersion_V2 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_MetadataVersion_V3 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_MetadataVersion_V4 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(3)) #define org_apache_arrow_flatbuf_MetadataVersion_V5 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(4)) static inline const char *org_apache_arrow_flatbuf_MetadataVersion_name(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return "V1"; case org_apache_arrow_flatbuf_MetadataVersion_V2: return "V2"; case org_apache_arrow_flatbuf_MetadataVersion_V3: return "V3"; case org_apache_arrow_flatbuf_MetadataVersion_V4: return "V4"; case org_apache_arrow_flatbuf_MetadataVersion_V5: return "V5"; default: return ""; } } static inline int org_apache_arrow_flatbuf_MetadataVersion_is_known_value(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V2: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V3: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V4: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V5: return 1; default: return 0; } } /** Represents Arrow Features that might not have full support * within implementations. This is intended to be used in * two scenarios: * 1. A mechanism for readers of Arrow Streams * and files to understand that the stream or file makes * use of a feature that isn't supported or unknown to * the implementation (and therefore can meet the Arrow * forward compatibility guarantees). * 2. A means of negotiating between a client and server * what features a stream is allowed to use. The enums * values here are intented to represent higher level * features, additional details maybe negotiated * with key-value pairs specific to the protocol. * * Enums added to this list should be assigned power-of-two values * to facilitate exchanging and comparing bitmaps for supported * features. */ typedef int64_t org_apache_arrow_flatbuf_Feature_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, 64) /** Needed to make flatbuffers happy. */ #define org_apache_arrow_flatbuf_Feature_UNUSED ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(0)) #define org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(1)) #define org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(2)) static inline const char *org_apache_arrow_flatbuf_Feature_name(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return "UNUSED"; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return "DICTIONARY_REPLACEMENT"; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return "COMPRESSED_BODY"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Feature_is_known_value(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return 1; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return 1; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_UnionMode_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 16) #define org_apache_arrow_flatbuf_UnionMode_Sparse ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_UnionMode_Dense ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_UnionMode_name(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return "Sparse"; case org_apache_arrow_flatbuf_UnionMode_Dense: return "Dense"; default: return ""; } } static inline int org_apache_arrow_flatbuf_UnionMode_is_known_value(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return 1; case org_apache_arrow_flatbuf_UnionMode_Dense: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_Precision_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 16) #define org_apache_arrow_flatbuf_Precision_HALF ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Precision_SINGLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_Precision_DOUBLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_Precision_name(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return "HALF"; case org_apache_arrow_flatbuf_Precision_SINGLE: return "SINGLE"; case org_apache_arrow_flatbuf_Precision_DOUBLE: return "DOUBLE"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Precision_is_known_value(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return 1; case org_apache_arrow_flatbuf_Precision_SINGLE: return 1; case org_apache_arrow_flatbuf_Precision_DOUBLE: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_DateUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 16) #define org_apache_arrow_flatbuf_DateUnit_DAY ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_DateUnit_MILLISECOND ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_DateUnit_name(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return "DAY"; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return "MILLISECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DateUnit_is_known_value(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return 1; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_TimeUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 16) #define org_apache_arrow_flatbuf_TimeUnit_SECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_TimeUnit_MILLISECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_TimeUnit_MICROSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_TimeUnit_NANOSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(3)) static inline const char *org_apache_arrow_flatbuf_TimeUnit_name(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return "SECOND"; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return "MILLISECOND"; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return "MICROSECOND"; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return "NANOSECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_TimeUnit_is_known_value(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_IntervalUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 16) #define org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_IntervalUnit_name(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return "YEAR_MONTH"; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return "DAY_TIME"; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return "MONTH_DAY_NANO"; default: return ""; } } static inline int org_apache_arrow_flatbuf_IntervalUnit_is_known_value(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return 1; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return 1; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Dictionary encoding metadata * Maintained for forwards compatibility, in the future * Dictionaries might be explicit maps between integers and values * allowing for non-contiguous index values */ typedef int16_t org_apache_arrow_flatbuf_DictionaryKind_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 16) #define org_apache_arrow_flatbuf_DictionaryKind_DenseArray ((org_apache_arrow_flatbuf_DictionaryKind_enum_t)INT16_C(0)) static inline const char *org_apache_arrow_flatbuf_DictionaryKind_name(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return "DenseArray"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DictionaryKind_is_known_value(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Endianness of the platform producing the data */ typedef int16_t org_apache_arrow_flatbuf_Endianness_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 16) #define org_apache_arrow_flatbuf_Endianness_Little ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Endianness_Big ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_Endianness_name(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return "Little"; case org_apache_arrow_flatbuf_Endianness_Big: return "Big"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Endianness_is_known_value(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return 1; case org_apache_arrow_flatbuf_Endianness_Big: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * A Buffer represents a single contiguous memory segment */ struct org_apache_arrow_flatbuf_Buffer { /** The relative offset into the shared memory page where the bytes for this * buffer starts */ alignas(8) int64_t offset; /** The absolute length (in bytes) of the memory buffer. The memory is found * from offset (inclusive) to offset + length (non-inclusive). When building * messages using the encapsulated IPC message, padding bytes may be written * after a buffer, but such padding bytes do not need to be accounted for in * the size here. */ alignas(8) int64_t length; }; static_assert(sizeof(org_apache_arrow_flatbuf_Buffer_t) == 16, "struct size mismatch"); static inline const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__const_ptr_add(const org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__ptr_add(org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_struct_t org_apache_arrow_flatbuf_Buffer_vec_at(org_apache_arrow_flatbuf_Buffer_vec_t vec, size_t i) __flatbuffers_struct_vec_at(vec, i) static inline size_t org_apache_arrow_flatbuf_Buffer__size(void) { return 16; } static inline size_t org_apache_arrow_flatbuf_Buffer_vec_len(org_apache_arrow_flatbuf_Buffer_vec_t vec) __flatbuffers_vec_len(vec) __flatbuffers_struct_as_root(org_apache_arrow_flatbuf_Buffer) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, offset, flatbuffers_int64, int64_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, length, flatbuffers_int64, int64_t) /** These are stored in the flatbuffer in the Type union below */ struct org_apache_arrow_flatbuf_Null_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Null_vec_len(org_apache_arrow_flatbuf_Null_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Null_table_t org_apache_arrow_flatbuf_Null_vec_at(org_apache_arrow_flatbuf_Null_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Null_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Null) /** A Struct_ in the flatbuffer metadata is the same as an Arrow Struct * (according to the physical memory layout). We used Struct_ here as * Struct is a reserved word in Flatbuffers */ struct org_apache_arrow_flatbuf_Struct__table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Struct__vec_len(org_apache_arrow_flatbuf_Struct__vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Struct__table_t org_apache_arrow_flatbuf_Struct__vec_at(org_apache_arrow_flatbuf_Struct__vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Struct__table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Struct_) struct org_apache_arrow_flatbuf_List_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_List_vec_len(org_apache_arrow_flatbuf_List_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_List_table_t org_apache_arrow_flatbuf_List_vec_at(org_apache_arrow_flatbuf_List_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_List_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_List) /** Same as List, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeList_vec_len(org_apache_arrow_flatbuf_LargeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeList_table_t org_apache_arrow_flatbuf_LargeList_vec_at(org_apache_arrow_flatbuf_LargeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeList) /** Represents the same logical types that List can, but contains offsets and * sizes allowing for writes in any order and sharing of child values among * list values. */ struct org_apache_arrow_flatbuf_ListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_ListView_vec_len(org_apache_arrow_flatbuf_ListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_ListView_table_t org_apache_arrow_flatbuf_ListView_vec_at(org_apache_arrow_flatbuf_ListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_ListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_ListView) /** Same as ListView, but with 64-bit offsets and sizes, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeListView_vec_len(org_apache_arrow_flatbuf_LargeListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeListView_table_t org_apache_arrow_flatbuf_LargeListView_vec_at(org_apache_arrow_flatbuf_LargeListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeListView) struct org_apache_arrow_flatbuf_FixedSizeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeList_vec_len(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeList_table_t org_apache_arrow_flatbuf_FixedSizeList_vec_at(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeList) /** Number of list items per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeList, listSize, flatbuffers_int32, int32_t, INT32_C(0)) /** A Map is a logical nested type that is represented as * * List> * * In this layout, the keys and values are each respectively contiguous. We do * not constrain the key and value types, so the application is responsible * for ensuring that the keys are hashable and unique. Whether the keys are sorted * may be set in the metadata for this field. * * In a field with Map type, the field has a child Struct field, which then * has two children: key type and the second the value type. The names of the * child fields may be respectively "entries", "key", and "value", but this is * not enforced. * * Map * ```text * - child[0] entries: Struct * - child[0] key: K * - child[1] value: V * ``` * Neither the "entries" field nor the "key" field may be nullable. * * The metadata is structured so that Arrow systems without special handling * for Map can make Map an alias for List. The "layout" attribute for the Map * field must have the same contents as a List. */ struct org_apache_arrow_flatbuf_Map_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Map_vec_len(org_apache_arrow_flatbuf_Map_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Map_table_t org_apache_arrow_flatbuf_Map_vec_at(org_apache_arrow_flatbuf_Map_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Map_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Map) /** Set to true if the keys within each value are sorted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Map, keysSorted, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** A union is a complex type with children in Field * By default ids in the type vector refer to the offsets in the children * optionally typeIds provides an indirection between the child offset and the type id * for each child `typeIds[offset]` is the id used in the type vector */ struct org_apache_arrow_flatbuf_Union_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Union_vec_len(org_apache_arrow_flatbuf_Union_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Union_table_t org_apache_arrow_flatbuf_Union_vec_at(org_apache_arrow_flatbuf_Union_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Union_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Union) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Union, mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Union, typeIds, flatbuffers_int32_vec_t, 0) struct org_apache_arrow_flatbuf_Int_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Int_vec_len(org_apache_arrow_flatbuf_Int_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Int_table_t org_apache_arrow_flatbuf_Int_vec_at(org_apache_arrow_flatbuf_Int_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Int_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Int) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Int, bitWidth, flatbuffers_int32, int32_t, INT32_C(0)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Int, is_signed, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) struct org_apache_arrow_flatbuf_FloatingPoint_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FloatingPoint_vec_len(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FloatingPoint_table_t org_apache_arrow_flatbuf_FloatingPoint_vec_at(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FloatingPoint_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FloatingPoint, precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, INT16_C(0)) /** Unicode with UTF-8 encoding */ struct org_apache_arrow_flatbuf_Utf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8_vec_len(org_apache_arrow_flatbuf_Utf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8_table_t org_apache_arrow_flatbuf_Utf8_vec_at(org_apache_arrow_flatbuf_Utf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8) /** Opaque binary data */ struct org_apache_arrow_flatbuf_Binary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Binary_vec_len(org_apache_arrow_flatbuf_Binary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Binary_table_t org_apache_arrow_flatbuf_Binary_vec_at(org_apache_arrow_flatbuf_Binary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Binary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Binary) /** Same as Utf8, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeUtf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeUtf8_vec_len(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeUtf8_table_t org_apache_arrow_flatbuf_LargeUtf8_vec_at(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeUtf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeUtf8) /** Same as Binary, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeBinary_vec_len(org_apache_arrow_flatbuf_LargeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeBinary_table_t org_apache_arrow_flatbuf_LargeBinary_vec_at(org_apache_arrow_flatbuf_LargeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeBinary) /** Logically the same as Utf8, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_Utf8View_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8View_vec_len(org_apache_arrow_flatbuf_Utf8View_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8View_table_t org_apache_arrow_flatbuf_Utf8View_vec_at(org_apache_arrow_flatbuf_Utf8View_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8View_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8View) /** Logically the same as Binary, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_BinaryView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_BinaryView_vec_len(org_apache_arrow_flatbuf_BinaryView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_BinaryView_table_t org_apache_arrow_flatbuf_BinaryView_vec_at(org_apache_arrow_flatbuf_BinaryView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_BinaryView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_BinaryView) struct org_apache_arrow_flatbuf_FixedSizeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_len(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeBinary_table_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeBinary) /** Number of bytes per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeBinary, byteWidth, flatbuffers_int32, int32_t, INT32_C(0)) struct org_apache_arrow_flatbuf_Bool_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Bool_vec_len(org_apache_arrow_flatbuf_Bool_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Bool_table_t org_apache_arrow_flatbuf_Bool_vec_at(org_apache_arrow_flatbuf_Bool_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Bool_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Bool) /** Contains two child arrays, run_ends and values. * The run_ends child array must be a 16/32/64-bit integer array * which encodes the indices at which the run with the value in * each corresponding index in the values child array ends. * Like list/struct types, the value array can be of any type. */ struct org_apache_arrow_flatbuf_RunEndEncoded_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_RunEndEncoded_vec_len(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_RunEndEncoded_table_t org_apache_arrow_flatbuf_RunEndEncoded_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_RunEndEncoded) /** Exact decimal value represented as an integer value in two's * complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers * are used. The representation uses the endianness indicated * in the Schema. */ struct org_apache_arrow_flatbuf_Decimal_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Decimal_vec_len(org_apache_arrow_flatbuf_Decimal_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Decimal_table_t org_apache_arrow_flatbuf_Decimal_vec_at(org_apache_arrow_flatbuf_Decimal_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Decimal_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Decimal) /** Total number of decimal digits */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Decimal, precision, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of digits after the decimal point "." */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Decimal, scale, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of bits per value. The only accepted widths are 128 and 256. * We use bitWidth for consistency with Int::bitWidth. */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_Decimal, bitWidth, flatbuffers_int32, int32_t, INT32_C(128)) /** Date is either a 32-bit or 64-bit signed integer type representing an * elapsed time since UNIX epoch (1970-01-01), stored in either of two units: * * * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no * leap seconds), where the values are evenly divisible by 86400000 * * Days (32 bits) since the UNIX epoch */ struct org_apache_arrow_flatbuf_Date_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Date_vec_len(org_apache_arrow_flatbuf_Date_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Date_table_t org_apache_arrow_flatbuf_Date_vec_at(org_apache_arrow_flatbuf_Date_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Date_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Date) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Date, unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, INT16_C(1)) /** Time is either a 32-bit or 64-bit signed integer type representing an * elapsed time since midnight, stored in either of four units: seconds, * milliseconds, microseconds or nanoseconds. * * The integer `bitWidth` depends on the `unit` and must be one of the following: * * SECOND and MILLISECOND: 32 bits * * MICROSECOND and NANOSECOND: 64 bits * * The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds * (exclusive), adjusted for the time unit (for example, up to 86400000 * exclusive for the MILLISECOND unit). * This definition doesn't allow for leap seconds. Time values from * measurements with leap seconds will need to be corrected when ingesting * into Arrow (for example by replacing the value 86400 with 86399). */ struct org_apache_arrow_flatbuf_Time_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Time_vec_len(org_apache_arrow_flatbuf_Time_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Time_table_t org_apache_arrow_flatbuf_Time_vec_at(org_apache_arrow_flatbuf_Time_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Time_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Time) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Time, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Time, bitWidth, flatbuffers_int32, int32_t, INT32_C(32)) /** Timestamp is a 64-bit signed integer representing an elapsed time since a * fixed epoch, stored in either of four units: seconds, milliseconds, * microseconds or nanoseconds, and is optionally annotated with a timezone. * * Timestamp values do not include any leap seconds (in other words, all * days are considered 86400 seconds long). * * Timestamps with a non-empty timezone * ------------------------------------ * * If a Timestamp column has a non-empty timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone * (the Unix epoch), regardless of the Timestamp's own timezone. * * Therefore, timestamp values with a non-empty timezone correspond to * physical points in time together with some additional information about * how the data was obtained and/or how to display it (the timezone). * * For example, the timestamp value 0 with the timezone string "Europe/Paris" * corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the * application may prefer to display it as "January 1st 1970, 01h00" in * the Europe/Paris timezone (which is the same physical point in time). * * One consequence is that timestamp values with a non-empty timezone * can be compared and ordered directly, since they all share the same * well-known point of reference (the Unix epoch). * * Timestamps with an unset / empty timezone * ----------------------------------------- * * If a Timestamp column has no timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone. * * Therefore, timestamp values without a timezone cannot be meaningfully * interpreted as physical points in time, but only as calendar / clock * indications ("wall clock time") in an unspecified timezone. * * For example, the timestamp value 0 with an empty timezone string * corresponds to "January 1st 1970, 00h00" in an unknown timezone: there * is not enough information to interpret it as a well-defined physical * point in time. * * One consequence is that timestamp values without a timezone cannot * be reliably compared or ordered, since they may have different points of * reference. In particular, it is *not* possible to interpret an unset * or empty timezone as the same as "UTC". * * Conversion between timezones * ---------------------------- * * If a Timestamp column has a non-empty timezone, changing the timezone * to a different non-empty value is a metadata-only operation: * the timestamp values need not change as their point of reference remains * the same (the Unix epoch). * * However, if a Timestamp column has no timezone value, changing it to a * non-empty value requires to think about the desired semantics. * One possibility is to assume that the original timestamp values are * relative to the epoch of the timezone being set; timestamp values should * then adjusted to the Unix epoch (for example, changing the timezone from * empty to "Europe/Paris" would require converting the timestamp values * from "Europe/Paris" to "UTC", which seems counter-intuitive but is * nevertheless correct). * * Guidelines for encoding data from external libraries * ---------------------------------------------------- * * Date & time libraries often have multiple different data types for temporal * data. In order to ease interoperability between different implementations the * Arrow project has some recommendations for encoding these types into a Timestamp * column. * * An "instant" represents a physical point in time that has no relevant timezone * (for example, astronomical data). To encode an instant, use a Timestamp with * the timezone string set to "UTC", and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * A "zoned date-time" represents a physical point in time annotated with an * informative timezone (for example, the timezone in which the data was * recorded). To encode a zoned date-time, use a Timestamp with the timezone * string set to the name of the timezone, and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * (There is some ambiguity between an instant and a zoned date-time with the * UTC timezone. Both of these are stored the same in Arrow. Typically, * this distinction does not matter. If it does, then an application should * use custom metadata or an extension type to distinguish between the two cases.) * * An "offset date-time" represents a physical point in time combined with an * explicit offset from UTC. To encode an offset date-time, use a Timestamp * with the timezone string set to the numeric timezone offset string * (e.g. "+03:00"), and make sure the Timestamp values are relative to * the UTC epoch (January 1st 1970, midnight). * * A "naive date-time" (also called "local date-time" in some libraries) * represents a wall clock time combined with a calendar date, but with * no indication of how to map this information to a physical point in time. * Naive date-times must be handled with care because of this missing * information, and also because daylight saving time (DST) may make * some values ambiguous or nonexistent. A naive date-time may be * stored as a struct with Date and Time fields. However, it may also be * encoded into a Timestamp column with an empty timezone. The timestamp * values should be computed "as if" the timezone of the date-time values * was UTC; for example, the naive date-time "January 1st 1970, 00h00" would * be encoded as timestamp value 0. */ struct org_apache_arrow_flatbuf_Timestamp_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Timestamp_vec_len(org_apache_arrow_flatbuf_Timestamp_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Timestamp_table_t org_apache_arrow_flatbuf_Timestamp_vec_at(org_apache_arrow_flatbuf_Timestamp_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Timestamp_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Timestamp) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Timestamp, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(0)) /** The timezone is an optional string indicating the name of a timezone, * one of: * * * As used in the Olson timezone database (the "tz database" or * "tzdata"), such as "America/New_York". * * An absolute timezone offset of the form "+XX:XX" or "-XX:XX", * such as "+07:30". * * Whether a timezone string is present indicates different semantics about * the data (see above). */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_Timestamp, timezone, 0) struct org_apache_arrow_flatbuf_Interval_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Interval_vec_len(org_apache_arrow_flatbuf_Interval_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Interval_table_t org_apache_arrow_flatbuf_Interval_vec_at(org_apache_arrow_flatbuf_Interval_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Interval_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Interval) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Interval, unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, INT16_C(0)) struct org_apache_arrow_flatbuf_Duration_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Duration_vec_len(org_apache_arrow_flatbuf_Duration_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Duration_table_t org_apache_arrow_flatbuf_Duration_vec_at(org_apache_arrow_flatbuf_Duration_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Duration_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Duration) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Duration, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) /** ---------------------------------------------------------------------- * Top-level Type value, enabling extensible type-specific metadata. We can * add new logical types to Type without breaking backwards compatibility */ typedef uint8_t org_apache_arrow_flatbuf_Type_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Type_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_Type) /** ---------------------------------------------------------------------- * user defined key value pairs to add custom metadata to arrow * key namespacing is the responsibility of the user */ #define org_apache_arrow_flatbuf_Type_NONE ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_Type_Null ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_Type_Int ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_Type_FloatingPoint ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(3)) #define org_apache_arrow_flatbuf_Type_Binary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(4)) #define org_apache_arrow_flatbuf_Type_Utf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(5)) #define org_apache_arrow_flatbuf_Type_Bool ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(6)) #define org_apache_arrow_flatbuf_Type_Decimal ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(7)) #define org_apache_arrow_flatbuf_Type_Date ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(8)) #define org_apache_arrow_flatbuf_Type_Time ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(9)) #define org_apache_arrow_flatbuf_Type_Timestamp ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(10)) #define org_apache_arrow_flatbuf_Type_Interval ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(11)) #define org_apache_arrow_flatbuf_Type_List ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(12)) #define org_apache_arrow_flatbuf_Type_Struct_ ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(13)) #define org_apache_arrow_flatbuf_Type_Union ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(14)) #define org_apache_arrow_flatbuf_Type_FixedSizeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(15)) #define org_apache_arrow_flatbuf_Type_FixedSizeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(16)) #define org_apache_arrow_flatbuf_Type_Map ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(17)) #define org_apache_arrow_flatbuf_Type_Duration ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(18)) #define org_apache_arrow_flatbuf_Type_LargeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(19)) #define org_apache_arrow_flatbuf_Type_LargeUtf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(20)) #define org_apache_arrow_flatbuf_Type_LargeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(21)) #define org_apache_arrow_flatbuf_Type_RunEndEncoded ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(22)) #define org_apache_arrow_flatbuf_Type_BinaryView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(23)) #define org_apache_arrow_flatbuf_Type_Utf8View ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(24)) #define org_apache_arrow_flatbuf_Type_ListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(25)) #define org_apache_arrow_flatbuf_Type_LargeListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(26)) static inline const char *org_apache_arrow_flatbuf_Type_type_name(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return "NONE"; case org_apache_arrow_flatbuf_Type_Null: return "Null"; case org_apache_arrow_flatbuf_Type_Int: return "Int"; case org_apache_arrow_flatbuf_Type_FloatingPoint: return "FloatingPoint"; case org_apache_arrow_flatbuf_Type_Binary: return "Binary"; case org_apache_arrow_flatbuf_Type_Utf8: return "Utf8"; case org_apache_arrow_flatbuf_Type_Bool: return "Bool"; case org_apache_arrow_flatbuf_Type_Decimal: return "Decimal"; case org_apache_arrow_flatbuf_Type_Date: return "Date"; case org_apache_arrow_flatbuf_Type_Time: return "Time"; case org_apache_arrow_flatbuf_Type_Timestamp: return "Timestamp"; case org_apache_arrow_flatbuf_Type_Interval: return "Interval"; case org_apache_arrow_flatbuf_Type_List: return "List"; case org_apache_arrow_flatbuf_Type_Struct_: return "Struct_"; case org_apache_arrow_flatbuf_Type_Union: return "Union"; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return "FixedSizeBinary"; case org_apache_arrow_flatbuf_Type_FixedSizeList: return "FixedSizeList"; case org_apache_arrow_flatbuf_Type_Map: return "Map"; case org_apache_arrow_flatbuf_Type_Duration: return "Duration"; case org_apache_arrow_flatbuf_Type_LargeBinary: return "LargeBinary"; case org_apache_arrow_flatbuf_Type_LargeUtf8: return "LargeUtf8"; case org_apache_arrow_flatbuf_Type_LargeList: return "LargeList"; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return "RunEndEncoded"; case org_apache_arrow_flatbuf_Type_BinaryView: return "BinaryView"; case org_apache_arrow_flatbuf_Type_Utf8View: return "Utf8View"; case org_apache_arrow_flatbuf_Type_ListView: return "ListView"; case org_apache_arrow_flatbuf_Type_LargeListView: return "LargeListView"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Type_is_known_type(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return 1; case org_apache_arrow_flatbuf_Type_Null: return 1; case org_apache_arrow_flatbuf_Type_Int: return 1; case org_apache_arrow_flatbuf_Type_FloatingPoint: return 1; case org_apache_arrow_flatbuf_Type_Binary: return 1; case org_apache_arrow_flatbuf_Type_Utf8: return 1; case org_apache_arrow_flatbuf_Type_Bool: return 1; case org_apache_arrow_flatbuf_Type_Decimal: return 1; case org_apache_arrow_flatbuf_Type_Date: return 1; case org_apache_arrow_flatbuf_Type_Time: return 1; case org_apache_arrow_flatbuf_Type_Timestamp: return 1; case org_apache_arrow_flatbuf_Type_Interval: return 1; case org_apache_arrow_flatbuf_Type_List: return 1; case org_apache_arrow_flatbuf_Type_Struct_: return 1; case org_apache_arrow_flatbuf_Type_Union: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeList: return 1; case org_apache_arrow_flatbuf_Type_Map: return 1; case org_apache_arrow_flatbuf_Type_Duration: return 1; case org_apache_arrow_flatbuf_Type_LargeBinary: return 1; case org_apache_arrow_flatbuf_Type_LargeUtf8: return 1; case org_apache_arrow_flatbuf_Type_LargeList: return 1; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return 1; case org_apache_arrow_flatbuf_Type_BinaryView: return 1; case org_apache_arrow_flatbuf_Type_Utf8View: return 1; case org_apache_arrow_flatbuf_Type_ListView: return 1; case org_apache_arrow_flatbuf_Type_LargeListView: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_KeyValue_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_KeyValue_vec_len(org_apache_arrow_flatbuf_KeyValue_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_KeyValue_table_t org_apache_arrow_flatbuf_KeyValue_vec_at(org_apache_arrow_flatbuf_KeyValue_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_KeyValue_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_KeyValue) __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_KeyValue, key, 0) __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_KeyValue, value, 0) struct org_apache_arrow_flatbuf_DictionaryEncoding_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_len(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_DictionaryEncoding_table_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_DictionaryEncoding) /** The known dictionary id in the application where this data is used. In * the file or streaming formats, the dictionary ids are found in the * DictionaryBatch messages */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_DictionaryEncoding, id, flatbuffers_int64, int64_t, INT64_C(0)) /** The dictionary indices are constrained to be non-negative integers. If * this field is null, the indices must be signed int32. To maximize * cross-language compatibility and performance, implementations are * recommended to prefer signed integer types over unsigned integer types * and to avoid uint64 indices unless they are required by an application. */ __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_DictionaryEncoding, indexType, org_apache_arrow_flatbuf_Int_table_t, 0) /** By default, dictionaries are not ordered, or the order does not have * semantic meaning. In some statistical, applications, dictionary-encoding * is used to represent ordered categorical data, and we provide a way to * preserve that metadata here */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_DictionaryEncoding, isOrdered, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_DictionaryEncoding, dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, INT16_C(0)) /** ---------------------------------------------------------------------- * A field represents a named column in a record / row batch or child of a * nested type. */ struct org_apache_arrow_flatbuf_Field_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Field_vec_len(org_apache_arrow_flatbuf_Field_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Field_table_t org_apache_arrow_flatbuf_Field_vec_at(org_apache_arrow_flatbuf_Field_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Field_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Field) /** Name is not required, in i.e. a List */ __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_Field, name, 0) /** Whether or not this field can contain nulls. Should be true in general. */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Field, nullable, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** This is the type of the decoded value if the field is dictionary encoded. */ __flatbuffers_define_union_field(flatbuffers_, 3, org_apache_arrow_flatbuf_Field, type, org_apache_arrow_flatbuf_Type, 0) /** Present only if the field is dictionary encoded. */ __flatbuffers_define_table_field(4, org_apache_arrow_flatbuf_Field, dictionary, org_apache_arrow_flatbuf_DictionaryEncoding_table_t, 0) /** children apply only to nested data types like Struct, List and Union. For * primitive types children will have length 0. */ __flatbuffers_define_vector_field(5, org_apache_arrow_flatbuf_Field, children, org_apache_arrow_flatbuf_Field_vec_t, 0) /** User-defined metadata */ __flatbuffers_define_vector_field(6, org_apache_arrow_flatbuf_Field, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** ---------------------------------------------------------------------- * A Schema describes the columns in a row batch */ struct org_apache_arrow_flatbuf_Schema_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Schema_vec_len(org_apache_arrow_flatbuf_Schema_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Schema_table_t org_apache_arrow_flatbuf_Schema_vec_at(org_apache_arrow_flatbuf_Schema_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Schema_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Schema) /** endianness of the buffer * it is Little Endian by default * if endianness doesn't match the underlying system then the vectors need to be converted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Schema, endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Schema, fields, org_apache_arrow_flatbuf_Field_vec_t, 0) __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Schema, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** Features used in the stream/file. */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Schema, features, org_apache_arrow_flatbuf_Feature_vec_t, 0) #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_READER_H */ #ifndef SCHEMA_BUILDER_H #define SCHEMA_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_MetadataVersion_formal_args , org_apache_arrow_flatbuf_MetadataVersion_enum_t v0 #define __org_apache_arrow_flatbuf_MetadataVersion_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t) #define __org_apache_arrow_flatbuf_Feature_formal_args , org_apache_arrow_flatbuf_Feature_enum_t v0 #define __org_apache_arrow_flatbuf_Feature_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t) #define __org_apache_arrow_flatbuf_UnionMode_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0 #define __org_apache_arrow_flatbuf_UnionMode_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t) #define __org_apache_arrow_flatbuf_Precision_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_Precision_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t) #define __org_apache_arrow_flatbuf_DateUnit_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_DateUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t) #define __org_apache_arrow_flatbuf_TimeUnit_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_TimeUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t) #define __org_apache_arrow_flatbuf_IntervalUnit_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_IntervalUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t) #define __org_apache_arrow_flatbuf_DictionaryKind_formal_args , org_apache_arrow_flatbuf_DictionaryKind_enum_t v0 #define __org_apache_arrow_flatbuf_DictionaryKind_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t) #define __org_apache_arrow_flatbuf_Endianness_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0 #define __org_apache_arrow_flatbuf_Endianness_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t) #define __org_apache_arrow_flatbuf_Buffer_formal_args , int64_t v0, int64_t v1 #define __org_apache_arrow_flatbuf_Buffer_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { p->offset = v0; p->length = v1; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { p->offset = p2->offset; p->length = p2->length; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_to_pe(&p->offset, v0); flatbuffers_int64_assign_to_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_to_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_to_pe(&p->length, &p2->length); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_from_pe(&p->offset, v0); flatbuffers_int64_assign_from_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_from_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_from_pe(&p->length, &p2->length); return p; } __flatbuffers_build_struct(flatbuffers_, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Buffer_file_identifier, org_apache_arrow_flatbuf_Buffer_type_identifier) __flatbuffers_define_fixed_array_primitives(flatbuffers_, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_Type_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_Type_union_vec_ref_t; static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Null_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Null_ref_t; static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Null, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Struct__required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Struct__ref_t; static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Struct_, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_List_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_List_ref_t; static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_List, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeList_ref_t; static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeList, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_ListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_ListView_ref_t; static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_ListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeListView_ref_t; static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeList_ref_t; static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Map_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Map_ref_t; static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Map, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Union_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Union_ref_t; static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Union, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Int_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Int_ref_t; static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Int, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FloatingPoint_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FloatingPoint_ref_t; static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8_ref_t; static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Binary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Binary_ref_t; static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Binary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeUtf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeUtf8_ref_t; static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeBinary_ref_t; static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8View_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8View_ref_t; static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_BinaryView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_BinaryView_ref_t; static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_ref_t; static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Bool_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Bool_ref_t; static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Bool, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_RunEndEncoded_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_RunEndEncoded_ref_t; static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Decimal_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Decimal_ref_t; static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Decimal, 3) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Date_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Date_ref_t; static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Date, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Time_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Time_ref_t; static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Time, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Timestamp_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Timestamp_ref_t; static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Interval_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Interval_ref_t; static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Interval, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Duration_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Duration_ref_t; static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Duration, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_KeyValue_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_KeyValue_ref_t; static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_DictionaryEncoding_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_ref_t; static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, 4) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Field_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Field_ref_t; static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Field, 7) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Schema_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Schema_ref_t; static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Schema, 4) #define __org_apache_arrow_flatbuf_Null_formal_args #define __org_apache_arrow_flatbuf_Null_call_args static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Null, org_apache_arrow_flatbuf_Null_file_identifier, org_apache_arrow_flatbuf_Null_type_identifier) #define __org_apache_arrow_flatbuf_Struct__formal_args #define __org_apache_arrow_flatbuf_Struct__call_args static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Struct_, org_apache_arrow_flatbuf_Struct__file_identifier, org_apache_arrow_flatbuf_Struct__type_identifier) #define __org_apache_arrow_flatbuf_List_formal_args #define __org_apache_arrow_flatbuf_List_call_args static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_List, org_apache_arrow_flatbuf_List_file_identifier, org_apache_arrow_flatbuf_List_type_identifier) #define __org_apache_arrow_flatbuf_LargeList_formal_args #define __org_apache_arrow_flatbuf_LargeList_call_args static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeList, org_apache_arrow_flatbuf_LargeList_file_identifier, org_apache_arrow_flatbuf_LargeList_type_identifier) #define __org_apache_arrow_flatbuf_ListView_formal_args #define __org_apache_arrow_flatbuf_ListView_call_args static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_ListView, org_apache_arrow_flatbuf_ListView_file_identifier, org_apache_arrow_flatbuf_ListView_type_identifier) #define __org_apache_arrow_flatbuf_LargeListView_formal_args #define __org_apache_arrow_flatbuf_LargeListView_call_args static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, org_apache_arrow_flatbuf_LargeListView_file_identifier, org_apache_arrow_flatbuf_LargeListView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeList_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeList_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList_file_identifier, org_apache_arrow_flatbuf_FixedSizeList_type_identifier) #define __org_apache_arrow_flatbuf_Map_formal_args , flatbuffers_bool_t v0 #define __org_apache_arrow_flatbuf_Map_call_args , v0 static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Map, org_apache_arrow_flatbuf_Map_file_identifier, org_apache_arrow_flatbuf_Map_type_identifier) #define __org_apache_arrow_flatbuf_Union_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0, flatbuffers_int32_vec_ref_t v1 #define __org_apache_arrow_flatbuf_Union_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Union, org_apache_arrow_flatbuf_Union_file_identifier, org_apache_arrow_flatbuf_Union_type_identifier) #define __org_apache_arrow_flatbuf_Int_formal_args , int32_t v0, flatbuffers_bool_t v1 #define __org_apache_arrow_flatbuf_Int_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_Int_file_identifier, org_apache_arrow_flatbuf_Int_type_identifier) #define __org_apache_arrow_flatbuf_FloatingPoint_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_FloatingPoint_call_args , v0 static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint_file_identifier, org_apache_arrow_flatbuf_FloatingPoint_type_identifier) #define __org_apache_arrow_flatbuf_Utf8_formal_args #define __org_apache_arrow_flatbuf_Utf8_call_args static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8, org_apache_arrow_flatbuf_Utf8_file_identifier, org_apache_arrow_flatbuf_Utf8_type_identifier) #define __org_apache_arrow_flatbuf_Binary_formal_args #define __org_apache_arrow_flatbuf_Binary_call_args static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Binary, org_apache_arrow_flatbuf_Binary_file_identifier, org_apache_arrow_flatbuf_Binary_type_identifier) #define __org_apache_arrow_flatbuf_LargeUtf8_formal_args #define __org_apache_arrow_flatbuf_LargeUtf8_call_args static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8_file_identifier, org_apache_arrow_flatbuf_LargeUtf8_type_identifier) #define __org_apache_arrow_flatbuf_LargeBinary_formal_args #define __org_apache_arrow_flatbuf_LargeBinary_call_args static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, org_apache_arrow_flatbuf_LargeBinary_file_identifier, org_apache_arrow_flatbuf_LargeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Utf8View_formal_args #define __org_apache_arrow_flatbuf_Utf8View_call_args static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, org_apache_arrow_flatbuf_Utf8View_file_identifier, org_apache_arrow_flatbuf_Utf8View_type_identifier) #define __org_apache_arrow_flatbuf_BinaryView_formal_args #define __org_apache_arrow_flatbuf_BinaryView_call_args static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, org_apache_arrow_flatbuf_BinaryView_file_identifier, org_apache_arrow_flatbuf_BinaryView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeBinary_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Bool_formal_args #define __org_apache_arrow_flatbuf_Bool_call_args static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Bool, org_apache_arrow_flatbuf_Bool_file_identifier, org_apache_arrow_flatbuf_Bool_type_identifier) #define __org_apache_arrow_flatbuf_RunEndEncoded_formal_args #define __org_apache_arrow_flatbuf_RunEndEncoded_call_args static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded_file_identifier, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier) #define __org_apache_arrow_flatbuf_Decimal_formal_args , int32_t v0, int32_t v1, int32_t v2 #define __org_apache_arrow_flatbuf_Decimal_call_args , v0, v1, v2 static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Decimal, org_apache_arrow_flatbuf_Decimal_file_identifier, org_apache_arrow_flatbuf_Decimal_type_identifier) #define __org_apache_arrow_flatbuf_Date_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Date_call_args , v0 static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Date, org_apache_arrow_flatbuf_Date_file_identifier, org_apache_arrow_flatbuf_Date_type_identifier) #define __org_apache_arrow_flatbuf_Time_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, int32_t v1 #define __org_apache_arrow_flatbuf_Time_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Time, org_apache_arrow_flatbuf_Time_file_identifier, org_apache_arrow_flatbuf_Time_type_identifier) #define __org_apache_arrow_flatbuf_Timestamp_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_Timestamp_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, org_apache_arrow_flatbuf_Timestamp_file_identifier, org_apache_arrow_flatbuf_Timestamp_type_identifier) #define __org_apache_arrow_flatbuf_Interval_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Interval_call_args , v0 static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Interval, org_apache_arrow_flatbuf_Interval_file_identifier, org_apache_arrow_flatbuf_Interval_type_identifier) #define __org_apache_arrow_flatbuf_Duration_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Duration_call_args , v0 static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Duration, org_apache_arrow_flatbuf_Duration_file_identifier, org_apache_arrow_flatbuf_Duration_type_identifier) #define __org_apache_arrow_flatbuf_KeyValue_formal_args , flatbuffers_string_ref_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_KeyValue_call_args , v0, v1 static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_KeyValue_file_identifier, org_apache_arrow_flatbuf_KeyValue_type_identifier) #define __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args , int64_t v0, org_apache_arrow_flatbuf_Int_ref_t v1, flatbuffers_bool_t v2, org_apache_arrow_flatbuf_DictionaryKind_enum_t v3 #define __org_apache_arrow_flatbuf_DictionaryEncoding_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier) #define __org_apache_arrow_flatbuf_Field_formal_args ,\ flatbuffers_string_ref_t v0, flatbuffers_bool_t v1, org_apache_arrow_flatbuf_Type_union_ref_t v3, org_apache_arrow_flatbuf_DictionaryEncoding_ref_t v4, org_apache_arrow_flatbuf_Field_vec_ref_t v5, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v6 #define __org_apache_arrow_flatbuf_Field_call_args ,\ v0, v1, v3, v4, v5, v6 static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field_file_identifier, org_apache_arrow_flatbuf_Field_type_identifier) #define __org_apache_arrow_flatbuf_Schema_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0, org_apache_arrow_flatbuf_Field_vec_ref_t v1, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v2, org_apache_arrow_flatbuf_Feature_vec_ref_t v3 #define __org_apache_arrow_flatbuf_Schema_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Schema, org_apache_arrow_flatbuf_Schema_file_identifier, org_apache_arrow_flatbuf_Schema_type_identifier) static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_NONE(void) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Null; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Int; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FloatingPoint; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Binary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Bool; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Decimal; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Date; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Time; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Timestamp; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Interval; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_List; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Struct_; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Union; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Map; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Duration; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeUtf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_RunEndEncoded; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_BinaryView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8View; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_ListView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeListView; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_Type) static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_clone(B, (org_apache_arrow_flatbuf_Null_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_clone(B, (org_apache_arrow_flatbuf_Int_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_clone(B, (org_apache_arrow_flatbuf_FloatingPoint_table_t)u.value)); case 4: return org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_clone(B, (org_apache_arrow_flatbuf_Binary_table_t)u.value)); case 5: return org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_clone(B, (org_apache_arrow_flatbuf_Utf8_table_t)u.value)); case 6: return org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_clone(B, (org_apache_arrow_flatbuf_Bool_table_t)u.value)); case 7: return org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_clone(B, (org_apache_arrow_flatbuf_Decimal_table_t)u.value)); case 8: return org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_clone(B, (org_apache_arrow_flatbuf_Date_table_t)u.value)); case 9: return org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_clone(B, (org_apache_arrow_flatbuf_Time_table_t)u.value)); case 10: return org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_clone(B, (org_apache_arrow_flatbuf_Timestamp_table_t)u.value)); case 11: return org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_clone(B, (org_apache_arrow_flatbuf_Interval_table_t)u.value)); case 12: return org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_clone(B, (org_apache_arrow_flatbuf_List_table_t)u.value)); case 13: return org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__clone(B, (org_apache_arrow_flatbuf_Struct__table_t)u.value)); case 14: return org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_clone(B, (org_apache_arrow_flatbuf_Union_table_t)u.value)); case 15: return org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_clone(B, (org_apache_arrow_flatbuf_FixedSizeBinary_table_t)u.value)); case 16: return org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_clone(B, (org_apache_arrow_flatbuf_FixedSizeList_table_t)u.value)); case 17: return org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_clone(B, (org_apache_arrow_flatbuf_Map_table_t)u.value)); case 18: return org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_clone(B, (org_apache_arrow_flatbuf_Duration_table_t)u.value)); case 19: return org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_clone(B, (org_apache_arrow_flatbuf_LargeBinary_table_t)u.value)); case 20: return org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_clone(B, (org_apache_arrow_flatbuf_LargeUtf8_table_t)u.value)); case 21: return org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_clone(B, (org_apache_arrow_flatbuf_LargeList_table_t)u.value)); case 22: return org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_clone(B, (org_apache_arrow_flatbuf_RunEndEncoded_table_t)u.value)); case 23: return org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_clone(B, (org_apache_arrow_flatbuf_BinaryView_table_t)u.value)); case 24: return org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_clone(B, (org_apache_arrow_flatbuf_Utf8View_table_t)u.value)); case 25: return org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_clone(B, (org_apache_arrow_flatbuf_ListView_table_t)u.value)); case 26: return org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_clone(B, (org_apache_arrow_flatbuf_LargeListView_table_t)u.value)); default: return org_apache_arrow_flatbuf_Type_as_NONE(); } } static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args) { if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } return org_apache_arrow_flatbuf_Null_end(B); } static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Null_end(B)); } static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args) { if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } return org_apache_arrow_flatbuf_Struct__end(B); } static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Struct__end(B)); } static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args) { if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } return org_apache_arrow_flatbuf_List_end(B); } static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_List_end(B)); } static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args) { if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeList_end(B); } static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeList_end(B)); } static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args) { if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_ListView_end(B); } static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_ListView_end(B)); } static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args) { if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeListView_end(B); } static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeListView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList_listSize, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeList) static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeList_end(B); } static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeList_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Map_keysSorted, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Map) static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args) { if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Map_end(B); } static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Map_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Union_mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Union) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Union_typeIds, flatbuffers_int32, int32_t, org_apache_arrow_flatbuf_Union) static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args) { if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_add(B, v1) || org_apache_arrow_flatbuf_Union_mode_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Union_end(B); } static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_pick(B, t) || org_apache_arrow_flatbuf_Union_mode_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Union_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Int_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Int) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Int_is_signed, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Int) static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args) { if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_add(B, v0) || org_apache_arrow_flatbuf_Int_is_signed_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_Int_end(B); } static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Int_is_signed_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Int_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint_precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_FloatingPoint) static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args) { if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FloatingPoint_end(B); } static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FloatingPoint_end(B)); } static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args) { if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8_end(B); } static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8_end(B)); } static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args) { if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } return org_apache_arrow_flatbuf_Binary_end(B); } static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Binary_end(B)); } static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args) { if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeUtf8_end(B); } static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeUtf8_end(B)); } static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args) { if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeBinary_end(B); } static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args) { if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8View_end(B); } static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8View_end(B)); } static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args) { if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } return org_apache_arrow_flatbuf_BinaryView_end(B); } static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_BinaryView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeBinary) static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeBinary_end(B); } static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args) { if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } return org_apache_arrow_flatbuf_Bool_end(B); } static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Bool_end(B)); } static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args) { if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } return org_apache_arrow_flatbuf_RunEndEncoded_end(B); } static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_RunEndEncoded_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Decimal_precision, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Decimal_scale, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_Decimal_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(128), org_apache_arrow_flatbuf_Decimal) static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args) { if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_add(B, v0) || org_apache_arrow_flatbuf_Decimal_scale_add(B, v1) || org_apache_arrow_flatbuf_Decimal_bitWidth_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_Decimal_end(B); } static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_pick(B, t) || org_apache_arrow_flatbuf_Decimal_scale_pick(B, t) || org_apache_arrow_flatbuf_Decimal_bitWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Decimal_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Date_unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Date) static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args) { if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Date_end(B); } static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Date_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Time_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Time) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Time_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(32), org_apache_arrow_flatbuf_Time) static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args) { if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_add(B, v1) || org_apache_arrow_flatbuf_Time_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Time_end(B); } static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Time_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Time_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_timezone, org_apache_arrow_flatbuf_Timestamp) static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args) { if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_add(B, v1) || org_apache_arrow_flatbuf_Timestamp_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Timestamp_end(B); } static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_pick(B, t) || org_apache_arrow_flatbuf_Timestamp_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Timestamp_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Interval_unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Interval) static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args) { if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Interval_end(B); } static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Interval_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Duration_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Duration) static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args) { if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Duration_end(B); } static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Duration_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_key, org_apache_arrow_flatbuf_KeyValue) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_value, org_apache_arrow_flatbuf_KeyValue) static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args) { if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_add(B, v0) || org_apache_arrow_flatbuf_KeyValue_value_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_KeyValue_end(B); } static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_pick(B, t) || org_apache_arrow_flatbuf_KeyValue_value_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_KeyValue_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_id, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_indexType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args) { if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_add(B, v0) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_add(B, v1) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_add(B, v3) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_DictionaryEncoding_end(B); } static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_DictionaryEncoding_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_Field_name, org_apache_arrow_flatbuf_Field) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Field_nullable, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_field(3, flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_field(4, flatbuffers_, org_apache_arrow_flatbuf_Field_dictionary, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(5, flatbuffers_, org_apache_arrow_flatbuf_Field_children, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(6, flatbuffers_, org_apache_arrow_flatbuf_Field_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Field) static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args) { if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_add(B, v0) || org_apache_arrow_flatbuf_Field_type_add_value(B, v3) || org_apache_arrow_flatbuf_Field_dictionary_add(B, v4) || org_apache_arrow_flatbuf_Field_children_add(B, v5) || org_apache_arrow_flatbuf_Field_custom_metadata_add(B, v6) || org_apache_arrow_flatbuf_Field_nullable_add(B, v1) || org_apache_arrow_flatbuf_Field_type_add_type(B, v3.type)) { return 0; } return org_apache_arrow_flatbuf_Field_end(B); } static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_pick(B, t) || org_apache_arrow_flatbuf_Field_type_pick(B, t) || org_apache_arrow_flatbuf_Field_dictionary_pick(B, t) || org_apache_arrow_flatbuf_Field_children_pick(B, t) || org_apache_arrow_flatbuf_Field_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Field_nullable_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Field_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Schema_endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Schema_fields, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Schema_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Schema_features, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, org_apache_arrow_flatbuf_Schema) static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args) { if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_add(B, v1) || org_apache_arrow_flatbuf_Schema_custom_metadata_add(B, v2) || org_apache_arrow_flatbuf_Schema_features_add(B, v3) || org_apache_arrow_flatbuf_Schema_endianness_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Schema_end(B); } static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_pick(B, t) || org_apache_arrow_flatbuf_Schema_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Schema_features_pick(B, t) || org_apache_arrow_flatbuf_Schema_endianness_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Schema_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_BUILDER_H */ #ifndef SCHEMA_VERIFIER_H #define SCHEMA_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_verifier.h" #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Type_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Null_verify_table); /* Null */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Int_verify_table); /* Int */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FloatingPoint_verify_table); /* FloatingPoint */ case 4: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Binary_verify_table); /* Binary */ case 5: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8_verify_table); /* Utf8 */ case 6: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Bool_verify_table); /* Bool */ case 7: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Decimal_verify_table); /* Decimal */ case 8: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Date_verify_table); /* Date */ case 9: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Time_verify_table); /* Time */ case 10: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Timestamp_verify_table); /* Timestamp */ case 11: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Interval_verify_table); /* Interval */ case 12: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_List_verify_table); /* List */ case 13: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Struct__verify_table); /* Struct_ */ case 14: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Union_verify_table); /* Union */ case 15: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); /* FixedSizeBinary */ case 16: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeList_verify_table); /* FixedSizeList */ case 17: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Map_verify_table); /* Map */ case 18: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Duration_verify_table); /* Duration */ case 19: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeBinary_verify_table); /* LargeBinary */ case 20: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeUtf8_verify_table); /* LargeUtf8 */ case 21: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeList_verify_table); /* LargeList */ case 22: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_RunEndEncoded_verify_table); /* RunEndEncoded */ case 23: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_BinaryView_verify_table); /* BinaryView */ case 24: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8View_verify_table); /* Utf8View */ case 25: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_ListView_verify_table); /* ListView */ case 26: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeListView_verify_table); /* LargeListView */ default: return flatcc_verify_ok; } } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root(buf, bufsiz, fid, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, fid, 16, 8); } static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Null_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_List_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* listSize */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 1, 1) /* keysSorted */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Map_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* mode */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 4, 4, INT64_C(1073741823)) /* typeIds */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Union_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* bitWidth */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* is_signed */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Int_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* precision */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* byteWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* precision */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* scale */)) return ret; if ((ret = flatcc_verify_field(td, 2, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Date_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Time_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* timezone */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* key */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* value */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* id */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 0, &org_apache_arrow_flatbuf_Int_verify_table) /* indexType */)) return ret; if ((ret = flatcc_verify_field(td, 2, 1, 1) /* isOrdered */)) return ret; if ((ret = flatcc_verify_field(td, 3, 2, 2) /* dictionaryKind */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* name */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* nullable */)) return ret; if ((ret = flatcc_verify_union_field(td, 3, 0, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_field(td, 4, 0, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table) /* dictionary */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 5, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* children */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 6, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Field_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* endianness */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 1, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* fields */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* features */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_VERIFIER_H */ #ifndef TENSOR_READER_H #define TENSOR_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef const struct org_apache_arrow_flatbuf_TensorDim_table *org_apache_arrow_flatbuf_TensorDim_table_t; typedef struct org_apache_arrow_flatbuf_TensorDim_table *org_apache_arrow_flatbuf_TensorDim_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_TensorDim_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_TensorDim_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Tensor_table *org_apache_arrow_flatbuf_Tensor_table_t; typedef struct org_apache_arrow_flatbuf_Tensor_table *org_apache_arrow_flatbuf_Tensor_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Tensor_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Tensor_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_TensorDim_file_identifier #define org_apache_arrow_flatbuf_TensorDim_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_TensorDim_file_identifier */ #ifndef org_apache_arrow_flatbuf_TensorDim_identifier #define org_apache_arrow_flatbuf_TensorDim_identifier 0 #endif #define org_apache_arrow_flatbuf_TensorDim_type_hash ((flatbuffers_thash_t)0xbc6d7b25) #define org_apache_arrow_flatbuf_TensorDim_type_identifier "\x25\x7b\x6d\xbc" #ifndef org_apache_arrow_flatbuf_TensorDim_file_extension #define org_apache_arrow_flatbuf_TensorDim_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Tensor_file_identifier #define org_apache_arrow_flatbuf_Tensor_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Tensor_file_identifier */ #ifndef org_apache_arrow_flatbuf_Tensor_identifier #define org_apache_arrow_flatbuf_Tensor_identifier 0 #endif #define org_apache_arrow_flatbuf_Tensor_type_hash ((flatbuffers_thash_t)0x1764df19) #define org_apache_arrow_flatbuf_Tensor_type_identifier "\x19\xdf\x64\x17" #ifndef org_apache_arrow_flatbuf_Tensor_file_extension #define org_apache_arrow_flatbuf_Tensor_file_extension "bin" #endif /** ---------------------------------------------------------------------- * Data structures for dense tensors * Shape data for a single axis in a tensor */ struct org_apache_arrow_flatbuf_TensorDim_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_TensorDim_vec_len(org_apache_arrow_flatbuf_TensorDim_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_TensorDim_table_t org_apache_arrow_flatbuf_TensorDim_vec_at(org_apache_arrow_flatbuf_TensorDim_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_TensorDim_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_TensorDim) /** Length of dimension */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_TensorDim, size, flatbuffers_int64, int64_t, INT64_C(0)) /** Name of the dimension, optional */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_TensorDim, name, 0) struct org_apache_arrow_flatbuf_Tensor_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Tensor_vec_len(org_apache_arrow_flatbuf_Tensor_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Tensor_table_t org_apache_arrow_flatbuf_Tensor_vec_at(org_apache_arrow_flatbuf_Tensor_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Tensor_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Tensor) /** The type of data contained in a value cell. Currently only fixed-width * value types are supported, no strings or nested types */ __flatbuffers_define_union_field(flatbuffers_, 1, org_apache_arrow_flatbuf_Tensor, type, org_apache_arrow_flatbuf_Type, 1) /** The dimensions of the tensor, optionally named */ __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Tensor, shape, org_apache_arrow_flatbuf_TensorDim_vec_t, 1) /** Non-negative byte offsets to advance one value cell along each dimension * If omitted, default to row-major order (C-like). */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Tensor, strides, flatbuffers_int64_vec_t, 0) /** The location and size of the tensor's data */ __flatbuffers_define_struct_field(4, org_apache_arrow_flatbuf_Tensor, data, org_apache_arrow_flatbuf_Buffer_struct_t, 1) #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_READER_H */ #ifndef TENSOR_BUILDER_H #define TENSOR_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #ifndef SCHEMA_BUILDER_H #include "Schema_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_TensorDim_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_TensorDim_ref_t; static org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_TensorDim_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_TensorDim, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Tensor_required[] = { 1, 2, 4, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Tensor_ref_t; static org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Tensor_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Tensor, 5) #define __org_apache_arrow_flatbuf_TensorDim_formal_args , int64_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_TensorDim_call_args , v0, v1 static inline org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_TensorDim_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_TensorDim_file_identifier, org_apache_arrow_flatbuf_TensorDim_type_identifier) #define __org_apache_arrow_flatbuf_Tensor_formal_args , org_apache_arrow_flatbuf_Type_union_ref_t v1, org_apache_arrow_flatbuf_TensorDim_vec_ref_t v2, flatbuffers_int64_vec_ref_t v3, org_apache_arrow_flatbuf_Buffer_t *v4 #define __org_apache_arrow_flatbuf_Tensor_call_args , v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Tensor_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Tensor, org_apache_arrow_flatbuf_Tensor_file_identifier, org_apache_arrow_flatbuf_Tensor_type_identifier) __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_TensorDim_size, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_TensorDim) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_TensorDim_name, org_apache_arrow_flatbuf_TensorDim) static inline org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_TensorDim_formal_args) { if (org_apache_arrow_flatbuf_TensorDim_start(B) || org_apache_arrow_flatbuf_TensorDim_size_add(B, v0) || org_apache_arrow_flatbuf_TensorDim_name_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_TensorDim_end(B); } static org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_TensorDim_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_TensorDim_start(B) || org_apache_arrow_flatbuf_TensorDim_size_pick(B, t) || org_apache_arrow_flatbuf_TensorDim_name_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_TensorDim_end(B)); } __flatbuffers_build_union_field(1, flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Tensor_shape, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Tensor_strides, flatbuffers_int64, int64_t, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_struct_field(4, flatbuffers_, org_apache_arrow_flatbuf_Tensor_data, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Tensor) static inline org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Tensor_formal_args) { if (org_apache_arrow_flatbuf_Tensor_start(B) || org_apache_arrow_flatbuf_Tensor_data_add(B, v4) || org_apache_arrow_flatbuf_Tensor_type_add_value(B, v1) || org_apache_arrow_flatbuf_Tensor_shape_add(B, v2) || org_apache_arrow_flatbuf_Tensor_strides_add(B, v3) || org_apache_arrow_flatbuf_Tensor_type_add_type(B, v1.type)) { return 0; } return org_apache_arrow_flatbuf_Tensor_end(B); } static org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Tensor_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Tensor_start(B) || org_apache_arrow_flatbuf_Tensor_data_pick(B, t) || org_apache_arrow_flatbuf_Tensor_type_pick(B, t) || org_apache_arrow_flatbuf_Tensor_shape_pick(B, t) || org_apache_arrow_flatbuf_Tensor_strides_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Tensor_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_BUILDER_H */ #ifndef TENSOR_VERIFIER_H #define TENSOR_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #include "flatcc/flatcc_verifier.h" #ifndef SCHEMA_VERIFIER_H #include "Schema_verifier.h" #endif #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_TensorDim_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Tensor_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_TensorDim_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* size */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* name */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_type_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_type_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static int org_apache_arrow_flatbuf_Tensor_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_union_field(td, 1, 1, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 1, &org_apache_arrow_flatbuf_TensorDim_verify_table) /* shape */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* strides */)) return ret; if ((ret = flatcc_verify_field(td, 4, 16, 8) /* data */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_type_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_type_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Tensor_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_VERIFIER_H */ #ifndef SPARSETENSOR_READER_H #define SPARSETENSOR_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef const struct org_apache_arrow_flatbuf_SparseTensorIndexCOO_table *org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t; typedef struct org_apache_arrow_flatbuf_SparseTensorIndexCOO_table *org_apache_arrow_flatbuf_SparseTensorIndexCOO_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCOO_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t; typedef struct org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseMatrixIndexCSX_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_SparseTensorIndexCSF_table *org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t; typedef struct org_apache_arrow_flatbuf_SparseTensorIndexCSF_table *org_apache_arrow_flatbuf_SparseTensorIndexCSF_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensorIndexCSF_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_SparseTensor_table *org_apache_arrow_flatbuf_SparseTensor_table_t; typedef struct org_apache_arrow_flatbuf_SparseTensor_table *org_apache_arrow_flatbuf_SparseTensor_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensor_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_SparseTensor_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_hash ((flatbuffers_thash_t)0x3b31385a) #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier "\x5a\x38\x31\x3b" #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_extension #define org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_hash ((flatbuffers_thash_t)0xec57ea87) #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier "\x87\xea\x57\xec" #ifndef org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_extension #define org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_hash ((flatbuffers_thash_t)0xf44edda9) #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier "\xa9\xdd\x4e\xf4" #ifndef org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_extension #define org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_SparseTensor_file_identifier #define org_apache_arrow_flatbuf_SparseTensor_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_SparseTensor_file_identifier */ #ifndef org_apache_arrow_flatbuf_SparseTensor_identifier #define org_apache_arrow_flatbuf_SparseTensor_identifier 0 #endif #define org_apache_arrow_flatbuf_SparseTensor_type_hash ((flatbuffers_thash_t)0xae6f7239) #define org_apache_arrow_flatbuf_SparseTensor_type_identifier "\x39\x72\x6f\xae" #ifndef org_apache_arrow_flatbuf_SparseTensor_file_extension #define org_apache_arrow_flatbuf_SparseTensor_file_extension "bin" #endif typedef int16_t org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t, 16) #define org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Row ((org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Column ((org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_name(org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Row: return "Row"; case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Column: return "Column"; default: return ""; } } static inline int org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_is_known_value(org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Row: return 1; case org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_Column: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * EXPERIMENTAL: Data structures for sparse tensors * Coordinate (COO) format of sparse tensor index. * * COO's index list are represented as a NxM matrix, * where N is the number of non-zero values, * and M is the number of dimensions of a sparse tensor. * * indicesBuffer stores the location and size of the data of this indices * matrix. The value type and the stride of the indices matrix is * specified in indicesType and indicesStrides fields. * * For example, let X be a 2x3x4x5 tensor, and it has the following * 6 non-zero values: * ```text * X[0, 1, 2, 0] := 1 * X[1, 1, 2, 3] := 2 * X[0, 2, 1, 0] := 3 * X[0, 1, 3, 0] := 4 * X[0, 1, 2, 1] := 5 * X[1, 2, 0, 4] := 6 * ``` * In COO format, the index matrix of X is the following 4x6 matrix: * ```text * [[0, 0, 0, 0, 1, 1], * [1, 1, 1, 2, 1, 2], * [2, 2, 3, 1, 2, 0], * [0, 1, 0, 0, 3, 4]] * ``` * When isCanonical is true, the indices is sorted in lexicographical order * (row-major order), and it does not have duplicated entries. Otherwise, * the indices may not be sorted, or may have duplicated entries. */ struct org_apache_arrow_flatbuf_SparseTensorIndexCOO_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_len(org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCOO_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseTensorIndexCOO) /** The type of values in indicesBuffer */ __flatbuffers_define_table_field(0, org_apache_arrow_flatbuf_SparseTensorIndexCOO, indicesType, org_apache_arrow_flatbuf_Int_table_t, 1) /** Non-negative byte offsets to advance one value cell along each dimension * If omitted, default to row-major order (C-like). */ __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_SparseTensorIndexCOO, indicesStrides, flatbuffers_int64_vec_t, 0) /** The location and size of the indices matrix's data */ __flatbuffers_define_struct_field(2, org_apache_arrow_flatbuf_SparseTensorIndexCOO, indicesBuffer, org_apache_arrow_flatbuf_Buffer_struct_t, 1) /** This flag is true if and only if the indices matrix is sorted in * row-major order, and does not have duplicated entries. * This sort order is the same as of Tensorflow's SparseTensor, * but it is inverse order of SciPy's canonical coo_matrix * (SciPy employs column-major order for its coo_matrix). */ __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_SparseTensorIndexCOO, isCanonical, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** Compressed Sparse format, that is matrix-specific. */ struct org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_len(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_at(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseMatrixIndexCSX) /** Which axis, row or column, is compressed */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, compressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t, INT16_C(0)) /** The type of values in indptrBuffer */ __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indptrType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indptrBuffer stores the location and size of indptr array that * represents the range of the rows. * The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data. * The length of this array is 1 + (the number of rows), and the type * of index value is long. * * For example, let X be the following 6x4 matrix: * ```text * X := [[0, 1, 2, 0], * [0, 0, 3, 0], * [0, 4, 0, 5], * [0, 0, 0, 0], * [6, 0, 7, 8], * [0, 9, 0, 0]]. * ``` * The array of non-zero values in X is: * ```text * values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. * ``` * And the indptr of X is: * ```text * indptr(X) = [0, 2, 3, 5, 5, 8, 10]. * ``` */ __flatbuffers_define_struct_field(2, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indptrBuffer, org_apache_arrow_flatbuf_Buffer_struct_t, 1) /** The type of values in indicesBuffer */ __flatbuffers_define_table_field(3, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indicesType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indicesBuffer stores the location and size of the array that * contains the column indices of the corresponding non-zero values. * The type of index value is long. * * For example, the indices of the above X is: * ```text * indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. * ``` * Note that the indices are sorted in lexicographical order for each row. */ __flatbuffers_define_struct_field(4, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, indicesBuffer, org_apache_arrow_flatbuf_Buffer_struct_t, 1) /** Compressed Sparse Fiber (CSF) sparse tensor index. */ struct org_apache_arrow_flatbuf_SparseTensorIndexCSF_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_len(org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCSF_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseTensorIndexCSF) /** CSF is a generalization of compressed sparse row (CSR) index. * See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) * * CSF index recursively compresses each dimension of a tensor into a set * of prefix trees. Each path from a root to leaf forms one tensor * non-zero index. CSF is implemented with two arrays of buffers and one * arrays of integers. * * For example, let X be a 2x3x4x5 tensor and let it have the following * 8 non-zero values: * ```text * X[0, 0, 0, 1] := 1 * X[0, 0, 0, 2] := 2 * X[0, 1, 0, 0] := 3 * X[0, 1, 0, 2] := 4 * X[0, 1, 1, 0] := 5 * X[1, 1, 1, 0] := 6 * X[1, 1, 1, 1] := 7 * X[1, 1, 1, 2] := 8 * ``` * As a prefix tree this would be represented as: * ```text * 0 1 * / \ | * 0 1 1 * / / \ | * 0 0 1 1 * /| /| | /| | * 1 2 0 2 0 0 1 2 * ``` * The type of values in indptrBuffers */ __flatbuffers_define_table_field(0, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indptrType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indptrBuffers stores the sparsity structure. * Each two consecutive dimensions in a tensor correspond to a buffer in * indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` * and `indptrBuffers[dim][i + 1]` signify a range of nodes in * `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. * * For example, the indptrBuffers for the above X is: * ```text * indptrBuffer(X) = [ * [0, 2, 3], * [0, 1, 3, 4], * [0, 2, 4, 5, 8] * ]. * ``` */ __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indptrBuffers, org_apache_arrow_flatbuf_Buffer_vec_t, 1) /** The type of values in indicesBuffers */ __flatbuffers_define_table_field(2, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indicesType, org_apache_arrow_flatbuf_Int_table_t, 1) /** indicesBuffers stores values of nodes. * Each tensor dimension corresponds to a buffer in indicesBuffers. * For example, the indicesBuffers for the above X is: * ```text * indicesBuffer(X) = [ * [0, 1], * [0, 1, 1], * [0, 0, 1, 1], * [1, 2, 0, 2, 0, 0, 1, 2] * ]. * ``` */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_SparseTensorIndexCSF, indicesBuffers, org_apache_arrow_flatbuf_Buffer_vec_t, 1) /** axisOrder stores the sequence in which dimensions were traversed to * produce the prefix tree. * For example, the axisOrder for the above X is: * ```text * axisOrder(X) = [0, 1, 2, 3]. * ``` */ __flatbuffers_define_vector_field(4, org_apache_arrow_flatbuf_SparseTensorIndexCSF, axisOrder, flatbuffers_int32_vec_t, 1) typedef uint8_t org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_SparseTensorIndex, org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndex) #define org_apache_arrow_flatbuf_SparseTensorIndex_NONE ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF ((org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t)UINT8_C(3)) static inline const char *org_apache_arrow_flatbuf_SparseTensorIndex_type_name(org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_SparseTensorIndex_NONE: return "NONE"; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO: return "SparseTensorIndexCOO"; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX: return "SparseMatrixIndexCSX"; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF: return "SparseTensorIndexCSF"; default: return ""; } } static inline int org_apache_arrow_flatbuf_SparseTensorIndex_is_known_type(org_apache_arrow_flatbuf_SparseTensorIndex_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_SparseTensorIndex_NONE: return 1; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO: return 1; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX: return 1; case org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_SparseTensor_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_SparseTensor_vec_len(org_apache_arrow_flatbuf_SparseTensor_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_SparseTensor_table_t org_apache_arrow_flatbuf_SparseTensor_vec_at(org_apache_arrow_flatbuf_SparseTensor_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_SparseTensor_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_SparseTensor) /** The type of data contained in a value cell. * Currently only fixed-width value types are supported, * no strings or nested types. */ __flatbuffers_define_union_field(flatbuffers_, 1, org_apache_arrow_flatbuf_SparseTensor, type, org_apache_arrow_flatbuf_Type, 1) /** The dimensions of the tensor, optionally named. */ __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_SparseTensor, shape, org_apache_arrow_flatbuf_TensorDim_vec_t, 1) /** The number of non-zero values in a sparse tensor. */ __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_SparseTensor, non_zero_length, flatbuffers_int64, int64_t, INT64_C(0)) /** Sparse tensor index */ __flatbuffers_define_union_field(flatbuffers_, 5, org_apache_arrow_flatbuf_SparseTensor, sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, 1) /** The location and size of the tensor's data */ __flatbuffers_define_struct_field(6, org_apache_arrow_flatbuf_SparseTensor, data, org_apache_arrow_flatbuf_Buffer_struct_t, 1) #include "flatcc/flatcc_epilogue.h" #endif /* SPARSETENSOR_READER_H */ #ifndef SPARSETENSOR_BUILDER_H #define SPARSETENSOR_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SPARSETENSOR_READER_H #include "SparseTensor_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #ifndef TENSOR_BUILDER_H #include "Tensor_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_formal_args , org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t v0 #define __org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_union_vec_ref_t; static org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndex_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseTensorIndexCOO_required[] = { 0, 2, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t; static org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO, 4) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_required[] = { 1, 2, 3, 4, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t; static org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, 5) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseTensorIndexCSF_required[] = { 0, 1, 2, 3, 4, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t; static org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF, 5) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_SparseTensor_required[] = { 1, 2, 5, 6, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_SparseTensor_ref_t; static org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensor_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor, 7) #define __org_apache_arrow_flatbuf_SparseTensorIndexCOO_formal_args , org_apache_arrow_flatbuf_Int_ref_t v0, flatbuffers_int64_vec_ref_t v1, org_apache_arrow_flatbuf_Buffer_t *v2, flatbuffers_bool_t v3 #define __org_apache_arrow_flatbuf_SparseTensorIndexCOO_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCOO_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO, org_apache_arrow_flatbuf_SparseTensorIndexCOO_file_identifier, org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier) #define __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_formal_args ,\ org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t v0, org_apache_arrow_flatbuf_Int_ref_t v1, org_apache_arrow_flatbuf_Buffer_t *v2, org_apache_arrow_flatbuf_Int_ref_t v3, org_apache_arrow_flatbuf_Buffer_t *v4 #define __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_call_args ,\ v0, v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_file_identifier, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier) #define __org_apache_arrow_flatbuf_SparseTensorIndexCSF_formal_args ,\ org_apache_arrow_flatbuf_Int_ref_t v0, org_apache_arrow_flatbuf_Buffer_vec_ref_t v1, org_apache_arrow_flatbuf_Int_ref_t v2, org_apache_arrow_flatbuf_Buffer_vec_ref_t v3, flatbuffers_int32_vec_ref_t v4 #define __org_apache_arrow_flatbuf_SparseTensorIndexCSF_call_args ,\ v0, v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCSF_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF, org_apache_arrow_flatbuf_SparseTensorIndexCSF_file_identifier, org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier) #define __org_apache_arrow_flatbuf_SparseTensor_formal_args ,\ org_apache_arrow_flatbuf_Type_union_ref_t v1, org_apache_arrow_flatbuf_TensorDim_vec_ref_t v2, int64_t v3, org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t v5, org_apache_arrow_flatbuf_Buffer_t *v6 #define __org_apache_arrow_flatbuf_SparseTensor_call_args ,\ v1, v2, v3, v5, v6 static inline org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensor_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor, org_apache_arrow_flatbuf_SparseTensor_file_identifier, org_apache_arrow_flatbuf_SparseTensor_type_identifier) static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_NONE(void) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCOO(org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t ref) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCOO; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseMatrixIndexCSX(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t ref) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_SparseMatrixIndexCSX; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCSF(org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t ref) { org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_SparseTensorIndex_SparseTensorIndexCSF; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndex) static org_apache_arrow_flatbuf_SparseTensorIndex_union_ref_t org_apache_arrow_flatbuf_SparseTensorIndex_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndex_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCOO(org_apache_arrow_flatbuf_SparseTensorIndexCOO_clone(B, (org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseMatrixIndexCSX(org_apache_arrow_flatbuf_SparseMatrixIndexCSX_clone(B, (org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_SparseTensorIndex_as_SparseTensorIndexCSF(org_apache_arrow_flatbuf_SparseTensorIndexCSF_clone(B, (org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t)u.value)); default: return org_apache_arrow_flatbuf_SparseTensorIndex_as_NONE(); } } __flatbuffers_build_table_field(0, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesStrides, flatbuffers_int64, int64_t, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_struct_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesBuffer, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCOO_isCanonical, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_SparseTensorIndexCOO) static inline org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCOO_formal_args) { if (org_apache_arrow_flatbuf_SparseTensorIndexCOO_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesBuffer_add(B, v2) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesType_add(B, v0) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesStrides_add(B, v1) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_isCanonical_add(B, v3)) { return 0; } return org_apache_arrow_flatbuf_SparseTensorIndexCOO_end(B); } static org_apache_arrow_flatbuf_SparseTensorIndexCOO_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCOO_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCOO_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseTensorIndexCOO_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesBuffer_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesType_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_indicesStrides_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCOO_isCanonical_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseTensorIndexCOO_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_compressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, org_apache_arrow_flatbuf_SparseMatrixCompressedAxis_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_struct_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrBuffer, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_table_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_struct_field(4, flatbuffers_, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesBuffer, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) static inline org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseMatrixIndexCSX_formal_args) { if (org_apache_arrow_flatbuf_SparseMatrixIndexCSX_start(B) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrBuffer_add(B, v2) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesBuffer_add(B, v4) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrType_add(B, v1) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesType_add(B, v3) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_compressedAxis_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_SparseMatrixIndexCSX_end(B); } static org_apache_arrow_flatbuf_SparseMatrixIndexCSX_ref_t org_apache_arrow_flatbuf_SparseMatrixIndexCSX_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseMatrixIndexCSX_start(B) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrBuffer_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesBuffer_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indptrType_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_indicesType_pick(B, t) || org_apache_arrow_flatbuf_SparseMatrixIndexCSX_compressedAxis_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_end(B)); } __flatbuffers_build_table_field(0, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrBuffers, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_table_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesBuffers, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_vector_field(4, flatbuffers_, org_apache_arrow_flatbuf_SparseTensorIndexCSF_axisOrder, flatbuffers_int32, int32_t, org_apache_arrow_flatbuf_SparseTensorIndexCSF) static inline org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensorIndexCSF_formal_args) { if (org_apache_arrow_flatbuf_SparseTensorIndexCSF_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrType_add(B, v0) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrBuffers_add(B, v1) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesType_add(B, v2) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesBuffers_add(B, v3) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_axisOrder_add(B, v4)) { return 0; } return org_apache_arrow_flatbuf_SparseTensorIndexCSF_end(B); } static org_apache_arrow_flatbuf_SparseTensorIndexCSF_ref_t org_apache_arrow_flatbuf_SparseTensorIndexCSF_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensorIndexCSF_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseTensorIndexCSF_start(B) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrType_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indptrBuffers_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesType_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_indicesBuffers_pick(B, t) || org_apache_arrow_flatbuf_SparseTensorIndexCSF_axisOrder_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseTensorIndexCSF_end(B)); } __flatbuffers_build_union_field(1, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_shape, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_non_zero_length, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_union_field(5, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, org_apache_arrow_flatbuf_SparseTensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, SparseTensorIndexCOO, org_apache_arrow_flatbuf_SparseTensorIndexCOO) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, SparseMatrixIndexCSX, org_apache_arrow_flatbuf_SparseMatrixIndexCSX) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_sparseIndex, org_apache_arrow_flatbuf_SparseTensorIndex, SparseTensorIndexCSF, org_apache_arrow_flatbuf_SparseTensorIndexCSF) __flatbuffers_build_struct_field(6, flatbuffers_, org_apache_arrow_flatbuf_SparseTensor_data, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_SparseTensor) static inline org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_SparseTensor_formal_args) { if (org_apache_arrow_flatbuf_SparseTensor_start(B) || org_apache_arrow_flatbuf_SparseTensor_non_zero_length_add(B, v3) || org_apache_arrow_flatbuf_SparseTensor_data_add(B, v6) || org_apache_arrow_flatbuf_SparseTensor_type_add_value(B, v1) || org_apache_arrow_flatbuf_SparseTensor_shape_add(B, v2) || org_apache_arrow_flatbuf_SparseTensor_sparseIndex_add_value(B, v5) || org_apache_arrow_flatbuf_SparseTensor_type_add_type(B, v1.type) || org_apache_arrow_flatbuf_SparseTensor_sparseIndex_add_type(B, v5.type)) { return 0; } return org_apache_arrow_flatbuf_SparseTensor_end(B); } static org_apache_arrow_flatbuf_SparseTensor_ref_t org_apache_arrow_flatbuf_SparseTensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_SparseTensor_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_SparseTensor_start(B) || org_apache_arrow_flatbuf_SparseTensor_non_zero_length_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_data_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_type_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_shape_pick(B, t) || org_apache_arrow_flatbuf_SparseTensor_sparseIndex_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_SparseTensor_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* SPARSETENSOR_BUILDER_H */ #ifndef SPARSETENSOR_VERIFIER_H #define SPARSETENSOR_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SPARSETENSOR_READER_H #include "SparseTensor_reader.h" #endif #include "flatcc/flatcc_verifier.h" #ifndef TENSOR_VERIFIER_H #include "Tensor_verifier.h" #endif #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseTensor_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_SparseTensorIndex_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); /* SparseTensorIndexCOO */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); /* SparseMatrixIndexCSX */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); /* SparseTensorIndexCSF */ default: return flatcc_verify_ok; } } static int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_table_field(td, 0, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indicesType */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 8, 8, INT64_C(536870911)) /* indicesStrides */)) return ret; if ((ret = flatcc_verify_field(td, 2, 16, 8) /* indicesBuffer */)) return ret; if ((ret = flatcc_verify_field(td, 3, 1, 1) /* isCanonical */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCOO_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCOO_verify_table); } static int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* compressedAxis */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indptrType */)) return ret; if ((ret = flatcc_verify_field(td, 2, 16, 8) /* indptrBuffer */)) return ret; if ((ret = flatcc_verify_table_field(td, 3, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indicesType */)) return ret; if ((ret = flatcc_verify_field(td, 4, 16, 8) /* indicesBuffer */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseMatrixIndexCSX_type_identifier, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static inline int org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseMatrixIndexCSX_verify_table); } static int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_table_field(td, 0, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indptrType */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 1, 16, 8, INT64_C(268435455)) /* indptrBuffers */)) return ret; if ((ret = flatcc_verify_table_field(td, 2, 1, &org_apache_arrow_flatbuf_Int_verify_table) /* indicesType */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 1, 16, 8, INT64_C(268435455)) /* indicesBuffers */)) return ret; if ((ret = flatcc_verify_vector_field(td, 4, 1, 4, 4, INT64_C(1073741823)) /* axisOrder */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensorIndexCSF_type_identifier, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensorIndexCSF_verify_table); } static int org_apache_arrow_flatbuf_SparseTensor_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_union_field(td, 1, 1, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 1, &org_apache_arrow_flatbuf_TensorDim_verify_table) /* shape */)) return ret; if ((ret = flatcc_verify_field(td, 3, 8, 8) /* non_zero_length */)) return ret; if ((ret = flatcc_verify_union_field(td, 5, 1, &org_apache_arrow_flatbuf_SparseTensorIndex_union_verifier) /* sparseIndex */)) return ret; if ((ret = flatcc_verify_field(td, 6, 16, 8) /* data */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_type_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_SparseTensor_type_identifier, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } static inline int org_apache_arrow_flatbuf_SparseTensor_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_SparseTensor_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* SPARSETENSOR_VERIFIER_H */ #ifndef SCHEMA_READER_H #define SCHEMA_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef struct org_apache_arrow_flatbuf_Buffer org_apache_arrow_flatbuf_Buffer_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_struct_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_struct_t; typedef const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_vec_t; typedef org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_table_t; typedef struct org_apache_arrow_flatbuf_Null_table *org_apache_arrow_flatbuf_Null_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Null_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__table_t; typedef struct org_apache_arrow_flatbuf_Struct__table *org_apache_arrow_flatbuf_Struct__mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Struct__mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_table_t; typedef struct org_apache_arrow_flatbuf_List_table *org_apache_arrow_flatbuf_List_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_List_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_table_t; typedef struct org_apache_arrow_flatbuf_LargeList_table *org_apache_arrow_flatbuf_LargeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_table_t; typedef struct org_apache_arrow_flatbuf_ListView_table *org_apache_arrow_flatbuf_ListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_ListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_table_t; typedef struct org_apache_arrow_flatbuf_LargeListView_table *org_apache_arrow_flatbuf_LargeListView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeListView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeList_table *org_apache_arrow_flatbuf_FixedSizeList_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeList_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_table_t; typedef struct org_apache_arrow_flatbuf_Map_table *org_apache_arrow_flatbuf_Map_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Map_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_table_t; typedef struct org_apache_arrow_flatbuf_Union_table *org_apache_arrow_flatbuf_Union_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Union_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_table_t; typedef struct org_apache_arrow_flatbuf_Int_table *org_apache_arrow_flatbuf_Int_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Int_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_table_t; typedef struct org_apache_arrow_flatbuf_FloatingPoint_table *org_apache_arrow_flatbuf_FloatingPoint_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FloatingPoint_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_table_t; typedef struct org_apache_arrow_flatbuf_Utf8_table *org_apache_arrow_flatbuf_Utf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_table_t; typedef struct org_apache_arrow_flatbuf_Binary_table *org_apache_arrow_flatbuf_Binary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Binary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_table_t; typedef struct org_apache_arrow_flatbuf_LargeUtf8_table *org_apache_arrow_flatbuf_LargeUtf8_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeUtf8_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_table_t; typedef struct org_apache_arrow_flatbuf_LargeBinary_table *org_apache_arrow_flatbuf_LargeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_LargeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_table_t; typedef struct org_apache_arrow_flatbuf_Utf8View_table *org_apache_arrow_flatbuf_Utf8View_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Utf8View_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_table_t; typedef struct org_apache_arrow_flatbuf_BinaryView_table *org_apache_arrow_flatbuf_BinaryView_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_BinaryView_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_table_t; typedef struct org_apache_arrow_flatbuf_FixedSizeBinary_table *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_FixedSizeBinary_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_table_t; typedef struct org_apache_arrow_flatbuf_Bool_table *org_apache_arrow_flatbuf_Bool_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Bool_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_table_t; typedef struct org_apache_arrow_flatbuf_RunEndEncoded_table *org_apache_arrow_flatbuf_RunEndEncoded_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_RunEndEncoded_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_table_t; typedef struct org_apache_arrow_flatbuf_Decimal_table *org_apache_arrow_flatbuf_Decimal_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Decimal_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_table_t; typedef struct org_apache_arrow_flatbuf_Date_table *org_apache_arrow_flatbuf_Date_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Date_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_table_t; typedef struct org_apache_arrow_flatbuf_Time_table *org_apache_arrow_flatbuf_Time_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Time_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_table_t; typedef struct org_apache_arrow_flatbuf_Timestamp_table *org_apache_arrow_flatbuf_Timestamp_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Timestamp_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_table_t; typedef struct org_apache_arrow_flatbuf_Interval_table *org_apache_arrow_flatbuf_Interval_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Interval_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_table_t; typedef struct org_apache_arrow_flatbuf_Duration_table *org_apache_arrow_flatbuf_Duration_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Duration_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_table_t; typedef struct org_apache_arrow_flatbuf_KeyValue_table *org_apache_arrow_flatbuf_KeyValue_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_KeyValue_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_table_t; typedef struct org_apache_arrow_flatbuf_DictionaryEncoding_table *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_DictionaryEncoding_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_table_t; typedef struct org_apache_arrow_flatbuf_Field_table *org_apache_arrow_flatbuf_Field_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Field_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_table_t; typedef struct org_apache_arrow_flatbuf_Schema_table *org_apache_arrow_flatbuf_Schema_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Schema_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_Null_file_identifier #define org_apache_arrow_flatbuf_Null_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Null_file_identifier */ #ifndef org_apache_arrow_flatbuf_Null_identifier #define org_apache_arrow_flatbuf_Null_identifier 0 #endif #define org_apache_arrow_flatbuf_Null_type_hash ((flatbuffers_thash_t)0x7b36a4dd) #define org_apache_arrow_flatbuf_Null_type_identifier "\xdd\xa4\x36\x7b" #ifndef org_apache_arrow_flatbuf_Null_file_extension #define org_apache_arrow_flatbuf_Null_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Struct__file_identifier #define org_apache_arrow_flatbuf_Struct__file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Struct__file_identifier */ #ifndef org_apache_arrow_flatbuf_Struct__identifier #define org_apache_arrow_flatbuf_Struct__identifier 0 #endif #define org_apache_arrow_flatbuf_Struct__type_hash ((flatbuffers_thash_t)0x6310f362) #define org_apache_arrow_flatbuf_Struct__type_identifier "\x62\xf3\x10\x63" #ifndef org_apache_arrow_flatbuf_Struct__file_extension #define org_apache_arrow_flatbuf_Struct__file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_List_file_identifier #define org_apache_arrow_flatbuf_List_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_List_file_identifier */ #ifndef org_apache_arrow_flatbuf_List_identifier #define org_apache_arrow_flatbuf_List_identifier 0 #endif #define org_apache_arrow_flatbuf_List_type_hash ((flatbuffers_thash_t)0xd4ce5878) #define org_apache_arrow_flatbuf_List_type_identifier "\x78\x58\xce\xd4" #ifndef org_apache_arrow_flatbuf_List_file_extension #define org_apache_arrow_flatbuf_List_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeList_file_identifier #define org_apache_arrow_flatbuf_LargeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeList_identifier #define org_apache_arrow_flatbuf_LargeList_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeList_type_hash ((flatbuffers_thash_t)0x38aa7e27) #define org_apache_arrow_flatbuf_LargeList_type_identifier "\x27\x7e\xaa\x38" #ifndef org_apache_arrow_flatbuf_LargeList_file_extension #define org_apache_arrow_flatbuf_LargeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_ListView_file_identifier #define org_apache_arrow_flatbuf_ListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_ListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_ListView_identifier #define org_apache_arrow_flatbuf_ListView_identifier 0 #endif #define org_apache_arrow_flatbuf_ListView_type_hash ((flatbuffers_thash_t)0x23d37919) #define org_apache_arrow_flatbuf_ListView_type_identifier "\x19\x79\xd3\x23" #ifndef org_apache_arrow_flatbuf_ListView_file_extension #define org_apache_arrow_flatbuf_ListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeListView_file_identifier #define org_apache_arrow_flatbuf_LargeListView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeListView_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeListView_identifier #define org_apache_arrow_flatbuf_LargeListView_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeListView_type_hash ((flatbuffers_thash_t)0x28efac02) #define org_apache_arrow_flatbuf_LargeListView_type_identifier "\x02\xac\xef\x28" #ifndef org_apache_arrow_flatbuf_LargeListView_file_extension #define org_apache_arrow_flatbuf_LargeListView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_identifier #define org_apache_arrow_flatbuf_FixedSizeList_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeList_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeList_identifier #define org_apache_arrow_flatbuf_FixedSizeList_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeList_type_hash ((flatbuffers_thash_t)0xcef245bb) #define org_apache_arrow_flatbuf_FixedSizeList_type_identifier "\xbb\x45\xf2\xce" #ifndef org_apache_arrow_flatbuf_FixedSizeList_file_extension #define org_apache_arrow_flatbuf_FixedSizeList_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Map_file_identifier #define org_apache_arrow_flatbuf_Map_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Map_file_identifier */ #ifndef org_apache_arrow_flatbuf_Map_identifier #define org_apache_arrow_flatbuf_Map_identifier 0 #endif #define org_apache_arrow_flatbuf_Map_type_hash ((flatbuffers_thash_t)0xcebef8e6) #define org_apache_arrow_flatbuf_Map_type_identifier "\xe6\xf8\xbe\xce" #ifndef org_apache_arrow_flatbuf_Map_file_extension #define org_apache_arrow_flatbuf_Map_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Union_file_identifier #define org_apache_arrow_flatbuf_Union_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Union_file_identifier */ #ifndef org_apache_arrow_flatbuf_Union_identifier #define org_apache_arrow_flatbuf_Union_identifier 0 #endif #define org_apache_arrow_flatbuf_Union_type_hash ((flatbuffers_thash_t)0x896bda57) #define org_apache_arrow_flatbuf_Union_type_identifier "\x57\xda\x6b\x89" #ifndef org_apache_arrow_flatbuf_Union_file_extension #define org_apache_arrow_flatbuf_Union_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Int_file_identifier #define org_apache_arrow_flatbuf_Int_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Int_file_identifier */ #ifndef org_apache_arrow_flatbuf_Int_identifier #define org_apache_arrow_flatbuf_Int_identifier 0 #endif #define org_apache_arrow_flatbuf_Int_type_hash ((flatbuffers_thash_t)0x30789001) #define org_apache_arrow_flatbuf_Int_type_identifier "\x01\x90\x78\x30" #ifndef org_apache_arrow_flatbuf_Int_file_extension #define org_apache_arrow_flatbuf_Int_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_identifier #define org_apache_arrow_flatbuf_FloatingPoint_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FloatingPoint_file_identifier */ #ifndef org_apache_arrow_flatbuf_FloatingPoint_identifier #define org_apache_arrow_flatbuf_FloatingPoint_identifier 0 #endif #define org_apache_arrow_flatbuf_FloatingPoint_type_hash ((flatbuffers_thash_t)0xf7d06268) #define org_apache_arrow_flatbuf_FloatingPoint_type_identifier "\x68\x62\xd0\xf7" #ifndef org_apache_arrow_flatbuf_FloatingPoint_file_extension #define org_apache_arrow_flatbuf_FloatingPoint_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8_file_identifier #define org_apache_arrow_flatbuf_Utf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8_identifier #define org_apache_arrow_flatbuf_Utf8_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8_type_hash ((flatbuffers_thash_t)0x8fe60d37) #define org_apache_arrow_flatbuf_Utf8_type_identifier "\x37\x0d\xe6\x8f" #ifndef org_apache_arrow_flatbuf_Utf8_file_extension #define org_apache_arrow_flatbuf_Utf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Binary_file_identifier #define org_apache_arrow_flatbuf_Binary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Binary_file_identifier */ #ifndef org_apache_arrow_flatbuf_Binary_identifier #define org_apache_arrow_flatbuf_Binary_identifier 0 #endif #define org_apache_arrow_flatbuf_Binary_type_hash ((flatbuffers_thash_t)0x8e21a795) #define org_apache_arrow_flatbuf_Binary_type_identifier "\x95\xa7\x21\x8e" #ifndef org_apache_arrow_flatbuf_Binary_file_extension #define org_apache_arrow_flatbuf_Binary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_identifier #define org_apache_arrow_flatbuf_LargeUtf8_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeUtf8_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeUtf8_identifier #define org_apache_arrow_flatbuf_LargeUtf8_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeUtf8_type_hash ((flatbuffers_thash_t)0x24ed2fb0) #define org_apache_arrow_flatbuf_LargeUtf8_type_identifier "\xb0\x2f\xed\x24" #ifndef org_apache_arrow_flatbuf_LargeUtf8_file_extension #define org_apache_arrow_flatbuf_LargeUtf8_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_LargeBinary_file_identifier #define org_apache_arrow_flatbuf_LargeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_LargeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_LargeBinary_identifier #define org_apache_arrow_flatbuf_LargeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_LargeBinary_type_hash ((flatbuffers_thash_t)0xbd437872) #define org_apache_arrow_flatbuf_LargeBinary_type_identifier "\x72\x78\x43\xbd" #ifndef org_apache_arrow_flatbuf_LargeBinary_file_extension #define org_apache_arrow_flatbuf_LargeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Utf8View_file_identifier #define org_apache_arrow_flatbuf_Utf8View_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Utf8View_file_identifier */ #ifndef org_apache_arrow_flatbuf_Utf8View_identifier #define org_apache_arrow_flatbuf_Utf8View_identifier 0 #endif #define org_apache_arrow_flatbuf_Utf8View_type_hash ((flatbuffers_thash_t)0xab7692) #define org_apache_arrow_flatbuf_Utf8View_type_identifier "\x92\x76\xab\x00" #ifndef org_apache_arrow_flatbuf_Utf8View_file_extension #define org_apache_arrow_flatbuf_Utf8View_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_BinaryView_file_identifier #define org_apache_arrow_flatbuf_BinaryView_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_BinaryView_file_identifier */ #ifndef org_apache_arrow_flatbuf_BinaryView_identifier #define org_apache_arrow_flatbuf_BinaryView_identifier 0 #endif #define org_apache_arrow_flatbuf_BinaryView_type_hash ((flatbuffers_thash_t)0x18c52428) #define org_apache_arrow_flatbuf_BinaryView_type_identifier "\x28\x24\xc5\x18" #ifndef org_apache_arrow_flatbuf_BinaryView_file_extension #define org_apache_arrow_flatbuf_BinaryView_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier */ #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_identifier #define org_apache_arrow_flatbuf_FixedSizeBinary_identifier 0 #endif #define org_apache_arrow_flatbuf_FixedSizeBinary_type_hash ((flatbuffers_thash_t)0x80d0f4ce) #define org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier "\xce\xf4\xd0\x80" #ifndef org_apache_arrow_flatbuf_FixedSizeBinary_file_extension #define org_apache_arrow_flatbuf_FixedSizeBinary_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Bool_file_identifier #define org_apache_arrow_flatbuf_Bool_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Bool_file_identifier */ #ifndef org_apache_arrow_flatbuf_Bool_identifier #define org_apache_arrow_flatbuf_Bool_identifier 0 #endif #define org_apache_arrow_flatbuf_Bool_type_hash ((flatbuffers_thash_t)0x96bf83f0) #define org_apache_arrow_flatbuf_Bool_type_identifier "\xf0\x83\xbf\x96" #ifndef org_apache_arrow_flatbuf_Bool_file_extension #define org_apache_arrow_flatbuf_Bool_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_RunEndEncoded_file_identifier */ #ifndef org_apache_arrow_flatbuf_RunEndEncoded_identifier #define org_apache_arrow_flatbuf_RunEndEncoded_identifier 0 #endif #define org_apache_arrow_flatbuf_RunEndEncoded_type_hash ((flatbuffers_thash_t)0x5a98bcc) #define org_apache_arrow_flatbuf_RunEndEncoded_type_identifier "\xcc\x8b\xa9\x05" #ifndef org_apache_arrow_flatbuf_RunEndEncoded_file_extension #define org_apache_arrow_flatbuf_RunEndEncoded_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Decimal_file_identifier #define org_apache_arrow_flatbuf_Decimal_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Decimal_file_identifier */ #ifndef org_apache_arrow_flatbuf_Decimal_identifier #define org_apache_arrow_flatbuf_Decimal_identifier 0 #endif #define org_apache_arrow_flatbuf_Decimal_type_hash ((flatbuffers_thash_t)0x91d1beb7) #define org_apache_arrow_flatbuf_Decimal_type_identifier "\xb7\xbe\xd1\x91" #ifndef org_apache_arrow_flatbuf_Decimal_file_extension #define org_apache_arrow_flatbuf_Decimal_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Date_file_identifier #define org_apache_arrow_flatbuf_Date_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Date_file_identifier */ #ifndef org_apache_arrow_flatbuf_Date_identifier #define org_apache_arrow_flatbuf_Date_identifier 0 #endif #define org_apache_arrow_flatbuf_Date_type_hash ((flatbuffers_thash_t)0xe0ccf624) #define org_apache_arrow_flatbuf_Date_type_identifier "\x24\xf6\xcc\xe0" #ifndef org_apache_arrow_flatbuf_Date_file_extension #define org_apache_arrow_flatbuf_Date_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Time_file_identifier #define org_apache_arrow_flatbuf_Time_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Time_file_identifier */ #ifndef org_apache_arrow_flatbuf_Time_identifier #define org_apache_arrow_flatbuf_Time_identifier 0 #endif #define org_apache_arrow_flatbuf_Time_type_hash ((flatbuffers_thash_t)0x2442a489) #define org_apache_arrow_flatbuf_Time_type_identifier "\x89\xa4\x42\x24" #ifndef org_apache_arrow_flatbuf_Time_file_extension #define org_apache_arrow_flatbuf_Time_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Timestamp_file_identifier #define org_apache_arrow_flatbuf_Timestamp_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Timestamp_file_identifier */ #ifndef org_apache_arrow_flatbuf_Timestamp_identifier #define org_apache_arrow_flatbuf_Timestamp_identifier 0 #endif #define org_apache_arrow_flatbuf_Timestamp_type_hash ((flatbuffers_thash_t)0x1fddf080) #define org_apache_arrow_flatbuf_Timestamp_type_identifier "\x80\xf0\xdd\x1f" #ifndef org_apache_arrow_flatbuf_Timestamp_file_extension #define org_apache_arrow_flatbuf_Timestamp_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Interval_file_identifier #define org_apache_arrow_flatbuf_Interval_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Interval_file_identifier */ #ifndef org_apache_arrow_flatbuf_Interval_identifier #define org_apache_arrow_flatbuf_Interval_identifier 0 #endif #define org_apache_arrow_flatbuf_Interval_type_hash ((flatbuffers_thash_t)0x1e2d6809) #define org_apache_arrow_flatbuf_Interval_type_identifier "\x09\x68\x2d\x1e" #ifndef org_apache_arrow_flatbuf_Interval_file_extension #define org_apache_arrow_flatbuf_Interval_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Duration_file_identifier #define org_apache_arrow_flatbuf_Duration_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Duration_file_identifier */ #ifndef org_apache_arrow_flatbuf_Duration_identifier #define org_apache_arrow_flatbuf_Duration_identifier 0 #endif #define org_apache_arrow_flatbuf_Duration_type_hash ((flatbuffers_thash_t)0x1ecea6b0) #define org_apache_arrow_flatbuf_Duration_type_identifier "\xb0\xa6\xce\x1e" #ifndef org_apache_arrow_flatbuf_Duration_file_extension #define org_apache_arrow_flatbuf_Duration_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_KeyValue_file_identifier #define org_apache_arrow_flatbuf_KeyValue_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_KeyValue_file_identifier */ #ifndef org_apache_arrow_flatbuf_KeyValue_identifier #define org_apache_arrow_flatbuf_KeyValue_identifier 0 #endif #define org_apache_arrow_flatbuf_KeyValue_type_hash ((flatbuffers_thash_t)0x3b264744) #define org_apache_arrow_flatbuf_KeyValue_type_identifier "\x44\x47\x26\x3b" #ifndef org_apache_arrow_flatbuf_KeyValue_file_extension #define org_apache_arrow_flatbuf_KeyValue_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier */ #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_identifier #define org_apache_arrow_flatbuf_DictionaryEncoding_identifier 0 #endif #define org_apache_arrow_flatbuf_DictionaryEncoding_type_hash ((flatbuffers_thash_t)0x8c703261) #define org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier "\x61\x32\x70\x8c" #ifndef org_apache_arrow_flatbuf_DictionaryEncoding_file_extension #define org_apache_arrow_flatbuf_DictionaryEncoding_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Field_file_identifier #define org_apache_arrow_flatbuf_Field_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Field_file_identifier */ #ifndef org_apache_arrow_flatbuf_Field_identifier #define org_apache_arrow_flatbuf_Field_identifier 0 #endif #define org_apache_arrow_flatbuf_Field_type_hash ((flatbuffers_thash_t)0xd981525c) #define org_apache_arrow_flatbuf_Field_type_identifier "\x5c\x52\x81\xd9" #ifndef org_apache_arrow_flatbuf_Field_file_extension #define org_apache_arrow_flatbuf_Field_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Buffer_file_identifier #define org_apache_arrow_flatbuf_Buffer_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Buffer_file_identifier */ #ifndef org_apache_arrow_flatbuf_Buffer_identifier #define org_apache_arrow_flatbuf_Buffer_identifier 0 #endif #define org_apache_arrow_flatbuf_Buffer_type_hash ((flatbuffers_thash_t)0x519d7fea) #define org_apache_arrow_flatbuf_Buffer_type_identifier "\xea\x7f\x9d\x51" #ifndef org_apache_arrow_flatbuf_Buffer_file_extension #define org_apache_arrow_flatbuf_Buffer_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Schema_file_identifier #define org_apache_arrow_flatbuf_Schema_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Schema_file_identifier */ #ifndef org_apache_arrow_flatbuf_Schema_identifier #define org_apache_arrow_flatbuf_Schema_identifier 0 #endif #define org_apache_arrow_flatbuf_Schema_type_hash ((flatbuffers_thash_t)0x406570b) #define org_apache_arrow_flatbuf_Schema_type_identifier "\x0b\x57\x06\x04" #ifndef org_apache_arrow_flatbuf_Schema_file_extension #define org_apache_arrow_flatbuf_Schema_file_extension "bin" #endif typedef int16_t org_apache_arrow_flatbuf_MetadataVersion_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t, 16) /** 0.1.0 (October 2016). */ #define org_apache_arrow_flatbuf_MetadataVersion_V1 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_MetadataVersion_V2 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_MetadataVersion_V3 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_MetadataVersion_V4 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(3)) #define org_apache_arrow_flatbuf_MetadataVersion_V5 ((org_apache_arrow_flatbuf_MetadataVersion_enum_t)INT16_C(4)) static inline const char *org_apache_arrow_flatbuf_MetadataVersion_name(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return "V1"; case org_apache_arrow_flatbuf_MetadataVersion_V2: return "V2"; case org_apache_arrow_flatbuf_MetadataVersion_V3: return "V3"; case org_apache_arrow_flatbuf_MetadataVersion_V4: return "V4"; case org_apache_arrow_flatbuf_MetadataVersion_V5: return "V5"; default: return ""; } } static inline int org_apache_arrow_flatbuf_MetadataVersion_is_known_value(org_apache_arrow_flatbuf_MetadataVersion_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_MetadataVersion_V1: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V2: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V3: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V4: return 1; case org_apache_arrow_flatbuf_MetadataVersion_V5: return 1; default: return 0; } } /** Represents Arrow Features that might not have full support * within implementations. This is intended to be used in * two scenarios: * 1. A mechanism for readers of Arrow Streams * and files to understand that the stream or file makes * use of a feature that isn't supported or unknown to * the implementation (and therefore can meet the Arrow * forward compatibility guarantees). * 2. A means of negotiating between a client and server * what features a stream is allowed to use. The enums * values here are intented to represent higher level * features, additional details maybe negotiated * with key-value pairs specific to the protocol. * * Enums added to this list should be assigned power-of-two values * to facilitate exchanging and comparing bitmaps for supported * features. */ typedef int64_t org_apache_arrow_flatbuf_Feature_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, 64) /** Needed to make flatbuffers happy. */ #define org_apache_arrow_flatbuf_Feature_UNUSED ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(0)) #define org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(1)) #define org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY ((org_apache_arrow_flatbuf_Feature_enum_t)INT64_C(2)) static inline const char *org_apache_arrow_flatbuf_Feature_name(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return "UNUSED"; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return "DICTIONARY_REPLACEMENT"; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return "COMPRESSED_BODY"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Feature_is_known_value(org_apache_arrow_flatbuf_Feature_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Feature_UNUSED: return 1; case org_apache_arrow_flatbuf_Feature_DICTIONARY_REPLACEMENT: return 1; case org_apache_arrow_flatbuf_Feature_COMPRESSED_BODY: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_UnionMode_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 16) #define org_apache_arrow_flatbuf_UnionMode_Sparse ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_UnionMode_Dense ((org_apache_arrow_flatbuf_UnionMode_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_UnionMode_name(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return "Sparse"; case org_apache_arrow_flatbuf_UnionMode_Dense: return "Dense"; default: return ""; } } static inline int org_apache_arrow_flatbuf_UnionMode_is_known_value(org_apache_arrow_flatbuf_UnionMode_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_UnionMode_Sparse: return 1; case org_apache_arrow_flatbuf_UnionMode_Dense: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_Precision_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 16) #define org_apache_arrow_flatbuf_Precision_HALF ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Precision_SINGLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_Precision_DOUBLE ((org_apache_arrow_flatbuf_Precision_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_Precision_name(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return "HALF"; case org_apache_arrow_flatbuf_Precision_SINGLE: return "SINGLE"; case org_apache_arrow_flatbuf_Precision_DOUBLE: return "DOUBLE"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Precision_is_known_value(org_apache_arrow_flatbuf_Precision_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Precision_HALF: return 1; case org_apache_arrow_flatbuf_Precision_SINGLE: return 1; case org_apache_arrow_flatbuf_Precision_DOUBLE: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_DateUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 16) #define org_apache_arrow_flatbuf_DateUnit_DAY ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_DateUnit_MILLISECOND ((org_apache_arrow_flatbuf_DateUnit_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_DateUnit_name(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return "DAY"; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return "MILLISECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DateUnit_is_known_value(org_apache_arrow_flatbuf_DateUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DateUnit_DAY: return 1; case org_apache_arrow_flatbuf_DateUnit_MILLISECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_TimeUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 16) #define org_apache_arrow_flatbuf_TimeUnit_SECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_TimeUnit_MILLISECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_TimeUnit_MICROSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(2)) #define org_apache_arrow_flatbuf_TimeUnit_NANOSECOND ((org_apache_arrow_flatbuf_TimeUnit_enum_t)INT16_C(3)) static inline const char *org_apache_arrow_flatbuf_TimeUnit_name(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return "SECOND"; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return "MILLISECOND"; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return "MICROSECOND"; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return "NANOSECOND"; default: return ""; } } static inline int org_apache_arrow_flatbuf_TimeUnit_is_known_value(org_apache_arrow_flatbuf_TimeUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_TimeUnit_SECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MILLISECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_MICROSECOND: return 1; case org_apache_arrow_flatbuf_TimeUnit_NANOSECOND: return 1; default: return 0; } } typedef int16_t org_apache_arrow_flatbuf_IntervalUnit_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 16) #define org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(1)) #define org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO ((org_apache_arrow_flatbuf_IntervalUnit_enum_t)INT16_C(2)) static inline const char *org_apache_arrow_flatbuf_IntervalUnit_name(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return "YEAR_MONTH"; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return "DAY_TIME"; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return "MONTH_DAY_NANO"; default: return ""; } } static inline int org_apache_arrow_flatbuf_IntervalUnit_is_known_value(org_apache_arrow_flatbuf_IntervalUnit_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_IntervalUnit_YEAR_MONTH: return 1; case org_apache_arrow_flatbuf_IntervalUnit_DAY_TIME: return 1; case org_apache_arrow_flatbuf_IntervalUnit_MONTH_DAY_NANO: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Dictionary encoding metadata * Maintained for forwards compatibility, in the future * Dictionaries might be explicit maps between integers and values * allowing for non-contiguous index values */ typedef int16_t org_apache_arrow_flatbuf_DictionaryKind_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 16) #define org_apache_arrow_flatbuf_DictionaryKind_DenseArray ((org_apache_arrow_flatbuf_DictionaryKind_enum_t)INT16_C(0)) static inline const char *org_apache_arrow_flatbuf_DictionaryKind_name(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return "DenseArray"; default: return ""; } } static inline int org_apache_arrow_flatbuf_DictionaryKind_is_known_value(org_apache_arrow_flatbuf_DictionaryKind_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_DictionaryKind_DenseArray: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * Endianness of the platform producing the data */ typedef int16_t org_apache_arrow_flatbuf_Endianness_enum_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 16) #define org_apache_arrow_flatbuf_Endianness_Little ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(0)) #define org_apache_arrow_flatbuf_Endianness_Big ((org_apache_arrow_flatbuf_Endianness_enum_t)INT16_C(1)) static inline const char *org_apache_arrow_flatbuf_Endianness_name(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return "Little"; case org_apache_arrow_flatbuf_Endianness_Big: return "Big"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Endianness_is_known_value(org_apache_arrow_flatbuf_Endianness_enum_t value) { switch (value) { case org_apache_arrow_flatbuf_Endianness_Little: return 1; case org_apache_arrow_flatbuf_Endianness_Big: return 1; default: return 0; } } /** ---------------------------------------------------------------------- * A Buffer represents a single contiguous memory segment */ struct org_apache_arrow_flatbuf_Buffer { /** The relative offset into the shared memory page where the bytes for this * buffer starts */ alignas(8) int64_t offset; /** The absolute length (in bytes) of the memory buffer. The memory is found * from offset (inclusive) to offset + length (non-inclusive). When building * messages using the encapsulated IPC message, padding bytes may be written * after a buffer, but such padding bytes do not need to be accounted for in * the size here. */ alignas(8) int64_t length; }; static_assert(sizeof(org_apache_arrow_flatbuf_Buffer_t) == 16, "struct size mismatch"); static inline const org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__const_ptr_add(const org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer__ptr_add(org_apache_arrow_flatbuf_Buffer_t *p, size_t i) { return p + i; } static inline org_apache_arrow_flatbuf_Buffer_struct_t org_apache_arrow_flatbuf_Buffer_vec_at(org_apache_arrow_flatbuf_Buffer_vec_t vec, size_t i) __flatbuffers_struct_vec_at(vec, i) static inline size_t org_apache_arrow_flatbuf_Buffer__size(void) { return 16; } static inline size_t org_apache_arrow_flatbuf_Buffer_vec_len(org_apache_arrow_flatbuf_Buffer_vec_t vec) __flatbuffers_vec_len(vec) __flatbuffers_struct_as_root(org_apache_arrow_flatbuf_Buffer) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, offset, flatbuffers_int64, int64_t) __flatbuffers_define_struct_scalar_field(org_apache_arrow_flatbuf_Buffer, length, flatbuffers_int64, int64_t) /** These are stored in the flatbuffer in the Type union below */ struct org_apache_arrow_flatbuf_Null_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Null_vec_len(org_apache_arrow_flatbuf_Null_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Null_table_t org_apache_arrow_flatbuf_Null_vec_at(org_apache_arrow_flatbuf_Null_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Null_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Null) /** A Struct_ in the flatbuffer metadata is the same as an Arrow Struct * (according to the physical memory layout). We used Struct_ here as * Struct is a reserved word in Flatbuffers */ struct org_apache_arrow_flatbuf_Struct__table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Struct__vec_len(org_apache_arrow_flatbuf_Struct__vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Struct__table_t org_apache_arrow_flatbuf_Struct__vec_at(org_apache_arrow_flatbuf_Struct__vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Struct__table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Struct_) struct org_apache_arrow_flatbuf_List_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_List_vec_len(org_apache_arrow_flatbuf_List_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_List_table_t org_apache_arrow_flatbuf_List_vec_at(org_apache_arrow_flatbuf_List_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_List_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_List) /** Same as List, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeList_vec_len(org_apache_arrow_flatbuf_LargeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeList_table_t org_apache_arrow_flatbuf_LargeList_vec_at(org_apache_arrow_flatbuf_LargeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeList) /** Represents the same logical types that List can, but contains offsets and * sizes allowing for writes in any order and sharing of child values among * list values. */ struct org_apache_arrow_flatbuf_ListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_ListView_vec_len(org_apache_arrow_flatbuf_ListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_ListView_table_t org_apache_arrow_flatbuf_ListView_vec_at(org_apache_arrow_flatbuf_ListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_ListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_ListView) /** Same as ListView, but with 64-bit offsets and sizes, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeListView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeListView_vec_len(org_apache_arrow_flatbuf_LargeListView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeListView_table_t org_apache_arrow_flatbuf_LargeListView_vec_at(org_apache_arrow_flatbuf_LargeListView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeListView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeListView) struct org_apache_arrow_flatbuf_FixedSizeList_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeList_vec_len(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeList_table_t org_apache_arrow_flatbuf_FixedSizeList_vec_at(org_apache_arrow_flatbuf_FixedSizeList_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeList_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeList) /** Number of list items per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeList, listSize, flatbuffers_int32, int32_t, INT32_C(0)) /** A Map is a logical nested type that is represented as * * List> * * In this layout, the keys and values are each respectively contiguous. We do * not constrain the key and value types, so the application is responsible * for ensuring that the keys are hashable and unique. Whether the keys are sorted * may be set in the metadata for this field. * * In a field with Map type, the field has a child Struct field, which then * has two children: key type and the second the value type. The names of the * child fields may be respectively "entries", "key", and "value", but this is * not enforced. * * Map * ```text * - child[0] entries: Struct * - child[0] key: K * - child[1] value: V * ``` * Neither the "entries" field nor the "key" field may be nullable. * * The metadata is structured so that Arrow systems without special handling * for Map can make Map an alias for List. The "layout" attribute for the Map * field must have the same contents as a List. */ struct org_apache_arrow_flatbuf_Map_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Map_vec_len(org_apache_arrow_flatbuf_Map_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Map_table_t org_apache_arrow_flatbuf_Map_vec_at(org_apache_arrow_flatbuf_Map_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Map_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Map) /** Set to true if the keys within each value are sorted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Map, keysSorted, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** A union is a complex type with children in Field * By default ids in the type vector refer to the offsets in the children * optionally typeIds provides an indirection between the child offset and the type id * for each child `typeIds[offset]` is the id used in the type vector */ struct org_apache_arrow_flatbuf_Union_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Union_vec_len(org_apache_arrow_flatbuf_Union_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Union_table_t org_apache_arrow_flatbuf_Union_vec_at(org_apache_arrow_flatbuf_Union_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Union_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Union) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Union, mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Union, typeIds, flatbuffers_int32_vec_t, 0) struct org_apache_arrow_flatbuf_Int_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Int_vec_len(org_apache_arrow_flatbuf_Int_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Int_table_t org_apache_arrow_flatbuf_Int_vec_at(org_apache_arrow_flatbuf_Int_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Int_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Int) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Int, bitWidth, flatbuffers_int32, int32_t, INT32_C(0)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Int, is_signed, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) struct org_apache_arrow_flatbuf_FloatingPoint_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FloatingPoint_vec_len(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FloatingPoint_table_t org_apache_arrow_flatbuf_FloatingPoint_vec_at(org_apache_arrow_flatbuf_FloatingPoint_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FloatingPoint_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FloatingPoint, precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, INT16_C(0)) /** Unicode with UTF-8 encoding */ struct org_apache_arrow_flatbuf_Utf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8_vec_len(org_apache_arrow_flatbuf_Utf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8_table_t org_apache_arrow_flatbuf_Utf8_vec_at(org_apache_arrow_flatbuf_Utf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8) /** Opaque binary data */ struct org_apache_arrow_flatbuf_Binary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Binary_vec_len(org_apache_arrow_flatbuf_Binary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Binary_table_t org_apache_arrow_flatbuf_Binary_vec_at(org_apache_arrow_flatbuf_Binary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Binary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Binary) /** Same as Utf8, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeUtf8_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeUtf8_vec_len(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeUtf8_table_t org_apache_arrow_flatbuf_LargeUtf8_vec_at(org_apache_arrow_flatbuf_LargeUtf8_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeUtf8_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeUtf8) /** Same as Binary, but with 64-bit offsets, allowing to represent * extremely large data values. */ struct org_apache_arrow_flatbuf_LargeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_LargeBinary_vec_len(org_apache_arrow_flatbuf_LargeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_LargeBinary_table_t org_apache_arrow_flatbuf_LargeBinary_vec_at(org_apache_arrow_flatbuf_LargeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_LargeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_LargeBinary) /** Logically the same as Utf8, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_Utf8View_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Utf8View_vec_len(org_apache_arrow_flatbuf_Utf8View_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Utf8View_table_t org_apache_arrow_flatbuf_Utf8View_vec_at(org_apache_arrow_flatbuf_Utf8View_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Utf8View_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Utf8View) /** Logically the same as Binary, but the internal representation uses a view * struct that contains the string length and either the string's entire data * inline (for small strings) or an inlined prefix, an index of another buffer, * and an offset pointing to a slice in that buffer (for non-small strings). * * Since it uses a variable number of data buffers, each Field with this type * must have a corresponding entry in `variadicBufferCounts`. */ struct org_apache_arrow_flatbuf_BinaryView_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_BinaryView_vec_len(org_apache_arrow_flatbuf_BinaryView_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_BinaryView_table_t org_apache_arrow_flatbuf_BinaryView_vec_at(org_apache_arrow_flatbuf_BinaryView_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_BinaryView_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_BinaryView) struct org_apache_arrow_flatbuf_FixedSizeBinary_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_len(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_FixedSizeBinary_table_t org_apache_arrow_flatbuf_FixedSizeBinary_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_FixedSizeBinary_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_FixedSizeBinary) /** Number of bytes per value */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_FixedSizeBinary, byteWidth, flatbuffers_int32, int32_t, INT32_C(0)) struct org_apache_arrow_flatbuf_Bool_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Bool_vec_len(org_apache_arrow_flatbuf_Bool_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Bool_table_t org_apache_arrow_flatbuf_Bool_vec_at(org_apache_arrow_flatbuf_Bool_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Bool_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Bool) /** Contains two child arrays, run_ends and values. * The run_ends child array must be a 16/32/64-bit integer array * which encodes the indices at which the run with the value in * each corresponding index in the values child array ends. * Like list/struct types, the value array can be of any type. */ struct org_apache_arrow_flatbuf_RunEndEncoded_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_RunEndEncoded_vec_len(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_RunEndEncoded_table_t org_apache_arrow_flatbuf_RunEndEncoded_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_RunEndEncoded_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_RunEndEncoded) /** Exact decimal value represented as an integer value in two's * complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers * are used. The representation uses the endianness indicated * in the Schema. */ struct org_apache_arrow_flatbuf_Decimal_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Decimal_vec_len(org_apache_arrow_flatbuf_Decimal_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Decimal_table_t org_apache_arrow_flatbuf_Decimal_vec_at(org_apache_arrow_flatbuf_Decimal_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Decimal_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Decimal) /** Total number of decimal digits */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Decimal, precision, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of digits after the decimal point "." */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Decimal, scale, flatbuffers_int32, int32_t, INT32_C(0)) /** Number of bits per value. The only accepted widths are 128 and 256. * We use bitWidth for consistency with Int::bitWidth. */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_Decimal, bitWidth, flatbuffers_int32, int32_t, INT32_C(128)) /** Date is either a 32-bit or 64-bit signed integer type representing an * elapsed time since UNIX epoch (1970-01-01), stored in either of two units: * * * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no * leap seconds), where the values are evenly divisible by 86400000 * * Days (32 bits) since the UNIX epoch */ struct org_apache_arrow_flatbuf_Date_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Date_vec_len(org_apache_arrow_flatbuf_Date_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Date_table_t org_apache_arrow_flatbuf_Date_vec_at(org_apache_arrow_flatbuf_Date_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Date_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Date) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Date, unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, INT16_C(1)) /** Time is either a 32-bit or 64-bit signed integer type representing an * elapsed time since midnight, stored in either of four units: seconds, * milliseconds, microseconds or nanoseconds. * * The integer `bitWidth` depends on the `unit` and must be one of the following: * * SECOND and MILLISECOND: 32 bits * * MICROSECOND and NANOSECOND: 64 bits * * The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds * (exclusive), adjusted for the time unit (for example, up to 86400000 * exclusive for the MILLISECOND unit). * This definition doesn't allow for leap seconds. Time values from * measurements with leap seconds will need to be corrected when ingesting * into Arrow (for example by replacing the value 86400 with 86399). */ struct org_apache_arrow_flatbuf_Time_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Time_vec_len(org_apache_arrow_flatbuf_Time_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Time_table_t org_apache_arrow_flatbuf_Time_vec_at(org_apache_arrow_flatbuf_Time_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Time_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Time) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Time, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Time, bitWidth, flatbuffers_int32, int32_t, INT32_C(32)) /** Timestamp is a 64-bit signed integer representing an elapsed time since a * fixed epoch, stored in either of four units: seconds, milliseconds, * microseconds or nanoseconds, and is optionally annotated with a timezone. * * Timestamp values do not include any leap seconds (in other words, all * days are considered 86400 seconds long). * * Timestamps with a non-empty timezone * ------------------------------------ * * If a Timestamp column has a non-empty timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone * (the Unix epoch), regardless of the Timestamp's own timezone. * * Therefore, timestamp values with a non-empty timezone correspond to * physical points in time together with some additional information about * how the data was obtained and/or how to display it (the timezone). * * For example, the timestamp value 0 with the timezone string "Europe/Paris" * corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the * application may prefer to display it as "January 1st 1970, 01h00" in * the Europe/Paris timezone (which is the same physical point in time). * * One consequence is that timestamp values with a non-empty timezone * can be compared and ordered directly, since they all share the same * well-known point of reference (the Unix epoch). * * Timestamps with an unset / empty timezone * ----------------------------------------- * * If a Timestamp column has no timezone value, its epoch is * 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone. * * Therefore, timestamp values without a timezone cannot be meaningfully * interpreted as physical points in time, but only as calendar / clock * indications ("wall clock time") in an unspecified timezone. * * For example, the timestamp value 0 with an empty timezone string * corresponds to "January 1st 1970, 00h00" in an unknown timezone: there * is not enough information to interpret it as a well-defined physical * point in time. * * One consequence is that timestamp values without a timezone cannot * be reliably compared or ordered, since they may have different points of * reference. In particular, it is *not* possible to interpret an unset * or empty timezone as the same as "UTC". * * Conversion between timezones * ---------------------------- * * If a Timestamp column has a non-empty timezone, changing the timezone * to a different non-empty value is a metadata-only operation: * the timestamp values need not change as their point of reference remains * the same (the Unix epoch). * * However, if a Timestamp column has no timezone value, changing it to a * non-empty value requires to think about the desired semantics. * One possibility is to assume that the original timestamp values are * relative to the epoch of the timezone being set; timestamp values should * then adjusted to the Unix epoch (for example, changing the timezone from * empty to "Europe/Paris" would require converting the timestamp values * from "Europe/Paris" to "UTC", which seems counter-intuitive but is * nevertheless correct). * * Guidelines for encoding data from external libraries * ---------------------------------------------------- * * Date & time libraries often have multiple different data types for temporal * data. In order to ease interoperability between different implementations the * Arrow project has some recommendations for encoding these types into a Timestamp * column. * * An "instant" represents a physical point in time that has no relevant timezone * (for example, astronomical data). To encode an instant, use a Timestamp with * the timezone string set to "UTC", and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * A "zoned date-time" represents a physical point in time annotated with an * informative timezone (for example, the timezone in which the data was * recorded). To encode a zoned date-time, use a Timestamp with the timezone * string set to the name of the timezone, and make sure the Timestamp values * are relative to the UTC epoch (January 1st 1970, midnight). * * (There is some ambiguity between an instant and a zoned date-time with the * UTC timezone. Both of these are stored the same in Arrow. Typically, * this distinction does not matter. If it does, then an application should * use custom metadata or an extension type to distinguish between the two cases.) * * An "offset date-time" represents a physical point in time combined with an * explicit offset from UTC. To encode an offset date-time, use a Timestamp * with the timezone string set to the numeric timezone offset string * (e.g. "+03:00"), and make sure the Timestamp values are relative to * the UTC epoch (January 1st 1970, midnight). * * A "naive date-time" (also called "local date-time" in some libraries) * represents a wall clock time combined with a calendar date, but with * no indication of how to map this information to a physical point in time. * Naive date-times must be handled with care because of this missing * information, and also because daylight saving time (DST) may make * some values ambiguous or nonexistent. A naive date-time may be * stored as a struct with Date and Time fields. However, it may also be * encoded into a Timestamp column with an empty timezone. The timestamp * values should be computed "as if" the timezone of the date-time values * was UTC; for example, the naive date-time "January 1st 1970, 00h00" would * be encoded as timestamp value 0. */ struct org_apache_arrow_flatbuf_Timestamp_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Timestamp_vec_len(org_apache_arrow_flatbuf_Timestamp_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Timestamp_table_t org_apache_arrow_flatbuf_Timestamp_vec_at(org_apache_arrow_flatbuf_Timestamp_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Timestamp_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Timestamp) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Timestamp, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(0)) /** The timezone is an optional string indicating the name of a timezone, * one of: * * * As used in the Olson timezone database (the "tz database" or * "tzdata"), such as "America/New_York". * * An absolute timezone offset of the form "+XX:XX" or "-XX:XX", * such as "+07:30". * * Whether a timezone string is present indicates different semantics about * the data (see above). */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_Timestamp, timezone, 0) struct org_apache_arrow_flatbuf_Interval_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Interval_vec_len(org_apache_arrow_flatbuf_Interval_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Interval_table_t org_apache_arrow_flatbuf_Interval_vec_at(org_apache_arrow_flatbuf_Interval_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Interval_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Interval) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Interval, unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, INT16_C(0)) struct org_apache_arrow_flatbuf_Duration_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Duration_vec_len(org_apache_arrow_flatbuf_Duration_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Duration_table_t org_apache_arrow_flatbuf_Duration_vec_at(org_apache_arrow_flatbuf_Duration_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Duration_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Duration) __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Duration, unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, INT16_C(1)) /** ---------------------------------------------------------------------- * Top-level Type value, enabling extensible type-specific metadata. We can * add new logical types to Type without breaking backwards compatibility */ typedef uint8_t org_apache_arrow_flatbuf_Type_union_type_t; __flatbuffers_define_integer_type(org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Type_union_type_t, 8) __flatbuffers_define_union(flatbuffers_, org_apache_arrow_flatbuf_Type) /** ---------------------------------------------------------------------- * user defined key value pairs to add custom metadata to arrow * key namespacing is the responsibility of the user */ #define org_apache_arrow_flatbuf_Type_NONE ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(0)) #define org_apache_arrow_flatbuf_Type_Null ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(1)) #define org_apache_arrow_flatbuf_Type_Int ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(2)) #define org_apache_arrow_flatbuf_Type_FloatingPoint ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(3)) #define org_apache_arrow_flatbuf_Type_Binary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(4)) #define org_apache_arrow_flatbuf_Type_Utf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(5)) #define org_apache_arrow_flatbuf_Type_Bool ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(6)) #define org_apache_arrow_flatbuf_Type_Decimal ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(7)) #define org_apache_arrow_flatbuf_Type_Date ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(8)) #define org_apache_arrow_flatbuf_Type_Time ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(9)) #define org_apache_arrow_flatbuf_Type_Timestamp ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(10)) #define org_apache_arrow_flatbuf_Type_Interval ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(11)) #define org_apache_arrow_flatbuf_Type_List ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(12)) #define org_apache_arrow_flatbuf_Type_Struct_ ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(13)) #define org_apache_arrow_flatbuf_Type_Union ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(14)) #define org_apache_arrow_flatbuf_Type_FixedSizeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(15)) #define org_apache_arrow_flatbuf_Type_FixedSizeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(16)) #define org_apache_arrow_flatbuf_Type_Map ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(17)) #define org_apache_arrow_flatbuf_Type_Duration ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(18)) #define org_apache_arrow_flatbuf_Type_LargeBinary ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(19)) #define org_apache_arrow_flatbuf_Type_LargeUtf8 ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(20)) #define org_apache_arrow_flatbuf_Type_LargeList ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(21)) #define org_apache_arrow_flatbuf_Type_RunEndEncoded ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(22)) #define org_apache_arrow_flatbuf_Type_BinaryView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(23)) #define org_apache_arrow_flatbuf_Type_Utf8View ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(24)) #define org_apache_arrow_flatbuf_Type_ListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(25)) #define org_apache_arrow_flatbuf_Type_LargeListView ((org_apache_arrow_flatbuf_Type_union_type_t)UINT8_C(26)) static inline const char *org_apache_arrow_flatbuf_Type_type_name(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return "NONE"; case org_apache_arrow_flatbuf_Type_Null: return "Null"; case org_apache_arrow_flatbuf_Type_Int: return "Int"; case org_apache_arrow_flatbuf_Type_FloatingPoint: return "FloatingPoint"; case org_apache_arrow_flatbuf_Type_Binary: return "Binary"; case org_apache_arrow_flatbuf_Type_Utf8: return "Utf8"; case org_apache_arrow_flatbuf_Type_Bool: return "Bool"; case org_apache_arrow_flatbuf_Type_Decimal: return "Decimal"; case org_apache_arrow_flatbuf_Type_Date: return "Date"; case org_apache_arrow_flatbuf_Type_Time: return "Time"; case org_apache_arrow_flatbuf_Type_Timestamp: return "Timestamp"; case org_apache_arrow_flatbuf_Type_Interval: return "Interval"; case org_apache_arrow_flatbuf_Type_List: return "List"; case org_apache_arrow_flatbuf_Type_Struct_: return "Struct_"; case org_apache_arrow_flatbuf_Type_Union: return "Union"; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return "FixedSizeBinary"; case org_apache_arrow_flatbuf_Type_FixedSizeList: return "FixedSizeList"; case org_apache_arrow_flatbuf_Type_Map: return "Map"; case org_apache_arrow_flatbuf_Type_Duration: return "Duration"; case org_apache_arrow_flatbuf_Type_LargeBinary: return "LargeBinary"; case org_apache_arrow_flatbuf_Type_LargeUtf8: return "LargeUtf8"; case org_apache_arrow_flatbuf_Type_LargeList: return "LargeList"; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return "RunEndEncoded"; case org_apache_arrow_flatbuf_Type_BinaryView: return "BinaryView"; case org_apache_arrow_flatbuf_Type_Utf8View: return "Utf8View"; case org_apache_arrow_flatbuf_Type_ListView: return "ListView"; case org_apache_arrow_flatbuf_Type_LargeListView: return "LargeListView"; default: return ""; } } static inline int org_apache_arrow_flatbuf_Type_is_known_type(org_apache_arrow_flatbuf_Type_union_type_t type) { switch (type) { case org_apache_arrow_flatbuf_Type_NONE: return 1; case org_apache_arrow_flatbuf_Type_Null: return 1; case org_apache_arrow_flatbuf_Type_Int: return 1; case org_apache_arrow_flatbuf_Type_FloatingPoint: return 1; case org_apache_arrow_flatbuf_Type_Binary: return 1; case org_apache_arrow_flatbuf_Type_Utf8: return 1; case org_apache_arrow_flatbuf_Type_Bool: return 1; case org_apache_arrow_flatbuf_Type_Decimal: return 1; case org_apache_arrow_flatbuf_Type_Date: return 1; case org_apache_arrow_flatbuf_Type_Time: return 1; case org_apache_arrow_flatbuf_Type_Timestamp: return 1; case org_apache_arrow_flatbuf_Type_Interval: return 1; case org_apache_arrow_flatbuf_Type_List: return 1; case org_apache_arrow_flatbuf_Type_Struct_: return 1; case org_apache_arrow_flatbuf_Type_Union: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeBinary: return 1; case org_apache_arrow_flatbuf_Type_FixedSizeList: return 1; case org_apache_arrow_flatbuf_Type_Map: return 1; case org_apache_arrow_flatbuf_Type_Duration: return 1; case org_apache_arrow_flatbuf_Type_LargeBinary: return 1; case org_apache_arrow_flatbuf_Type_LargeUtf8: return 1; case org_apache_arrow_flatbuf_Type_LargeList: return 1; case org_apache_arrow_flatbuf_Type_RunEndEncoded: return 1; case org_apache_arrow_flatbuf_Type_BinaryView: return 1; case org_apache_arrow_flatbuf_Type_Utf8View: return 1; case org_apache_arrow_flatbuf_Type_ListView: return 1; case org_apache_arrow_flatbuf_Type_LargeListView: return 1; default: return 0; } } struct org_apache_arrow_flatbuf_KeyValue_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_KeyValue_vec_len(org_apache_arrow_flatbuf_KeyValue_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_KeyValue_table_t org_apache_arrow_flatbuf_KeyValue_vec_at(org_apache_arrow_flatbuf_KeyValue_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_KeyValue_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_KeyValue) __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_KeyValue, key, 0) __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_KeyValue, value, 0) struct org_apache_arrow_flatbuf_DictionaryEncoding_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_len(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_DictionaryEncoding_table_t org_apache_arrow_flatbuf_DictionaryEncoding_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_DictionaryEncoding_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_DictionaryEncoding) /** The known dictionary id in the application where this data is used. In * the file or streaming formats, the dictionary ids are found in the * DictionaryBatch messages */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_DictionaryEncoding, id, flatbuffers_int64, int64_t, INT64_C(0)) /** The dictionary indices are constrained to be non-negative integers. If * this field is null, the indices must be signed int32. To maximize * cross-language compatibility and performance, implementations are * recommended to prefer signed integer types over unsigned integer types * and to avoid uint64 indices unless they are required by an application. */ __flatbuffers_define_table_field(1, org_apache_arrow_flatbuf_DictionaryEncoding, indexType, org_apache_arrow_flatbuf_Int_table_t, 0) /** By default, dictionaries are not ordered, or the order does not have * semantic meaning. In some statistical, applications, dictionary-encoding * is used to represent ordered categorical data, and we provide a way to * preserve that metadata here */ __flatbuffers_define_scalar_field(2, org_apache_arrow_flatbuf_DictionaryEncoding, isOrdered, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) __flatbuffers_define_scalar_field(3, org_apache_arrow_flatbuf_DictionaryEncoding, dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, INT16_C(0)) /** ---------------------------------------------------------------------- * A field represents a named column in a record / row batch or child of a * nested type. */ struct org_apache_arrow_flatbuf_Field_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Field_vec_len(org_apache_arrow_flatbuf_Field_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Field_table_t org_apache_arrow_flatbuf_Field_vec_at(org_apache_arrow_flatbuf_Field_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Field_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Field) /** Name is not required, in i.e. a List */ __flatbuffers_define_string_field(0, org_apache_arrow_flatbuf_Field, name, 0) /** Whether or not this field can contain nulls. Should be true in general. */ __flatbuffers_define_scalar_field(1, org_apache_arrow_flatbuf_Field, nullable, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(0)) /** This is the type of the decoded value if the field is dictionary encoded. */ __flatbuffers_define_union_field(flatbuffers_, 3, org_apache_arrow_flatbuf_Field, type, org_apache_arrow_flatbuf_Type, 0) /** Present only if the field is dictionary encoded. */ __flatbuffers_define_table_field(4, org_apache_arrow_flatbuf_Field, dictionary, org_apache_arrow_flatbuf_DictionaryEncoding_table_t, 0) /** children apply only to nested data types like Struct, List and Union. For * primitive types children will have length 0. */ __flatbuffers_define_vector_field(5, org_apache_arrow_flatbuf_Field, children, org_apache_arrow_flatbuf_Field_vec_t, 0) /** User-defined metadata */ __flatbuffers_define_vector_field(6, org_apache_arrow_flatbuf_Field, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** ---------------------------------------------------------------------- * A Schema describes the columns in a row batch */ struct org_apache_arrow_flatbuf_Schema_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Schema_vec_len(org_apache_arrow_flatbuf_Schema_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Schema_table_t org_apache_arrow_flatbuf_Schema_vec_at(org_apache_arrow_flatbuf_Schema_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Schema_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Schema) /** endianness of the buffer * it is Little Endian by default * if endianness doesn't match the underlying system then the vectors need to be converted */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_Schema, endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, INT16_C(0)) __flatbuffers_define_vector_field(1, org_apache_arrow_flatbuf_Schema, fields, org_apache_arrow_flatbuf_Field_vec_t, 0) __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Schema, custom_metadata, org_apache_arrow_flatbuf_KeyValue_vec_t, 0) /** Features used in the stream/file. */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Schema, features, org_apache_arrow_flatbuf_Feature_vec_t, 0) #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_READER_H */ #ifndef SCHEMA_BUILDER_H #define SCHEMA_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif #define __org_apache_arrow_flatbuf_MetadataVersion_formal_args , org_apache_arrow_flatbuf_MetadataVersion_enum_t v0 #define __org_apache_arrow_flatbuf_MetadataVersion_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_MetadataVersion, org_apache_arrow_flatbuf_MetadataVersion_enum_t) #define __org_apache_arrow_flatbuf_Feature_formal_args , org_apache_arrow_flatbuf_Feature_enum_t v0 #define __org_apache_arrow_flatbuf_Feature_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t) #define __org_apache_arrow_flatbuf_UnionMode_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0 #define __org_apache_arrow_flatbuf_UnionMode_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t) #define __org_apache_arrow_flatbuf_Precision_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_Precision_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t) #define __org_apache_arrow_flatbuf_DateUnit_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_DateUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t) #define __org_apache_arrow_flatbuf_TimeUnit_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_TimeUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t) #define __org_apache_arrow_flatbuf_IntervalUnit_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_IntervalUnit_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t) #define __org_apache_arrow_flatbuf_DictionaryKind_formal_args , org_apache_arrow_flatbuf_DictionaryKind_enum_t v0 #define __org_apache_arrow_flatbuf_DictionaryKind_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t) #define __org_apache_arrow_flatbuf_Endianness_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0 #define __org_apache_arrow_flatbuf_Endianness_call_args , v0 __flatbuffers_build_scalar(flatbuffers_, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t) #define __org_apache_arrow_flatbuf_Buffer_formal_args , int64_t v0, int64_t v1 #define __org_apache_arrow_flatbuf_Buffer_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { p->offset = v0; p->length = v1; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { p->offset = p2->offset; p->length = p2->length; return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_to_pe(&p->offset, v0); flatbuffers_int64_assign_to_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_to_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_to_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_to_pe(&p->length, &p2->length); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_assign_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, int64_t v0, int64_t v1) { flatbuffers_int64_assign_from_pe(&p->offset, v0); flatbuffers_int64_assign_from_pe(&p->length, v1); return p; } static inline org_apache_arrow_flatbuf_Buffer_t *org_apache_arrow_flatbuf_Buffer_copy_from_pe(org_apache_arrow_flatbuf_Buffer_t *p, const org_apache_arrow_flatbuf_Buffer_t *p2) { flatbuffers_int64_copy_from_pe(&p->offset, &p2->offset); flatbuffers_int64_copy_from_pe(&p->length, &p2->length); return p; } __flatbuffers_build_struct(flatbuffers_, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Buffer_file_identifier, org_apache_arrow_flatbuf_Buffer_type_identifier) __flatbuffers_define_fixed_array_primitives(flatbuffers_, org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer_t) typedef flatbuffers_union_ref_t org_apache_arrow_flatbuf_Type_union_ref_t; typedef flatbuffers_union_vec_ref_t org_apache_arrow_flatbuf_Type_union_vec_ref_t; static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t t); static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Null_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Null_ref_t; static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Null, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Struct__required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Struct__ref_t; static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Struct_, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_List_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_List_ref_t; static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_List, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeList_ref_t; static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeList, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_ListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_ListView_ref_t; static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_ListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeListView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeListView_ref_t; static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeList_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeList_ref_t; static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Map_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Map_ref_t; static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Map, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Union_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Union_ref_t; static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Union, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Int_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Int_ref_t; static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Int, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FloatingPoint_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FloatingPoint_ref_t; static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8_ref_t; static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Binary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Binary_ref_t; static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Binary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeUtf8_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeUtf8_ref_t; static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_LargeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_LargeBinary_ref_t; static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Utf8View_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Utf8View_ref_t; static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_BinaryView_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_BinaryView_ref_t; static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_FixedSizeBinary_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_ref_t; static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Bool_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Bool_ref_t; static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Bool, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_RunEndEncoded_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_RunEndEncoded_ref_t; static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, 0) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Decimal_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Decimal_ref_t; static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Decimal, 3) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Date_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Date_ref_t; static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Date, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Time_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Time_ref_t; static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Time, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Timestamp_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Timestamp_ref_t; static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Interval_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Interval_ref_t; static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Interval, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Duration_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Duration_ref_t; static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Duration, 1) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_KeyValue_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_KeyValue_ref_t; static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_DictionaryEncoding_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_ref_t; static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, 4) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Field_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Field_ref_t; static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Field, 7) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Schema_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Schema_ref_t; static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Schema, 4) #define __org_apache_arrow_flatbuf_Null_formal_args #define __org_apache_arrow_flatbuf_Null_call_args static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Null, org_apache_arrow_flatbuf_Null_file_identifier, org_apache_arrow_flatbuf_Null_type_identifier) #define __org_apache_arrow_flatbuf_Struct__formal_args #define __org_apache_arrow_flatbuf_Struct__call_args static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Struct_, org_apache_arrow_flatbuf_Struct__file_identifier, org_apache_arrow_flatbuf_Struct__type_identifier) #define __org_apache_arrow_flatbuf_List_formal_args #define __org_apache_arrow_flatbuf_List_call_args static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_List, org_apache_arrow_flatbuf_List_file_identifier, org_apache_arrow_flatbuf_List_type_identifier) #define __org_apache_arrow_flatbuf_LargeList_formal_args #define __org_apache_arrow_flatbuf_LargeList_call_args static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeList, org_apache_arrow_flatbuf_LargeList_file_identifier, org_apache_arrow_flatbuf_LargeList_type_identifier) #define __org_apache_arrow_flatbuf_ListView_formal_args #define __org_apache_arrow_flatbuf_ListView_call_args static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_ListView, org_apache_arrow_flatbuf_ListView_file_identifier, org_apache_arrow_flatbuf_ListView_type_identifier) #define __org_apache_arrow_flatbuf_LargeListView_formal_args #define __org_apache_arrow_flatbuf_LargeListView_call_args static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeListView, org_apache_arrow_flatbuf_LargeListView_file_identifier, org_apache_arrow_flatbuf_LargeListView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeList_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeList_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList_file_identifier, org_apache_arrow_flatbuf_FixedSizeList_type_identifier) #define __org_apache_arrow_flatbuf_Map_formal_args , flatbuffers_bool_t v0 #define __org_apache_arrow_flatbuf_Map_call_args , v0 static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Map, org_apache_arrow_flatbuf_Map_file_identifier, org_apache_arrow_flatbuf_Map_type_identifier) #define __org_apache_arrow_flatbuf_Union_formal_args , org_apache_arrow_flatbuf_UnionMode_enum_t v0, flatbuffers_int32_vec_ref_t v1 #define __org_apache_arrow_flatbuf_Union_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Union, org_apache_arrow_flatbuf_Union_file_identifier, org_apache_arrow_flatbuf_Union_type_identifier) #define __org_apache_arrow_flatbuf_Int_formal_args , int32_t v0, flatbuffers_bool_t v1 #define __org_apache_arrow_flatbuf_Int_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_Int_file_identifier, org_apache_arrow_flatbuf_Int_type_identifier) #define __org_apache_arrow_flatbuf_FloatingPoint_formal_args , org_apache_arrow_flatbuf_Precision_enum_t v0 #define __org_apache_arrow_flatbuf_FloatingPoint_call_args , v0 static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint_file_identifier, org_apache_arrow_flatbuf_FloatingPoint_type_identifier) #define __org_apache_arrow_flatbuf_Utf8_formal_args #define __org_apache_arrow_flatbuf_Utf8_call_args static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8, org_apache_arrow_flatbuf_Utf8_file_identifier, org_apache_arrow_flatbuf_Utf8_type_identifier) #define __org_apache_arrow_flatbuf_Binary_formal_args #define __org_apache_arrow_flatbuf_Binary_call_args static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Binary, org_apache_arrow_flatbuf_Binary_file_identifier, org_apache_arrow_flatbuf_Binary_type_identifier) #define __org_apache_arrow_flatbuf_LargeUtf8_formal_args #define __org_apache_arrow_flatbuf_LargeUtf8_call_args static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8_file_identifier, org_apache_arrow_flatbuf_LargeUtf8_type_identifier) #define __org_apache_arrow_flatbuf_LargeBinary_formal_args #define __org_apache_arrow_flatbuf_LargeBinary_call_args static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_LargeBinary, org_apache_arrow_flatbuf_LargeBinary_file_identifier, org_apache_arrow_flatbuf_LargeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Utf8View_formal_args #define __org_apache_arrow_flatbuf_Utf8View_call_args static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Utf8View, org_apache_arrow_flatbuf_Utf8View_file_identifier, org_apache_arrow_flatbuf_Utf8View_type_identifier) #define __org_apache_arrow_flatbuf_BinaryView_formal_args #define __org_apache_arrow_flatbuf_BinaryView_call_args static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_BinaryView, org_apache_arrow_flatbuf_BinaryView_file_identifier, org_apache_arrow_flatbuf_BinaryView_type_identifier) #define __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args , int32_t v0 #define __org_apache_arrow_flatbuf_FixedSizeBinary_call_args , v0 static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary_file_identifier, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier) #define __org_apache_arrow_flatbuf_Bool_formal_args #define __org_apache_arrow_flatbuf_Bool_call_args static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Bool, org_apache_arrow_flatbuf_Bool_file_identifier, org_apache_arrow_flatbuf_Bool_type_identifier) #define __org_apache_arrow_flatbuf_RunEndEncoded_formal_args #define __org_apache_arrow_flatbuf_RunEndEncoded_call_args static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded_file_identifier, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier) #define __org_apache_arrow_flatbuf_Decimal_formal_args , int32_t v0, int32_t v1, int32_t v2 #define __org_apache_arrow_flatbuf_Decimal_call_args , v0, v1, v2 static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Decimal, org_apache_arrow_flatbuf_Decimal_file_identifier, org_apache_arrow_flatbuf_Decimal_type_identifier) #define __org_apache_arrow_flatbuf_Date_formal_args , org_apache_arrow_flatbuf_DateUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Date_call_args , v0 static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Date, org_apache_arrow_flatbuf_Date_file_identifier, org_apache_arrow_flatbuf_Date_type_identifier) #define __org_apache_arrow_flatbuf_Time_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, int32_t v1 #define __org_apache_arrow_flatbuf_Time_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Time, org_apache_arrow_flatbuf_Time_file_identifier, org_apache_arrow_flatbuf_Time_type_identifier) #define __org_apache_arrow_flatbuf_Timestamp_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_Timestamp_call_args , v0, v1 static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Timestamp, org_apache_arrow_flatbuf_Timestamp_file_identifier, org_apache_arrow_flatbuf_Timestamp_type_identifier) #define __org_apache_arrow_flatbuf_Interval_formal_args , org_apache_arrow_flatbuf_IntervalUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Interval_call_args , v0 static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Interval, org_apache_arrow_flatbuf_Interval_file_identifier, org_apache_arrow_flatbuf_Interval_type_identifier) #define __org_apache_arrow_flatbuf_Duration_formal_args , org_apache_arrow_flatbuf_TimeUnit_enum_t v0 #define __org_apache_arrow_flatbuf_Duration_call_args , v0 static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Duration, org_apache_arrow_flatbuf_Duration_file_identifier, org_apache_arrow_flatbuf_Duration_type_identifier) #define __org_apache_arrow_flatbuf_KeyValue_formal_args , flatbuffers_string_ref_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_KeyValue_call_args , v0, v1 static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_KeyValue_file_identifier, org_apache_arrow_flatbuf_KeyValue_type_identifier) #define __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args , int64_t v0, org_apache_arrow_flatbuf_Int_ref_t v1, flatbuffers_bool_t v2, org_apache_arrow_flatbuf_DictionaryKind_enum_t v3 #define __org_apache_arrow_flatbuf_DictionaryEncoding_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_DictionaryEncoding_file_identifier, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier) #define __org_apache_arrow_flatbuf_Field_formal_args ,\ flatbuffers_string_ref_t v0, flatbuffers_bool_t v1, org_apache_arrow_flatbuf_Type_union_ref_t v3, org_apache_arrow_flatbuf_DictionaryEncoding_ref_t v4, org_apache_arrow_flatbuf_Field_vec_ref_t v5, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v6 #define __org_apache_arrow_flatbuf_Field_call_args ,\ v0, v1, v3, v4, v5, v6 static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field_file_identifier, org_apache_arrow_flatbuf_Field_type_identifier) #define __org_apache_arrow_flatbuf_Schema_formal_args , org_apache_arrow_flatbuf_Endianness_enum_t v0, org_apache_arrow_flatbuf_Field_vec_ref_t v1, org_apache_arrow_flatbuf_KeyValue_vec_ref_t v2, org_apache_arrow_flatbuf_Feature_vec_ref_t v3 #define __org_apache_arrow_flatbuf_Schema_call_args , v0, v1, v2, v3 static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Schema, org_apache_arrow_flatbuf_Schema_file_identifier, org_apache_arrow_flatbuf_Schema_type_identifier) static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_NONE(void) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_NONE; uref.value = 0; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Null; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Int; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FloatingPoint; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Binary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Bool; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Decimal; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Date; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Time; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Timestamp; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Interval; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_List; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Struct_; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Union; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_FixedSizeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Map; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Duration; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeBinary; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeUtf8; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeList; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_RunEndEncoded; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_BinaryView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_Utf8View; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_ListView; uref.value = ref; return uref; } static inline org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_ref_t ref) { org_apache_arrow_flatbuf_Type_union_ref_t uref; uref.type = org_apache_arrow_flatbuf_Type_LargeListView; uref.value = ref; return uref; } __flatbuffers_build_union_vector(flatbuffers_, org_apache_arrow_flatbuf_Type) static org_apache_arrow_flatbuf_Type_union_ref_t org_apache_arrow_flatbuf_Type_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Type_union_t u) { switch (u.type) { case 1: return org_apache_arrow_flatbuf_Type_as_Null(org_apache_arrow_flatbuf_Null_clone(B, (org_apache_arrow_flatbuf_Null_table_t)u.value)); case 2: return org_apache_arrow_flatbuf_Type_as_Int(org_apache_arrow_flatbuf_Int_clone(B, (org_apache_arrow_flatbuf_Int_table_t)u.value)); case 3: return org_apache_arrow_flatbuf_Type_as_FloatingPoint(org_apache_arrow_flatbuf_FloatingPoint_clone(B, (org_apache_arrow_flatbuf_FloatingPoint_table_t)u.value)); case 4: return org_apache_arrow_flatbuf_Type_as_Binary(org_apache_arrow_flatbuf_Binary_clone(B, (org_apache_arrow_flatbuf_Binary_table_t)u.value)); case 5: return org_apache_arrow_flatbuf_Type_as_Utf8(org_apache_arrow_flatbuf_Utf8_clone(B, (org_apache_arrow_flatbuf_Utf8_table_t)u.value)); case 6: return org_apache_arrow_flatbuf_Type_as_Bool(org_apache_arrow_flatbuf_Bool_clone(B, (org_apache_arrow_flatbuf_Bool_table_t)u.value)); case 7: return org_apache_arrow_flatbuf_Type_as_Decimal(org_apache_arrow_flatbuf_Decimal_clone(B, (org_apache_arrow_flatbuf_Decimal_table_t)u.value)); case 8: return org_apache_arrow_flatbuf_Type_as_Date(org_apache_arrow_flatbuf_Date_clone(B, (org_apache_arrow_flatbuf_Date_table_t)u.value)); case 9: return org_apache_arrow_flatbuf_Type_as_Time(org_apache_arrow_flatbuf_Time_clone(B, (org_apache_arrow_flatbuf_Time_table_t)u.value)); case 10: return org_apache_arrow_flatbuf_Type_as_Timestamp(org_apache_arrow_flatbuf_Timestamp_clone(B, (org_apache_arrow_flatbuf_Timestamp_table_t)u.value)); case 11: return org_apache_arrow_flatbuf_Type_as_Interval(org_apache_arrow_flatbuf_Interval_clone(B, (org_apache_arrow_flatbuf_Interval_table_t)u.value)); case 12: return org_apache_arrow_flatbuf_Type_as_List(org_apache_arrow_flatbuf_List_clone(B, (org_apache_arrow_flatbuf_List_table_t)u.value)); case 13: return org_apache_arrow_flatbuf_Type_as_Struct_(org_apache_arrow_flatbuf_Struct__clone(B, (org_apache_arrow_flatbuf_Struct__table_t)u.value)); case 14: return org_apache_arrow_flatbuf_Type_as_Union(org_apache_arrow_flatbuf_Union_clone(B, (org_apache_arrow_flatbuf_Union_table_t)u.value)); case 15: return org_apache_arrow_flatbuf_Type_as_FixedSizeBinary(org_apache_arrow_flatbuf_FixedSizeBinary_clone(B, (org_apache_arrow_flatbuf_FixedSizeBinary_table_t)u.value)); case 16: return org_apache_arrow_flatbuf_Type_as_FixedSizeList(org_apache_arrow_flatbuf_FixedSizeList_clone(B, (org_apache_arrow_flatbuf_FixedSizeList_table_t)u.value)); case 17: return org_apache_arrow_flatbuf_Type_as_Map(org_apache_arrow_flatbuf_Map_clone(B, (org_apache_arrow_flatbuf_Map_table_t)u.value)); case 18: return org_apache_arrow_flatbuf_Type_as_Duration(org_apache_arrow_flatbuf_Duration_clone(B, (org_apache_arrow_flatbuf_Duration_table_t)u.value)); case 19: return org_apache_arrow_flatbuf_Type_as_LargeBinary(org_apache_arrow_flatbuf_LargeBinary_clone(B, (org_apache_arrow_flatbuf_LargeBinary_table_t)u.value)); case 20: return org_apache_arrow_flatbuf_Type_as_LargeUtf8(org_apache_arrow_flatbuf_LargeUtf8_clone(B, (org_apache_arrow_flatbuf_LargeUtf8_table_t)u.value)); case 21: return org_apache_arrow_flatbuf_Type_as_LargeList(org_apache_arrow_flatbuf_LargeList_clone(B, (org_apache_arrow_flatbuf_LargeList_table_t)u.value)); case 22: return org_apache_arrow_flatbuf_Type_as_RunEndEncoded(org_apache_arrow_flatbuf_RunEndEncoded_clone(B, (org_apache_arrow_flatbuf_RunEndEncoded_table_t)u.value)); case 23: return org_apache_arrow_flatbuf_Type_as_BinaryView(org_apache_arrow_flatbuf_BinaryView_clone(B, (org_apache_arrow_flatbuf_BinaryView_table_t)u.value)); case 24: return org_apache_arrow_flatbuf_Type_as_Utf8View(org_apache_arrow_flatbuf_Utf8View_clone(B, (org_apache_arrow_flatbuf_Utf8View_table_t)u.value)); case 25: return org_apache_arrow_flatbuf_Type_as_ListView(org_apache_arrow_flatbuf_ListView_clone(B, (org_apache_arrow_flatbuf_ListView_table_t)u.value)); case 26: return org_apache_arrow_flatbuf_Type_as_LargeListView(org_apache_arrow_flatbuf_LargeListView_clone(B, (org_apache_arrow_flatbuf_LargeListView_table_t)u.value)); default: return org_apache_arrow_flatbuf_Type_as_NONE(); } } static inline org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Null_formal_args) { if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } return org_apache_arrow_flatbuf_Null_end(B); } static org_apache_arrow_flatbuf_Null_ref_t org_apache_arrow_flatbuf_Null_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Null_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Null_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Null_end(B)); } static inline org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Struct__formal_args) { if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } return org_apache_arrow_flatbuf_Struct__end(B); } static org_apache_arrow_flatbuf_Struct__ref_t org_apache_arrow_flatbuf_Struct__clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Struct__table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Struct__start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Struct__end(B)); } static inline org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_List_formal_args) { if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } return org_apache_arrow_flatbuf_List_end(B); } static org_apache_arrow_flatbuf_List_ref_t org_apache_arrow_flatbuf_List_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_List_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_List_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_List_end(B)); } static inline org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeList_formal_args) { if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeList_end(B); } static org_apache_arrow_flatbuf_LargeList_ref_t org_apache_arrow_flatbuf_LargeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeList_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeList_end(B)); } static inline org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_ListView_formal_args) { if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_ListView_end(B); } static org_apache_arrow_flatbuf_ListView_ref_t org_apache_arrow_flatbuf_ListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_ListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_ListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_ListView_end(B)); } static inline org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeListView_formal_args) { if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeListView_end(B); } static org_apache_arrow_flatbuf_LargeListView_ref_t org_apache_arrow_flatbuf_LargeListView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeListView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeListView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeListView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeList_listSize, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeList) static inline org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeList_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeList_end(B); } static org_apache_arrow_flatbuf_FixedSizeList_ref_t org_apache_arrow_flatbuf_FixedSizeList_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeList_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeList_start(B) || org_apache_arrow_flatbuf_FixedSizeList_listSize_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeList_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Map_keysSorted, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Map) static inline org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Map_formal_args) { if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Map_end(B); } static org_apache_arrow_flatbuf_Map_ref_t org_apache_arrow_flatbuf_Map_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Map_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Map_start(B) || org_apache_arrow_flatbuf_Map_keysSorted_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Map_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Union_mode, org_apache_arrow_flatbuf_UnionMode, org_apache_arrow_flatbuf_UnionMode_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Union) __flatbuffers_build_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Union_typeIds, flatbuffers_int32, int32_t, org_apache_arrow_flatbuf_Union) static inline org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Union_formal_args) { if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_add(B, v1) || org_apache_arrow_flatbuf_Union_mode_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Union_end(B); } static org_apache_arrow_flatbuf_Union_ref_t org_apache_arrow_flatbuf_Union_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Union_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Union_start(B) || org_apache_arrow_flatbuf_Union_typeIds_pick(B, t) || org_apache_arrow_flatbuf_Union_mode_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Union_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Int_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Int) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Int_is_signed, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Int) static inline org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Int_formal_args) { if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_add(B, v0) || org_apache_arrow_flatbuf_Int_is_signed_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_Int_end(B); } static org_apache_arrow_flatbuf_Int_ref_t org_apache_arrow_flatbuf_Int_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Int_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Int_start(B) || org_apache_arrow_flatbuf_Int_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Int_is_signed_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Int_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FloatingPoint_precision, org_apache_arrow_flatbuf_Precision, org_apache_arrow_flatbuf_Precision_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_FloatingPoint) static inline org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FloatingPoint_formal_args) { if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FloatingPoint_end(B); } static org_apache_arrow_flatbuf_FloatingPoint_ref_t org_apache_arrow_flatbuf_FloatingPoint_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FloatingPoint_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FloatingPoint_start(B) || org_apache_arrow_flatbuf_FloatingPoint_precision_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FloatingPoint_end(B)); } static inline org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8_formal_args) { if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8_end(B); } static org_apache_arrow_flatbuf_Utf8_ref_t org_apache_arrow_flatbuf_Utf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8_end(B)); } static inline org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Binary_formal_args) { if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } return org_apache_arrow_flatbuf_Binary_end(B); } static org_apache_arrow_flatbuf_Binary_ref_t org_apache_arrow_flatbuf_Binary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Binary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Binary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Binary_end(B)); } static inline org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeUtf8_formal_args) { if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeUtf8_end(B); } static org_apache_arrow_flatbuf_LargeUtf8_ref_t org_apache_arrow_flatbuf_LargeUtf8_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeUtf8_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeUtf8_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeUtf8_end(B)); } static inline org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_LargeBinary_formal_args) { if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } return org_apache_arrow_flatbuf_LargeBinary_end(B); } static org_apache_arrow_flatbuf_LargeBinary_ref_t org_apache_arrow_flatbuf_LargeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_LargeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_LargeBinary_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_LargeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Utf8View_formal_args) { if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } return org_apache_arrow_flatbuf_Utf8View_end(B); } static org_apache_arrow_flatbuf_Utf8View_ref_t org_apache_arrow_flatbuf_Utf8View_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Utf8View_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Utf8View_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Utf8View_end(B)); } static inline org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_BinaryView_formal_args) { if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } return org_apache_arrow_flatbuf_BinaryView_end(B); } static org_apache_arrow_flatbuf_BinaryView_ref_t org_apache_arrow_flatbuf_BinaryView_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_BinaryView_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_BinaryView_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_BinaryView_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_FixedSizeBinary) static inline org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_FixedSizeBinary_formal_args) { if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_FixedSizeBinary_end(B); } static org_apache_arrow_flatbuf_FixedSizeBinary_ref_t org_apache_arrow_flatbuf_FixedSizeBinary_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_FixedSizeBinary_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_FixedSizeBinary_start(B) || org_apache_arrow_flatbuf_FixedSizeBinary_byteWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_FixedSizeBinary_end(B)); } static inline org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Bool_formal_args) { if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } return org_apache_arrow_flatbuf_Bool_end(B); } static org_apache_arrow_flatbuf_Bool_ref_t org_apache_arrow_flatbuf_Bool_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Bool_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Bool_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Bool_end(B)); } static inline org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_RunEndEncoded_formal_args) { if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } return org_apache_arrow_flatbuf_RunEndEncoded_end(B); } static org_apache_arrow_flatbuf_RunEndEncoded_ref_t org_apache_arrow_flatbuf_RunEndEncoded_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_RunEndEncoded_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_RunEndEncoded_start(B)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_RunEndEncoded_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Decimal_precision, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Decimal_scale, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_Decimal_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(128), org_apache_arrow_flatbuf_Decimal) static inline org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Decimal_formal_args) { if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_add(B, v0) || org_apache_arrow_flatbuf_Decimal_scale_add(B, v1) || org_apache_arrow_flatbuf_Decimal_bitWidth_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_Decimal_end(B); } static org_apache_arrow_flatbuf_Decimal_ref_t org_apache_arrow_flatbuf_Decimal_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Decimal_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Decimal_start(B) || org_apache_arrow_flatbuf_Decimal_precision_pick(B, t) || org_apache_arrow_flatbuf_Decimal_scale_pick(B, t) || org_apache_arrow_flatbuf_Decimal_bitWidth_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Decimal_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Date_unit, org_apache_arrow_flatbuf_DateUnit, org_apache_arrow_flatbuf_DateUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Date) static inline org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Date_formal_args) { if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Date_end(B); } static org_apache_arrow_flatbuf_Date_ref_t org_apache_arrow_flatbuf_Date_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Date_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Date_start(B) || org_apache_arrow_flatbuf_Date_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Date_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Time_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Time) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Time_bitWidth, flatbuffers_int32, int32_t, 4, 4, INT32_C(32), org_apache_arrow_flatbuf_Time) static inline org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Time_formal_args) { if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_add(B, v1) || org_apache_arrow_flatbuf_Time_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Time_end(B); } static org_apache_arrow_flatbuf_Time_ref_t org_apache_arrow_flatbuf_Time_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Time_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Time_start(B) || org_apache_arrow_flatbuf_Time_bitWidth_pick(B, t) || org_apache_arrow_flatbuf_Time_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Time_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_Timestamp_timezone, org_apache_arrow_flatbuf_Timestamp) static inline org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Timestamp_formal_args) { if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_add(B, v1) || org_apache_arrow_flatbuf_Timestamp_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Timestamp_end(B); } static org_apache_arrow_flatbuf_Timestamp_ref_t org_apache_arrow_flatbuf_Timestamp_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Timestamp_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Timestamp_start(B) || org_apache_arrow_flatbuf_Timestamp_timezone_pick(B, t) || org_apache_arrow_flatbuf_Timestamp_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Timestamp_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Interval_unit, org_apache_arrow_flatbuf_IntervalUnit, org_apache_arrow_flatbuf_IntervalUnit_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Interval) static inline org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Interval_formal_args) { if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Interval_end(B); } static org_apache_arrow_flatbuf_Interval_ref_t org_apache_arrow_flatbuf_Interval_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Interval_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Interval_start(B) || org_apache_arrow_flatbuf_Interval_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Interval_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Duration_unit, org_apache_arrow_flatbuf_TimeUnit, org_apache_arrow_flatbuf_TimeUnit_enum_t, 2, 2, INT16_C(1), org_apache_arrow_flatbuf_Duration) static inline org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Duration_formal_args) { if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Duration_end(B); } static org_apache_arrow_flatbuf_Duration_ref_t org_apache_arrow_flatbuf_Duration_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Duration_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Duration_start(B) || org_apache_arrow_flatbuf_Duration_unit_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Duration_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_key, org_apache_arrow_flatbuf_KeyValue) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_KeyValue_value, org_apache_arrow_flatbuf_KeyValue) static inline org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_KeyValue_formal_args) { if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_add(B, v0) || org_apache_arrow_flatbuf_KeyValue_value_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_KeyValue_end(B); } static org_apache_arrow_flatbuf_KeyValue_ref_t org_apache_arrow_flatbuf_KeyValue_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_KeyValue_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_KeyValue_start(B) || org_apache_arrow_flatbuf_KeyValue_key_pick(B, t) || org_apache_arrow_flatbuf_KeyValue_value_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_KeyValue_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_id, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_table_field(1, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_indexType, org_apache_arrow_flatbuf_Int, org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(2, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) __flatbuffers_build_scalar_field(3, flatbuffers_, org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind, org_apache_arrow_flatbuf_DictionaryKind, org_apache_arrow_flatbuf_DictionaryKind_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_DictionaryEncoding) static inline org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_DictionaryEncoding_formal_args) { if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_add(B, v0) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_add(B, v1) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_add(B, v3) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_add(B, v2)) { return 0; } return org_apache_arrow_flatbuf_DictionaryEncoding_end(B); } static org_apache_arrow_flatbuf_DictionaryEncoding_ref_t org_apache_arrow_flatbuf_DictionaryEncoding_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_DictionaryEncoding_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_DictionaryEncoding_start(B) || org_apache_arrow_flatbuf_DictionaryEncoding_id_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_indexType_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_dictionaryKind_pick(B, t) || org_apache_arrow_flatbuf_DictionaryEncoding_isOrdered_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_DictionaryEncoding_end(B)); } __flatbuffers_build_string_field(0, flatbuffers_, org_apache_arrow_flatbuf_Field_name, org_apache_arrow_flatbuf_Field) __flatbuffers_build_scalar_field(1, flatbuffers_, org_apache_arrow_flatbuf_Field_nullable, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(0), org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_field(3, flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Field) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Field_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_field(4, flatbuffers_, org_apache_arrow_flatbuf_Field_dictionary, org_apache_arrow_flatbuf_DictionaryEncoding, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(5, flatbuffers_, org_apache_arrow_flatbuf_Field_children, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Field) __flatbuffers_build_table_vector_field(6, flatbuffers_, org_apache_arrow_flatbuf_Field_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Field) static inline org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Field_formal_args) { if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_add(B, v0) || org_apache_arrow_flatbuf_Field_type_add_value(B, v3) || org_apache_arrow_flatbuf_Field_dictionary_add(B, v4) || org_apache_arrow_flatbuf_Field_children_add(B, v5) || org_apache_arrow_flatbuf_Field_custom_metadata_add(B, v6) || org_apache_arrow_flatbuf_Field_nullable_add(B, v1) || org_apache_arrow_flatbuf_Field_type_add_type(B, v3.type)) { return 0; } return org_apache_arrow_flatbuf_Field_end(B); } static org_apache_arrow_flatbuf_Field_ref_t org_apache_arrow_flatbuf_Field_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Field_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Field_start(B) || org_apache_arrow_flatbuf_Field_name_pick(B, t) || org_apache_arrow_flatbuf_Field_type_pick(B, t) || org_apache_arrow_flatbuf_Field_dictionary_pick(B, t) || org_apache_arrow_flatbuf_Field_children_pick(B, t) || org_apache_arrow_flatbuf_Field_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Field_nullable_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Field_end(B)); } __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_Schema_endianness, org_apache_arrow_flatbuf_Endianness, org_apache_arrow_flatbuf_Endianness_enum_t, 2, 2, INT16_C(0), org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(1, flatbuffers_, org_apache_arrow_flatbuf_Schema_fields, org_apache_arrow_flatbuf_Field, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Schema_custom_metadata, org_apache_arrow_flatbuf_KeyValue, org_apache_arrow_flatbuf_Schema) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Schema_features, org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature_enum_t, org_apache_arrow_flatbuf_Schema) static inline org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Schema_formal_args) { if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_add(B, v1) || org_apache_arrow_flatbuf_Schema_custom_metadata_add(B, v2) || org_apache_arrow_flatbuf_Schema_features_add(B, v3) || org_apache_arrow_flatbuf_Schema_endianness_add(B, v0)) { return 0; } return org_apache_arrow_flatbuf_Schema_end(B); } static org_apache_arrow_flatbuf_Schema_ref_t org_apache_arrow_flatbuf_Schema_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Schema_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Schema_start(B) || org_apache_arrow_flatbuf_Schema_fields_pick(B, t) || org_apache_arrow_flatbuf_Schema_custom_metadata_pick(B, t) || org_apache_arrow_flatbuf_Schema_features_pick(B, t) || org_apache_arrow_flatbuf_Schema_endianness_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Schema_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_BUILDER_H */ #ifndef SCHEMA_VERIFIER_H #define SCHEMA_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_verifier.h" #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Type_union_verifier(flatcc_union_verifier_descriptor_t *ud) { switch (ud->type) { case 1: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Null_verify_table); /* Null */ case 2: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Int_verify_table); /* Int */ case 3: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FloatingPoint_verify_table); /* FloatingPoint */ case 4: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Binary_verify_table); /* Binary */ case 5: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8_verify_table); /* Utf8 */ case 6: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Bool_verify_table); /* Bool */ case 7: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Decimal_verify_table); /* Decimal */ case 8: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Date_verify_table); /* Date */ case 9: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Time_verify_table); /* Time */ case 10: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Timestamp_verify_table); /* Timestamp */ case 11: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Interval_verify_table); /* Interval */ case 12: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_List_verify_table); /* List */ case 13: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Struct__verify_table); /* Struct_ */ case 14: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Union_verify_table); /* Union */ case 15: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); /* FixedSizeBinary */ case 16: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_FixedSizeList_verify_table); /* FixedSizeList */ case 17: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Map_verify_table); /* Map */ case 18: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Duration_verify_table); /* Duration */ case 19: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeBinary_verify_table); /* LargeBinary */ case 20: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeUtf8_verify_table); /* LargeUtf8 */ case 21: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeList_verify_table); /* LargeList */ case 22: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_RunEndEncoded_verify_table); /* RunEndEncoded */ case 23: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_BinaryView_verify_table); /* BinaryView */ case 24: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_Utf8View_verify_table); /* Utf8View */ case 25: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_ListView_verify_table); /* ListView */ case 26: return flatcc_verify_union_table(ud, org_apache_arrow_flatbuf_LargeListView_verify_table); /* LargeListView */ default: return flatcc_verify_ok; } } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_identifier, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Buffer_type_hash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_struct_as_typed_root_with_size(buf, bufsiz, thash, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root(buf, bufsiz, fid, 16, 8); } static inline int org_apache_arrow_flatbuf_Buffer_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_struct_as_root_with_size(buf, bufsiz, fid, 16, 8); } static int org_apache_arrow_flatbuf_Null_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Null_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Null_type_identifier, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static inline int org_apache_arrow_flatbuf_Null_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Null_verify_table); } static int org_apache_arrow_flatbuf_Struct__verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Struct__type_identifier, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static inline int org_apache_arrow_flatbuf_Struct__verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Struct__verify_table); } static int org_apache_arrow_flatbuf_List_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_List_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_List_type_identifier, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static inline int org_apache_arrow_flatbuf_List_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_List_verify_table); } static int org_apache_arrow_flatbuf_LargeList_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeList_type_identifier, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static inline int org_apache_arrow_flatbuf_LargeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeList_verify_table); } static int org_apache_arrow_flatbuf_ListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_ListView_type_identifier, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static inline int org_apache_arrow_flatbuf_ListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_ListView_verify_table); } static int org_apache_arrow_flatbuf_LargeListView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeListView_type_identifier, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static inline int org_apache_arrow_flatbuf_LargeListView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeListView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeList_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* listSize */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeList_type_identifier, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeList_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeList_verify_table); } static int org_apache_arrow_flatbuf_Map_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 1, 1) /* keysSorted */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Map_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Map_type_identifier, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static inline int org_apache_arrow_flatbuf_Map_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Map_verify_table); } static int org_apache_arrow_flatbuf_Union_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* mode */)) return ret; if ((ret = flatcc_verify_vector_field(td, 1, 0, 4, 4, INT64_C(1073741823)) /* typeIds */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Union_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Union_type_identifier, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static inline int org_apache_arrow_flatbuf_Union_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Union_verify_table); } static int org_apache_arrow_flatbuf_Int_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* bitWidth */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* is_signed */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Int_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Int_type_identifier, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static inline int org_apache_arrow_flatbuf_Int_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Int_verify_table); } static int org_apache_arrow_flatbuf_FloatingPoint_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* precision */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FloatingPoint_type_identifier, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static inline int org_apache_arrow_flatbuf_FloatingPoint_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FloatingPoint_verify_table); } static int org_apache_arrow_flatbuf_Utf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8_type_identifier, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8_verify_table); } static int org_apache_arrow_flatbuf_Binary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Binary_type_identifier, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static inline int org_apache_arrow_flatbuf_Binary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Binary_verify_table); } static int org_apache_arrow_flatbuf_LargeUtf8_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeUtf8_type_identifier, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static inline int org_apache_arrow_flatbuf_LargeUtf8_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeUtf8_verify_table); } static int org_apache_arrow_flatbuf_LargeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_LargeBinary_type_identifier, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_LargeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_LargeBinary_verify_table); } static int org_apache_arrow_flatbuf_Utf8View_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Utf8View_type_identifier, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static inline int org_apache_arrow_flatbuf_Utf8View_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Utf8View_verify_table); } static int org_apache_arrow_flatbuf_BinaryView_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_BinaryView_type_identifier, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static inline int org_apache_arrow_flatbuf_BinaryView_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_BinaryView_verify_table); } static int org_apache_arrow_flatbuf_FixedSizeBinary_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* byteWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_FixedSizeBinary_type_identifier, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static inline int org_apache_arrow_flatbuf_FixedSizeBinary_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_FixedSizeBinary_verify_table); } static int org_apache_arrow_flatbuf_Bool_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Bool_type_identifier, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static inline int org_apache_arrow_flatbuf_Bool_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Bool_verify_table); } static int org_apache_arrow_flatbuf_RunEndEncoded_verify_table(flatcc_table_verifier_descriptor_t *td) { return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_RunEndEncoded_type_identifier, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static inline int org_apache_arrow_flatbuf_RunEndEncoded_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_RunEndEncoded_verify_table); } static int org_apache_arrow_flatbuf_Decimal_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 4, 4) /* precision */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* scale */)) return ret; if ((ret = flatcc_verify_field(td, 2, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Decimal_type_identifier, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static inline int org_apache_arrow_flatbuf_Decimal_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Decimal_verify_table); } static int org_apache_arrow_flatbuf_Date_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Date_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Date_type_identifier, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static inline int org_apache_arrow_flatbuf_Date_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Date_verify_table); } static int org_apache_arrow_flatbuf_Time_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_field(td, 1, 4, 4) /* bitWidth */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Time_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Time_type_identifier, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static inline int org_apache_arrow_flatbuf_Time_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Time_verify_table); } static int org_apache_arrow_flatbuf_Timestamp_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* timezone */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Timestamp_type_identifier, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static inline int org_apache_arrow_flatbuf_Timestamp_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Timestamp_verify_table); } static int org_apache_arrow_flatbuf_Interval_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Interval_type_identifier, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static inline int org_apache_arrow_flatbuf_Interval_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Interval_verify_table); } static int org_apache_arrow_flatbuf_Duration_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* unit */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Duration_type_identifier, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static inline int org_apache_arrow_flatbuf_Duration_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Duration_verify_table); } static int org_apache_arrow_flatbuf_KeyValue_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* key */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* value */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_KeyValue_type_identifier, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static inline int org_apache_arrow_flatbuf_KeyValue_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_KeyValue_verify_table); } static int org_apache_arrow_flatbuf_DictionaryEncoding_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* id */)) return ret; if ((ret = flatcc_verify_table_field(td, 1, 0, &org_apache_arrow_flatbuf_Int_verify_table) /* indexType */)) return ret; if ((ret = flatcc_verify_field(td, 2, 1, 1) /* isOrdered */)) return ret; if ((ret = flatcc_verify_field(td, 3, 2, 2) /* dictionaryKind */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_DictionaryEncoding_type_identifier, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static inline int org_apache_arrow_flatbuf_DictionaryEncoding_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table); } static int org_apache_arrow_flatbuf_Field_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_string_field(td, 0, 0) /* name */)) return ret; if ((ret = flatcc_verify_field(td, 1, 1, 1) /* nullable */)) return ret; if ((ret = flatcc_verify_union_field(td, 3, 0, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_field(td, 4, 0, &org_apache_arrow_flatbuf_DictionaryEncoding_verify_table) /* dictionary */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 5, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* children */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 6, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Field_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Field_type_identifier, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static inline int org_apache_arrow_flatbuf_Field_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Field_verify_table); } static int org_apache_arrow_flatbuf_Schema_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 2, 2) /* endianness */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 1, 0, &org_apache_arrow_flatbuf_Field_verify_table) /* fields */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 0, &org_apache_arrow_flatbuf_KeyValue_verify_table) /* custom_metadata */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* features */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Schema_type_identifier, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } static inline int org_apache_arrow_flatbuf_Schema_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Schema_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* SCHEMA_VERIFIER_H */ #ifndef TENSOR_READER_H #define TENSOR_READER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" #endif #ifndef SCHEMA_READER_H #include "Schema_reader.h" #endif #include "flatcc/flatcc_flatbuffers.h" #ifndef __alignas_is_defined #include #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif typedef const struct org_apache_arrow_flatbuf_TensorDim_table *org_apache_arrow_flatbuf_TensorDim_table_t; typedef struct org_apache_arrow_flatbuf_TensorDim_table *org_apache_arrow_flatbuf_TensorDim_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_TensorDim_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_TensorDim_mutable_vec_t; typedef const struct org_apache_arrow_flatbuf_Tensor_table *org_apache_arrow_flatbuf_Tensor_table_t; typedef struct org_apache_arrow_flatbuf_Tensor_table *org_apache_arrow_flatbuf_Tensor_mutable_table_t; typedef const flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Tensor_vec_t; typedef flatbuffers_uoffset_t *org_apache_arrow_flatbuf_Tensor_mutable_vec_t; #ifndef org_apache_arrow_flatbuf_TensorDim_file_identifier #define org_apache_arrow_flatbuf_TensorDim_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_TensorDim_file_identifier */ #ifndef org_apache_arrow_flatbuf_TensorDim_identifier #define org_apache_arrow_flatbuf_TensorDim_identifier 0 #endif #define org_apache_arrow_flatbuf_TensorDim_type_hash ((flatbuffers_thash_t)0xbc6d7b25) #define org_apache_arrow_flatbuf_TensorDim_type_identifier "\x25\x7b\x6d\xbc" #ifndef org_apache_arrow_flatbuf_TensorDim_file_extension #define org_apache_arrow_flatbuf_TensorDim_file_extension "bin" #endif #ifndef org_apache_arrow_flatbuf_Tensor_file_identifier #define org_apache_arrow_flatbuf_Tensor_file_identifier 0 #endif /* deprecated, use org_apache_arrow_flatbuf_Tensor_file_identifier */ #ifndef org_apache_arrow_flatbuf_Tensor_identifier #define org_apache_arrow_flatbuf_Tensor_identifier 0 #endif #define org_apache_arrow_flatbuf_Tensor_type_hash ((flatbuffers_thash_t)0x1764df19) #define org_apache_arrow_flatbuf_Tensor_type_identifier "\x19\xdf\x64\x17" #ifndef org_apache_arrow_flatbuf_Tensor_file_extension #define org_apache_arrow_flatbuf_Tensor_file_extension "bin" #endif /** ---------------------------------------------------------------------- * Data structures for dense tensors * Shape data for a single axis in a tensor */ struct org_apache_arrow_flatbuf_TensorDim_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_TensorDim_vec_len(org_apache_arrow_flatbuf_TensorDim_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_TensorDim_table_t org_apache_arrow_flatbuf_TensorDim_vec_at(org_apache_arrow_flatbuf_TensorDim_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_TensorDim_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_TensorDim) /** Length of dimension */ __flatbuffers_define_scalar_field(0, org_apache_arrow_flatbuf_TensorDim, size, flatbuffers_int64, int64_t, INT64_C(0)) /** Name of the dimension, optional */ __flatbuffers_define_string_field(1, org_apache_arrow_flatbuf_TensorDim, name, 0) struct org_apache_arrow_flatbuf_Tensor_table { uint8_t unused__; }; static inline size_t org_apache_arrow_flatbuf_Tensor_vec_len(org_apache_arrow_flatbuf_Tensor_vec_t vec) __flatbuffers_vec_len(vec) static inline org_apache_arrow_flatbuf_Tensor_table_t org_apache_arrow_flatbuf_Tensor_vec_at(org_apache_arrow_flatbuf_Tensor_vec_t vec, size_t i) __flatbuffers_offset_vec_at(org_apache_arrow_flatbuf_Tensor_table_t, vec, i, 0) __flatbuffers_table_as_root(org_apache_arrow_flatbuf_Tensor) /** The type of data contained in a value cell. Currently only fixed-width * value types are supported, no strings or nested types */ __flatbuffers_define_union_field(flatbuffers_, 1, org_apache_arrow_flatbuf_Tensor, type, org_apache_arrow_flatbuf_Type, 1) /** The dimensions of the tensor, optionally named */ __flatbuffers_define_vector_field(2, org_apache_arrow_flatbuf_Tensor, shape, org_apache_arrow_flatbuf_TensorDim_vec_t, 1) /** Non-negative byte offsets to advance one value cell along each dimension * If omitted, default to row-major order (C-like). */ __flatbuffers_define_vector_field(3, org_apache_arrow_flatbuf_Tensor, strides, flatbuffers_int64_vec_t, 0) /** The location and size of the tensor's data */ __flatbuffers_define_struct_field(4, org_apache_arrow_flatbuf_Tensor, data, org_apache_arrow_flatbuf_Buffer_struct_t, 1) #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_READER_H */ #ifndef TENSOR_BUILDER_H #define TENSOR_BUILDER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #ifndef FLATBUFFERS_COMMON_BUILDER_H #include "flatbuffers_common_builder.h" #endif #ifndef SCHEMA_BUILDER_H #include "Schema_builder.h" #endif #include "flatcc/flatcc_prologue.h" #ifndef flatbuffers_identifier #define flatbuffers_identifier 0 #endif #ifndef flatbuffers_extension #define flatbuffers_extension "bin" #endif static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_TensorDim_required[] = { 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_TensorDim_ref_t; static org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_TensorDim_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_TensorDim, 2) static const flatbuffers_voffset_t __org_apache_arrow_flatbuf_Tensor_required[] = { 1, 2, 4, 0 }; typedef flatbuffers_ref_t org_apache_arrow_flatbuf_Tensor_ref_t; static org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Tensor_table_t t); __flatbuffers_build_table(flatbuffers_, org_apache_arrow_flatbuf_Tensor, 5) #define __org_apache_arrow_flatbuf_TensorDim_formal_args , int64_t v0, flatbuffers_string_ref_t v1 #define __org_apache_arrow_flatbuf_TensorDim_call_args , v0, v1 static inline org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_TensorDim_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_TensorDim_file_identifier, org_apache_arrow_flatbuf_TensorDim_type_identifier) #define __org_apache_arrow_flatbuf_Tensor_formal_args , org_apache_arrow_flatbuf_Type_union_ref_t v1, org_apache_arrow_flatbuf_TensorDim_vec_ref_t v2, flatbuffers_int64_vec_ref_t v3, org_apache_arrow_flatbuf_Buffer_t *v4 #define __org_apache_arrow_flatbuf_Tensor_call_args , v1, v2, v3, v4 static inline org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Tensor_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, org_apache_arrow_flatbuf_Tensor, org_apache_arrow_flatbuf_Tensor_file_identifier, org_apache_arrow_flatbuf_Tensor_type_identifier) __flatbuffers_build_scalar_field(0, flatbuffers_, org_apache_arrow_flatbuf_TensorDim_size, flatbuffers_int64, int64_t, 8, 8, INT64_C(0), org_apache_arrow_flatbuf_TensorDim) __flatbuffers_build_string_field(1, flatbuffers_, org_apache_arrow_flatbuf_TensorDim_name, org_apache_arrow_flatbuf_TensorDim) static inline org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_TensorDim_formal_args) { if (org_apache_arrow_flatbuf_TensorDim_start(B) || org_apache_arrow_flatbuf_TensorDim_size_add(B, v0) || org_apache_arrow_flatbuf_TensorDim_name_add(B, v1)) { return 0; } return org_apache_arrow_flatbuf_TensorDim_end(B); } static org_apache_arrow_flatbuf_TensorDim_ref_t org_apache_arrow_flatbuf_TensorDim_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_TensorDim_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_TensorDim_start(B) || org_apache_arrow_flatbuf_TensorDim_size_pick(B, t) || org_apache_arrow_flatbuf_TensorDim_name_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_TensorDim_end(B)); } __flatbuffers_build_union_field(1, flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Null, org_apache_arrow_flatbuf_Null) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Int, org_apache_arrow_flatbuf_Int) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FloatingPoint, org_apache_arrow_flatbuf_FloatingPoint) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Binary, org_apache_arrow_flatbuf_Binary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Utf8, org_apache_arrow_flatbuf_Utf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Bool, org_apache_arrow_flatbuf_Bool) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Decimal, org_apache_arrow_flatbuf_Decimal) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Date, org_apache_arrow_flatbuf_Date) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Time, org_apache_arrow_flatbuf_Time) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Timestamp, org_apache_arrow_flatbuf_Timestamp) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Interval, org_apache_arrow_flatbuf_Interval) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, List, org_apache_arrow_flatbuf_List) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Struct_, org_apache_arrow_flatbuf_Struct_) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Union, org_apache_arrow_flatbuf_Union) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FixedSizeBinary, org_apache_arrow_flatbuf_FixedSizeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, FixedSizeList, org_apache_arrow_flatbuf_FixedSizeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Map, org_apache_arrow_flatbuf_Map) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Duration, org_apache_arrow_flatbuf_Duration) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeBinary, org_apache_arrow_flatbuf_LargeBinary) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeUtf8, org_apache_arrow_flatbuf_LargeUtf8) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeList, org_apache_arrow_flatbuf_LargeList) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, RunEndEncoded, org_apache_arrow_flatbuf_RunEndEncoded) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, BinaryView, org_apache_arrow_flatbuf_BinaryView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, Utf8View, org_apache_arrow_flatbuf_Utf8View) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, ListView, org_apache_arrow_flatbuf_ListView) __flatbuffers_build_union_table_value_field(flatbuffers_, org_apache_arrow_flatbuf_Tensor_type, org_apache_arrow_flatbuf_Type, LargeListView, org_apache_arrow_flatbuf_LargeListView) __flatbuffers_build_table_vector_field(2, flatbuffers_, org_apache_arrow_flatbuf_Tensor_shape, org_apache_arrow_flatbuf_TensorDim, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_vector_field(3, flatbuffers_, org_apache_arrow_flatbuf_Tensor_strides, flatbuffers_int64, int64_t, org_apache_arrow_flatbuf_Tensor) __flatbuffers_build_struct_field(4, flatbuffers_, org_apache_arrow_flatbuf_Tensor_data, org_apache_arrow_flatbuf_Buffer, 16, 8, org_apache_arrow_flatbuf_Tensor) static inline org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_create(flatbuffers_builder_t *B __org_apache_arrow_flatbuf_Tensor_formal_args) { if (org_apache_arrow_flatbuf_Tensor_start(B) || org_apache_arrow_flatbuf_Tensor_data_add(B, v4) || org_apache_arrow_flatbuf_Tensor_type_add_value(B, v1) || org_apache_arrow_flatbuf_Tensor_shape_add(B, v2) || org_apache_arrow_flatbuf_Tensor_strides_add(B, v3) || org_apache_arrow_flatbuf_Tensor_type_add_type(B, v1.type)) { return 0; } return org_apache_arrow_flatbuf_Tensor_end(B); } static org_apache_arrow_flatbuf_Tensor_ref_t org_apache_arrow_flatbuf_Tensor_clone(flatbuffers_builder_t *B, org_apache_arrow_flatbuf_Tensor_table_t t) { __flatbuffers_memoize_begin(B, t); if (org_apache_arrow_flatbuf_Tensor_start(B) || org_apache_arrow_flatbuf_Tensor_data_pick(B, t) || org_apache_arrow_flatbuf_Tensor_type_pick(B, t) || org_apache_arrow_flatbuf_Tensor_shape_pick(B, t) || org_apache_arrow_flatbuf_Tensor_strides_pick(B, t)) { return 0; } __flatbuffers_memoize_end(B, t, org_apache_arrow_flatbuf_Tensor_end(B)); } #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_BUILDER_H */ #ifndef TENSOR_VERIFIER_H #define TENSOR_VERIFIER_H /* Generated by flatcc 0.6.2 FlatBuffers schema compiler for C by dvide.com */ #ifndef TENSOR_READER_H #include "Tensor_reader.h" #endif #include "flatcc/flatcc_verifier.h" #ifndef SCHEMA_VERIFIER_H #include "Schema_verifier.h" #endif #include "flatcc/flatcc_prologue.h" static int org_apache_arrow_flatbuf_TensorDim_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_Tensor_verify_table(flatcc_table_verifier_descriptor_t *td); static int org_apache_arrow_flatbuf_TensorDim_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_field(td, 0, 8, 8) /* size */)) return ret; if ((ret = flatcc_verify_string_field(td, 1, 0) /* name */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_type_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_TensorDim_type_identifier, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static inline int org_apache_arrow_flatbuf_TensorDim_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_TensorDim_verify_table); } static int org_apache_arrow_flatbuf_Tensor_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; if ((ret = flatcc_verify_union_field(td, 1, 1, &org_apache_arrow_flatbuf_Type_union_verifier) /* type */)) return ret; if ((ret = flatcc_verify_table_vector_field(td, 2, 1, &org_apache_arrow_flatbuf_TensorDim_verify_table) /* shape */)) return ret; if ((ret = flatcc_verify_vector_field(td, 3, 0, 8, 8, INT64_C(536870911)) /* strides */)) return ret; if ((ret = flatcc_verify_field(td, 4, 16, 8) /* data */)) return ret; return flatcc_verify_ok; } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_typed_root(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_type_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_typed_root_with_size(const void *buf, size_t bufsiz) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, org_apache_arrow_flatbuf_Tensor_type_identifier, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_identifier_and_size(const void *buf, size_t bufsiz, const char *fid) { return flatcc_verify_table_as_root_with_size(buf, bufsiz, fid, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Tensor_verify_table); } static inline int org_apache_arrow_flatbuf_Tensor_verify_as_root_with_type_hash_and_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { return flatcc_verify_table_as_typed_root_with_size(buf, bufsiz, thash, &org_apache_arrow_flatbuf_Tensor_verify_table); } #include "flatcc/flatcc_epilogue.h" #endif /* TENSOR_VERIFIER_H */ // 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 #include #include #include // For thread safe shared buffers we need C11 + stdatomic.h // Can compile with -DNANOARROW_IPC_USE_STDATOMIC=0 or 1 to override // automatic detection #if !defined(NANOARROW_IPC_USE_STDATOMIC) #define NANOARROW_IPC_USE_STDATOMIC 0 // Check for C11 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L // Check for GCC 4.8, which doesn't include stdatomic.h but does // not define __STDC_NO_ATOMICS__ #if defined(__clang__) || !defined(__GNUC__) || __GNUC__ >= 5 #if !defined(__STDC_NO_ATOMICS__) #include #undef NANOARROW_IPC_USE_STDATOMIC #define NANOARROW_IPC_USE_STDATOMIC 1 #endif #endif #endif #endif #include "nanoarrow.h" #include "nanoarrow_ipc.h" // R 3.6 / Windows builds on a very old toolchain that does not define ENODATA #if defined(_WIN32) && !defined(_MSC_VER) && !defined(ENODATA) #define ENODATA 120 #endif #define NANOARROW_IPC_MAGIC "ARROW1" // Internal representation of a parsed "Field" from flatbuffers. This // represents a field in a depth-first walk of column arrays and their // children. struct ArrowIpcField { // Pointer to the ArrowIpcDecoderPrivate::array_view or child for this node struct ArrowArrayView* array_view; // Pointer to the ArrowIpcDecoderPrivate::array or child for this node. This // array is scratch space for any intermediary allocations (i.e., it is never moved // to the user). struct ArrowArray* array; // The cumulative number of buffers preceding this node. int64_t buffer_offset; }; // Internal data specific to the read/decode process struct ArrowIpcDecoderPrivate { // The endianness that will be assumed for decoding future RecordBatch messages enum ArrowIpcEndianness endianness; // A cached system endianness value enum ArrowIpcEndianness system_endianness; // An ArrowArrayView whose length/null_count/buffers are set directly from the // deserialized flatbuffer message (i.e., no fully underlying ArrowArray exists, // although some buffers may be temporarily owned by ArrowIpcDecoderPrivate::array). struct ArrowArrayView array_view; // An ArrowArray with the same structure as the ArrowArrayView whose ArrowArrayBuffer() // values are used to allocate or store memory when this is required. This ArrowArray // is never moved to the caller; however, its buffers may be moved to the final output // ArrowArray if the caller requests one. struct ArrowArray array; // The number of fields in the flattened depth-first walk of columns and their children int64_t n_fields; // Array of cached information such that given a field index it is possible to locate // the ArrowArrayView/ArrowArray where the depth-first buffer/field walk should start. struct ArrowIpcField* fields; // The number of buffers that future RecordBatch messages must have to match the schema // that has been set. int64_t n_buffers; // The number of union fields in the Schema. int64_t n_union_fields; // A pointer to the last flatbuffers message. const void* last_message; // Storage for a Footer struct ArrowIpcFooter footer; }; ArrowErrorCode ArrowIpcCheckRuntime(struct ArrowError* error) { // Avoids an unused warning when bundling the header into nanoarrow_ipc.c NANOARROW_UNUSED(flatbuffers_end); const char* nanoarrow_runtime_version = ArrowNanoarrowVersion(); const char* nanoarrow_ipc_build_time_version = NANOARROW_VERSION; if (strcmp(nanoarrow_runtime_version, nanoarrow_ipc_build_time_version) != 0) { ArrowErrorSet(error, "Expected nanoarrow runtime version '%s' but found version '%s'", nanoarrow_ipc_build_time_version, nanoarrow_runtime_version); return EINVAL; } return NANOARROW_OK; } #if NANOARROW_IPC_USE_STDATOMIC struct ArrowIpcSharedBufferPrivate { struct ArrowBuffer src; atomic_long reference_count; }; static int64_t ArrowIpcSharedBufferUpdate( struct ArrowIpcSharedBufferPrivate* private_data, int delta) { int64_t old_count = atomic_fetch_add(&private_data->reference_count, delta); return old_count + delta; } static void ArrowIpcSharedBufferSet(struct ArrowIpcSharedBufferPrivate* private_data, int64_t count) { atomic_store(&private_data->reference_count, count); } int ArrowIpcSharedBufferIsThreadSafe(void) { return 1; } #else struct ArrowIpcSharedBufferPrivate { struct ArrowBuffer src; int64_t reference_count; }; static int64_t ArrowIpcSharedBufferUpdate( struct ArrowIpcSharedBufferPrivate* private_data, int delta) { private_data->reference_count += delta; return private_data->reference_count; } static void ArrowIpcSharedBufferSet(struct ArrowIpcSharedBufferPrivate* private_data, int64_t count) { private_data->reference_count = count; } int ArrowIpcSharedBufferIsThreadSafe(void) { return 0; } #endif static void ArrowIpcSharedBufferFree(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t size) { NANOARROW_UNUSED(allocator); NANOARROW_UNUSED(ptr); NANOARROW_UNUSED(size); struct ArrowIpcSharedBufferPrivate* private_data = (struct ArrowIpcSharedBufferPrivate*)allocator->private_data; if (ArrowIpcSharedBufferUpdate(private_data, -1) == 0) { ArrowBufferReset(&private_data->src); ArrowFree(private_data); } } ArrowErrorCode ArrowIpcSharedBufferInit(struct ArrowIpcSharedBuffer* shared, struct ArrowBuffer* src) { if (src->data == NULL) { ArrowBufferMove(src, &shared->private_src); return NANOARROW_OK; } struct ArrowIpcSharedBufferPrivate* private_data = (struct ArrowIpcSharedBufferPrivate*)ArrowMalloc( sizeof(struct ArrowIpcSharedBufferPrivate)); if (private_data == NULL) { return ENOMEM; } ArrowBufferMove(src, &private_data->src); ArrowIpcSharedBufferSet(private_data, 1); ArrowBufferInit(&shared->private_src); shared->private_src.data = private_data->src.data; shared->private_src.size_bytes = private_data->src.size_bytes; // Don't expose any extra capcity from src so that any calls to ArrowBufferAppend // on this buffer will fail. shared->private_src.capacity_bytes = private_data->src.size_bytes; shared->private_src.allocator = ArrowBufferDeallocator(&ArrowIpcSharedBufferFree, private_data); return NANOARROW_OK; } static void ArrowIpcSharedBufferClone(struct ArrowIpcSharedBuffer* shared, struct ArrowBuffer* shared_out) { if (shared->private_src.data == NULL) { ArrowBufferInit(shared_out); shared_out->size_bytes = shared_out->size_bytes; shared_out->capacity_bytes = shared_out->capacity_bytes; return; } struct ArrowIpcSharedBufferPrivate* private_data = (struct ArrowIpcSharedBufferPrivate*)shared->private_src.allocator.private_data; ArrowIpcSharedBufferUpdate(private_data, 1); memcpy(shared_out, shared, sizeof(struct ArrowBuffer)); } void ArrowIpcSharedBufferReset(struct ArrowIpcSharedBuffer* shared) { ArrowBufferReset(&shared->private_src); } static int ArrowIpcDecoderNeedsSwapEndian(struct ArrowIpcDecoder* decoder) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; switch (private_data->endianness) { case NANOARROW_IPC_ENDIANNESS_LITTLE: case NANOARROW_IPC_ENDIANNESS_BIG: return private_data->endianness != NANOARROW_IPC_ENDIANNESS_UNINITIALIZED && private_data->endianness != private_data->system_endianness; default: return 0; } } ArrowErrorCode ArrowIpcDecoderInit(struct ArrowIpcDecoder* decoder) { memset(decoder, 0, sizeof(struct ArrowIpcDecoder)); struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)ArrowMalloc(sizeof(struct ArrowIpcDecoderPrivate)); if (private_data == NULL) { return ENOMEM; } memset(private_data, 0, sizeof(struct ArrowIpcDecoderPrivate)); private_data->system_endianness = ArrowIpcSystemEndianness(); ArrowIpcFooterInit(&private_data->footer); decoder->private_data = private_data; return NANOARROW_OK; } void ArrowIpcDecoderReset(struct ArrowIpcDecoder* decoder) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; if (private_data != NULL) { ArrowArrayViewReset(&private_data->array_view); if (private_data->array.release != NULL) { ArrowArrayRelease(&private_data->array); } if (private_data->fields != NULL) { ArrowFree(private_data->fields); private_data->n_fields = 0; } private_data->n_union_fields = 0; ArrowIpcFooterReset(&private_data->footer); ArrowFree(private_data); memset(decoder, 0, sizeof(struct ArrowIpcDecoder)); } } static inline int32_t ArrowIpcReadInt32LE(struct ArrowBufferView* data, int swap_endian) { int32_t value; memcpy(&value, data->data.as_uint8, sizeof(int32_t)); if (swap_endian) { value = bswap32(value); } data->data.as_uint8 += sizeof(int32_t); data->size_bytes -= sizeof(int32_t); return value; } #define ns(x) FLATBUFFERS_WRAP_NAMESPACE(org_apache_arrow_flatbuf, x) static int ArrowIpcDecoderSetMetadata(struct ArrowSchema* schema, ns(KeyValue_vec_t) kv_vec, struct ArrowError* error) { int64_t n_pairs = ns(KeyValue_vec_len(kv_vec)); if (n_pairs == 0) { return NANOARROW_OK; } if (n_pairs > 2147483647) { ArrowErrorSet(error, "Expected between 0 and 2147483647 key/value pairs but found %" PRId64, n_pairs); return EINVAL; } struct ArrowBuffer buf; struct ArrowStringView key; struct ArrowStringView value; ns(KeyValue_table_t) kv; int result = ArrowMetadataBuilderInit(&buf, NULL); if (result != NANOARROW_OK) { ArrowBufferReset(&buf); ArrowErrorSet(error, "ArrowMetadataBuilderInit() failed"); return result; } for (int64_t i = 0; i < n_pairs; i++) { kv = ns(KeyValue_vec_at(kv_vec, i)); key.data = ns(KeyValue_key(kv)); key.size_bytes = strlen(key.data); value.data = ns(KeyValue_value(kv)); value.size_bytes = strlen(value.data); result = ArrowMetadataBuilderAppend(&buf, key, value); if (result != NANOARROW_OK) { ArrowBufferReset(&buf); ArrowErrorSet(error, "ArrowMetadataBuilderAppend() failed"); return result; } } result = ArrowSchemaSetMetadata(schema, (const char*)buf.data); ArrowBufferReset(&buf); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetMetadata() failed"); return result; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeSimple(struct ArrowSchema* schema, int nanoarrow_type, struct ArrowError* error) { int result = ArrowSchemaSetType(schema, nanoarrow_type); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetType() failed for type %s", ArrowTypeString(nanoarrow_type)); return result; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeInt(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Int_table_t) type = (ns(Int_table_t))type_generic; int is_signed = ns(Int_is_signed_get(type)); int bitwidth = ns(Int_bitWidth_get(type)); int nanoarrow_type = NANOARROW_TYPE_UNINITIALIZED; if (is_signed) { switch (bitwidth) { case 8: nanoarrow_type = NANOARROW_TYPE_INT8; break; case 16: nanoarrow_type = NANOARROW_TYPE_INT16; break; case 32: nanoarrow_type = NANOARROW_TYPE_INT32; break; case 64: nanoarrow_type = NANOARROW_TYPE_INT64; break; default: ArrowErrorSet(error, "Expected signed int bitwidth of 8, 16, 32, or 64 but got %d", bitwidth); return EINVAL; } } else { switch (bitwidth) { case 8: nanoarrow_type = NANOARROW_TYPE_UINT8; break; case 16: nanoarrow_type = NANOARROW_TYPE_UINT16; break; case 32: nanoarrow_type = NANOARROW_TYPE_UINT32; break; case 64: nanoarrow_type = NANOARROW_TYPE_UINT64; break; default: ArrowErrorSet(error, "Expected unsigned int bitwidth of 8, 16, 32, or 64 but got %d", bitwidth); return EINVAL; } } return ArrowIpcDecoderSetTypeSimple(schema, nanoarrow_type, error); } static int ArrowIpcDecoderSetTypeFloatingPoint(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(FloatingPoint_table_t) type = (ns(FloatingPoint_table_t))type_generic; int precision = ns(FloatingPoint_precision(type)); switch (precision) { case ns(Precision_HALF): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_HALF_FLOAT, error); case ns(Precision_SINGLE): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_FLOAT, error); case ns(Precision_DOUBLE): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_DOUBLE, error); default: ArrowErrorSet(error, "Unexpected FloatingPoint Precision value: %d", precision); return EINVAL; } } static int ArrowIpcDecoderSetTypeDecimal(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Decimal_table_t) type = (ns(Decimal_table_t))type_generic; int scale = ns(Decimal_scale(type)); int precision = ns(Decimal_precision(type)); int bitwidth = ns(Decimal_bitWidth(type)); int result; switch (bitwidth) { case 128: result = ArrowSchemaSetTypeDecimal(schema, NANOARROW_TYPE_DECIMAL128, precision, scale); break; case 256: result = ArrowSchemaSetTypeDecimal(schema, NANOARROW_TYPE_DECIMAL256, precision, scale); break; default: ArrowErrorSet(error, "Unexpected Decimal bitwidth value: %d", bitwidth); return EINVAL; } if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetTypeDecimal() failed"); return result; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeFixedSizeBinary(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(FixedSizeBinary_table_t) type = (ns(FixedSizeBinary_table_t))type_generic; int fixed_size = ns(FixedSizeBinary_byteWidth(type)); NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowSchemaSetTypeFixedSize(schema, NANOARROW_TYPE_FIXED_SIZE_BINARY, fixed_size), error); return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeDate(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Date_table_t) type = (ns(Date_table_t))type_generic; int date_unit = ns(Date_unit(type)); switch (date_unit) { case ns(DateUnit_DAY): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_DATE32, error); case ns(DateUnit_MILLISECOND): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_DATE64, error); default: ArrowErrorSet(error, "Unexpected Date DateUnit value: %d", (int)date_unit); return EINVAL; } } static int ArrowIpcDecoderSetTypeTime(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Time_table_t) type = (ns(Time_table_t))type_generic; int time_unit = ns(Time_unit(type)); int bitwidth = ns(Time_bitWidth(type)); int nanoarrow_type; switch (time_unit) { case ns(TimeUnit_SECOND): case ns(TimeUnit_MILLISECOND): if (bitwidth != 32) { ArrowErrorSet(error, "Expected bitwidth of 32 for Time TimeUnit %s but found %d", ns(TimeUnit_name(ns(Time_unit(type)))), bitwidth); return EINVAL; } nanoarrow_type = NANOARROW_TYPE_TIME32; break; case ns(TimeUnit_MICROSECOND): case ns(TimeUnit_NANOSECOND): if (bitwidth != 64) { ArrowErrorSet(error, "Expected bitwidth of 64 for Time TimeUnit %s but found %d", ns(TimeUnit_name(ns(Time_unit(type)))), bitwidth); return EINVAL; } nanoarrow_type = NANOARROW_TYPE_TIME64; break; default: ArrowErrorSet(error, "Unexpected Time TimeUnit value: %d", time_unit); return EINVAL; } int result = ArrowSchemaSetTypeDateTime(schema, nanoarrow_type, time_unit, NULL); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetTypeDateTime() failed"); return result; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeTimestamp(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Timestamp_table_t) type = (ns(Timestamp_table_t))type_generic; int time_unit = ns(Timestamp_unit(type)); const char* timezone = ""; if (ns(Timestamp_timezone_is_present(type))) { timezone = ns(Timestamp_timezone_get(type)); } int result = ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_TIMESTAMP, time_unit, timezone); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetTypeDateTime() failed"); return result; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeDuration(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Duration_table_t) type = (ns(Duration_table_t))type_generic; int time_unit = ns(Duration_unit(type)); int result = ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_DURATION, time_unit, NULL); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetTypeDateTime() failed"); return result; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeInterval(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Interval_table_t) type = (ns(Interval_table_t))type_generic; int interval_unit = ns(Interval_unit(type)); switch (interval_unit) { case ns(IntervalUnit_YEAR_MONTH): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_INTERVAL_MONTHS, error); case ns(IntervalUnit_DAY_TIME): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_INTERVAL_DAY_TIME, error); case ns(IntervalUnit_MONTH_DAY_NANO): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO, error); default: ArrowErrorSet(error, "Unexpected Interval unit value: %d", interval_unit); return EINVAL; } } // We can't quite use nanoarrow's built-in SchemaSet functions for nested types // because the IPC format allows modifying some of the defaults those functions assume. // In particular, the allocate + initialize children step is handled outside these // setters. static int ArrowIpcDecoderSetTypeSimpleNested(struct ArrowSchema* schema, const char* format, struct ArrowError* error) { int result = ArrowSchemaSetFormat(schema, format); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetFormat('%s') failed", format); return result; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeFixedSizeList(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(FixedSizeList_table_t) type = (ns(FixedSizeList_table_t))type_generic; int32_t fixed_size = ns(FixedSizeList_listSize(type)); char fixed_size_str[128]; int n_chars = snprintf(fixed_size_str, 128, "+w:%d", fixed_size); if (n_chars < 0) { ArrowErrorSet(error, "snprintf() encoding error"); return ERANGE; } fixed_size_str[n_chars] = '\0'; return ArrowIpcDecoderSetTypeSimpleNested(schema, fixed_size_str, error); } static int ArrowIpcDecoderSetTypeMap(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, struct ArrowError* error) { ns(Map_table_t) type = (ns(Map_table_t))type_generic; NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderSetTypeSimpleNested(schema, "+m", error)); if (ns(Map_keysSorted(type))) { schema->flags |= ARROW_FLAG_MAP_KEYS_SORTED; } else { schema->flags &= ~ARROW_FLAG_MAP_KEYS_SORTED; } return NANOARROW_OK; } static int ArrowIpcDecoderSetTypeUnion(struct ArrowSchema* schema, flatbuffers_generic_t type_generic, int64_t n_children, struct ArrowError* error) { ns(Union_table_t) type = (ns(Union_table_t))type_generic; int union_mode = ns(Union_mode(type)); if (n_children < 0 || n_children > 127) { ArrowErrorSet(error, "Expected between 0 and 127 children for Union type but found %" PRId64, n_children); return EINVAL; } // Max valid typeIds size is 127; the longest single ID that could be present here // is -INT_MIN (11 chars). With commas and the prefix the max size would be // 1527 characters. (Any ids outside the range 0...127 are unlikely to be valid // elsewhere but they could in theory be present here). char union_types_str[2048]; memset(union_types_str, 0, sizeof(union_types_str)); char* format_cursor = union_types_str; int format_out_size = sizeof(union_types_str); int n_chars = 0; switch (union_mode) { case ns(UnionMode_Sparse): n_chars = snprintf(format_cursor, format_out_size, "+us:"); format_cursor += n_chars; format_out_size -= n_chars; break; case ns(UnionMode_Dense): n_chars = snprintf(format_cursor, format_out_size, "+ud:"); format_cursor += n_chars; format_out_size -= n_chars; break; default: ArrowErrorSet(error, "Unexpected Union UnionMode value: %d", union_mode); return EINVAL; } if (n_chars < 0) { ArrowErrorSet(error, "snprintf() encoding error"); return ERANGE; } if (ns(Union_typeIds_is_present(type))) { flatbuffers_int32_vec_t type_ids = ns(Union_typeIds(type)); int64_t n_type_ids = flatbuffers_int32_vec_len(type_ids); if (n_type_ids != n_children) { ArrowErrorSet(error, "Expected between %" PRId64 " children for Union type with %" PRId64 " typeIds but found %" PRId64, n_type_ids, n_type_ids, n_children); return EINVAL; } if (n_type_ids > 0) { n_chars = snprintf(format_cursor, format_out_size, "%d", flatbuffers_int32_vec_at(type_ids, 0)); format_cursor += n_chars; format_out_size -= n_chars; if (n_chars < 0) { ArrowErrorSet(error, "snprintf() encoding error"); return ERANGE; } for (int64_t i = 1; i < n_type_ids; i++) { n_chars = snprintf(format_cursor, format_out_size, ",%" PRId32, flatbuffers_int32_vec_at(type_ids, i)); format_cursor += n_chars; format_out_size -= n_chars; if (n_chars < 0) { ArrowErrorSet(error, "snprintf() encoding error"); return ERANGE; } } } } else if (n_children > 0) { n_chars = snprintf(format_cursor, format_out_size, "0"); format_cursor += n_chars; format_out_size -= n_chars; if (n_chars < 0) { ArrowErrorSet(error, "snprintf() encoding error"); return ERANGE; } for (int64_t i = 1; i < n_children; i++) { n_chars = snprintf(format_cursor, format_out_size, ",%" PRId64, i); format_cursor += n_chars; format_out_size -= n_chars; if (n_chars < 0) { ArrowErrorSet(error, "snprintf() encoding error"); return ERANGE; } } } return ArrowIpcDecoderSetTypeSimpleNested(schema, union_types_str, error); } static int ArrowIpcDecoderSetType(struct ArrowSchema* schema, ns(Field_table_t) field, int64_t n_children, struct ArrowError* error) { int type_type = ns(Field_type_type(field)); switch (type_type) { case ns(Type_Null): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_NA, error); case ns(Type_Bool): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_BOOL, error); case ns(Type_Int): return ArrowIpcDecoderSetTypeInt(schema, ns(Field_type_get(field)), error); case ns(Type_FloatingPoint): return ArrowIpcDecoderSetTypeFloatingPoint(schema, ns(Field_type_get(field)), error); case ns(Type_Decimal): return ArrowIpcDecoderSetTypeDecimal(schema, ns(Field_type_get(field)), error); case ns(Type_Binary): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_BINARY, error); case ns(Type_LargeBinary): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_LARGE_BINARY, error); case ns(Type_FixedSizeBinary): return ArrowIpcDecoderSetTypeFixedSizeBinary(schema, ns(Field_type_get(field)), error); case ns(Type_Utf8): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_STRING, error); case ns(Type_LargeUtf8): return ArrowIpcDecoderSetTypeSimple(schema, NANOARROW_TYPE_LARGE_STRING, error); case ns(Type_Date): return ArrowIpcDecoderSetTypeDate(schema, ns(Field_type_get(field)), error); case ns(Type_Time): return ArrowIpcDecoderSetTypeTime(schema, ns(Field_type_get(field)), error); case ns(Type_Timestamp): return ArrowIpcDecoderSetTypeTimestamp(schema, ns(Field_type_get(field)), error); case ns(Type_Duration): return ArrowIpcDecoderSetTypeDuration(schema, ns(Field_type_get(field)), error); case ns(Type_Interval): return ArrowIpcDecoderSetTypeInterval(schema, ns(Field_type_get(field)), error); case ns(Type_Struct_): return ArrowIpcDecoderSetTypeSimpleNested(schema, "+s", error); case ns(Type_List): return ArrowIpcDecoderSetTypeSimpleNested(schema, "+l", error); case ns(Type_LargeList): return ArrowIpcDecoderSetTypeSimpleNested(schema, "+L", error); case ns(Type_FixedSizeList): return ArrowIpcDecoderSetTypeFixedSizeList(schema, ns(Field_type_get(field)), error); case ns(Type_Map): return ArrowIpcDecoderSetTypeMap(schema, ns(Field_type_get(field)), error); case ns(Type_Union): return ArrowIpcDecoderSetTypeUnion(schema, ns(Field_type_get(field)), n_children, error); default: ArrowErrorSet(error, "Unrecognized Field type with value %d", type_type); return EINVAL; } } static int ArrowIpcDecoderSetChildren(struct ArrowSchema* schema, ns(Field_vec_t) fields, struct ArrowError* error); static int ArrowIpcDecoderSetField(struct ArrowSchema* schema, ns(Field_table_t) field, struct ArrowError* error) { // No dictionary support yet if (ns(Field_dictionary_is_present(field))) { ArrowErrorSet(error, "Schema message field with DictionaryEncoding not supported"); return ENOTSUP; } int result; if (ns(Field_name_is_present(field))) { result = ArrowSchemaSetName(schema, ns(Field_name_get(field))); } else { result = ArrowSchemaSetName(schema, ""); } if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaSetName() failed"); return result; } // Sets the schema->format and validates type-related inconsistencies // that might exist in the flatbuffer ns(Field_vec_t) children = ns(Field_children(field)); int64_t n_children = ns(Field_vec_len(children)); NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderSetType(schema, field, n_children, error)); // nanoarrow's type setters set the nullable flag by default, so we might // have to unset it here. if (ns(Field_nullable_get(field))) { schema->flags |= ARROW_FLAG_NULLABLE; } else { schema->flags &= ~ARROW_FLAG_NULLABLE; } // Children are defined separately in the flatbuffer, so we allocate, initialize // and set them separately as well. result = ArrowSchemaAllocateChildren(schema, n_children); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowSchemaAllocateChildren() failed"); return result; } for (int64_t i = 0; i < n_children; i++) { ArrowSchemaInit(schema->children[i]); } NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderSetChildren(schema, children, error)); return ArrowIpcDecoderSetMetadata(schema, ns(Field_custom_metadata(field)), error); } static int ArrowIpcDecoderSetChildren(struct ArrowSchema* schema, ns(Field_vec_t) fields, struct ArrowError* error) { int64_t n_fields = ns(Schema_vec_len(fields)); for (int64_t i = 0; i < n_fields; i++) { ns(Field_table_t) field = ns(Field_vec_at(fields, i)); NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderSetField(schema->children[i], field, error)); } return NANOARROW_OK; } static int ArrowIpcDecoderDecodeSchemaHeader(struct ArrowIpcDecoder* decoder, flatbuffers_generic_t message_header, struct ArrowError* error) { ns(Schema_table_t) schema = (ns(Schema_table_t))message_header; int endianness = ns(Schema_endianness(schema)); switch (endianness) { case ns(Endianness_Little): decoder->endianness = NANOARROW_IPC_ENDIANNESS_LITTLE; break; case ns(Endianness_Big): decoder->endianness = NANOARROW_IPC_ENDIANNESS_BIG; break; default: ArrowErrorSet(error, "Expected Schema endianness of 0 (little) or 1 (big) but got %d", endianness); return EINVAL; } ns(Feature_vec_t) features = ns(Schema_features(schema)); int64_t n_features = ns(Feature_vec_len(features)); decoder->feature_flags = 0; for (int64_t i = 0; i < n_features; i++) { ns(Feature_enum_t) feature = ns(Feature_vec_at(features, i)); switch (feature) { case ns(Feature_COMPRESSED_BODY): decoder->feature_flags |= NANOARROW_IPC_FEATURE_COMPRESSED_BODY; break; case ns(Feature_DICTIONARY_REPLACEMENT): decoder->feature_flags |= NANOARROW_IPC_FEATURE_DICTIONARY_REPLACEMENT; break; default: ArrowErrorSet(error, "Unrecognized Schema feature with value %d", (int)feature); return EINVAL; } } return NANOARROW_OK; } static int ArrowIpcDecoderDecodeRecordBatchHeader(struct ArrowIpcDecoder* decoder, flatbuffers_generic_t message_header, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; ns(RecordBatch_table_t) batch = (ns(RecordBatch_table_t))message_header; ns(FieldNode_vec_t) fields = ns(RecordBatch_nodes(batch)); ns(Buffer_vec_t) buffers = ns(RecordBatch_buffers(batch)); int64_t n_fields = ns(FieldNode_vec_len(fields)); int64_t n_buffers = ns(Buffer_vec_len(buffers)); // Check field node and buffer count. We have one more field and buffer // because we count the root struct and the flatbuffer message does not. if ((n_fields + 1) != private_data->n_fields) { ArrowErrorSet(error, "Expected %" PRId64 " field nodes in message but found %" PRId64, private_data->n_fields - 1, n_fields); return EINVAL; } int64_t n_expected_buffers = private_data->n_buffers; if (decoder->metadata_version < NANOARROW_IPC_METADATA_VERSION_V5) { // Unions had null buffers before arrow 1.0, so expect one extra buffer per union // field n_expected_buffers += private_data->n_union_fields; } if ((n_buffers + 1) != n_expected_buffers) { ArrowErrorSet(error, "Expected %" PRId64 " buffers in message but found %" PRId64, n_expected_buffers - 1, n_buffers); return EINVAL; } if (ns(RecordBatch_compression_is_present(batch))) { ns(BodyCompression_table_t) compression = ns(RecordBatch_compression(batch)); ns(CompressionType_enum_t) codec = ns(BodyCompression_codec(compression)); switch (codec) { case ns(CompressionType_LZ4_FRAME): decoder->codec = NANOARROW_IPC_COMPRESSION_TYPE_LZ4_FRAME; break; case ns(CompressionType_ZSTD): decoder->codec = NANOARROW_IPC_COMPRESSION_TYPE_ZSTD; break; default: ArrowErrorSet(error, "Unrecognized RecordBatch BodyCompression codec value: %d", (int)codec); return EINVAL; } } else { decoder->codec = NANOARROW_IPC_COMPRESSION_TYPE_NONE; } // Copying field node and buffer information is separate so as only to pay for the // nodes that are actually accessed. return NANOARROW_OK; } // Wipes any "current message" fields before moving on to a new message static inline void ArrowIpcDecoderResetHeaderInfo(struct ArrowIpcDecoder* decoder) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; decoder->message_type = 0; decoder->metadata_version = 0; decoder->endianness = 0; decoder->feature_flags = 0; decoder->codec = 0; decoder->header_size_bytes = 0; decoder->body_size_bytes = 0; decoder->footer = NULL; ArrowIpcFooterReset(&private_data->footer); private_data->last_message = NULL; } // Returns NANOARROW_OK if data is large enough to read the first 8 bytes // of the message header, ESPIPE if reading more data might help, or EINVAL if the content // is not valid. Advances the input ArrowBufferView by prefix_size (8 bytes or 4 bytes if // the message is pre-0.15 and has no continuation). Sets decoder->header_size_bytes // to the flatbuffers length plus the prefix_size. static inline int ArrowIpcDecoderReadHeaderPrefix(struct ArrowIpcDecoder* decoder, struct ArrowBufferView* data_mut, int32_t* prefix_size_bytes, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; if (data_mut->size_bytes < 8) { ArrowErrorSet(error, "Expected data of at least 8 bytes but only %" PRId64 " bytes remain", data_mut->size_bytes); return ESPIPE; } int swap_endian = private_data->system_endianness == NANOARROW_IPC_ENDIANNESS_BIG; int32_t continuation = ArrowIpcReadInt32LE(data_mut, swap_endian); int32_t length; if ((uint32_t)continuation != 0xFFFFFFFF) { if (continuation < 0) { ArrowErrorSet(error, "Expected 0xFFFFFFFF at start of message but found 0x%08X", (unsigned int)continuation); return EINVAL; } // Tolerate pre-0.15 encapsulated messages which only had the length prefix length = continuation; *prefix_size_bytes = sizeof(length); } else { length = ArrowIpcReadInt32LE(data_mut, swap_endian); *prefix_size_bytes = sizeof(continuation) + sizeof(length); } decoder->header_size_bytes = *prefix_size_bytes + length; if (length < 0) { ArrowErrorSet(error, "Expected message size > 0 but found message size of %" PRId32 " bytes", length); return EINVAL; } if (length == 0) { ArrowErrorSet(error, "End of Arrow stream"); return ENODATA; } return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderPeekHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, int32_t* prefix_size_bytes, struct ArrowError* error) { ArrowIpcDecoderResetHeaderInfo(decoder); NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderReadHeaderPrefix(decoder, &data, prefix_size_bytes, error)); return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderVerifyHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; ArrowIpcDecoderResetHeaderInfo(decoder); int32_t prefix_size_bytes; NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderReadHeaderPrefix(decoder, &data, &prefix_size_bytes, error)); // Check that data contains at least the entire header (return ESPIPE to signal // that reading more data may help). if (data.size_bytes < decoder->header_size_bytes - prefix_size_bytes) { ArrowErrorSet(error, "Expected >= %d bytes of remaining data but found %" PRId64 " bytes in buffer", decoder->header_size_bytes, data.size_bytes + prefix_size_bytes); return ESPIPE; } // Run flatbuffers verification enum flatcc_verify_error_no verify_error = ns(Message_verify_as_root(data.data.as_uint8, decoder->header_size_bytes - prefix_size_bytes); if (verify_error != flatcc_verify_ok)) { ArrowErrorSet(error, "Message flatbuffer verification failed (%d) %s", (int)verify_error, flatcc_verify_error_string(verify_error)); return EINVAL; } // Read some basic information from the message ns(Message_table_t) message = ns(Message_as_root(data.data.as_uint8)); decoder->metadata_version = ns(Message_version(message)); decoder->message_type = ns(Message_header_type(message)); decoder->body_size_bytes = ns(Message_bodyLength(message)); private_data->last_message = ns(Message_header_get(message)); return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderPeekFooter(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; ArrowIpcDecoderResetHeaderInfo(decoder); if (data.size_bytes < (int)strlen(NANOARROW_IPC_MAGIC) + (int)sizeof(int32_t)) { ArrowErrorSet(error, "Expected data of at least 10 bytes but only %" PRId64 " bytes are available", data.size_bytes); return ESPIPE; } const char* data_end = data.data.as_char + data.size_bytes; const char* magic = data_end - strlen(NANOARROW_IPC_MAGIC); const char* footer_size_data = magic - sizeof(int32_t); if (memcmp(magic, NANOARROW_IPC_MAGIC, strlen(NANOARROW_IPC_MAGIC)) != 0) { ArrowErrorSet(error, "Expected file to end with ARROW1 but got %s", data_end); return EINVAL; } int32_t footer_size; memcpy(&footer_size, footer_size_data, sizeof(footer_size)); if (private_data->system_endianness == NANOARROW_IPC_ENDIANNESS_BIG) { footer_size = bswap32(footer_size); } if (footer_size < 0) { ArrowErrorSet(error, "Expected footer size > 0 but found footer size of %d bytes", footer_size); return EINVAL; } decoder->header_size_bytes = footer_size; return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderVerifyFooter(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error) { NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderPeekFooter(decoder, data, error)); // Check that data contains at least the entire footer (return ESPIPE to signal // that reading more data may help). int32_t footer_and_size_and_magic_size = decoder->header_size_bytes + sizeof(int32_t) + strlen(NANOARROW_IPC_MAGIC); if (data.size_bytes < footer_and_size_and_magic_size) { ArrowErrorSet(error, "Expected >= %d bytes of data but only %" PRId64 " bytes are in the buffer", footer_and_size_and_magic_size, data.size_bytes); return ESPIPE; } const uint8_t* footer_data = data.data.as_uint8 + data.size_bytes - footer_and_size_and_magic_size; // Run flatbuffers verification enum flatcc_verify_error_no verify_error = ns(Footer_verify_as_root(footer_data, decoder->header_size_bytes)); if (verify_error != flatcc_verify_ok) { ArrowErrorSet(error, "Footer flatbuffer verification failed (%d) %s", (int)verify_error, flatcc_verify_error_string(verify_error)); return EINVAL; } // Read some basic information from the message ns(Footer_table_t) footer = ns(Footer_as_root(footer_data)); if (ns(Footer_schema(footer)) == NULL) { ArrowErrorSet(error, "Footer has no schema"); return EINVAL; } decoder->metadata_version = ns(Footer_version(footer)); decoder->body_size_bytes = 0; return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderDecodeHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; ArrowIpcDecoderResetHeaderInfo(decoder); int32_t prefix_size_bytes; NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderReadHeaderPrefix(decoder, &data, &prefix_size_bytes, error)); // Check that data contains at least the entire header (return ESPIPE to signal // that reading more data may help). if (data.size_bytes < decoder->header_size_bytes - prefix_size_bytes) { ArrowErrorSet(error, "Expected >= %d bytes of remaining data but found %" PRId64 " bytes in buffer", decoder->header_size_bytes, data.size_bytes + prefix_size_bytes); return ESPIPE; } ns(Message_table_t) message = ns(Message_as_root(data.data.as_uint8)); if (!message) { return EINVAL; } // Read some basic information from the message decoder->metadata_version = ns(Message_version(message)); decoder->message_type = ns(Message_header_type(message)); decoder->body_size_bytes = ns(Message_bodyLength(message)); switch (decoder->metadata_version) { case ns(MetadataVersion_V4): case ns(MetadataVersion_V5): break; ArrowErrorSet(error, "Expected metadata version V4 or V5 but found %s", ns(MetadataVersion_name(ns(Message_version(message))))); return EINVAL; case ns(MetadataVersion_V1): case ns(MetadataVersion_V2): case ns(MetadataVersion_V3): default: ArrowErrorSet(error, "Unexpected value for Message metadata version (%d)", decoder->metadata_version); return EINVAL; } flatbuffers_generic_t message_header = ns(Message_header_get(message)); switch (decoder->message_type) { case ns(MessageHeader_Schema): NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderDecodeSchemaHeader(decoder, message_header, error)); break; case ns(MessageHeader_RecordBatch): NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderDecodeRecordBatchHeader(decoder, message_header, error)); break; case ns(MessageHeader_DictionaryBatch): case ns(MessageHeader_Tensor): case ns(MessageHeader_SparseTensor): ArrowErrorSet(error, "Unsupported message type: '%s'", ns(MessageHeader_type_name(ns(Message_header_type(message))))); return ENOTSUP; default: ArrowErrorSet(error, "Unknown message type: %d", (int)(decoder->message_type)); return EINVAL; } private_data->last_message = message_header; return NANOARROW_OK; } static ArrowErrorCode ArrowIpcDecoderDecodeSchemaImpl(ns(Schema_table_t) schema, struct ArrowSchema* out, struct ArrowError* error) { ArrowSchemaInit(out); // Top-level batch schema is typically non-nullable out->flags = 0; ns(Field_vec_t) fields = ns(Schema_fields(schema)); int64_t n_fields = ns(Schema_vec_len(fields)); ArrowErrorCode result = ArrowSchemaSetTypeStruct(out, n_fields); if (result != NANOARROW_OK) { ArrowErrorSet(error, "Failed to allocate struct schema with %" PRId64 " children", n_fields); return result; } NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderSetChildren(out, fields, error)); NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderSetMetadata(out, ns(Schema_custom_metadata(schema)), error)); return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderDecodeSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* out, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; if (private_data->last_message == NULL || decoder->message_type != NANOARROW_IPC_MESSAGE_TYPE_SCHEMA) { ArrowErrorSet(error, "decoder did not just decode a Schema message"); return EINVAL; } struct ArrowSchema tmp; ArrowErrorCode result = ArrowIpcDecoderDecodeSchemaImpl( (ns(Schema_table_t))private_data->last_message, &tmp, error); if (result != NANOARROW_OK) { ArrowSchemaRelease(&tmp); return result; } ArrowSchemaMove(&tmp, out); return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderDecodeFooter(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; int32_t footer_and_size_and_magic_size = decoder->header_size_bytes + sizeof(int32_t) + strlen(NANOARROW_IPC_MAGIC); const uint8_t* footer_data = data.data.as_uint8 + data.size_bytes - footer_and_size_and_magic_size; ns(Footer_table_t) footer = ns(Footer_as_root(footer_data)); NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderDecodeSchemaHeader(decoder, ns(Footer_schema(footer)), error)); NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderDecodeSchemaImpl( ns(Footer_schema(footer)), &private_data->footer.schema, error)); ns(Block_vec_t) blocks = ns(Footer_recordBatches(footer)); int64_t n = ns(Block_vec_len(blocks)); NANOARROW_RETURN_NOT_OK(ArrowBufferResize(&private_data->footer.record_batch_blocks, sizeof(struct ArrowIpcFileBlock) * n, /*shrink_to_fit=*/0)); struct ArrowIpcFileBlock* record_batches = (struct ArrowIpcFileBlock*)private_data->footer.record_batch_blocks.data; for (int64_t i = 0; i < n; i++) { record_batches[i].offset = ns(Block_offset(blocks + i)); record_batches[i].metadata_length = ns(Block_metaDataLength(blocks + i)); record_batches[i].body_length = ns(Block_bodyLength(blocks + i)); } decoder->footer = &private_data->footer; return NANOARROW_OK; } static void ArrowIpcDecoderCountFields(struct ArrowSchema* schema, int64_t* n_fields) { *n_fields += 1; for (int64_t i = 0; i < schema->n_children; i++) { ArrowIpcDecoderCountFields(schema->children[i], n_fields); } } static void ArrowIpcDecoderInitFields(struct ArrowIpcField* fields, struct ArrowArrayView* array_view, struct ArrowArray* array, int64_t* n_fields, int64_t* n_buffers, int64_t* n_union_fields) { struct ArrowIpcField* field = fields + (*n_fields); field->array_view = array_view; field->array = array; field->buffer_offset = *n_buffers; for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { *n_buffers += array_view->layout.buffer_type[i] != NANOARROW_BUFFER_TYPE_NONE; } *n_union_fields += array_view->storage_type == NANOARROW_TYPE_SPARSE_UNION || array_view->storage_type == NANOARROW_TYPE_DENSE_UNION; *n_fields += 1; for (int64_t i = 0; i < array_view->n_children; i++) { ArrowIpcDecoderInitFields(fields, array_view->children[i], array->children[i], n_fields, n_buffers, n_union_fields); } } ArrowErrorCode ArrowIpcDecoderSetSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* schema, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; // Reset previously allocated schema-specific resources private_data->n_buffers = 0; private_data->n_fields = 0; private_data->n_union_fields = 0; ArrowArrayViewReset(&private_data->array_view); if (private_data->array.release != NULL) { ArrowArrayRelease(&private_data->array); } if (private_data->fields != NULL) { ArrowFree(private_data->fields); } // Allocate Array and ArrayView based on schema without moving the schema. // This will fail if the schema is not valid. NANOARROW_RETURN_NOT_OK( ArrowArrayViewInitFromSchema(&private_data->array_view, schema, error)); NANOARROW_RETURN_NOT_OK(ArrowArrayInitFromArrayView(&private_data->array, &private_data->array_view, error)); // Root must be a struct if (private_data->array_view.storage_type != NANOARROW_TYPE_STRUCT) { ArrowErrorSet(error, "schema must be a struct type"); return EINVAL; } // Walk tree and calculate how many fields we need to allocate ArrowIpcDecoderCountFields(schema, &private_data->n_fields); private_data->fields = (struct ArrowIpcField*)ArrowMalloc(private_data->n_fields * sizeof(struct ArrowIpcField)); if (private_data->fields == NULL) { ArrowErrorSet(error, "Failed to allocate decoder->fields"); return ENOMEM; } memset(private_data->fields, 0, private_data->n_fields * sizeof(struct ArrowIpcField)); // Init field information and calculate starting buffer offset for each int64_t field_i = 0; ArrowIpcDecoderInitFields(private_data->fields, &private_data->array_view, &private_data->array, &field_i, &private_data->n_buffers, &private_data->n_union_fields); return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderSetEndianness(struct ArrowIpcDecoder* decoder, enum ArrowIpcEndianness endianness) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; switch (endianness) { case NANOARROW_IPC_ENDIANNESS_UNINITIALIZED: case NANOARROW_IPC_ENDIANNESS_LITTLE: case NANOARROW_IPC_ENDIANNESS_BIG: private_data->endianness = endianness; return NANOARROW_OK; default: return EINVAL; } } /// \brief Information required to read and/or decompress a single buffer /// /// The RecordBatch message header contains a description of each buffer /// in the message body. The ArrowIpcBufferSource is the parsed result of /// a single buffer with compression and endian information such that the /// original buffer can be reconstructed. struct ArrowIpcBufferSource { int64_t body_offset_bytes; int64_t buffer_length_bytes; enum ArrowIpcCompressionType codec; enum ArrowType data_type; int64_t element_size_bits; int swap_endian; }; /// \brief Materializing ArrowBuffer objects /// /// Given a description of where a buffer is located inside the message body, make /// the ArrowBuffer that will be placed into the correct ArrowArray. The decoder /// does not do any IO and does not make any assumptions about how or if the body /// has been read into memory. This abstraction is currently internal and exists /// to support the two obvious ways a user might go about this: (1) using a /// non-owned view of memory that must be copied slice-wise or (2) adding a reference /// to an ArrowIpcSharedBuffer and returning a slice of that memory. struct ArrowIpcBufferFactory { /// \brief User-defined callback to populate a buffer view /// /// At the time that this callback is called, the ArrowIpcBufferSource has been checked /// to ensure that it is within the body size declared by the message header. A /// possibly preallocated ArrowBuffer (dst) is provided, which implementations must use /// if an allocation is required (in which case the view must be populated pointing to /// the contents of the ArrowBuffer) If NANOARROW_OK is not returned, error must contain /// a null-terminated message. ArrowErrorCode (*make_buffer)(struct ArrowIpcBufferFactory* factory, struct ArrowIpcBufferSource* src, struct ArrowBufferView* dst_view, struct ArrowBuffer* dst, struct ArrowError* error); /// \brief Caller-defined private data to be used in the callback. /// /// Usually this would be a description of where the body has been read into memory or /// information required to do so. void* private_data; }; static ArrowErrorCode ArrowIpcMakeBufferFromView(struct ArrowIpcBufferFactory* factory, struct ArrowIpcBufferSource* src, struct ArrowBufferView* dst_view, struct ArrowBuffer* dst, struct ArrowError* error) { NANOARROW_UNUSED(factory); NANOARROW_UNUSED(dst); NANOARROW_UNUSED(error); struct ArrowBufferView* body = (struct ArrowBufferView*)factory->private_data; dst_view->data.as_uint8 = body->data.as_uint8 + src->body_offset_bytes; dst_view->size_bytes = src->buffer_length_bytes; return NANOARROW_OK; } static struct ArrowIpcBufferFactory ArrowIpcBufferFactoryFromView( struct ArrowBufferView* buffer_view) { struct ArrowIpcBufferFactory out; out.make_buffer = &ArrowIpcMakeBufferFromView; out.private_data = buffer_view; return out; } static ArrowErrorCode ArrowIpcMakeBufferFromShared(struct ArrowIpcBufferFactory* factory, struct ArrowIpcBufferSource* src, struct ArrowBufferView* dst_view, struct ArrowBuffer* dst, struct ArrowError* error) { NANOARROW_UNUSED(error); struct ArrowIpcSharedBuffer* shared = (struct ArrowIpcSharedBuffer*)factory->private_data; ArrowBufferReset(dst); ArrowIpcSharedBufferClone(shared, dst); dst->data += src->body_offset_bytes; dst->size_bytes = src->buffer_length_bytes; dst_view->data.data = dst->data; dst_view->size_bytes = dst->size_bytes; return NANOARROW_OK; } static struct ArrowIpcBufferFactory ArrowIpcBufferFactoryFromShared( struct ArrowIpcSharedBuffer* shared) { struct ArrowIpcBufferFactory out; out.make_buffer = &ArrowIpcMakeBufferFromShared; out.private_data = shared; return out; } // Just for the purposes of endian-swapping struct ArrowIpcIntervalMonthDayNano { uint32_t months; uint32_t days; uint64_t ns; }; static int ArrowIpcDecoderSwapEndian(struct ArrowIpcBufferSource* src, struct ArrowBufferView* out_view, struct ArrowBuffer* dst, struct ArrowError* error) { NANOARROW_DCHECK(out_view->size_bytes > 0); NANOARROW_DCHECK(out_view->data.data != NULL); // Some buffer data types don't need any endian swapping switch (src->data_type) { case NANOARROW_TYPE_BOOL: case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_BINARY: return NANOARROW_OK; default: break; } // Make sure dst is not a shared buffer that we can't modify struct ArrowBuffer tmp; ArrowBufferInit(&tmp); if (dst->allocator.private_data != NULL) { ArrowBufferMove(dst, &tmp); ArrowBufferInit(dst); } if (dst->size_bytes == 0) { NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(dst, out_view->size_bytes)); dst->size_bytes = out_view->size_bytes; } switch (src->data_type) { case NANOARROW_TYPE_DECIMAL128: case NANOARROW_TYPE_DECIMAL256: { const uint64_t* ptr_src = out_view->data.as_uint64; uint64_t* ptr_dst = (uint64_t*)dst->data; uint64_t words[4]; int n_words = (int)(src->element_size_bits / 64); NANOARROW_DCHECK(n_words == 2 || n_words == 4); for (int64_t i = 0; i < (dst->size_bytes / n_words / 8); i++) { for (int j = 0; j < n_words; j++) { words[j] = bswap64(ptr_src[i * n_words + j]); } for (int j = 0; j < n_words; j++) { ptr_dst[i * n_words + j] = words[n_words - j - 1]; } } break; } case NANOARROW_TYPE_INTERVAL_DAY_TIME: { uint32_t* ptr = (uint32_t*)dst->data; for (int64_t i = 0; i < (dst->size_bytes / 4); i++) { ptr[i] = bswap32(out_view->data.as_uint32[i]); } break; } case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: { const uint8_t* ptr_src = out_view->data.as_uint8; uint8_t* ptr_dst = dst->data; int item_size_bytes = 16; struct ArrowIpcIntervalMonthDayNano item; for (int64_t i = 0; i < (dst->size_bytes / item_size_bytes); i++) { memcpy(&item, ptr_src + i * item_size_bytes, item_size_bytes); item.months = bswap32(item.months); item.days = bswap32(item.days); item.ns = bswap64(item.ns); memcpy(ptr_dst + i * item_size_bytes, &item, item_size_bytes); } break; } default: switch (src->element_size_bits) { case 16: { uint16_t* ptr = (uint16_t*)dst->data; for (int64_t i = 0; i < (dst->size_bytes / 2); i++) { ptr[i] = bswap16(out_view->data.as_uint16[i]); } break; } case 32: { uint32_t* ptr = (uint32_t*)dst->data; for (int64_t i = 0; i < (dst->size_bytes / 4); i++) { ptr[i] = bswap32(out_view->data.as_uint32[i]); } break; } case 64: { uint64_t* ptr = (uint64_t*)dst->data; for (int64_t i = 0; i < (dst->size_bytes / 8); i++) { ptr[i] = bswap64(out_view->data.as_uint64[i]); } break; } default: ArrowErrorSet( error, "Endian swapping for element bitwidth %" PRId64 " is not supported", src->element_size_bits); return ENOTSUP; } break; } ArrowBufferReset(&tmp); out_view->data.data = dst->data; return NANOARROW_OK; } struct ArrowIpcArraySetter { ns(FieldNode_vec_t) fields; int64_t field_i; ns(Buffer_vec_t) buffers; int64_t buffer_i; int64_t body_size_bytes; struct ArrowIpcBufferSource src; struct ArrowIpcBufferFactory factory; enum ArrowIpcMetadataVersion version; }; static int ArrowIpcDecoderMakeBuffer(struct ArrowIpcArraySetter* setter, int64_t offset, int64_t length, struct ArrowBufferView* out_view, struct ArrowBuffer* out, struct ArrowError* error) { out_view->data.data = NULL; out_view->size_bytes = 0; if (length == 0) { return NANOARROW_OK; } // Check that this buffer fits within the body int64_t buffer_start = offset; int64_t buffer_end = buffer_start + length; if (buffer_start < 0 || buffer_end > setter->body_size_bytes) { ArrowErrorSet(error, "Buffer requires body offsets [%" PRId64 "..%" PRId64 ") but body has size %" PRId64, buffer_start, buffer_end, setter->body_size_bytes); return EINVAL; } // If the ArrowIpcBufferFactory is made public, these should get moved (since then a // user could inject support for either one). More likely, by the time that happens, // this library will be able to support some of these features. if (setter->src.codec != NANOARROW_IPC_COMPRESSION_TYPE_NONE) { ArrowErrorSet(error, "The nanoarrow_ipc extension does not support compression"); return ENOTSUP; } setter->src.body_offset_bytes = offset; setter->src.buffer_length_bytes = length; NANOARROW_RETURN_NOT_OK( setter->factory.make_buffer(&setter->factory, &setter->src, out_view, out, error)); if (setter->src.swap_endian) { NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderSwapEndian(&setter->src, out_view, out, error)); } return NANOARROW_OK; } static int ArrowIpcDecoderWalkGetArray(struct ArrowArrayView* array_view, struct ArrowArray* array, struct ArrowArray* out, struct ArrowError* error) { out->length = array_view->length; out->null_count = array_view->null_count; for (int64_t i = 0; i < array->n_buffers; i++) { struct ArrowBufferView view = array_view->buffer_views[i]; struct ArrowBuffer* scratch_buffer = ArrowArrayBuffer(array, i); struct ArrowBuffer* buffer_out = ArrowArrayBuffer(out, i); // If the scratch buffer was used, move it to the final array. Otherwise, // copy the view. if (scratch_buffer->size_bytes == 0) { NANOARROW_RETURN_NOT_OK(ArrowBufferAppendBufferView(buffer_out, view)); } else if (scratch_buffer->data == view.data.as_uint8) { ArrowBufferMove(scratch_buffer, buffer_out); } else { ArrowErrorSet( error, "Internal: scratch buffer was used but doesn't point to the same data as view"); return EINVAL; } } for (int64_t i = 0; i < array->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderWalkGetArray( array_view->children[i], array->children[i], out->children[i], error)); } return NANOARROW_OK; } static int ArrowIpcDecoderWalkSetArrayView(struct ArrowIpcArraySetter* setter, struct ArrowArrayView* array_view, struct ArrowArray* array, struct ArrowError* error) { ns(FieldNode_struct_t) field = ns(FieldNode_vec_at(setter->fields, (size_t)setter->field_i)); array_view->length = ns(FieldNode_length(field)); array_view->null_count = ns(FieldNode_null_count(field)); setter->field_i += 1; if (array_view->storage_type == NANOARROW_TYPE_SPARSE_UNION || array_view->storage_type == NANOARROW_TYPE_DENSE_UNION) { if (setter->version < NANOARROW_IPC_METADATA_VERSION_V5) { ns(Buffer_struct_t) buffer = ns(Buffer_vec_at(setter->buffers, (size_t)setter->buffer_i)); if (ns(Buffer_length(buffer)) != 0) { ArrowErrorSet(error, "Cannot read pre-1.0.0 Union array with top-level validity bitmap"); return EINVAL; } // skip the empty validity bitmap setter->buffer_i += 1; } } for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { if (array_view->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_NONE) { break; } ns(Buffer_struct_t) buffer = ns(Buffer_vec_at(setter->buffers, (size_t)setter->buffer_i)); int64_t buffer_offset = ns(Buffer_offset(buffer)); int64_t buffer_length = ns(Buffer_length(buffer)); setter->buffer_i += 1; // Provide a buffer that will be used if any allocation has to occur struct ArrowBuffer* buffer_dst = ArrowArrayBuffer(array, i); // Attempt to re-use any previous allocation unless this buffer is // wrapping a custom allocator. if (buffer_dst->allocator.private_data != NULL) { ArrowBufferReset(buffer_dst); } else { buffer_dst->size_bytes = 0; } setter->src.data_type = array_view->layout.buffer_data_type[i]; setter->src.element_size_bits = array_view->layout.element_size_bits[i]; NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderMakeBuffer(setter, buffer_offset, buffer_length, &array_view->buffer_views[i], buffer_dst, error)); } for (int64_t i = 0; i < array_view->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderWalkSetArrayView( setter, array_view->children[i], array->children[i], error)); } return NANOARROW_OK; } static ArrowErrorCode ArrowIpcDecoderDecodeArrayInternal( struct ArrowIpcDecoder* decoder, int64_t field_i, struct ArrowArray* out, enum ArrowValidationLevel validation_level, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; struct ArrowIpcField* root = private_data->fields + field_i + 1; if (field_i == -1) { NANOARROW_RETURN_NOT_OK( ArrowArrayInitFromArrayView(out, &private_data->array_view, error)); out->length = private_data->array_view.length; out->null_count = private_data->array_view.null_count; for (int64_t i = 0; i < private_data->array_view.n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderWalkGetArray( private_data->array_view.children[i], private_data->array.children[i], out->children[i], error)); } } else { NANOARROW_RETURN_NOT_OK(ArrowArrayInitFromArrayView(out, root->array_view, error)); NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderWalkGetArray(root->array_view, root->array, out, error)); } // If validation is going to happen it has already occurred; however, the part of // ArrowArrayFinishBuilding() that allocates a data buffer if the data buffer is // NULL (required for compatibility with Arrow <= 9.0.0) assumes CPU data access // and thus needs a validation level >= default. if (validation_level >= NANOARROW_VALIDATION_LEVEL_DEFAULT) { NANOARROW_RETURN_NOT_OK( ArrowArrayFinishBuilding(out, NANOARROW_VALIDATION_LEVEL_DEFAULT, error)); } else { NANOARROW_RETURN_NOT_OK( ArrowArrayFinishBuilding(out, NANOARROW_VALIDATION_LEVEL_NONE, error)); } return NANOARROW_OK; } static ArrowErrorCode ArrowIpcDecoderDecodeArrayViewInternal( struct ArrowIpcDecoder* decoder, struct ArrowIpcBufferFactory factory, int64_t field_i, struct ArrowArrayView** out_view, struct ArrowError* error) { struct ArrowIpcDecoderPrivate* private_data = (struct ArrowIpcDecoderPrivate*)decoder->private_data; if (private_data->last_message == NULL || decoder->message_type != NANOARROW_IPC_MESSAGE_TYPE_RECORD_BATCH) { ArrowErrorSet(error, "decoder did not just decode a RecordBatch message"); return EINVAL; } // RecordBatch messages don't count the root node but decoder->fields does // (decoder->fields[0] is the root field) if (field_i + 1 >= private_data->n_fields) { ArrowErrorSet(error, "cannot decode column %" PRId64 "; there are only %" PRId64, field_i, private_data->n_fields - 1); return EINVAL; } ns(RecordBatch_table_t) batch = (ns(RecordBatch_table_t))private_data->last_message; struct ArrowIpcField* root = private_data->fields + field_i + 1; struct ArrowIpcArraySetter setter; setter.fields = ns(RecordBatch_nodes(batch)); setter.field_i = field_i; setter.buffers = ns(RecordBatch_buffers(batch)); setter.buffer_i = root->buffer_offset - 1; setter.body_size_bytes = decoder->body_size_bytes; setter.factory = factory; setter.src.codec = decoder->codec; setter.src.swap_endian = ArrowIpcDecoderNeedsSwapEndian(decoder); setter.version = decoder->metadata_version; // The flatbuffers FieldNode doesn't count the root struct so we have to loop over the // children ourselves if (field_i == -1) { root->array_view->length = ns(RecordBatch_length(batch)); root->array_view->null_count = 0; setter.field_i++; setter.buffer_i++; for (int64_t i = 0; i < root->array_view->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderWalkSetArrayView( &setter, root->array_view->children[i], root->array->children[i], error)); } } else { NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderWalkSetArrayView(&setter, root->array_view, root->array, error)); } *out_view = root->array_view; return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderDecodeArrayView(struct ArrowIpcDecoder* decoder, struct ArrowBufferView body, int64_t i, struct ArrowArrayView** out, struct ArrowError* error) { return ArrowIpcDecoderDecodeArrayViewInternal( decoder, ArrowIpcBufferFactoryFromView(&body), i, out, error); } ArrowErrorCode ArrowIpcDecoderDecodeArray(struct ArrowIpcDecoder* decoder, struct ArrowBufferView body, int64_t i, struct ArrowArray* out, enum ArrowValidationLevel validation_level, struct ArrowError* error) { struct ArrowArrayView* array_view; NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderDecodeArrayViewInternal( decoder, ArrowIpcBufferFactoryFromView(&body), i, &array_view, error)); NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidate(array_view, validation_level, error)); struct ArrowArray temp; temp.release = NULL; int result = ArrowIpcDecoderDecodeArrayInternal(decoder, i, &temp, validation_level, error); if (result != NANOARROW_OK && temp.release != NULL) { ArrowArrayRelease(&temp); } else if (result != NANOARROW_OK) { return result; } ArrowArrayMove(&temp, out); return NANOARROW_OK; } ArrowErrorCode ArrowIpcDecoderDecodeArrayFromShared( struct ArrowIpcDecoder* decoder, struct ArrowIpcSharedBuffer* body, int64_t i, struct ArrowArray* out, enum ArrowValidationLevel validation_level, struct ArrowError* error) { struct ArrowArrayView* array_view; NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderDecodeArrayViewInternal( decoder, ArrowIpcBufferFactoryFromShared(body), i, &array_view, error)); NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidate(array_view, validation_level, error)); struct ArrowArray temp; temp.release = NULL; int result = ArrowIpcDecoderDecodeArrayInternal(decoder, i, &temp, validation_level, error); if (result != NANOARROW_OK && temp.release != NULL) { ArrowArrayRelease(&temp); } else if (result != NANOARROW_OK) { return result; } ArrowArrayMove(&temp, out); return NANOARROW_OK; } // 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 #include #include #include "flatcc/flatcc_builder.h" #include "nanoarrow.h" #include "nanoarrow_ipc.h" #define ns(x) FLATBUFFERS_WRAP_NAMESPACE(org_apache_arrow_flatbuf, x) #define FLATCC_RETURN_UNLESS_0_NO_NS(x, error) \ if ((x) != 0) { \ ArrowErrorSet(error, "%s:%d: %s failed", __FILE__, __LINE__, #x); \ return ENOMEM; \ } #define FLATCC_RETURN_UNLESS_0(x, error) FLATCC_RETURN_UNLESS_0_NO_NS(ns(x), error) #define FLATCC_RETURN_IF_NULL(x, error) \ if (!(x)) { \ ArrowErrorSet(error, "%s:%d: %s was null", __FILE__, __LINE__, #x); \ return ENOMEM; \ } struct ArrowIpcEncoderPrivate { flatcc_builder_t builder; struct ArrowBuffer buffers; struct ArrowBuffer nodes; int encoding_footer; }; ArrowErrorCode ArrowIpcEncoderInit(struct ArrowIpcEncoder* encoder) { NANOARROW_DCHECK(encoder != NULL); memset(encoder, 0, sizeof(struct ArrowIpcEncoder)); encoder->private_data = ArrowMalloc(sizeof(struct ArrowIpcEncoderPrivate)); struct ArrowIpcEncoderPrivate* private = (struct ArrowIpcEncoderPrivate*)encoder->private_data; if (private == NULL) { return ENOMEM; } if (flatcc_builder_init(&private->builder) == -1) { ArrowFree(private); return ESPIPE; } private->encoding_footer = 0; ArrowBufferInit(&private->buffers); ArrowBufferInit(&private->nodes); return NANOARROW_OK; } void ArrowIpcEncoderReset(struct ArrowIpcEncoder* encoder) { NANOARROW_DCHECK(encoder != NULL); struct ArrowIpcEncoderPrivate* private = (struct ArrowIpcEncoderPrivate*)encoder->private_data; if (private != NULL) { flatcc_builder_clear(&private->builder); ArrowBufferReset(&private->nodes); ArrowBufferReset(&private->buffers); ArrowFree(private); } memset(encoder, 0, sizeof(struct ArrowIpcEncoder)); } static ArrowErrorCode ArrowIpcEncoderWriteContinuationAndSize(struct ArrowBuffer* out, size_t size) { _NANOARROW_CHECK_UPPER_LIMIT(size, INT32_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(out, -1)); if (ArrowIpcSystemEndianness() == NANOARROW_IPC_ENDIANNESS_BIG) { return ArrowBufferAppendInt32(out, (int32_t)bswap32((uint32_t)size)); } else { return ArrowBufferAppendInt32(out, (int32_t)size); } } ArrowErrorCode ArrowIpcEncoderFinalizeBuffer(struct ArrowIpcEncoder* encoder, char encapsulate, struct ArrowBuffer* out) { NANOARROW_DCHECK(encoder != NULL && encoder->private_data != NULL && out != NULL); struct ArrowIpcEncoderPrivate* private = (struct ArrowIpcEncoderPrivate*)encoder->private_data; size_t size = flatcc_builder_get_buffer_size(&private->builder); if (encapsulate) { int64_t padded_size = _ArrowRoundUpToMultipleOf8(size); NANOARROW_RETURN_NOT_OK( ArrowBufferReserve(out, sizeof(int32_t) + sizeof(int32_t) + padded_size)); NANOARROW_ASSERT_OK(ArrowIpcEncoderWriteContinuationAndSize(out, padded_size)); } else { NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(out, size)); } if (size == 0) { // Finalizing an empty flatcc_builder_t triggers an assertion return NANOARROW_OK; } void* data = flatcc_builder_copy_buffer(&private->builder, out->data + out->size_bytes, size); NANOARROW_DCHECK(data != NULL); NANOARROW_UNUSED(data); out->size_bytes += size; while (encapsulate && out->size_bytes % 8 != 0) { // zero padding bytes, if any out->data[out->size_bytes++] = 0; } // don't deallocate yet, just wipe the builder's current Message flatcc_builder_reset(&private->builder); return NANOARROW_OK; } static ArrowErrorCode ArrowIpcEncodeFieldType(flatcc_builder_t* builder, const struct ArrowSchemaView* schema_view, struct ArrowError* error) { switch (schema_view->type) { case NANOARROW_TYPE_NA: FLATCC_RETURN_UNLESS_0(Field_type_Null_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_BOOL: FLATCC_RETURN_UNLESS_0(Field_type_Bool_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT8: FLATCC_RETURN_UNLESS_0( Field_type_Int_create(builder, 8, schema_view->type == NANOARROW_TYPE_INT8), error); return NANOARROW_OK; case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT16: FLATCC_RETURN_UNLESS_0( Field_type_Int_create(builder, 16, schema_view->type == NANOARROW_TYPE_INT16), error); return NANOARROW_OK; case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT32: FLATCC_RETURN_UNLESS_0( Field_type_Int_create(builder, 32, schema_view->type == NANOARROW_TYPE_INT32), error); return NANOARROW_OK; case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_INT64: FLATCC_RETURN_UNLESS_0( Field_type_Int_create(builder, 64, schema_view->type == NANOARROW_TYPE_INT64), error); return NANOARROW_OK; case NANOARROW_TYPE_HALF_FLOAT: FLATCC_RETURN_UNLESS_0(Field_type_FloatingPoint_create(builder, ns(Precision_HALF)), error); return NANOARROW_OK; case NANOARROW_TYPE_FLOAT: FLATCC_RETURN_UNLESS_0( Field_type_FloatingPoint_create(builder, ns(Precision_SINGLE)), error); return NANOARROW_OK; case NANOARROW_TYPE_DOUBLE: FLATCC_RETURN_UNLESS_0( Field_type_FloatingPoint_create(builder, ns(Precision_DOUBLE)), error); return NANOARROW_OK; case NANOARROW_TYPE_DECIMAL128: case NANOARROW_TYPE_DECIMAL256: FLATCC_RETURN_UNLESS_0( Field_type_Decimal_create(builder, schema_view->decimal_precision, schema_view->decimal_scale, schema_view->decimal_bitwidth), error); return NANOARROW_OK; case NANOARROW_TYPE_STRING: FLATCC_RETURN_UNLESS_0(Field_type_Utf8_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_LARGE_STRING: FLATCC_RETURN_UNLESS_0(Field_type_LargeUtf8_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_BINARY: FLATCC_RETURN_UNLESS_0(Field_type_Binary_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_LARGE_BINARY: FLATCC_RETURN_UNLESS_0(Field_type_LargeBinary_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_DATE32: FLATCC_RETURN_UNLESS_0(Field_type_Date_create(builder, ns(DateUnit_DAY)), error); return NANOARROW_OK; case NANOARROW_TYPE_DATE64: FLATCC_RETURN_UNLESS_0(Field_type_Date_create(builder, ns(DateUnit_MILLISECOND)), error); return NANOARROW_OK; case NANOARROW_TYPE_INTERVAL_MONTHS: FLATCC_RETURN_UNLESS_0( Field_type_Interval_create(builder, ns(IntervalUnit_YEAR_MONTH)), error); return NANOARROW_OK; case NANOARROW_TYPE_INTERVAL_DAY_TIME: FLATCC_RETURN_UNLESS_0( Field_type_Interval_create(builder, ns(IntervalUnit_DAY_TIME)), error); return NANOARROW_OK; case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: FLATCC_RETURN_UNLESS_0( Field_type_Interval_create(builder, ns(IntervalUnit_MONTH_DAY_NANO)), error); return NANOARROW_OK; case NANOARROW_TYPE_TIMESTAMP: FLATCC_RETURN_UNLESS_0(Field_type_Timestamp_start(builder), error); FLATCC_RETURN_UNLESS_0( Timestamp_unit_add(builder, (ns(TimeUnit_enum_t))schema_view->time_unit), error); if (schema_view->timezone && schema_view->timezone[0] != 0) { FLATCC_RETURN_UNLESS_0( Timestamp_timezone_create_str(builder, schema_view->timezone), error); } FLATCC_RETURN_UNLESS_0(Field_type_Timestamp_end(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_TIME32: FLATCC_RETURN_UNLESS_0( Field_type_Time_create(builder, (ns(TimeUnit_enum_t))schema_view->time_unit, 32), error); return NANOARROW_OK; case NANOARROW_TYPE_TIME64: FLATCC_RETURN_UNLESS_0( Field_type_Time_create(builder, (ns(TimeUnit_enum_t))schema_view->time_unit, 64), error); return NANOARROW_OK; case NANOARROW_TYPE_DURATION: FLATCC_RETURN_UNLESS_0(Field_type_Duration_create( builder, (ns(TimeUnit_enum_t))schema_view->time_unit), error); return NANOARROW_OK; case NANOARROW_TYPE_FIXED_SIZE_BINARY: FLATCC_RETURN_UNLESS_0( Field_type_FixedSizeBinary_create(builder, schema_view->fixed_size), error); return NANOARROW_OK; case NANOARROW_TYPE_LIST: FLATCC_RETURN_UNLESS_0(Field_type_List_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_LARGE_LIST: FLATCC_RETURN_UNLESS_0(Field_type_LargeList_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_FIXED_SIZE_LIST: FLATCC_RETURN_UNLESS_0( Field_type_FixedSizeList_create(builder, schema_view->fixed_size), error); return NANOARROW_OK; case NANOARROW_TYPE_RUN_END_ENCODED: FLATCC_RETURN_UNLESS_0(Field_type_RunEndEncoded_create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_STRUCT: FLATCC_RETURN_UNLESS_0(Field_type_Struct__create(builder), error); return NANOARROW_OK; case NANOARROW_TYPE_SPARSE_UNION: case NANOARROW_TYPE_DENSE_UNION: { FLATCC_RETURN_UNLESS_0(Field_type_Union_start(builder), error); FLATCC_RETURN_UNLESS_0( Union_mode_add(builder, schema_view->type == NANOARROW_TYPE_DENSE_UNION), error); if (schema_view->union_type_ids) { int8_t type_ids[128]; int n = _ArrowParseUnionTypeIds(schema_view->union_type_ids, type_ids); if (n != 0) { FLATCC_RETURN_UNLESS_0(Union_typeIds_start(builder), error); int32_t* type_ids_32 = (int32_t*)ns(Union_typeIds_extend(builder, n)); FLATCC_RETURN_IF_NULL(type_ids_32, error); for (int i = 0; i < n; i++) { type_ids_32[i] = type_ids[i]; } FLATCC_RETURN_UNLESS_0(Union_typeIds_end(builder), error); } } FLATCC_RETURN_UNLESS_0(Field_type_Union_end(builder), error); return NANOARROW_OK; } case NANOARROW_TYPE_MAP: FLATCC_RETURN_UNLESS_0( Field_type_Map_create(builder, schema_view->schema->flags & ARROW_FLAG_MAP_KEYS_SORTED), error); return NANOARROW_OK; case NANOARROW_TYPE_DICTIONARY: ArrowErrorSet(error, "IPC encoding of dictionary types unsupported"); return ENOTSUP; default: ArrowErrorSet(error, "Expected a valid enum ArrowType value but found %d", schema_view->type); return EINVAL; } } static ArrowErrorCode ArrowIpcEncodeField(flatcc_builder_t* builder, const struct ArrowSchema* schema, struct ArrowError* error); static ArrowErrorCode ArrowIpcEncodeMetadata(flatcc_builder_t* builder, const struct ArrowSchema* schema, int (*push_start)(flatcc_builder_t*), ns(KeyValue_ref_t) * (*push_end)(flatcc_builder_t*), struct ArrowError* error) { struct ArrowMetadataReader metadata; NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowMetadataReaderInit(&metadata, schema->metadata), error); while (metadata.remaining_keys > 0) { struct ArrowStringView key, value; NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowMetadataReaderRead(&metadata, &key, &value), error); FLATCC_RETURN_UNLESS_0_NO_NS(push_start(builder), error); FLATCC_RETURN_UNLESS_0(KeyValue_key_create_strn(builder, key.data, key.size_bytes), error); FLATCC_RETURN_UNLESS_0( KeyValue_value_create_strn(builder, value.data, value.size_bytes), error); FLATCC_RETURN_IF_NULL(push_end(builder), error); } return NANOARROW_OK; } static ArrowErrorCode ArrowIpcEncodeFields(flatcc_builder_t* builder, const struct ArrowSchema* schema, int (*push_start)(flatcc_builder_t*), ns(Field_ref_t) * (*push_end)(flatcc_builder_t*), struct ArrowError* error) { for (int i = 0; i < schema->n_children; i++) { FLATCC_RETURN_UNLESS_0_NO_NS(push_start(builder), error); NANOARROW_RETURN_NOT_OK(ArrowIpcEncodeField(builder, schema->children[i], error)); FLATCC_RETURN_IF_NULL(push_end(builder), error); } return NANOARROW_OK; } static ArrowErrorCode ArrowIpcEncodeField(flatcc_builder_t* builder, const struct ArrowSchema* schema, struct ArrowError* error) { FLATCC_RETURN_UNLESS_0(Field_name_create_str(builder, schema->name), error); FLATCC_RETURN_UNLESS_0( Field_nullable_add(builder, (schema->flags & ARROW_FLAG_NULLABLE) != 0), error); struct ArrowSchemaView schema_view; NANOARROW_RETURN_NOT_OK(ArrowSchemaViewInit(&schema_view, schema, error)); NANOARROW_RETURN_NOT_OK(ArrowIpcEncodeFieldType(builder, &schema_view, error)); if (schema->n_children != 0) { FLATCC_RETURN_UNLESS_0(Field_children_start(builder), error); NANOARROW_RETURN_NOT_OK(ArrowIpcEncodeFields(builder, schema, &ns(Field_children_push_start), &ns(Field_children_push_end), error)); FLATCC_RETURN_UNLESS_0(Field_children_end(builder), error); } if (schema->metadata) { FLATCC_RETURN_UNLESS_0(Field_custom_metadata_start(builder), error); NANOARROW_RETURN_NOT_OK( ArrowIpcEncodeMetadata(builder, schema, &ns(Field_custom_metadata_push_start), &ns(Field_custom_metadata_push_end), error)); FLATCC_RETURN_UNLESS_0(Field_custom_metadata_end(builder), error); } return NANOARROW_OK; } static ArrowErrorCode ArrowIpcEncodeSchema(flatcc_builder_t* builder, const struct ArrowSchema* schema, struct ArrowError* error) { NANOARROW_DCHECK(schema->release != NULL); if (strcmp(schema->format, "+s") != 0) { ArrowErrorSet( error, "Cannot encode schema with format '%s'; top level schema must have struct type", schema->format); return EINVAL; } if (ArrowIpcSystemEndianness() == NANOARROW_IPC_ENDIANNESS_LITTLE) { FLATCC_RETURN_UNLESS_0(Schema_endianness_add(builder, ns(Endianness_Little)), error); } else { FLATCC_RETURN_UNLESS_0(Schema_endianness_add(builder, ns(Endianness_Big)), error); } FLATCC_RETURN_UNLESS_0(Schema_fields_start(builder), error); NANOARROW_RETURN_NOT_OK(ArrowIpcEncodeFields(builder, schema, &ns(Schema_fields_push_start), &ns(Schema_fields_push_end), error)); FLATCC_RETURN_UNLESS_0(Schema_fields_end(builder), error); FLATCC_RETURN_UNLESS_0(Schema_custom_metadata_start(builder), error); if (schema->metadata) { NANOARROW_RETURN_NOT_OK( ArrowIpcEncodeMetadata(builder, schema, &ns(Schema_custom_metadata_push_start), &ns(Schema_custom_metadata_push_end), error)); } FLATCC_RETURN_UNLESS_0(Schema_custom_metadata_end(builder), error); FLATCC_RETURN_UNLESS_0(Schema_features_start(builder), error); FLATCC_RETURN_UNLESS_0(Schema_features_end(builder), error); return NANOARROW_OK; } ArrowErrorCode ArrowIpcEncoderEncodeSchema(struct ArrowIpcEncoder* encoder, const struct ArrowSchema* schema, struct ArrowError* error) { NANOARROW_DCHECK(encoder != NULL && encoder->private_data != NULL && schema != NULL); struct ArrowIpcEncoderPrivate* private = (struct ArrowIpcEncoderPrivate*)encoder->private_data; flatcc_builder_t* builder = &private->builder; FLATCC_RETURN_UNLESS_0(Message_start_as_root(builder), error); FLATCC_RETURN_UNLESS_0(Message_version_add(builder, ns(MetadataVersion_V5)), error); FLATCC_RETURN_UNLESS_0(Message_header_Schema_start(builder), error); NANOARROW_RETURN_NOT_OK(ArrowIpcEncodeSchema(builder, schema, error)); FLATCC_RETURN_UNLESS_0(Message_header_Schema_end(builder), error); FLATCC_RETURN_UNLESS_0(Message_bodyLength_add(builder, 0), error); FLATCC_RETURN_IF_NULL(ns(Message_end_as_root(builder)), error); return NANOARROW_OK; } struct ArrowIpcBufferEncoder { /// \brief Callback invoked against each buffer to be encoded /// /// Encoding of buffers is left as a callback to accommodate dissociated data storage. /// One implementation of this callback might copy all buffers into a contiguous body /// for use in an arrow IPC stream, another implementation might store offsets and /// lengths relative to a known arena. ArrowErrorCode (*encode_buffer)(struct ArrowBufferView buffer_view, struct ArrowIpcEncoder* encoder, struct ArrowIpcBufferEncoder* buffer_encoder, int64_t* offset, int64_t* length, struct ArrowError* error); /// \brief Pointer to arbitrary data used by encode_buffer() void* encode_buffer_state; /// \brief Finalized body length of the most recently encoded RecordBatch message /// /// encode_buffer() is expected to update this while encoding each buffer. After all /// buffers are encoded, this will be written to the RecordBatch's .bodyLength int64_t body_length; }; static ArrowErrorCode ArrowIpcEncoderBuildContiguousBodyBufferCallback( struct ArrowBufferView buffer_view, struct ArrowIpcEncoder* encoder, struct ArrowIpcBufferEncoder* buffer_encoder, int64_t* offset, int64_t* length, struct ArrowError* error) { NANOARROW_UNUSED(encoder); struct ArrowBuffer* body_buffer = (struct ArrowBuffer*)buffer_encoder->encode_buffer_state; int64_t old_size = body_buffer->size_bytes; int64_t buffer_begin = _ArrowRoundUpToMultipleOf8(old_size); int64_t buffer_end = buffer_begin + buffer_view.size_bytes; int64_t new_size = _ArrowRoundUpToMultipleOf8(buffer_end); // reserve all the memory we'll need now NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowBufferReserve(body_buffer, new_size - old_size), error); // zero padding up to the start of the buffer NANOARROW_ASSERT_OK(ArrowBufferAppendFill(body_buffer, 0, buffer_begin - old_size)); // store offset and length of the buffer *offset = buffer_begin; *length = buffer_view.size_bytes; NANOARROW_ASSERT_OK( ArrowBufferAppend(body_buffer, buffer_view.data.data, buffer_view.size_bytes)); // zero padding after writing the buffer NANOARROW_DCHECK(body_buffer->size_bytes == buffer_end); NANOARROW_ASSERT_OK(ArrowBufferAppendFill(body_buffer, 0, new_size - buffer_end)); buffer_encoder->body_length = body_buffer->size_bytes; return NANOARROW_OK; } static ArrowErrorCode ArrowIpcEncoderEncodeRecordBatchImpl( struct ArrowIpcEncoder* encoder, struct ArrowIpcBufferEncoder* buffer_encoder, const struct ArrowArrayView* array_view, struct ArrowBuffer* buffers, struct ArrowBuffer* nodes, struct ArrowError* error) { if (array_view->offset != 0) { ArrowErrorSet(error, "Cannot encode arrays with nonzero offset"); return ENOTSUP; } for (int64_t c = 0; c < array_view->n_children; ++c) { const struct ArrowArrayView* child = array_view->children[c]; struct ns(FieldNode) node = {child->length, child->null_count}; NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowBufferAppend(nodes, &node, sizeof(node)), error); for (int64_t b = 0; b < child->array->n_buffers; ++b) { struct ns(Buffer) buffer; NANOARROW_RETURN_NOT_OK( buffer_encoder->encode_buffer(child->buffer_views[b], encoder, buffer_encoder, &buffer.offset, &buffer.length, error)); NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowBufferAppend(buffers, &buffer, sizeof(buffer)), error); } NANOARROW_RETURN_NOT_OK(ArrowIpcEncoderEncodeRecordBatchImpl( encoder, buffer_encoder, child, buffers, nodes, error)); } return NANOARROW_OK; } static ArrowErrorCode ArrowIpcEncoderEncodeRecordBatch( struct ArrowIpcEncoder* encoder, struct ArrowIpcBufferEncoder* buffer_encoder, const struct ArrowArrayView* array_view, struct ArrowError* error) { NANOARROW_DCHECK(encoder != NULL && encoder->private_data != NULL && buffer_encoder != NULL && buffer_encoder->encode_buffer != NULL); if (array_view->null_count != 0 && ArrowArrayViewComputeNullCount(array_view) != 0) { ArrowErrorSet(error, "RecordBatches cannot be constructed from arrays with top level nulls"); return EINVAL; } if (array_view->storage_type != NANOARROW_TYPE_STRUCT) { ArrowErrorSet( error, "RecordBatches cannot be constructed from arrays of type other than struct"); return EINVAL; } struct ArrowIpcEncoderPrivate* private = (struct ArrowIpcEncoderPrivate*)encoder->private_data; flatcc_builder_t* builder = &private->builder; FLATCC_RETURN_UNLESS_0(Message_start_as_root(builder), error); FLATCC_RETURN_UNLESS_0(Message_version_add(builder, ns(MetadataVersion_V5)), error); FLATCC_RETURN_UNLESS_0(Message_header_RecordBatch_start(builder), error); FLATCC_RETURN_UNLESS_0(RecordBatch_length_add(builder, array_view->length), error); NANOARROW_ASSERT_OK(ArrowBufferResize(&private->buffers, 0, 0)); NANOARROW_ASSERT_OK(ArrowBufferResize(&private->nodes, 0, 0)); NANOARROW_RETURN_NOT_OK(ArrowIpcEncoderEncodeRecordBatchImpl( encoder, buffer_encoder, array_view, &private->buffers, &private->nodes, error)); FLATCC_RETURN_UNLESS_0(RecordBatch_nodes_create( // builder, (struct ns(FieldNode)*)private->nodes.data, private->nodes.size_bytes / sizeof(struct ns(FieldNode))), error); FLATCC_RETURN_UNLESS_0(RecordBatch_buffers_create( // builder, (struct ns(Buffer)*)private->buffers.data, private->buffers.size_bytes / sizeof(struct ns(Buffer))), error); FLATCC_RETURN_UNLESS_0(Message_header_RecordBatch_end(builder), error); FLATCC_RETURN_UNLESS_0(Message_bodyLength_add(builder, buffer_encoder->body_length), error); FLATCC_RETURN_IF_NULL(ns(Message_end_as_root(builder)), error); return NANOARROW_OK; } ArrowErrorCode ArrowIpcEncoderEncodeSimpleRecordBatch( struct ArrowIpcEncoder* encoder, const struct ArrowArrayView* array_view, struct ArrowBuffer* body_buffer, struct ArrowError* error) { NANOARROW_DCHECK(encoder != NULL && encoder->private_data != NULL && body_buffer != NULL); struct ArrowIpcBufferEncoder buffer_encoder = { .encode_buffer = &ArrowIpcEncoderBuildContiguousBodyBufferCallback, .encode_buffer_state = body_buffer, .body_length = 0, }; return ArrowIpcEncoderEncodeRecordBatch(encoder, &buffer_encoder, array_view, error); } void ArrowIpcFooterInit(struct ArrowIpcFooter* footer) { footer->schema.release = NULL; ArrowBufferInit(&footer->record_batch_blocks); } void ArrowIpcFooterReset(struct ArrowIpcFooter* footer) { if (footer->schema.release != NULL) { ArrowSchemaRelease(&footer->schema); } ArrowBufferReset(&footer->record_batch_blocks); } ArrowErrorCode ArrowIpcEncoderEncodeFooter(struct ArrowIpcEncoder* encoder, const struct ArrowIpcFooter* footer, struct ArrowError* error) { NANOARROW_DCHECK(encoder != NULL && encoder->private_data != NULL && footer != NULL); struct ArrowIpcEncoderPrivate* private = (struct ArrowIpcEncoderPrivate*)encoder->private_data; flatcc_builder_t* builder = &private->builder; FLATCC_RETURN_UNLESS_0(Footer_start_as_root(builder), error); FLATCC_RETURN_UNLESS_0(Footer_version_add(builder, ns(MetadataVersion_V5)), error); FLATCC_RETURN_UNLESS_0(Footer_schema_start(builder), error); NANOARROW_RETURN_NOT_OK(ArrowIpcEncodeSchema(builder, &footer->schema, error)); FLATCC_RETURN_UNLESS_0(Footer_schema_end(builder), error); const struct ArrowIpcFileBlock* blocks = (struct ArrowIpcFileBlock*)footer->record_batch_blocks.data; int64_t n_blocks = footer->record_batch_blocks.size_bytes / sizeof(struct ArrowIpcFileBlock); FLATCC_RETURN_UNLESS_0(Footer_recordBatches_start(builder), error); struct ns(Block)* flatcc_RecordBatch_blocks = ns(Footer_recordBatches_extend(builder, n_blocks)); FLATCC_RETURN_IF_NULL(flatcc_RecordBatch_blocks, error); for (int64_t i = 0; i < n_blocks; i++) { struct ns(Block) block = { blocks[i].offset, blocks[i].metadata_length, blocks[i].body_length, }; flatcc_RecordBatch_blocks[i] = block; } FLATCC_RETURN_UNLESS_0(Footer_recordBatches_end(builder), error); FLATCC_RETURN_IF_NULL(ns(Footer_end_as_root(builder)), error); return NANOARROW_OK; } // 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 #include #include #include #include "nanoarrow.h" #include "nanoarrow_ipc.h" // R 3.6 / Windows builds on a very old toolchain that does not define ENODATA #if defined(_WIN32) && !defined(_MSC_VER) && !defined(ENODATA) #define ENODATA 120 #endif // Sentinel value to indicate that we haven't read a message yet // and don't know the number of header prefix bytes to expect. static const int32_t kExpectedHeaderPrefixSizeNotSet = -1; void ArrowIpcInputStreamMove(struct ArrowIpcInputStream* src, struct ArrowIpcInputStream* dst) { memcpy(dst, src, sizeof(struct ArrowIpcInputStream)); src->release = NULL; } struct ArrowIpcInputStreamBufferPrivate { struct ArrowBuffer input; int64_t cursor_bytes; }; static ArrowErrorCode ArrowIpcInputStreamBufferRead(struct ArrowIpcInputStream* stream, uint8_t* buf, int64_t buf_size_bytes, int64_t* size_read_out, struct ArrowError* error) { NANOARROW_UNUSED(error); if (buf_size_bytes == 0) { *size_read_out = 0; return NANOARROW_OK; } struct ArrowIpcInputStreamBufferPrivate* private_data = (struct ArrowIpcInputStreamBufferPrivate*)stream->private_data; int64_t bytes_remaining = private_data->input.size_bytes - private_data->cursor_bytes; int64_t bytes_to_read; if (bytes_remaining > buf_size_bytes) { bytes_to_read = buf_size_bytes; } else { bytes_to_read = bytes_remaining; } if (bytes_to_read > 0) { memcpy(buf, private_data->input.data + private_data->cursor_bytes, bytes_to_read); } *size_read_out = bytes_to_read; private_data->cursor_bytes += bytes_to_read; return NANOARROW_OK; } static void ArrowIpcInputStreamBufferRelease(struct ArrowIpcInputStream* stream) { struct ArrowIpcInputStreamBufferPrivate* private_data = (struct ArrowIpcInputStreamBufferPrivate*)stream->private_data; ArrowBufferReset(&private_data->input); ArrowFree(private_data); stream->release = NULL; } ArrowErrorCode ArrowIpcInputStreamInitBuffer(struct ArrowIpcInputStream* stream, struct ArrowBuffer* input) { NANOARROW_DCHECK(stream != NULL); struct ArrowIpcInputStreamBufferPrivate* private_data = (struct ArrowIpcInputStreamBufferPrivate*)ArrowMalloc( sizeof(struct ArrowIpcInputStreamBufferPrivate)); if (private_data == NULL) { return ENOMEM; } ArrowBufferMove(input, &private_data->input); private_data->cursor_bytes = 0; stream->read = &ArrowIpcInputStreamBufferRead; stream->release = &ArrowIpcInputStreamBufferRelease; stream->private_data = private_data; return NANOARROW_OK; } struct ArrowIpcInputStreamFilePrivate { FILE* file_ptr; int stream_finished; int close_on_release; }; static void ArrowIpcInputStreamFileRelease(struct ArrowIpcInputStream* stream) { struct ArrowIpcInputStreamFilePrivate* private_data = (struct ArrowIpcInputStreamFilePrivate*)stream->private_data; if (private_data->file_ptr != NULL && private_data->close_on_release) { fclose(private_data->file_ptr); } ArrowFree(private_data); stream->release = NULL; } static ArrowErrorCode ArrowIpcInputStreamFileRead(struct ArrowIpcInputStream* stream, uint8_t* buf, int64_t buf_size_bytes, int64_t* size_read_out, struct ArrowError* error) { struct ArrowIpcInputStreamFilePrivate* private_data = (struct ArrowIpcInputStreamFilePrivate*)stream->private_data; if (private_data->stream_finished) { *size_read_out = 0; return NANOARROW_OK; } // Do the read int64_t bytes_read = (int64_t)fread(buf, 1, buf_size_bytes, private_data->file_ptr); *size_read_out = bytes_read; if (bytes_read != buf_size_bytes) { private_data->stream_finished = 1; // Inspect error int has_error = !feof(private_data->file_ptr) && ferror(private_data->file_ptr); // Try to close the file now if (private_data->close_on_release) { if (fclose(private_data->file_ptr) == 0) { private_data->file_ptr = NULL; } } // Maybe return error if (has_error) { ArrowErrorSet(error, "ArrowIpcInputStreamFile IO error"); return EIO; } } return NANOARROW_OK; } ArrowErrorCode ArrowIpcInputStreamInitFile(struct ArrowIpcInputStream* stream, void* file_ptr, int close_on_release) { NANOARROW_DCHECK(stream != NULL); if (file_ptr == NULL) { return errno ? errno : EINVAL; } struct ArrowIpcInputStreamFilePrivate* private_data = (struct ArrowIpcInputStreamFilePrivate*)ArrowMalloc( sizeof(struct ArrowIpcInputStreamFilePrivate)); if (private_data == NULL) { return ENOMEM; } private_data->file_ptr = (FILE*)file_ptr; private_data->close_on_release = close_on_release; private_data->stream_finished = 0; stream->read = &ArrowIpcInputStreamFileRead; stream->release = &ArrowIpcInputStreamFileRelease; stream->private_data = private_data; return NANOARROW_OK; } struct ArrowIpcArrayStreamReaderPrivate { struct ArrowIpcInputStream input; struct ArrowIpcDecoder decoder; int use_shared_buffers; struct ArrowSchema out_schema; int64_t field_index; struct ArrowBuffer header; struct ArrowBuffer body; int32_t expected_header_prefix_size; struct ArrowError error; }; static void ArrowIpcArrayStreamReaderRelease(struct ArrowArrayStream* stream) { struct ArrowIpcArrayStreamReaderPrivate* private_data = (struct ArrowIpcArrayStreamReaderPrivate*)stream->private_data; if (private_data->input.release != NULL) { private_data->input.release(&private_data->input); } ArrowIpcDecoderReset(&private_data->decoder); if (private_data->out_schema.release != NULL) { ArrowSchemaRelease(&private_data->out_schema); } ArrowBufferReset(&private_data->header); ArrowBufferReset(&private_data->body); ArrowFree(private_data); stream->release = NULL; } static int ArrowIpcArrayStreamReaderNextHeader( struct ArrowIpcArrayStreamReaderPrivate* private_data, enum ArrowIpcMessageType message_type) { private_data->header.size_bytes = 0; int64_t bytes_read = 0; // Read 8 bytes (continuation + header size in bytes) NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowBufferReserve(&private_data->header, 8), &private_data->error); NANOARROW_RETURN_NOT_OK(private_data->input.read(&private_data->input, private_data->header.data, 8, &bytes_read, &private_data->error)); private_data->header.size_bytes += bytes_read; if (bytes_read == 0) { // The caller might not use this error message (e.g., if the end of the stream // is one of the valid outcomes) but we set the error anyway in case it gets // propagated higher (e.g., if the stream is empty and there's no schema message) ArrowErrorSet(&private_data->error, "No data available on stream"); return ENODATA; } else if (bytes_read == 4 && private_data->expected_header_prefix_size == 4) { // Special case very, very old IPC streams that used 0x00000000 as the // end-of-stream indicator. We may want to remove this case at some point: // https://github.com/apache/arrow-nanoarrow/issues/648 uint32_t last_four_bytes = 0; memcpy(&last_four_bytes, private_data->header.data, sizeof(uint32_t)); if (last_four_bytes == 0) { ArrowErrorSet(&private_data->error, "No data available on stream"); return ENODATA; } else { ArrowErrorSet(&private_data->error, "Expected 0x00000000 if exactly four bytes are available at the end " "of a stream"); return EINVAL; } } else if (bytes_read != 8) { ArrowErrorSet(&private_data->error, "Expected at least 8 bytes in remainder of stream"); return EINVAL; } struct ArrowBufferView input_view; input_view.data.data = private_data->header.data; input_view.size_bytes = private_data->header.size_bytes; // Use PeekHeader to fill in decoder.header_size_bytes int32_t prefix_size_bytes = 0; NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderPeekHeader( &private_data->decoder, input_view, &prefix_size_bytes, &private_data->error)); // Check for a consistent header prefix size if (private_data->expected_header_prefix_size != kExpectedHeaderPrefixSizeNotSet && prefix_size_bytes != private_data->expected_header_prefix_size) { ArrowErrorSet(&private_data->error, "Expected prefix %d prefix header bytes but found %d", (int)private_data->expected_header_prefix_size, (int)prefix_size_bytes); return EINVAL; } else { private_data->expected_header_prefix_size = prefix_size_bytes; } // Legacy streams are missing the 0xFFFFFFFF at the start of the message. The // decoder can handle this; however, verification will fail because flatbuffers // must be 8-byte aligned. To handle this case, we prepend the continuation // token to the start of the stream and ensure that we read four fewer bytes // the next time we issue a read. We may be able to remove this case in the future: // https://github.com/apache/arrow-nanoarrow/issues/648 int64_t extra_bytes_already_read = 0; if (prefix_size_bytes == 4) { NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowBufferReserve(&private_data->header, 4), &private_data->error); memmove(private_data->header.data + 4, private_data->header.data, private_data->header.size_bytes); uint32_t continuation = 0xFFFFFFFFU; memcpy(private_data->header.data, &continuation, sizeof(uint32_t)); private_data->header.size_bytes += 4; extra_bytes_already_read = 4; input_view.data.data = private_data->header.data; input_view.size_bytes = private_data->header.size_bytes; int32_t new_prefix_size_bytes; NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderPeekHeader(&private_data->decoder, input_view, &new_prefix_size_bytes, &private_data->error)); NANOARROW_DCHECK(new_prefix_size_bytes == 8); } // Read the header bytes int64_t expected_header_bytes = private_data->decoder.header_size_bytes - 8; NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowBufferReserve(&private_data->header, expected_header_bytes - extra_bytes_already_read), &private_data->error); NANOARROW_RETURN_NOT_OK(private_data->input.read( &private_data->input, private_data->header.data + private_data->header.size_bytes, expected_header_bytes - extra_bytes_already_read, &bytes_read, &private_data->error)); private_data->header.size_bytes += bytes_read; // Verify + decode the header input_view.data.data = private_data->header.data; input_view.size_bytes = private_data->header.size_bytes; NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderVerifyHeader(&private_data->decoder, input_view, &private_data->error)); // If we have a 4-byte header prefix, make sure the metadata version is V4 // (Note that some V4 IPC files have an 8 byte header prefix). if (prefix_size_bytes == 4 && private_data->decoder.metadata_version != NANOARROW_IPC_METADATA_VERSION_V4) { ArrowErrorSet(&private_data->error, "Header prefix size of four bytes is only allowed for V4 metadata"); return EINVAL; } // Don't decode the message if it's of the wrong type (because the error message // is better communicated by the caller) if (private_data->decoder.message_type != message_type) { return NANOARROW_OK; } NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderDecodeHeader(&private_data->decoder, input_view, &private_data->error)); return NANOARROW_OK; } static int ArrowIpcArrayStreamReaderNextBody( struct ArrowIpcArrayStreamReaderPrivate* private_data) { int64_t bytes_read; int64_t bytes_to_read = private_data->decoder.body_size_bytes; // Read the body bytes private_data->body.size_bytes = 0; NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowBufferReserve(&private_data->body, bytes_to_read), &private_data->error); NANOARROW_RETURN_NOT_OK(private_data->input.read(&private_data->input, private_data->body.data, bytes_to_read, &bytes_read, &private_data->error)); private_data->body.size_bytes += bytes_read; if (bytes_read != bytes_to_read) { ArrowErrorSet(&private_data->error, "Expected to be able to read %" PRId64 " bytes for message body but got %" PRId64, bytes_to_read, bytes_read); return ESPIPE; } else { return NANOARROW_OK; } } static int ArrowIpcArrayStreamReaderReadSchemaIfNeeded( struct ArrowIpcArrayStreamReaderPrivate* private_data) { if (private_data->out_schema.release != NULL) { return NANOARROW_OK; } NANOARROW_RETURN_NOT_OK(ArrowIpcArrayStreamReaderNextHeader( private_data, NANOARROW_IPC_MESSAGE_TYPE_SCHEMA)); // Error if this isn't a schema message if (private_data->decoder.message_type != NANOARROW_IPC_MESSAGE_TYPE_SCHEMA) { ArrowErrorSet(&private_data->error, "Unexpected message type at start of input (expected Schema)"); return EINVAL; } // ...or if it uses features we don't support if (private_data->decoder.feature_flags & NANOARROW_IPC_FEATURE_COMPRESSED_BODY) { ArrowErrorSet(&private_data->error, "This stream uses unsupported feature COMPRESSED_BODY"); return EINVAL; } if (private_data->decoder.feature_flags & NANOARROW_IPC_FEATURE_DICTIONARY_REPLACEMENT) { ArrowErrorSet(&private_data->error, "This stream uses unsupported feature DICTIONARY_REPLACEMENT"); return EINVAL; } // Notify the decoder of buffer endianness NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowIpcDecoderSetEndianness(&private_data->decoder, private_data->decoder.endianness), &private_data->error); struct ArrowSchema tmp; NANOARROW_RETURN_NOT_OK( ArrowIpcDecoderDecodeSchema(&private_data->decoder, &tmp, &private_data->error)); // Only support "read the whole thing" for now if (private_data->field_index != -1) { ArrowSchemaRelease(&tmp); ArrowErrorSet(&private_data->error, "Field index != -1 is not yet supported"); return ENOTSUP; } // Notify the decoder of the schema for forthcoming messages int result = ArrowIpcDecoderSetSchema(&private_data->decoder, &tmp, &private_data->error); if (result != NANOARROW_OK) { ArrowSchemaRelease(&tmp); return result; } ArrowSchemaMove(&tmp, &private_data->out_schema); return NANOARROW_OK; } static int ArrowIpcArrayStreamReaderGetSchema(struct ArrowArrayStream* stream, struct ArrowSchema* out) { struct ArrowIpcArrayStreamReaderPrivate* private_data = (struct ArrowIpcArrayStreamReaderPrivate*)stream->private_data; private_data->error.message[0] = '\0'; NANOARROW_RETURN_NOT_OK(ArrowIpcArrayStreamReaderReadSchemaIfNeeded(private_data)); return ArrowSchemaDeepCopy(&private_data->out_schema, out); } static int ArrowIpcArrayStreamReaderGetNext(struct ArrowArrayStream* stream, struct ArrowArray* out) { struct ArrowIpcArrayStreamReaderPrivate* private_data = (struct ArrowIpcArrayStreamReaderPrivate*)stream->private_data; ArrowErrorInit(&private_data->error); NANOARROW_RETURN_NOT_OK(ArrowIpcArrayStreamReaderReadSchemaIfNeeded(private_data)); // Read + decode the next header int result = ArrowIpcArrayStreamReaderNextHeader( private_data, NANOARROW_IPC_MESSAGE_TYPE_RECORD_BATCH); if (result == ENODATA) { // Stream is finished either because there is no input or because // end of stream bytes were read. out->release = NULL; return NANOARROW_OK; } else if (result != NANOARROW_OK) { // Other error return result; } // Make sure we have a RecordBatch message if (private_data->decoder.message_type != NANOARROW_IPC_MESSAGE_TYPE_RECORD_BATCH) { ArrowErrorSet(&private_data->error, "Unexpected message type (expected RecordBatch)"); return EINVAL; } // Read in the body NANOARROW_RETURN_NOT_OK(ArrowIpcArrayStreamReaderNextBody(private_data)); struct ArrowArray tmp; if (private_data->use_shared_buffers) { struct ArrowIpcSharedBuffer shared; NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowIpcSharedBufferInit(&shared, &private_data->body), &private_data->error); result = ArrowIpcDecoderDecodeArrayFromShared( &private_data->decoder, &shared, private_data->field_index, &tmp, NANOARROW_VALIDATION_LEVEL_FULL, &private_data->error); ArrowIpcSharedBufferReset(&shared); NANOARROW_RETURN_NOT_OK(result); } else { struct ArrowBufferView body_view; body_view.data.data = private_data->body.data; body_view.size_bytes = private_data->body.size_bytes; NANOARROW_RETURN_NOT_OK(ArrowIpcDecoderDecodeArray( &private_data->decoder, body_view, private_data->field_index, &tmp, NANOARROW_VALIDATION_LEVEL_FULL, &private_data->error)); } ArrowArrayMove(&tmp, out); return NANOARROW_OK; } static const char* ArrowIpcArrayStreamReaderGetLastError( struct ArrowArrayStream* stream) { struct ArrowIpcArrayStreamReaderPrivate* private_data = (struct ArrowIpcArrayStreamReaderPrivate*)stream->private_data; return private_data->error.message; } ArrowErrorCode ArrowIpcArrayStreamReaderInit( struct ArrowArrayStream* out, struct ArrowIpcInputStream* input_stream, struct ArrowIpcArrayStreamReaderOptions* options) { struct ArrowIpcArrayStreamReaderPrivate* private_data = (struct ArrowIpcArrayStreamReaderPrivate*)ArrowMalloc( sizeof(struct ArrowIpcArrayStreamReaderPrivate)); if (private_data == NULL) { return ENOMEM; } int result = ArrowIpcDecoderInit(&private_data->decoder); if (result != NANOARROW_OK) { ArrowFree(private_data); return result; } ArrowBufferInit(&private_data->header); ArrowBufferInit(&private_data->body); private_data->out_schema.release = NULL; ArrowIpcInputStreamMove(input_stream, &private_data->input); private_data->expected_header_prefix_size = kExpectedHeaderPrefixSizeNotSet; if (options != NULL) { private_data->field_index = options->field_index; private_data->use_shared_buffers = options->use_shared_buffers; } else { private_data->field_index = -1; private_data->use_shared_buffers = ArrowIpcSharedBufferIsThreadSafe(); } out->private_data = private_data; out->get_schema = &ArrowIpcArrayStreamReaderGetSchema; out->get_next = &ArrowIpcArrayStreamReaderGetNext; out->get_last_error = &ArrowIpcArrayStreamReaderGetLastError; out->release = &ArrowIpcArrayStreamReaderRelease; return NANOARROW_OK; } // 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 #include #include #include "flatcc/flatcc_builder.h" #include "nanoarrow.h" #include "nanoarrow_ipc.h" #define ns(x) FLATBUFFERS_WRAP_NAMESPACE(org_apache_arrow_flatbuf, x) void ArrowIpcOutputStreamMove(struct ArrowIpcOutputStream* src, struct ArrowIpcOutputStream* dst) { NANOARROW_DCHECK(src != NULL && dst != NULL); memcpy(dst, src, sizeof(struct ArrowIpcOutputStream)); src->release = NULL; } ArrowErrorCode ArrowIpcOutputStreamWrite(struct ArrowIpcOutputStream* stream, struct ArrowBufferView data, struct ArrowError* error) { while (data.size_bytes != 0) { int64_t bytes_written = 0; NANOARROW_RETURN_NOT_OK(stream->write(stream, data.data.as_uint8, data.size_bytes, &bytes_written, error)); data.size_bytes -= bytes_written; data.data.as_uint8 += bytes_written; } return NANOARROW_OK; } struct ArrowIpcOutputStreamBufferPrivate { struct ArrowBuffer* output; }; static ArrowErrorCode ArrowIpcOutputStreamBufferWrite(struct ArrowIpcOutputStream* stream, const void* buf, int64_t buf_size_bytes, int64_t* size_written_out, struct ArrowError* error) { struct ArrowIpcOutputStreamBufferPrivate* private_data = (struct ArrowIpcOutputStreamBufferPrivate*)stream->private_data; NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowBufferAppend(private_data->output, buf, buf_size_bytes), error); *size_written_out = buf_size_bytes; return NANOARROW_OK; } static void ArrowIpcOutputStreamBufferRelease(struct ArrowIpcOutputStream* stream) { struct ArrowIpcOutputStreamBufferPrivate* private_data = (struct ArrowIpcOutputStreamBufferPrivate*)stream->private_data; ArrowFree(private_data); stream->release = NULL; } ArrowErrorCode ArrowIpcOutputStreamInitBuffer(struct ArrowIpcOutputStream* stream, struct ArrowBuffer* output) { NANOARROW_DCHECK(stream != NULL && output != NULL); struct ArrowIpcOutputStreamBufferPrivate* private_data = (struct ArrowIpcOutputStreamBufferPrivate*)ArrowMalloc( sizeof(struct ArrowIpcOutputStreamBufferPrivate)); if (private_data == NULL) { return ENOMEM; } private_data->output = output; stream->write = &ArrowIpcOutputStreamBufferWrite; stream->release = &ArrowIpcOutputStreamBufferRelease; stream->private_data = private_data; return NANOARROW_OK; } struct ArrowIpcOutputStreamFilePrivate { FILE* file_ptr; int stream_finished; int close_on_release; }; static void ArrowIpcOutputStreamFileRelease(struct ArrowIpcOutputStream* stream) { struct ArrowIpcOutputStreamFilePrivate* private_data = (struct ArrowIpcOutputStreamFilePrivate*)stream->private_data; if (private_data->file_ptr != NULL && private_data->close_on_release) { fclose(private_data->file_ptr); } ArrowFree(private_data); stream->release = NULL; } static ArrowErrorCode ArrowIpcOutputStreamFileWrite(struct ArrowIpcOutputStream* stream, const void* buf, int64_t buf_size_bytes, int64_t* size_written_out, struct ArrowError* error) { struct ArrowIpcOutputStreamFilePrivate* private_data = (struct ArrowIpcOutputStreamFilePrivate*)stream->private_data; if (private_data->stream_finished) { *size_written_out = 0; return NANOARROW_OK; } // Do the write int64_t bytes_written = (int64_t)fwrite(buf, 1, buf_size_bytes, private_data->file_ptr); *size_written_out = bytes_written; if (bytes_written != buf_size_bytes) { private_data->stream_finished = 1; // Inspect error int has_error = !feof(private_data->file_ptr) && ferror(private_data->file_ptr); // Try to close the file now if (private_data->close_on_release) { if (fclose(private_data->file_ptr) == 0) { private_data->file_ptr = NULL; } } // Maybe return error if (has_error) { ArrowErrorSet(error, "ArrowIpcOutputStreamFile IO error"); return EIO; } } return NANOARROW_OK; } ArrowErrorCode ArrowIpcOutputStreamInitFile(struct ArrowIpcOutputStream* stream, void* file_ptr, int close_on_release) { NANOARROW_DCHECK(stream != NULL); if (file_ptr == NULL) { return errno ? errno : EINVAL; } struct ArrowIpcOutputStreamFilePrivate* private_data = (struct ArrowIpcOutputStreamFilePrivate*)ArrowMalloc( sizeof(struct ArrowIpcOutputStreamFilePrivate)); if (private_data == NULL) { return ENOMEM; } private_data->file_ptr = (FILE*)file_ptr; private_data->close_on_release = close_on_release; private_data->stream_finished = 0; stream->write = &ArrowIpcOutputStreamFileWrite; stream->release = &ArrowIpcOutputStreamFileRelease; stream->private_data = private_data; return NANOARROW_OK; } struct ArrowIpcWriterPrivate { struct ArrowIpcEncoder encoder; struct ArrowIpcOutputStream output_stream; struct ArrowBuffer buffer; struct ArrowBuffer body_buffer; int writing_file; int64_t bytes_written; struct ArrowIpcFooter footer; }; ArrowErrorCode ArrowIpcWriterInit(struct ArrowIpcWriter* writer, struct ArrowIpcOutputStream* output_stream) { NANOARROW_DCHECK(writer != NULL && output_stream != NULL); struct ArrowIpcWriterPrivate* private = (struct ArrowIpcWriterPrivate*)ArrowMalloc(sizeof(struct ArrowIpcWriterPrivate)); if (private == NULL) { return ENOMEM; } NANOARROW_RETURN_NOT_OK(ArrowIpcEncoderInit(&private->encoder)); ArrowIpcOutputStreamMove(output_stream, &private->output_stream); ArrowBufferInit(&private->buffer); ArrowBufferInit(&private->body_buffer); private->writing_file = 0; private->bytes_written = 0; ArrowIpcFooterInit(&private->footer); writer->private_data = private; return NANOARROW_OK; } void ArrowIpcWriterReset(struct ArrowIpcWriter* writer) { NANOARROW_DCHECK(writer != NULL); struct ArrowIpcWriterPrivate* private = (struct ArrowIpcWriterPrivate*)writer->private_data; if (private != NULL) { ArrowIpcEncoderReset(&private->encoder); private->output_stream.release(&private->output_stream); ArrowBufferReset(&private->buffer); ArrowBufferReset(&private->body_buffer); ArrowIpcFooterReset(&private->footer); ArrowFree(private); } memset(writer, 0, sizeof(struct ArrowIpcWriter)); } static struct ArrowBufferView ArrowBufferToBufferView(const struct ArrowBuffer* buffer) { struct ArrowBufferView buffer_view = { .data.as_uint8 = buffer->data, .size_bytes = buffer->size_bytes, }; return buffer_view; } // Eventually, it may be necessary to construct an ArrowIpcWriter which doesn't rely on // blocking writes (ArrowIpcOutputStreamWrite). For example an ArrowIpcOutputStream // might wrap a socket which is not always able to transmit all bytes of a Message. In // that case users of ArrowIpcWriter might prefer to do other work until a socket is // ready rather than blocking, or timeout, or otherwise respond to partial transmission. // // This could be handled by: // - keeping partially sent buffers internal and signalling incomplete transmission by // raising EAGAIN, returning "bytes actually written", ... // - when the caller is ready to try again, call ArrowIpcWriterWriteSome() // - exposing internal buffers which have not been completely sent, deferring // follow-up transmission to the caller ArrowErrorCode ArrowIpcWriterWriteSchema(struct ArrowIpcWriter* writer, const struct ArrowSchema* in, struct ArrowError* error) { NANOARROW_DCHECK(writer != NULL && writer->private_data != NULL && in != NULL); struct ArrowIpcWriterPrivate* private = (struct ArrowIpcWriterPrivate*)writer->private_data; NANOARROW_ASSERT_OK(ArrowBufferResize(&private->buffer, 0, 0)); NANOARROW_RETURN_NOT_OK(ArrowIpcEncoderEncodeSchema(&private->encoder, in, error)); NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowIpcEncoderFinalizeBuffer(&private->encoder, /*encapsulate=*/1, &private->buffer), error); if (private->writing_file) { NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowSchemaDeepCopy(in, &private->footer.schema), error); } private->bytes_written += private->buffer.size_bytes; return ArrowIpcOutputStreamWrite(&private->output_stream, ArrowBufferToBufferView(&private->buffer), error); } ArrowErrorCode ArrowIpcWriterWriteArrayView(struct ArrowIpcWriter* writer, const struct ArrowArrayView* in, struct ArrowError* error) { NANOARROW_DCHECK(writer != NULL && writer->private_data != NULL); struct ArrowIpcWriterPrivate* private = (struct ArrowIpcWriterPrivate*)writer->private_data; if (in == NULL) { int32_t eos[] = {-1, 0}; private->bytes_written += sizeof(eos); struct ArrowBufferView eos_view = {.data.as_int32 = eos, .size_bytes = sizeof(eos)}; return ArrowIpcOutputStreamWrite(&private->output_stream, eos_view, error); } NANOARROW_ASSERT_OK(ArrowBufferResize(&private->buffer, 0, 0)); NANOARROW_ASSERT_OK(ArrowBufferResize(&private->body_buffer, 0, 0)); NANOARROW_RETURN_NOT_OK(ArrowIpcEncoderEncodeSimpleRecordBatch( &private->encoder, in, &private->body_buffer, error)); NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowIpcEncoderFinalizeBuffer(&private->encoder, /*encapsulate=*/1, &private->buffer), error); if (private->writing_file) { _NANOARROW_CHECK_RANGE(private->buffer.size_bytes, 0, INT32_MAX); struct ArrowIpcFileBlock block = { .offset = private->bytes_written, .metadata_length = (int32_t) private->buffer.size_bytes, .body_length = private->body_buffer.size_bytes, }; NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowBufferAppend(&private->footer.record_batch_blocks, &block, sizeof(block)), error); } private->bytes_written += private->buffer.size_bytes; private->bytes_written += private->body_buffer.size_bytes; NANOARROW_RETURN_NOT_OK(ArrowIpcOutputStreamWrite( &private->output_stream, ArrowBufferToBufferView(&private->buffer), error)); NANOARROW_RETURN_NOT_OK(ArrowIpcOutputStreamWrite( &private->output_stream, ArrowBufferToBufferView(&private->body_buffer), error)); return NANOARROW_OK; } static ArrowErrorCode ArrowIpcWriterWriteArrayStreamImpl( struct ArrowIpcWriter* writer, struct ArrowArrayStream* in, struct ArrowSchema* schema, struct ArrowArray* array, struct ArrowArrayView* array_view, struct ArrowError* error) { NANOARROW_RETURN_NOT_OK(ArrowArrayStreamGetSchema(in, schema, error)); NANOARROW_RETURN_NOT_OK(ArrowIpcWriterWriteSchema(writer, schema, error)); NANOARROW_RETURN_NOT_OK(ArrowArrayViewInitFromSchema(array_view, schema, error)); while (1) { NANOARROW_RETURN_NOT_OK(ArrowArrayStreamGetNext(in, array, error)); if (array->release == NULL) { break; } NANOARROW_RETURN_NOT_OK(ArrowArrayViewSetArray(array_view, array, error)); NANOARROW_RETURN_NOT_OK(ArrowIpcWriterWriteArrayView(writer, array_view, error)); ArrowArrayRelease(array); } // The stream is complete, signal the end to the caller return ArrowIpcWriterWriteArrayView(writer, NULL, error); } ArrowErrorCode ArrowIpcWriterWriteArrayStream(struct ArrowIpcWriter* writer, struct ArrowArrayStream* in, struct ArrowError* error) { NANOARROW_DCHECK(writer != NULL && writer->private_data != NULL && in != NULL); struct ArrowSchema schema = {.release = NULL}; struct ArrowArray array = {.release = NULL}; struct ArrowArrayView array_view; ArrowArrayViewInitFromType(&array_view, NANOARROW_TYPE_UNINITIALIZED); ArrowErrorCode result = ArrowIpcWriterWriteArrayStreamImpl(writer, in, &schema, &array, &array_view, error); if (schema.release != NULL) { ArrowSchemaRelease(&schema); } if (array.release != NULL) { ArrowArrayRelease(&array); } ArrowArrayViewReset(&array_view); return result; } #define NANOARROW_IPC_FILE_PADDED_MAGIC "ARROW1\0" ArrowErrorCode ArrowIpcWriterStartFile(struct ArrowIpcWriter* writer, struct ArrowError* error) { NANOARROW_DCHECK(writer != NULL && writer->private_data != NULL); struct ArrowIpcWriterPrivate* private = (struct ArrowIpcWriterPrivate*)writer->private_data; NANOARROW_DCHECK(!private->writing_file && private->bytes_written == 0); struct ArrowBufferView magic = { .data.data = NANOARROW_IPC_FILE_PADDED_MAGIC, .size_bytes = sizeof(NANOARROW_IPC_FILE_PADDED_MAGIC), }; NANOARROW_RETURN_NOT_OK( ArrowIpcOutputStreamWrite(&private->output_stream, magic, error)); private->writing_file = 1; private->bytes_written = magic.size_bytes; return NANOARROW_OK; } ArrowErrorCode ArrowIpcWriterFinalizeFile(struct ArrowIpcWriter* writer, struct ArrowError* error) { NANOARROW_DCHECK(writer != NULL && writer->private_data != NULL); struct ArrowIpcWriterPrivate* private = (struct ArrowIpcWriterPrivate*)writer->private_data; NANOARROW_DCHECK(private->writing_file); NANOARROW_ASSERT_OK(ArrowBufferResize(&private->buffer, 0, 0)); NANOARROW_RETURN_NOT_OK( ArrowIpcEncoderEncodeFooter(&private->encoder, &private->footer, error)); NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowIpcEncoderFinalizeBuffer(&private->encoder, /*encapsulate=*/0, &private->buffer), error); _NANOARROW_CHECK_RANGE(private->buffer.size_bytes, 0, INT32_MAX); int32_t size = (int32_t) private->buffer.size_bytes; // we don't pad the magic at the end of the file struct ArrowStringView unpadded_magic = ArrowCharView(NANOARROW_IPC_FILE_PADDED_MAGIC); NANOARROW_DCHECK(unpadded_magic.size_bytes == 6); // just append to private->buffer instead of queueing two more tiny writes NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowBufferReserve(&private->buffer, sizeof(size) + unpadded_magic.size_bytes), error); if (ArrowIpcSystemEndianness() == NANOARROW_IPC_ENDIANNESS_BIG) { size = (int32_t)bswap32((uint32_t)size); } NANOARROW_ASSERT_OK(ArrowBufferAppendInt32(&private->buffer, size)); NANOARROW_ASSERT_OK(ArrowBufferAppendStringView(&private->buffer, unpadded_magic)); NANOARROW_RETURN_NOT_OK(ArrowIpcOutputStreamWrite( &private->output_stream, ArrowBufferToBufferView(&private->buffer), error)); private->bytes_written += private->buffer.size_bytes; return NANOARROW_OK; } nanoarrow/src/convert.c0000644000176200001440000004135214672341746014716 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" #include "array.h" #include "convert.h" #include "materialize.h" #include "schema.h" static R_xlen_t nanoarrow_vec_size(SEXP vec_sexp, struct PTypeView* ptype_view) { if (ptype_view->vector_type == VECTOR_TYPE_DATA_FRAME) { return nanoarrow_data_frame_size(vec_sexp); } else { return Rf_xlength(vec_sexp); } } static void finalize_converter(SEXP converter_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); if (converter != NULL) { ArrowArrayViewReset(&converter->array_view); if (converter->children != NULL) { ArrowFree(converter->children); } ArrowFree(converter); } } SEXP nanoarrow_converter_from_type(enum VectorType vector_type) { struct RConverter* converter = (struct RConverter*)ArrowMalloc(sizeof(struct RConverter)); if (converter == NULL) { Rf_error("Failed to allocate RConverter"); } // 0: ptype, 1: schema_xptr, 2: array_xptr, 3: children, 4: result SEXP converter_shelter = PROTECT(Rf_allocVector(VECSXP, 5)); SEXP converter_xptr = PROTECT(R_MakeExternalPtr(converter, R_NilValue, converter_shelter)); R_RegisterCFinalizer(converter_xptr, &finalize_converter); ArrowArrayViewInitFromType(&converter->array_view, NANOARROW_TYPE_UNINITIALIZED); converter->schema_view.type = NANOARROW_TYPE_UNINITIALIZED; converter->schema_view.storage_type = NANOARROW_TYPE_UNINITIALIZED; converter->src.array_view = &converter->array_view; converter->dst.vec_sexp = R_NilValue; converter->options = NULL; converter->error.message[0] = '\0'; converter->size = 0; converter->capacity = 0; converter->n_children = 0; converter->children = NULL; converter->ptype_view.vector_type = vector_type; converter->ptype_view.ptype = R_NilValue; switch (vector_type) { case VECTOR_TYPE_NULL: converter->ptype_view.sexp_type = NILSXP; break; case VECTOR_TYPE_LGL: converter->ptype_view.sexp_type = LGLSXP; break; case VECTOR_TYPE_INT: converter->ptype_view.sexp_type = INTSXP; break; case VECTOR_TYPE_DBL: converter->ptype_view.sexp_type = REALSXP; break; case VECTOR_TYPE_CHR: converter->ptype_view.sexp_type = STRSXP; break; default: UNPROTECT(2); return R_NilValue; } UNPROTECT(2); return converter_xptr; } static enum RTimeUnits time_units_from_difftime(SEXP ptype) { SEXP units_attr = Rf_getAttrib(ptype, Rf_install("units")); if (units_attr == R_NilValue || TYPEOF(units_attr) != STRSXP || Rf_length(units_attr) != 1) { Rf_error("Expected difftime 'units' attribute of type character(1)"); } const char* dst_units = Rf_translateCharUTF8(STRING_ELT(units_attr, 0)); if (strcmp(dst_units, "secs") == 0) { return R_TIME_UNIT_SECONDS; } else if (strcmp(dst_units, "mins") == 0) { return R_TIME_UNIT_MINUTES; } else if (strcmp(dst_units, "hours") == 0) { return R_TIME_UNIT_HOURS; } else if (strcmp(dst_units, "days") == 0) { return R_TIME_UNIT_DAYS; } else if (strcmp(dst_units, "weeks") == 0) { return R_TIME_UNIT_WEEKS; } else { Rf_error("Unexpected value for difftime 'units' attribute"); return R_TIME_UNIT_SECONDS; } } static void set_converter_data_frame(SEXP converter_xptr, struct RConverter* converter, SEXP ptype) { converter->n_children = Rf_xlength(ptype); converter->children = (struct RConverter**)ArrowMalloc(converter->n_children * sizeof(struct RConverter*)); if (converter->children == NULL) { Rf_error("Failed to allocate converter children array"); } SEXP child_converter_xptrs = PROTECT(Rf_allocVector(VECSXP, converter->n_children)); for (R_xlen_t i = 0; i < converter->n_children; i++) { SEXP child_ptype = VECTOR_ELT(ptype, i); SEXP child_converter = PROTECT(nanoarrow_converter_from_ptype(child_ptype)); converter->children[i] = (struct RConverter*)R_ExternalPtrAddr(child_converter); SET_VECTOR_ELT(child_converter_xptrs, i, child_converter); UNPROTECT(1); } SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SET_VECTOR_ELT(converter_shelter, 3, child_converter_xptrs); UNPROTECT(1); } static void set_converter_list_of(SEXP converter_xptr, struct RConverter* converter, SEXP ptype) { SEXP child_ptype = Rf_getAttrib(ptype, Rf_install("ptype")); if (child_ptype == R_NilValue) { Rf_error("Expected attribute 'ptype' for conversion to list_of"); } converter->children = (struct RConverter**)ArrowMalloc(1 * sizeof(struct RConverter*)); if (converter->children == NULL) { Rf_error("Failed to allocate converter children array"); } converter->n_children = 1; SEXP child_converter_xptrs = PROTECT(Rf_allocVector(VECSXP, 1)); SEXP child_converter = PROTECT(nanoarrow_converter_from_ptype(child_ptype)); converter->children[0] = (struct RConverter*)R_ExternalPtrAddr(child_converter); SET_VECTOR_ELT(child_converter_xptrs, 0, child_converter); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SET_VECTOR_ELT(converter_shelter, 3, child_converter_xptrs); UNPROTECT(2); } static int set_converter_children_schema(SEXP converter_xptr, SEXP schema_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); if (schema->n_children != converter->n_children) { ArrowErrorSet(&converter->error, "Expected schema with %ld children but got schema with %ld children", (long)converter->n_children, (long)schema->n_children); return EINVAL; } SEXP child_converter_xptrs = VECTOR_ELT(converter_shelter, 3); for (R_xlen_t i = 0; i < converter->n_children; i++) { SEXP child_converter_xptr = VECTOR_ELT(child_converter_xptrs, i); SEXP child_schema_xptr = PROTECT(borrow_schema_child_xptr(schema_xptr, i)); int result = nanoarrow_converter_set_schema(child_converter_xptr, child_schema_xptr); UNPROTECT(1); if (result != NANOARROW_OK) { return result; } } return NANOARROW_OK; } static int set_converter_children_array(SEXP converter_xptr, SEXP array_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); if (array->n_children != converter->n_children) { ArrowErrorSet(&converter->error, "Expected array with %ld children but got array with %ld children", (long)converter->n_children, (long)array->n_children); return EINVAL; } SEXP child_converter_xptrs = VECTOR_ELT(converter_shelter, 3); for (R_xlen_t i = 0; i < converter->n_children; i++) { SEXP child_converter_xptr = VECTOR_ELT(child_converter_xptrs, i); SEXP child_array_xptr = PROTECT(borrow_array_child_xptr(array_xptr, i)); int result = nanoarrow_converter_set_array(child_converter_xptr, child_array_xptr); UNPROTECT(1); if (result != NANOARROW_OK) { return result; } } return NANOARROW_OK; } SEXP nanoarrow_converter_from_ptype(SEXP ptype) { SEXP converter_xptr = PROTECT(nanoarrow_converter_from_type(VECTOR_TYPE_NULL)); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); if (Rf_isObject(ptype)) { if (nanoarrow_ptype_is_data_frame(ptype)) { converter->ptype_view.vector_type = VECTOR_TYPE_DATA_FRAME; set_converter_data_frame(converter_xptr, converter, ptype); } else if (Rf_inherits(ptype, "blob")) { converter->ptype_view.vector_type = VECTOR_TYPE_BLOB; } else if (Rf_inherits(ptype, "vctrs_list_of")) { converter->ptype_view.vector_type = VECTOR_TYPE_LIST_OF; set_converter_list_of(converter_xptr, converter, ptype); } else if (Rf_inherits(ptype, "vctrs_unspecified")) { converter->ptype_view.vector_type = VECTOR_TYPE_UNSPECIFIED; } else if (Rf_inherits(ptype, "Date")) { converter->ptype_view.vector_type = VECTOR_TYPE_DATE; converter->ptype_view.r_time_units = R_TIME_UNIT_DAYS; } else if (Rf_inherits(ptype, "POSIXct")) { converter->ptype_view.vector_type = VECTOR_TYPE_POSIXCT; converter->ptype_view.r_time_units = R_TIME_UNIT_SECONDS; } else if (Rf_inherits(ptype, "difftime")) { converter->ptype_view.vector_type = VECTOR_TYPE_DIFFTIME; converter->ptype_view.r_time_units = time_units_from_difftime(ptype); } else if (Rf_inherits(ptype, "integer64")) { converter->ptype_view.vector_type = VECTOR_TYPE_INTEGER64; } else { converter->ptype_view.vector_type = VECTOR_TYPE_OTHER; } } else { switch (TYPEOF(ptype)) { case LGLSXP: converter->ptype_view.vector_type = VECTOR_TYPE_LGL; break; case INTSXP: converter->ptype_view.vector_type = VECTOR_TYPE_INT; break; case REALSXP: converter->ptype_view.vector_type = VECTOR_TYPE_DBL; break; case STRSXP: converter->ptype_view.vector_type = VECTOR_TYPE_CHR; break; default: converter->ptype_view.vector_type = VECTOR_TYPE_OTHER; break; } } converter->ptype_view.ptype = ptype; converter->ptype_view.sexp_type = TYPEOF(ptype); SET_VECTOR_ELT(converter_shelter, 0, ptype); UNPROTECT(1); return converter_xptr; } int nanoarrow_converter_set_schema(SEXP converter_xptr, SEXP schema_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); NANOARROW_RETURN_NOT_OK( ArrowSchemaViewInit(&converter->schema_view, schema, &converter->error)); // TODO: Currently we error at the materialize stage if a conversion is not possible; // however, at this stage we have all the information we need to calculate that. SET_VECTOR_ELT(converter_shelter, 1, schema_xptr); ArrowArrayViewReset(&converter->array_view); SET_VECTOR_ELT(converter_shelter, 2, R_NilValue); NANOARROW_RETURN_NOT_OK( ArrowArrayViewInitFromSchema(&converter->array_view, schema, &converter->error)); if (converter->ptype_view.vector_type == VECTOR_TYPE_LIST_OF || converter->ptype_view.vector_type == VECTOR_TYPE_DATA_FRAME) { set_converter_children_schema(converter_xptr, schema_xptr); } return NANOARROW_OK; } int nanoarrow_converter_set_array(SEXP converter_xptr, SEXP array_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); NANOARROW_RETURN_NOT_OK( ArrowArrayViewSetArray(&converter->array_view, array, &converter->error)); SET_VECTOR_ELT(converter_shelter, 2, array_xptr); converter->src.offset = 0; converter->src.length = 0; if (converter->ptype_view.vector_type == VECTOR_TYPE_LIST_OF || converter->ptype_view.vector_type == VECTOR_TYPE_DATA_FRAME) { set_converter_children_array(converter_xptr, array_xptr); } return NANOARROW_OK; } void sync_after_converter_reallocate(SEXP converter_xptr, struct RConverter* converter, SEXP result_sexp, R_xlen_t capacity) { SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SET_VECTOR_ELT(converter_shelter, 4, result_sexp); converter->dst.vec_sexp = result_sexp; converter->dst.offset = 0; converter->dst.length = 0; converter->size = 0; converter->capacity = capacity; if (converter->ptype_view.vector_type == VECTOR_TYPE_DATA_FRAME) { SEXP child_converters = VECTOR_ELT(converter_shelter, 3); for (R_xlen_t i = 0; i < converter->n_children; i++) { sync_after_converter_reallocate(VECTOR_ELT(child_converters, i), converter->children[i], VECTOR_ELT(result_sexp, i), capacity); } } } int nanoarrow_converter_reserve(SEXP converter_xptr, R_xlen_t additional_size) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SEXP current_result = VECTOR_ELT(converter_shelter, 4); if (current_result != R_NilValue) { ArrowErrorSet(&converter->error, "Reallocation in converter is not implemented"); return ENOTSUP; } SEXP result_sexp; if (converter->ptype_view.ptype != R_NilValue) { result_sexp = PROTECT( nanoarrow_materialize_realloc(converter->ptype_view.ptype, additional_size)); } else { result_sexp = PROTECT(nanoarrow_alloc_type(converter->ptype_view.vector_type, additional_size)); } sync_after_converter_reallocate(converter_xptr, converter, result_sexp, additional_size); UNPROTECT(1); return NANOARROW_OK; } R_xlen_t nanoarrow_converter_materialize_n(SEXP converter_xptr, R_xlen_t n) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); if ((converter->dst.offset + n) > converter->capacity) { n = converter->capacity - converter->dst.offset; } if ((converter->src.offset + n) > converter->array_view.array->length) { n = converter->array_view.array->length - converter->src.offset; } if (n == 0) { return 0; } converter->src.length = converter->dst.length = n; int result = nanoarrow_materialize(converter, converter_xptr); if (result != NANOARROW_OK) { ArrowErrorSet(&converter->error, "Error in nanoarrow_materialize()"); return 0; } converter->src.offset += n; converter->dst.offset += n; converter->size += n; return n; } int nanoarrow_converter_materialize_all(SEXP converter_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); R_xlen_t remaining = converter->array_view.array->length; NANOARROW_RETURN_NOT_OK(nanoarrow_converter_reserve(converter_xptr, remaining)); if (nanoarrow_converter_materialize_n(converter_xptr, remaining) != remaining) { return ERANGE; } else { return NANOARROW_OK; } } int nanoarrow_converter_finalize(SEXP converter_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SEXP current_result = VECTOR_ELT(converter_shelter, 4); NANOARROW_RETURN_NOT_OK(nanoarrow_materialize_finalize_result(converter_xptr)); // Check result size. A future implementation could also shrink the length // or reallocate a shorter vector. R_xlen_t current_result_size = nanoarrow_vec_size(current_result, &converter->ptype_view); if (current_result_size != converter->size) { ArrowErrorSet(&converter->error, "Expected result of size %ld but got result of size %ld", (long)current_result_size, (long)converter->size); return ENOTSUP; } return NANOARROW_OK; } SEXP nanoarrow_converter_release_result(SEXP converter_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); // PROTECT()ing here because we are about to release the object from the // shelter of the converter and return it SEXP result = PROTECT(VECTOR_ELT(converter_shelter, 4)); SET_VECTOR_ELT(converter_shelter, 4, R_NilValue); // Reset the converter state converter->dst.vec_sexp = R_NilValue; converter->dst.offset = 0; converter->dst.length = 0; converter->size = 0; converter->capacity = 0; UNPROTECT(1); return result; } void nanoarrow_converter_stop(SEXP converter_xptr) { struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); Rf_error("%s", ArrowErrorMessage(&converter->error)); } nanoarrow/src/materialize_date.h0000644000176200001440000000251414502402562016525 0ustar liggesusers // 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. #ifndef R_MATERIALIZE_DATE_H_INCLUDED #define R_MATERIALIZE_DATE_H_INCLUDED #include #include #include "materialize_common.h" #include "materialize_dbl.h" #include "nanoarrow.h" static int nanoarrow_materialize_date(struct RConverter* converter) { if (converter->ptype_view.sexp_type == REALSXP) { switch (converter->schema_view.type) { case NANOARROW_TYPE_NA: case NANOARROW_TYPE_DATE32: return nanoarrow_materialize_dbl(converter); default: break; } } return ENOTSUP; } #endif nanoarrow/src/nanoarrow_ipc.h0000644000176200001440000007607014702632113016072 0ustar liggesusers// 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. #ifndef NANOARROW_IPC_H_INCLUDED #define NANOARROW_IPC_H_INCLUDED #include "nanoarrow.h" #ifdef NANOARROW_NAMESPACE #define ArrowIpcCheckRuntime NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcCheckRuntime) #define ArrowIpcSharedBufferIsThreadSafe \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferIsThreadSafe) #define ArrowIpcSharedBufferInit \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferInit) #define ArrowIpcSharedBufferReset \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferReset) #define ArrowIpcDecoderInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderInit) #define ArrowIpcDecoderReset NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderReset) #define ArrowIpcDecoderPeekHeader \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderPeekHeader) #define ArrowIpcDecoderVerifyHeader \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderVerifyHeader) #define ArrowIpcDecoderDecodeHeader \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeHeader) #define ArrowIpcDecoderDecodeSchema \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeSchema) #define ArrowIpcDecoderDecodeArrayView \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArrayView) #define ArrowIpcDecoderDecodeArray \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArray) #define ArrowIpcDecoderDecodeArrayFromShared \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArrayFromShared) #define ArrowIpcDecoderSetSchema \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderSetSchema) #define ArrowIpcDecoderSetEndianness \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderSetEndianness) #define ArrowIpcDecoderPeekFooter \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderPeekFooter) #define ArrowIpcDecoderVerifyFooter \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderVerifyFooter) #define ArrowIpcDecoderDecodeFooter \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeFooter) #define ArrowIpcInputStreamInitBuffer \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamInitBuffer) #define ArrowIpcInputStreamInitFile \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamInitFile) #define ArrowIpcInputStreamMove \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamMove) #define ArrowIpcArrayStreamReaderInit \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcArrayStreamReaderInit) #define ArrowIpcEncoderInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcEncoderInit) #define ArrowIpcEncoderReset NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcEncoderReset) #define ArrowIpcEncoderFinalizeBuffer \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcEncoderFinalizeBuffer) #define ArrowIpcEncoderEncodeSchema \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcEncoderEncodeSchema) #define ArrowIpcEncoderEncodeSimpleRecordBatch \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcEncoderEncodeSimpleRecordBatch) #define ArrowIpcOutputStreamInitBuffer \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcOutputStreamInitBuffer) #define ArrowIpcOutputStreamInitFile \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcOutputStreamInitFile) #define ArrowIpcOutputStreamWrite \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcOutputStreamWrite) #define ArrowIpcOutputStreamMove \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcOutputStreamMove) #define ArrowIpcWriterInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcWriterInit) #define ArrowIpcWriterReset NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcWriterReset) #define ArrowIpcWriterWriteSchema \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcWriterWriteSchema) #define ArrowIpcWriterWriteArrayView \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcWriterWriteArrayView) #define ArrowIpcWriterWriteArrayStream \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcWriterWriteArrayStream) #define ArrowIpcWriterStartFile \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcWriterStartFile) #define ArrowIpcWriterFinalizeFile \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcWriterFinalizeFile) #define ArrowIpcFooterInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcFooterInit) #define ArrowIpcFooterReset NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcFooterReset) #define ArrowIpcEncoderEncodeFooter \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcEncoderEncodeFooter) #endif #ifdef __cplusplus extern "C" { #endif /// \defgroup nanoarrow_ipc Nanoarrow IPC extension /// /// Except where noted, objects are not thread-safe and clients should /// take care to serialize accesses to methods. /// /// Because this library is intended to be vendored, it provides full type /// definitions and encourages clients to stack or statically allocate /// where convenient. /// /// @{ /// \brief Metadata version enumerator enum ArrowIpcMetadataVersion { NANOARROW_IPC_METADATA_VERSION_V1, NANOARROW_IPC_METADATA_VERSION_V2, NANOARROW_IPC_METADATA_VERSION_V3, NANOARROW_IPC_METADATA_VERSION_V4, NANOARROW_IPC_METADATA_VERSION_V5 }; /// \brief Message type enumerator enum ArrowIpcMessageType { NANOARROW_IPC_MESSAGE_TYPE_UNINITIALIZED, NANOARROW_IPC_MESSAGE_TYPE_SCHEMA, NANOARROW_IPC_MESSAGE_TYPE_DICTIONARY_BATCH, NANOARROW_IPC_MESSAGE_TYPE_RECORD_BATCH, NANOARROW_IPC_MESSAGE_TYPE_TENSOR, NANOARROW_IPC_MESSAGE_TYPE_SPARSE_TENSOR }; /// \brief Endianness enumerator enum ArrowIpcEndianness { NANOARROW_IPC_ENDIANNESS_UNINITIALIZED, NANOARROW_IPC_ENDIANNESS_LITTLE, NANOARROW_IPC_ENDIANNESS_BIG }; /// \brief Compression type enumerator enum ArrowIpcCompressionType { NANOARROW_IPC_COMPRESSION_TYPE_NONE, NANOARROW_IPC_COMPRESSION_TYPE_LZ4_FRAME, NANOARROW_IPC_COMPRESSION_TYPE_ZSTD }; /// \brief Feature flag for a stream that uses dictionary replacement #define NANOARROW_IPC_FEATURE_DICTIONARY_REPLACEMENT 1 /// \brief Feature flag for a stream that uses compression #define NANOARROW_IPC_FEATURE_COMPRESSED_BODY 2 /// \brief Checks the nanoarrow runtime to make sure the run/build versions match ArrowErrorCode ArrowIpcCheckRuntime(struct ArrowError* error); /// \brief Get the endianness of the current runtime static inline enum ArrowIpcEndianness ArrowIpcSystemEndianness(void) { uint32_t check = 1; char first_byte; memcpy(&first_byte, &check, sizeof(char)); if (first_byte) { return NANOARROW_IPC_ENDIANNESS_LITTLE; } else { return NANOARROW_IPC_ENDIANNESS_BIG; } } /// \brief A structure representing a reference-counted buffer that may be passed to /// ArrowIpcDecoderDecodeArrayFromShared(). struct ArrowIpcSharedBuffer { struct ArrowBuffer private_src; }; /// \brief Initialize the contents of a ArrowIpcSharedBuffer struct /// /// If NANOARROW_OK is returned, the ArrowIpcSharedBuffer takes ownership of /// src. ArrowErrorCode ArrowIpcSharedBufferInit(struct ArrowIpcSharedBuffer* shared, struct ArrowBuffer* src); /// \brief Release the caller's copy of the shared buffer /// /// When finished, the caller must relinquish its own copy of the shared data /// using this function. The original buffer will continue to exist until all /// ArrowArray objects that refer to it have also been released. void ArrowIpcSharedBufferReset(struct ArrowIpcSharedBuffer* shared); /// \brief Check for shared buffer thread safety /// /// Thread-safe shared buffers require C11 and the stdatomic.h header. /// If either are unavailable, shared buffers are still possible but /// the resulting arrays must not be passed to other threads to be released. int ArrowIpcSharedBufferIsThreadSafe(void); /// \brief Decoder for Arrow IPC messages /// /// This structure is intended to be allocated by the caller, /// initialized using ArrowIpcDecoderInit(), and released with /// ArrowIpcDecoderReset(). These fields should not be modified /// by the caller but can be read following a call to /// ArrowIpcDecoderPeekHeader(), ArrowIpcDecoderVerifyHeader(), or /// ArrowIpcDecoderDecodeHeader(). struct ArrowIpcDecoder { /// \brief The last verified or decoded message type enum ArrowIpcMessageType message_type; /// \brief The metadata version as indicated by the current schema message enum ArrowIpcMetadataVersion metadata_version; /// \brief Buffer endianness as indicated by the current schema message enum ArrowIpcEndianness endianness; /// \brief Arrow IPC Features used as indicated by the current Schema message int32_t feature_flags; /// \brief Compression used by the current RecordBatch message enum ArrowIpcCompressionType codec; /// \brief The number of bytes in the current header message /// /// This value includes the 8 bytes before the start of the header message /// content and any padding bytes required to make the header message size /// be a multiple of 8 bytes. int32_t header_size_bytes; /// \brief The number of bytes in the forthcoming body message. int64_t body_size_bytes; /// \brief The last decoded Footer /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. struct ArrowIpcFooter* footer; /// \brief Private resources managed by this library void* private_data; }; /// \brief Initialize a decoder ArrowErrorCode ArrowIpcDecoderInit(struct ArrowIpcDecoder* decoder); /// \brief Release all resources attached to a decoder void ArrowIpcDecoderReset(struct ArrowIpcDecoder* decoder); /// \brief Peek at a message header /// /// The first 8 bytes of an Arrow IPC message are 0xFFFFFFFF followed by the size /// of the header as a little-endian 32-bit integer. ArrowIpcDecoderPeekHeader() reads /// these bytes and returns ESPIPE if there are not enough remaining bytes in data to read /// the entire header message, EINVAL if the first 8 bytes are not valid, ENODATA if the /// Arrow end-of-stream indicator has been reached, or NANOARROW_OK otherwise. /// /// Pre-1.0 messages were not prefixed with 0xFFFFFFFF. For these messages, a value /// of 4 will be placed into prefix_size_bytes; otherwise a value of 8 will be placed /// into prefix_size_bytes. ArrowErrorCode ArrowIpcDecoderPeekHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, int32_t* prefix_size_bytes, struct ArrowError* error); /// \brief Verify a message header /// /// Runs ArrowIpcDecoderPeekHeader() to ensure data is sufficiently large but additionally /// runs flatbuffer verification to ensure that decoding the data will not access /// memory outside of the buffer specified by data. ArrowIpcDecoderVerifyHeader() will /// also set decoder.header_size_bytes, decoder.body_size_bytes, decoder.metadata_version, /// and decoder.message_type. /// /// Returns as ArrowIpcDecoderPeekHeader() and additionally will /// return EINVAL if flatbuffer verification fails. ArrowErrorCode ArrowIpcDecoderVerifyHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error); /// \brief Decode a message header /// /// Runs ArrowIpcDecoderPeekHeader() to ensure data is sufficiently large and decodes /// the content of the message header. If data contains a schema message, /// decoder.endianness and decoder.feature_flags is set and ArrowIpcDecoderDecodeSchema() /// can be used to obtain the decoded schema. If data contains a record batch message, /// decoder.codec is set and a successful call can be followed by a call to /// ArrowIpcDecoderDecodeArray(). /// /// In almost all cases this should be preceded by a call to /// ArrowIpcDecoderVerifyHeader() to ensure decoding does not access data outside of the /// specified buffer. /// /// Returns EINVAL if the content of the message cannot be decoded or ENOTSUP if the /// content of the message uses features not supported by this library. ArrowErrorCode ArrowIpcDecoderDecodeHeader(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error); /// \brief Decode an ArrowSchema /// /// After a successful call to ArrowIpcDecoderDecodeHeader(), retrieve an ArrowSchema. /// The caller is responsible for releasing the schema if NANOARROW_OK is returned. /// /// Returns EINVAL if the decoder did not just decode a schema message or /// NANOARROW_OK otherwise. ArrowErrorCode ArrowIpcDecoderDecodeSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* out, struct ArrowError* error); /// \brief Set the ArrowSchema used to decode future record batch messages /// /// Prepares the decoder for future record batch messages /// of this type. The decoder takes ownership of schema if NANOARROW_OK is returned. /// Note that you must call this explicitly after decoding a /// Schema message (i.e., the decoder does not assume that the last-decoded /// schema message applies to future record batch messages). /// /// Returns EINVAL if schema validation fails or NANOARROW_OK otherwise. ArrowErrorCode ArrowIpcDecoderSetSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* schema, struct ArrowError* error); /// \brief Set the endianness used to decode future record batch messages /// /// Prepares the decoder for future record batch messages with the specified /// endianness. Note that you must call this explicitly after decoding a /// Schema message (i.e., the decoder does not assume that the last-decoded /// schema message applies to future record batch messages). /// /// Returns NANOARROW_OK on success. ArrowErrorCode ArrowIpcDecoderSetEndianness(struct ArrowIpcDecoder* decoder, enum ArrowIpcEndianness endianness); /// \brief Decode an ArrowArrayView /// /// After a successful call to ArrowIpcDecoderDecodeHeader(), deserialize the content /// of body into an internally-managed ArrowArrayView and return it. Note that field index /// does not equate to column index if any columns contain nested types. Use a value of -1 /// to decode the entire array into a struct. The pointed-to ArrowArrayView is owned by /// the ArrowIpcDecoder and must not be released. /// /// For streams that match system endianness and do not use compression, this operation /// will not perform any heap allocations; however, the buffers referred to by the /// returned ArrowArrayView are only valid as long as the buffer referred to by body stays /// valid. ArrowErrorCode ArrowIpcDecoderDecodeArrayView(struct ArrowIpcDecoder* decoder, struct ArrowBufferView body, int64_t i, struct ArrowArrayView** out, struct ArrowError* error); /// \brief Decode an ArrowArray /// /// After a successful call to ArrowIpcDecoderDecodeHeader(), assemble an ArrowArray given /// a message body and a field index. Note that field index does not equate to column /// index if any columns contain nested types. Use a value of -1 to decode the entire /// array into a struct. The caller is responsible for releasing the array if /// NANOARROW_OK is returned. /// /// Returns EINVAL if the decoder did not just decode a record batch message, ENOTSUP /// if the message uses features not supported by this library, or or NANOARROW_OK /// otherwise. ArrowErrorCode ArrowIpcDecoderDecodeArray(struct ArrowIpcDecoder* decoder, struct ArrowBufferView body, int64_t i, struct ArrowArray* out, enum ArrowValidationLevel validation_level, struct ArrowError* error); /// \brief Decode an ArrowArray from an owned buffer /// /// This implementation takes advantage of the fact that it can avoid copying individual /// buffers. In all cases the caller must ArrowIpcSharedBufferReset() body after one or /// more calls to ArrowIpcDecoderDecodeArrayFromShared(). If /// ArrowIpcSharedBufferIsThreadSafe() returns 0, out must not be released by another /// thread. ArrowErrorCode ArrowIpcDecoderDecodeArrayFromShared( struct ArrowIpcDecoder* decoder, struct ArrowIpcSharedBuffer* shared, int64_t i, struct ArrowArray* out, enum ArrowValidationLevel validation_level, struct ArrowError* error); /// \brief An user-extensible input data source struct ArrowIpcInputStream { /// \brief Read up to buf_size_bytes from stream into buf /// /// The actual number of bytes read is placed in the value pointed to by /// size_read_out. Returns NANOARROW_OK on success. ArrowErrorCode (*read)(struct ArrowIpcInputStream* stream, uint8_t* buf, int64_t buf_size_bytes, int64_t* size_read_out, struct ArrowError* error); /// \brief Release the stream and any resources it may be holding /// /// Release callback implementations must set the release member to NULL. /// Callers must check that the release callback is not NULL before calling /// read() or release(). void (*release)(struct ArrowIpcInputStream* stream); /// \brief Private implementation-defined data void* private_data; }; /// \brief Transfer ownership of an ArrowIpcInputStream void ArrowIpcInputStreamMove(struct ArrowIpcInputStream* src, struct ArrowIpcInputStream* dst); /// \brief Create an input stream from an ArrowBuffer /// /// The stream takes ownership of the buffer and reads bytes from it. ArrowErrorCode ArrowIpcInputStreamInitBuffer(struct ArrowIpcInputStream* stream, struct ArrowBuffer* input); /// \brief Create an input stream from a C FILE* pointer /// /// Note that the ArrowIpcInputStream has no mechanism to communicate an error /// if file_ptr fails to close. If this behaviour is needed, pass false to /// close_on_release and handle closing the file independently from stream. ArrowErrorCode ArrowIpcInputStreamInitFile(struct ArrowIpcInputStream* stream, void* file_ptr, int close_on_release); /// \brief Options for ArrowIpcArrayStreamReaderInit() struct ArrowIpcArrayStreamReaderOptions { /// \brief The field index to extract. /// /// Defaults to -1 (i.e., read all fields). Note that this field index refers to /// the flattened tree of children and not necessarily the column index. int64_t field_index; /// \brief Set to a non-zero value to share the message body buffer among decoded arrays /// /// Sharing buffers is a good choice when (1) using memory-mapped IO /// (since unreferenced portions of the file are often not loaded into memory) or /// (2) if all data from all columns are about to be referenced anyway. When loading /// a single field there is probably no advantage to using shared buffers. /// Defaults to the value of ArrowIpcSharedBufferIsThreadSafe(). int use_shared_buffers; }; /// \brief Initialize an ArrowArrayStream from an input stream of bytes /// /// The stream of bytes must begin with a Schema message and be followed by /// zero or more RecordBatch messages as described in the Arrow IPC stream /// format specification. Returns NANOARROW_OK on success. If NANOARROW_OK /// is returned, the ArrowArrayStream takes ownership of input_stream and /// the caller is responsible for releasing out. ArrowErrorCode ArrowIpcArrayStreamReaderInit( struct ArrowArrayStream* out, struct ArrowIpcInputStream* input_stream, struct ArrowIpcArrayStreamReaderOptions* options); /// \brief Encoder for Arrow IPC messages /// /// This structure is intended to be allocated by the caller, /// initialized using ArrowIpcEncoderInit(), and released with /// ArrowIpcEncoderReset(). struct ArrowIpcEncoder { /// \brief Private resources managed by this library void* private_data; }; /// \brief Initialize an encoder /// /// If NANOARROW_OK is returned, the caller must call ArrowIpcEncoderReset() /// to release resources allocated by this function. ArrowErrorCode ArrowIpcEncoderInit(struct ArrowIpcEncoder* encoder); /// \brief Release all resources attached to an encoder void ArrowIpcEncoderReset(struct ArrowIpcEncoder* encoder); /// \brief Finalize the most recently encoded message into a buffer /// /// If specified, the message will be encapsulated (prefixed with the continuation /// marker and the header size and 0-padded to a multiple of 8 bytes). /// /// The bytes of the encoded message will be appended to the provided buffer. ArrowErrorCode ArrowIpcEncoderFinalizeBuffer(struct ArrowIpcEncoder* encoder, char encapsulate, struct ArrowBuffer* out); /// \brief Encode an ArrowSchema /// /// Returns ENOMEM if allocation fails, NANOARROW_OK otherwise. ArrowErrorCode ArrowIpcEncoderEncodeSchema(struct ArrowIpcEncoder* encoder, const struct ArrowSchema* schema, struct ArrowError* error); /// \brief Encode a struct typed ArrayView to a flatbuffer RecordBatch, embedded in a /// Message. /// /// Body buffers are concatenated into a contiguous, padded body_buffer. /// /// Returns ENOMEM if allocation fails, NANOARROW_OK otherwise. ArrowErrorCode ArrowIpcEncoderEncodeSimpleRecordBatch( struct ArrowIpcEncoder* encoder, const struct ArrowArrayView* array_view, struct ArrowBuffer* body_buffer, struct ArrowError* error); /// \brief An user-extensible output data sink struct ArrowIpcOutputStream { /// \brief Write up to buf_size_bytes from stream into buf /// /// The actual number of bytes written is placed in the value pointed to by /// size_read_out. Returns NANOARROW_OK on success. ArrowErrorCode (*write)(struct ArrowIpcOutputStream* stream, const void* buf, int64_t buf_size_bytes, int64_t* size_written_out, struct ArrowError* error); /// \brief Release the stream and any resources it may be holding /// /// Release callback implementations must set the release member to NULL. /// Callers must check that the release callback is not NULL before calling /// read() or release(). void (*release)(struct ArrowIpcOutputStream* stream); /// \brief Private implementation-defined data void* private_data; }; /// \brief Transfer ownership of an ArrowIpcOutputStream void ArrowIpcOutputStreamMove(struct ArrowIpcOutputStream* src, struct ArrowIpcOutputStream* dst); /// \brief Create an output stream from an ArrowBuffer /// /// All bytes witten to the stream will be appended to the buffer. /// The stream does not take ownership of the buffer. ArrowErrorCode ArrowIpcOutputStreamInitBuffer(struct ArrowIpcOutputStream* stream, struct ArrowBuffer* output); /// \brief Create an output stream from a C FILE* pointer /// /// Note that the ArrowIpcOutputStream has no mechanism to communicate an error /// if file_ptr fails to close. If this behaviour is needed, pass false to /// close_on_release and handle closing the file independently from stream. ArrowErrorCode ArrowIpcOutputStreamInitFile(struct ArrowIpcOutputStream* stream, void* file_ptr, int close_on_release); /// \brief Write to a stream, trying again until all are written or the stream errors. ArrowErrorCode ArrowIpcOutputStreamWrite(struct ArrowIpcOutputStream* stream, struct ArrowBufferView data, struct ArrowError* error); /// \brief A stream writer which encodes Schemas and ArrowArrays into an IPC byte stream /// /// This structure is intended to be allocated by the caller, /// initialized using ArrowIpcWriterInit(), and released with /// ArrowIpcWriterReset(). struct ArrowIpcWriter { /// \brief Private resources managed by this library void* private_data; }; /// \brief Initialize an output stream of bytes from an ArrowArrayStream /// /// Returns NANOARROW_OK on success. If NANOARROW_OK is returned the writer /// takes ownership of the output byte stream, and the caller is /// responsible for releasing the writer by calling ArrowIpcWriterReset(). ArrowErrorCode ArrowIpcWriterInit(struct ArrowIpcWriter* writer, struct ArrowIpcOutputStream* output_stream); /// \brief Release all resources attached to a writer void ArrowIpcWriterReset(struct ArrowIpcWriter* writer); /// \brief Write a schema to the output byte stream /// /// Errors are propagated from the underlying encoder and output byte stream. ArrowErrorCode ArrowIpcWriterWriteSchema(struct ArrowIpcWriter* writer, const struct ArrowSchema* in, struct ArrowError* error); /// \brief Write an array view to the output byte stream /// /// The array view may be NULL, in which case an EOS will be written. /// The writer does not check that a schema was already written. /// /// Errors are propagated from the underlying encoder and output byte stream, ArrowErrorCode ArrowIpcWriterWriteArrayView(struct ArrowIpcWriter* writer, const struct ArrowArrayView* in, struct ArrowError* error); /// \brief Write an entire stream (including EOS) to the output byte stream /// /// Errors are propagated from the underlying encoder, array stream, and output byte /// stream. ArrowErrorCode ArrowIpcWriterWriteArrayStream(struct ArrowIpcWriter* writer, struct ArrowArrayStream* in, struct ArrowError* error); /// \brief Start writing an IPC file /// /// Writes the Arrow IPC magic and sets the writer up to track written blocks. ArrowErrorCode ArrowIpcWriterStartFile(struct ArrowIpcWriter* writer, struct ArrowError* error); /// \brief Finish writing an IPC file /// /// Writes the IPC file's footer, footer size, and ending magic. ArrowErrorCode ArrowIpcWriterFinalizeFile(struct ArrowIpcWriter* writer, struct ArrowError* error); /// @} // Internal APIs: /// \brief Represents a byte range in an IPC file. /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. struct ArrowIpcFileBlock { /// \brief offset relative to the first byte of the file. int64_t offset; /// \brief length of encapsulated metadata Message (including padding) int32_t metadata_length; /// \brief length of contiguous body buffers (including padding) int64_t body_length; }; /// \brief A footer for use in an IPC file /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. /// /// This structure is intended to be allocated by the caller, initialized using /// ArrowIpcFooterInit(), and released with ArrowIpcFooterReset(). struct ArrowIpcFooter { /// \brief the Footer's embedded Schema struct ArrowSchema schema; /// \brief all blocks containing RecordBatch Messages struct ArrowBuffer record_batch_blocks; }; /// \brief Initialize a footer /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. void ArrowIpcFooterInit(struct ArrowIpcFooter* footer); /// \brief Release all resources attached to an footer /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. void ArrowIpcFooterReset(struct ArrowIpcFooter* footer); /// \brief Encode a footer for use in an IPC file /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. /// /// Returns ENOMEM if allocation fails, NANOARROW_OK otherwise. ArrowErrorCode ArrowIpcEncoderEncodeFooter(struct ArrowIpcEncoder* encoder, const struct ArrowIpcFooter* footer, struct ArrowError* error); /// \brief Peek at a footer /// /// The last 10 bytes of an Arrow IPC file are the footer size as a little-endian /// 32-bit integer followed by the ARROW1 magic. ArrowIpcDecoderPeekFooter() reads /// these bytes and returns ESPIPE if there are not enough remaining bytes in data /// to read the entire footer, EINVAL if the last 10 bytes are not valid, /// or NANOARROW_OK otherwise. /// /// The footer size will be stored in decoder.header_size_bytes. /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. ArrowErrorCode ArrowIpcDecoderPeekFooter(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error); /// \brief Verify a footer /// /// Runs ArrowIpcDecoderPeekFooter() to ensure data is sufficiently large but additionally /// runs flatbuffer verification to ensure that decoding the data will not access /// memory outside of the buffer specified by data. ArrowIpcDecoderVerifyFooter() will /// also set decoder.header_size_bytes and decoder.metadata_version. /// /// Returns as ArrowIpcDecoderPeekFooter() and additionally will /// return EINVAL if flatbuffer verification fails. /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. ArrowErrorCode ArrowIpcDecoderVerifyFooter(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error); /// \brief Decode a footer /// /// Runs ArrowIpcDecoderPeekFooter() to ensure data is sufficiently large and decodes /// the content of the footer. decoder.footer will be set for access to the file's /// schema and record batches. In almost all cases this should be preceded by a call to /// ArrowIpcDecoderVerifyFooter() to ensure decoding does not access data outside of the /// specified buffer. /// /// Returns EINVAL if the content of the footer cannot be decoded or ENOTSUP if the /// content of the footer uses features not supported by this library. /// /// \warning This API is currently only public for use in integration testing; /// use at your own risk. ArrowErrorCode ArrowIpcDecoderDecodeFooter(struct ArrowIpcDecoder* decoder, struct ArrowBufferView data, struct ArrowError* error); #ifdef __cplusplus } #endif #endif nanoarrow/src/nanoarrow.h0000644000176200001440000047143114702632113015237 0ustar liggesusers// 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. #ifndef NANOARROW_BUILD_ID_H_INCLUDED #define NANOARROW_BUILD_ID_H_INCLUDED #define NANOARROW_VERSION_MAJOR 0 #define NANOARROW_VERSION_MINOR 6 #define NANOARROW_VERSION_PATCH 0 #define NANOARROW_VERSION "0.6.0" #define NANOARROW_VERSION_INT \ (NANOARROW_VERSION_MAJOR * 10000 + NANOARROW_VERSION_MINOR * 100 + \ NANOARROW_VERSION_PATCH) #define NANOARROW_NAMESPACE RPkg #endif // 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. #ifndef NANOARROW_NANOARROW_TYPES_H_INCLUDED #define NANOARROW_NANOARROW_TYPES_H_INCLUDED #include #include #if defined(NANOARROW_DEBUG) && !defined(NANOARROW_PRINT_AND_DIE) #include #include #endif #ifdef __cplusplus extern "C" { #endif // Extra guard for versions of Arrow without the canonical guard #ifndef ARROW_FLAG_DICTIONARY_ORDERED /// \defgroup nanoarrow-arrow-cdata Arrow C Data interface /// /// The Arrow C Data (https://arrow.apache.org/docs/format/CDataInterface.html) /// and Arrow C Stream (https://arrow.apache.org/docs/format/CStreamInterface.html) /// interfaces are part of the /// Arrow Columnar Format specification /// (https://arrow.apache.org/docs/format/Columnar.html). See the Arrow documentation for /// documentation of these structures. /// /// @{ #ifndef ARROW_C_DATA_INTERFACE #define ARROW_C_DATA_INTERFACE #define ARROW_FLAG_DICTIONARY_ORDERED 1 #define ARROW_FLAG_NULLABLE 2 #define ARROW_FLAG_MAP_KEYS_SORTED 4 struct ArrowSchema { // Array type description const char* format; const char* name; const char* metadata; int64_t flags; int64_t n_children; struct ArrowSchema** children; struct ArrowSchema* dictionary; // Release callback void (*release)(struct ArrowSchema*); // Opaque producer-specific data void* private_data; }; struct ArrowArray { // Array data description int64_t length; int64_t null_count; int64_t offset; int64_t n_buffers; int64_t n_children; const void** buffers; struct ArrowArray** children; struct ArrowArray* dictionary; // Release callback void (*release)(struct ArrowArray*); // Opaque producer-specific data void* private_data; }; #endif // ARROW_C_DATA_INTERFACE #ifndef ARROW_C_STREAM_INTERFACE #define ARROW_C_STREAM_INTERFACE struct ArrowArrayStream { // Callback to get the stream type // (will be the same for all arrays in the stream). // // Return value: 0 if successful, an `errno`-compatible error code otherwise. // // If successful, the ArrowSchema must be released independently from the stream. int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out); // Callback to get the next array // (if no error and the array is released, the stream has ended) // // Return value: 0 if successful, an `errno`-compatible error code otherwise. // // If successful, the ArrowArray must be released independently from the stream. int (*get_next)(struct ArrowArrayStream*, struct ArrowArray* out); // Callback to get optional detailed error information. // This must only be called if the last stream operation failed // with a non-0 return code. // // Return value: pointer to a null-terminated character array describing // the last error, or NULL if no description is available. // // The returned pointer is only valid until the next operation on this stream // (including release). const char* (*get_last_error)(struct ArrowArrayStream*); // Release callback: release the stream's own resources. // Note that arrays returned by `get_next` must be individually released. void (*release)(struct ArrowArrayStream*); // Opaque producer-specific data void* private_data; }; #endif // ARROW_C_STREAM_INTERFACE #endif // ARROW_FLAG_DICTIONARY_ORDERED /// @} // Utility macros #define _NANOARROW_CONCAT(x, y) x##y #define _NANOARROW_MAKE_NAME(x, y) _NANOARROW_CONCAT(x, y) #define _NANOARROW_RETURN_NOT_OK_IMPL(NAME, EXPR) \ do { \ const int NAME = (EXPR); \ if (NAME) return NAME; \ } while (0) #define _NANOARROW_CHECK_RANGE(x_, min_, max_) \ NANOARROW_RETURN_NOT_OK((x_ >= min_ && x_ <= max_) ? NANOARROW_OK : EINVAL) #define _NANOARROW_CHECK_UPPER_LIMIT(x_, max_) \ NANOARROW_RETURN_NOT_OK((x_ <= max_) ? NANOARROW_OK : EINVAL) #if defined(NANOARROW_DEBUG) #define _NANOARROW_RETURN_NOT_OK_WITH_ERROR_IMPL(NAME, EXPR, ERROR_PTR_EXPR, EXPR_STR) \ do { \ const int NAME = (EXPR); \ if (NAME) { \ ArrowErrorSet((ERROR_PTR_EXPR), "%s failed with errno %d(%s)\n* %s:%d", EXPR_STR, \ NAME, strerror(NAME), __FILE__, __LINE__); \ return NAME; \ } \ } while (0) #else #define _NANOARROW_RETURN_NOT_OK_WITH_ERROR_IMPL(NAME, EXPR, ERROR_PTR_EXPR, EXPR_STR) \ do { \ const int NAME = (EXPR); \ if (NAME) { \ ArrowErrorSet((ERROR_PTR_EXPR), "%s failed with errno %d", EXPR_STR, NAME); \ return NAME; \ } \ } while (0) #endif #if defined(NANOARROW_DEBUG) // For checking ArrowErrorSet() calls for valid printf format strings/arguments // If using mingw's c99-compliant printf, we need a different format-checking attribute #if defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW_PRINTF_FORMAT) #define NANOARROW_CHECK_PRINTF_ATTRIBUTE \ __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3))) #elif defined(__GNUC__) #define NANOARROW_CHECK_PRINTF_ATTRIBUTE __attribute__((format(printf, 2, 3))) #else #define NANOARROW_CHECK_PRINTF_ATTRIBUTE #endif // For checking calls to functions that return ArrowErrorCode #if defined(__GNUC__) && (__GNUC__ >= 4) #define NANOARROW_CHECK_RETURN_ATTRIBUTE __attribute__((warn_unused_result)) #elif defined(_MSC_VER) && (_MSC_VER >= 1700) #define NANOARROW_CHECK_RETURN_ATTRIBUTE _Check_return_ #else #define NANOARROW_CHECK_RETURN_ATTRIBUTE #endif #else #define NANOARROW_CHECK_RETURN_ATTRIBUTE #define NANOARROW_CHECK_PRINTF_ATTRIBUTE #endif #define NANOARROW_UNUSED(x) (void)(x) /// \brief Return code for success. /// \ingroup nanoarrow-errors #define NANOARROW_OK 0 /// \brief Represents an errno-compatible error code /// \ingroup nanoarrow-errors typedef int ArrowErrorCode; #if defined(NANOARROW_DEBUG) #define ArrowErrorCode NANOARROW_CHECK_RETURN_ATTRIBUTE ArrowErrorCode #endif /// \brief Flags supported by ArrowSchemaViewInit() /// \ingroup nanoarrow-schema-view #define NANOARROW_FLAG_ALL_SUPPORTED \ (ARROW_FLAG_DICTIONARY_ORDERED | ARROW_FLAG_NULLABLE | ARROW_FLAG_MAP_KEYS_SORTED) /// \brief Error type containing a UTF-8 encoded message. /// \ingroup nanoarrow-errors struct ArrowError { /// \brief A character buffer with space for an error message. char message[1024]; }; /// \brief Ensure an ArrowError is null-terminated by zeroing the first character. /// \ingroup nanoarrow-errors /// /// If error is NULL, this function does nothing. static inline void ArrowErrorInit(struct ArrowError* error) { if (error != NULL) { error->message[0] = '\0'; } } /// \brief Get the contents of an error /// \ingroup nanoarrow-errors /// /// If error is NULL, returns "", or returns the contents of the error message /// otherwise. static inline const char* ArrowErrorMessage(struct ArrowError* error) { if (error == NULL) { return ""; } else { return error->message; } } /// \brief Set the contents of an error from an existing null-terminated string /// \ingroup nanoarrow-errors /// /// If error is NULL, this function does nothing. static inline void ArrowErrorSetString(struct ArrowError* error, const char* src) { if (error == NULL) { return; } int64_t src_len = strlen(src); if (src_len >= ((int64_t)sizeof(error->message))) { memcpy(error->message, src, sizeof(error->message) - 1); error->message[sizeof(error->message) - 1] = '\0'; } else { memcpy(error->message, src, src_len); error->message[src_len] = '\0'; } } /// \brief Check the result of an expression and return it if not NANOARROW_OK /// \ingroup nanoarrow-errors #define NANOARROW_RETURN_NOT_OK(EXPR) \ _NANOARROW_RETURN_NOT_OK_IMPL(_NANOARROW_MAKE_NAME(errno_status_, __COUNTER__), EXPR) /// \brief Check the result of an expression and return it if not NANOARROW_OK, /// adding an auto-generated message to an ArrowError. /// \ingroup nanoarrow-errors /// /// This macro is used to ensure that functions that accept an ArrowError /// as input always set its message when returning an error code (e.g., when calling /// a nanoarrow function that does *not* accept ArrowError). #define NANOARROW_RETURN_NOT_OK_WITH_ERROR(EXPR, ERROR_EXPR) \ _NANOARROW_RETURN_NOT_OK_WITH_ERROR_IMPL( \ _NANOARROW_MAKE_NAME(errno_status_, __COUNTER__), EXPR, ERROR_EXPR, #EXPR) #if defined(NANOARROW_DEBUG) && !defined(NANOARROW_PRINT_AND_DIE) #define NANOARROW_PRINT_AND_DIE(VALUE, EXPR_STR) \ do { \ fprintf(stderr, "%s failed with code %d\n* %s:%d\n", EXPR_STR, (int)(VALUE), \ __FILE__, (int)__LINE__); \ abort(); \ } while (0) #endif #if defined(NANOARROW_DEBUG) #define _NANOARROW_ASSERT_OK_IMPL(NAME, EXPR, EXPR_STR) \ do { \ const int NAME = (EXPR); \ if (NAME) NANOARROW_PRINT_AND_DIE(NAME, EXPR_STR); \ } while (0) /// \brief Assert that an expression's value is NANOARROW_OK /// \ingroup nanoarrow-errors /// /// If nanoarrow was built in debug mode (i.e., defined(NANOARROW_DEBUG) is true), /// print a message to stderr and abort. If nanoarrow was built in release mode, /// this statement has no effect. You can customize fatal error behaviour /// be defining the NANOARROW_PRINT_AND_DIE macro before including nanoarrow.h /// This macro is provided as a convenience for users and is not used internally. #define NANOARROW_ASSERT_OK(EXPR) \ _NANOARROW_ASSERT_OK_IMPL(_NANOARROW_MAKE_NAME(errno_status_, __COUNTER__), EXPR, #EXPR) #define _NANOARROW_DCHECK_IMPL(EXPR, EXPR_STR) \ do { \ if (!(EXPR)) NANOARROW_PRINT_AND_DIE(-1, EXPR_STR); \ } while (0) #define NANOARROW_DCHECK(EXPR) _NANOARROW_DCHECK_IMPL(EXPR, #EXPR) #else #define NANOARROW_ASSERT_OK(EXPR) (void)(EXPR) #define NANOARROW_DCHECK(EXPR) #endif static inline void ArrowSchemaMove(struct ArrowSchema* src, struct ArrowSchema* dst) { NANOARROW_DCHECK(src != NULL); NANOARROW_DCHECK(dst != NULL); memcpy(dst, src, sizeof(struct ArrowSchema)); src->release = NULL; } static inline void ArrowSchemaRelease(struct ArrowSchema* schema) { NANOARROW_DCHECK(schema != NULL); schema->release(schema); NANOARROW_DCHECK(schema->release == NULL); } static inline void ArrowArrayMove(struct ArrowArray* src, struct ArrowArray* dst) { NANOARROW_DCHECK(src != NULL); NANOARROW_DCHECK(dst != NULL); memcpy(dst, src, sizeof(struct ArrowArray)); src->release = NULL; } static inline void ArrowArrayRelease(struct ArrowArray* array) { NANOARROW_DCHECK(array != NULL); array->release(array); NANOARROW_DCHECK(array->release == NULL); } static inline void ArrowArrayStreamMove(struct ArrowArrayStream* src, struct ArrowArrayStream* dst) { NANOARROW_DCHECK(src != NULL); NANOARROW_DCHECK(dst != NULL); memcpy(dst, src, sizeof(struct ArrowArrayStream)); src->release = NULL; } static inline const char* ArrowArrayStreamGetLastError( struct ArrowArrayStream* array_stream) { NANOARROW_DCHECK(array_stream != NULL); const char* value = array_stream->get_last_error(array_stream); if (value == NULL) { return ""; } else { return value; } } static inline ArrowErrorCode ArrowArrayStreamGetSchema( struct ArrowArrayStream* array_stream, struct ArrowSchema* out, struct ArrowError* error) { NANOARROW_DCHECK(array_stream != NULL); int result = array_stream->get_schema(array_stream, out); if (result != NANOARROW_OK && error != NULL) { ArrowErrorSetString(error, ArrowArrayStreamGetLastError(array_stream)); } return result; } static inline ArrowErrorCode ArrowArrayStreamGetNext( struct ArrowArrayStream* array_stream, struct ArrowArray* out, struct ArrowError* error) { NANOARROW_DCHECK(array_stream != NULL); int result = array_stream->get_next(array_stream, out); if (result != NANOARROW_OK && error != NULL) { ArrowErrorSetString(error, ArrowArrayStreamGetLastError(array_stream)); } return result; } static inline void ArrowArrayStreamRelease(struct ArrowArrayStream* array_stream) { NANOARROW_DCHECK(array_stream != NULL); array_stream->release(array_stream); NANOARROW_DCHECK(array_stream->release == NULL); } static char _ArrowIsLittleEndian(void) { uint32_t check = 1; char first_byte; memcpy(&first_byte, &check, sizeof(char)); return first_byte; } /// \brief Arrow type enumerator /// \ingroup nanoarrow-utils /// /// These names are intended to map to the corresponding arrow::Type::type /// enumerator; however, the numeric values are specifically not equal /// (i.e., do not rely on numeric comparison). enum ArrowType { NANOARROW_TYPE_UNINITIALIZED = 0, NANOARROW_TYPE_NA = 1, NANOARROW_TYPE_BOOL, NANOARROW_TYPE_UINT8, NANOARROW_TYPE_INT8, NANOARROW_TYPE_UINT16, NANOARROW_TYPE_INT16, NANOARROW_TYPE_UINT32, NANOARROW_TYPE_INT32, NANOARROW_TYPE_UINT64, NANOARROW_TYPE_INT64, NANOARROW_TYPE_HALF_FLOAT, NANOARROW_TYPE_FLOAT, NANOARROW_TYPE_DOUBLE, NANOARROW_TYPE_STRING, NANOARROW_TYPE_BINARY, NANOARROW_TYPE_FIXED_SIZE_BINARY, NANOARROW_TYPE_DATE32, NANOARROW_TYPE_DATE64, NANOARROW_TYPE_TIMESTAMP, NANOARROW_TYPE_TIME32, NANOARROW_TYPE_TIME64, NANOARROW_TYPE_INTERVAL_MONTHS, NANOARROW_TYPE_INTERVAL_DAY_TIME, NANOARROW_TYPE_DECIMAL128, NANOARROW_TYPE_DECIMAL256, NANOARROW_TYPE_LIST, NANOARROW_TYPE_STRUCT, NANOARROW_TYPE_SPARSE_UNION, NANOARROW_TYPE_DENSE_UNION, NANOARROW_TYPE_DICTIONARY, NANOARROW_TYPE_MAP, NANOARROW_TYPE_EXTENSION, NANOARROW_TYPE_FIXED_SIZE_LIST, NANOARROW_TYPE_DURATION, NANOARROW_TYPE_LARGE_STRING, NANOARROW_TYPE_LARGE_BINARY, NANOARROW_TYPE_LARGE_LIST, NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO, NANOARROW_TYPE_RUN_END_ENCODED, NANOARROW_TYPE_BINARY_VIEW, NANOARROW_TYPE_STRING_VIEW }; /// \brief Get a string value of an enum ArrowType value /// \ingroup nanoarrow-utils /// /// Returns NULL for invalid values for type static inline const char* ArrowTypeString(enum ArrowType type); static inline const char* ArrowTypeString(enum ArrowType type) { switch (type) { case NANOARROW_TYPE_NA: return "na"; case NANOARROW_TYPE_BOOL: return "bool"; case NANOARROW_TYPE_UINT8: return "uint8"; case NANOARROW_TYPE_INT8: return "int8"; case NANOARROW_TYPE_UINT16: return "uint16"; case NANOARROW_TYPE_INT16: return "int16"; case NANOARROW_TYPE_UINT32: return "uint32"; case NANOARROW_TYPE_INT32: return "int32"; case NANOARROW_TYPE_UINT64: return "uint64"; case NANOARROW_TYPE_INT64: return "int64"; case NANOARROW_TYPE_HALF_FLOAT: return "half_float"; case NANOARROW_TYPE_FLOAT: return "float"; case NANOARROW_TYPE_DOUBLE: return "double"; case NANOARROW_TYPE_STRING: return "string"; case NANOARROW_TYPE_BINARY: return "binary"; case NANOARROW_TYPE_FIXED_SIZE_BINARY: return "fixed_size_binary"; case NANOARROW_TYPE_DATE32: return "date32"; case NANOARROW_TYPE_DATE64: return "date64"; case NANOARROW_TYPE_TIMESTAMP: return "timestamp"; case NANOARROW_TYPE_TIME32: return "time32"; case NANOARROW_TYPE_TIME64: return "time64"; case NANOARROW_TYPE_INTERVAL_MONTHS: return "interval_months"; case NANOARROW_TYPE_INTERVAL_DAY_TIME: return "interval_day_time"; case NANOARROW_TYPE_DECIMAL128: return "decimal128"; case NANOARROW_TYPE_DECIMAL256: return "decimal256"; case NANOARROW_TYPE_LIST: return "list"; case NANOARROW_TYPE_STRUCT: return "struct"; case NANOARROW_TYPE_SPARSE_UNION: return "sparse_union"; case NANOARROW_TYPE_DENSE_UNION: return "dense_union"; case NANOARROW_TYPE_DICTIONARY: return "dictionary"; case NANOARROW_TYPE_MAP: return "map"; case NANOARROW_TYPE_EXTENSION: return "extension"; case NANOARROW_TYPE_FIXED_SIZE_LIST: return "fixed_size_list"; case NANOARROW_TYPE_DURATION: return "duration"; case NANOARROW_TYPE_LARGE_STRING: return "large_string"; case NANOARROW_TYPE_LARGE_BINARY: return "large_binary"; case NANOARROW_TYPE_LARGE_LIST: return "large_list"; case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: return "interval_month_day_nano"; case NANOARROW_TYPE_RUN_END_ENCODED: return "run_end_encoded"; case NANOARROW_TYPE_BINARY_VIEW: return "binary_view"; case NANOARROW_TYPE_STRING_VIEW: return "string_view"; default: return NULL; } } /// \brief Arrow time unit enumerator /// \ingroup nanoarrow-utils /// /// These names and values map to the corresponding arrow::TimeUnit::type /// enumerator. enum ArrowTimeUnit { NANOARROW_TIME_UNIT_SECOND = 0, NANOARROW_TIME_UNIT_MILLI = 1, NANOARROW_TIME_UNIT_MICRO = 2, NANOARROW_TIME_UNIT_NANO = 3 }; /// \brief Validation level enumerator /// \ingroup nanoarrow-array enum ArrowValidationLevel { /// \brief Do not validate buffer sizes or content. NANOARROW_VALIDATION_LEVEL_NONE = 0, /// \brief Validate buffer sizes that depend on array length but do not validate buffer /// sizes that depend on buffer data access. NANOARROW_VALIDATION_LEVEL_MINIMAL = 1, /// \brief Validate all buffer sizes, including those that require buffer data access, /// but do not perform any checks that are O(1) along the length of the buffers. NANOARROW_VALIDATION_LEVEL_DEFAULT = 2, /// \brief Validate all buffer sizes and all buffer content. This is useful in the /// context of untrusted input or input that may have been corrupted in transit. NANOARROW_VALIDATION_LEVEL_FULL = 3 }; /// \brief Comparison level enumerator /// \ingroup nanoarrow-utils enum ArrowCompareLevel { /// \brief Consider arrays equal if buffers contain identical content /// and have identical offset, null count, and length. Note that this is /// a much stricter check than logical equality, which would take into /// account potentially different content of null slots, arrays with a /// non-zero offset, and other considerations. NANOARROW_COMPARE_IDENTICAL, }; /// \brief Get a string value of an enum ArrowTimeUnit value /// \ingroup nanoarrow-utils /// /// Returns NULL for invalid values for time_unit static inline const char* ArrowTimeUnitString(enum ArrowTimeUnit time_unit); static inline const char* ArrowTimeUnitString(enum ArrowTimeUnit time_unit) { switch (time_unit) { case NANOARROW_TIME_UNIT_SECOND: return "s"; case NANOARROW_TIME_UNIT_MILLI: return "ms"; case NANOARROW_TIME_UNIT_MICRO: return "us"; case NANOARROW_TIME_UNIT_NANO: return "ns"; default: return NULL; } } /// \brief Functional types of buffers as described in the Arrow Columnar Specification /// \ingroup nanoarrow-array-view enum ArrowBufferType { NANOARROW_BUFFER_TYPE_NONE, NANOARROW_BUFFER_TYPE_VALIDITY, NANOARROW_BUFFER_TYPE_TYPE_ID, NANOARROW_BUFFER_TYPE_UNION_OFFSET, NANOARROW_BUFFER_TYPE_DATA_OFFSET, NANOARROW_BUFFER_TYPE_DATA, NANOARROW_BUFFER_TYPE_VARIADIC_DATA, NANOARROW_BUFFER_TYPE_VARIADIC_SIZE }; /// \brief The maximum number of fixed buffers in an ArrowArrayView or ArrowLayout /// \ingroup nanoarrow-array-view #define NANOARROW_MAX_FIXED_BUFFERS 3 /// \brief An non-owning view of a string /// \ingroup nanoarrow-utils struct ArrowStringView { /// \brief A pointer to the start of the string /// /// If size_bytes is 0, this value may be NULL. const char* data; /// \brief The size of the string in bytes, /// /// (Not including the null terminator.) int64_t size_bytes; }; /// \brief Return a view of a const C string /// \ingroup nanoarrow-utils static inline struct ArrowStringView ArrowCharView(const char* value); static inline struct ArrowStringView ArrowCharView(const char* value) { struct ArrowStringView out; out.data = value; if (value) { out.size_bytes = (int64_t)strlen(value); } else { out.size_bytes = 0; } return out; } union ArrowBufferViewData { const void* data; const int8_t* as_int8; const uint8_t* as_uint8; const int16_t* as_int16; const uint16_t* as_uint16; const int32_t* as_int32; const uint32_t* as_uint32; const int64_t* as_int64; const uint64_t* as_uint64; const double* as_double; const float* as_float; const char* as_char; const union ArrowBinaryView* as_binary_view; }; /// \brief An non-owning view of a buffer /// \ingroup nanoarrow-utils struct ArrowBufferView { /// \brief A pointer to the start of the buffer /// /// If size_bytes is 0, this value may be NULL. union ArrowBufferViewData data; /// \brief The size of the buffer in bytes int64_t size_bytes; }; /// \brief Array buffer allocation and deallocation /// \ingroup nanoarrow-buffer /// /// Container for allocate, reallocate, and free methods that can be used /// to customize allocation and deallocation of buffers when constructing /// an ArrowArray. struct ArrowBufferAllocator { /// \brief Reallocate a buffer or return NULL if it cannot be reallocated uint8_t* (*reallocate)(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t old_size, int64_t new_size); /// \brief Deallocate a buffer allocated by this allocator void (*free)(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t size); /// \brief Opaque data specific to the allocator void* private_data; }; typedef void (*ArrowBufferDeallocatorCallback)(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t size); /// \brief An owning mutable view of a buffer /// \ingroup nanoarrow-buffer struct ArrowBuffer { /// \brief A pointer to the start of the buffer /// /// If capacity_bytes is 0, this value may be NULL. uint8_t* data; /// \brief The size of the buffer in bytes int64_t size_bytes; /// \brief The capacity of the buffer in bytes int64_t capacity_bytes; /// \brief The allocator that will be used to reallocate and/or free the buffer struct ArrowBufferAllocator allocator; }; /// \brief An owning mutable view of a bitmap /// \ingroup nanoarrow-bitmap struct ArrowBitmap { /// \brief An ArrowBuffer to hold the allocated memory struct ArrowBuffer buffer; /// \brief The number of bits that have been appended to the bitmap int64_t size_bits; }; /// \brief A description of an arrangement of buffers /// \ingroup nanoarrow-utils /// /// Contains the minimum amount of information required to /// calculate the size of each buffer in an ArrowArray knowing only /// the length and offset of the array. struct ArrowLayout { /// \brief The function of each buffer enum ArrowBufferType buffer_type[NANOARROW_MAX_FIXED_BUFFERS]; /// \brief The data type of each buffer enum ArrowType buffer_data_type[NANOARROW_MAX_FIXED_BUFFERS]; /// \brief The size of an element each buffer or 0 if this size is variable or unknown int64_t element_size_bits[NANOARROW_MAX_FIXED_BUFFERS]; /// \brief The number of elements in the child array per element in this array for a /// fixed-size list int64_t child_size_elements; }; /// \brief A non-owning view of an ArrowArray /// \ingroup nanoarrow-array-view /// /// This data structure provides access to the values contained within /// an ArrowArray with fields provided in a more readily-extractible /// form. You can re-use an ArrowArrayView for multiple ArrowArrays /// with the same storage type, use it to represent a hypothetical /// ArrowArray that does not exist yet, or use it to validate the buffers /// of a future ArrowArray. struct ArrowArrayView { /// \brief The underlying ArrowArray or NULL if it has not been set or /// if the buffers in this ArrowArrayView are not backed by an ArrowArray. const struct ArrowArray* array; /// \brief The number of elements from the physical start of the buffers. int64_t offset; /// \brief The number of elements in this view. int64_t length; /// \brief A cached null count or -1 to indicate that this value is unknown. int64_t null_count; /// \brief The type used to store values in this array /// /// This type represents only the minimum required information to /// extract values from the array buffers (e.g., for a Date32 array, /// this value will be NANOARROW_TYPE_INT32). For dictionary-encoded /// arrays, this will be the index type. enum ArrowType storage_type; /// \brief The buffer types, strides, and sizes of this Array's buffers struct ArrowLayout layout; /// \brief This Array's buffers as ArrowBufferView objects struct ArrowBufferView buffer_views[NANOARROW_MAX_FIXED_BUFFERS]; /// \brief The number of children of this view int64_t n_children; /// \brief Pointers to views of this array's children struct ArrowArrayView** children; /// \brief Pointer to a view of this array's dictionary struct ArrowArrayView* dictionary; /// \brief Union type id to child index mapping /// /// If storage_type is a union type, a 256-byte ArrowMalloc()ed buffer /// such that child_index == union_type_id_map[type_id] and /// type_id == union_type_id_map[128 + child_index]. This value may be /// NULL in the case where child_id == type_id. int8_t* union_type_id_map; /// \brief Number of variadic buffers int32_t n_variadic_buffers; /// \brief Pointers to variadic buffers of binary/string_view arrays const void** variadic_buffers; /// \brief Size of each variadic buffer int64_t* variadic_buffer_sizes; }; // Used as the private data member for ArrowArrays allocated here and accessed // internally within inline ArrowArray* helpers. struct ArrowArrayPrivateData { // Holder for the validity buffer (or first buffer for union types, which are // the only type whose first buffer is not a valdiity buffer) struct ArrowBitmap bitmap; // Holder for additional buffers as required struct ArrowBuffer buffers[NANOARROW_MAX_FIXED_BUFFERS - 1]; // The array of pointers to buffers. This must be updated after a sequence // of appends to synchronize its values with the actual buffer addresses // (which may have been reallocated during that time) const void** buffer_data; // The storage data type, or NANOARROW_TYPE_UNINITIALIZED if unknown enum ArrowType storage_type; // The buffer arrangement for the storage type struct ArrowLayout layout; // Flag to indicate if there are non-sequence union type ids. // In the future this could be replaced with a type id<->child mapping // to support constructing unions in append mode where type_id != child_index int8_t union_type_id_is_child_index; // Number of variadic buffers for binary view types int32_t n_variadic_buffers; // Variadic buffers for binary view types struct ArrowBuffer* variadic_buffers; // Size of each variadic buffer in bytes int64_t* variadic_buffer_sizes; }; /// \brief A representation of an interval. /// \ingroup nanoarrow-utils struct ArrowInterval { /// \brief The type of interval being used enum ArrowType type; /// \brief The number of months represented by the interval int32_t months; /// \brief The number of days represented by the interval int32_t days; /// \brief The number of ms represented by the interval int32_t ms; /// \brief The number of ns represented by the interval int64_t ns; }; /// \brief Zero initialize an Interval with a given unit /// \ingroup nanoarrow-utils static inline void ArrowIntervalInit(struct ArrowInterval* interval, enum ArrowType type) { memset(interval, 0, sizeof(struct ArrowInterval)); interval->type = type; } /// \brief A representation of a fixed-precision decimal number /// \ingroup nanoarrow-utils /// /// This structure should be initialized with ArrowDecimalInit() once and /// values set using ArrowDecimalSetInt(), ArrowDecimalSetBytes128(), /// or ArrowDecimalSetBytes256(). struct ArrowDecimal { /// \brief An array of 64-bit integers of n_words length defined in native-endian order uint64_t words[4]; /// \brief The number of significant digits this decimal number can represent int32_t precision; /// \brief The number of digits after the decimal point. This can be negative. int32_t scale; /// \brief The number of words in the words array int n_words; /// \brief Cached value used by the implementation int high_word_index; /// \brief Cached value used by the implementation int low_word_index; }; /// \brief Initialize a decimal with a given set of type parameters /// \ingroup nanoarrow-utils static inline void ArrowDecimalInit(struct ArrowDecimal* decimal, int32_t bitwidth, int32_t precision, int32_t scale) { memset(decimal->words, 0, sizeof(decimal->words)); decimal->precision = precision; decimal->scale = scale; decimal->n_words = (int)(bitwidth / 8 / sizeof(uint64_t)); if (_ArrowIsLittleEndian()) { decimal->low_word_index = 0; decimal->high_word_index = decimal->n_words - 1; } else { decimal->low_word_index = decimal->n_words - 1; decimal->high_word_index = 0; } } /// \brief Get a signed integer value of a sufficiently small ArrowDecimal /// /// This does not check if the decimal's precision sufficiently small to fit /// within the signed 64-bit integer range (A precision less than or equal /// to 18 is sufficiently small). static inline int64_t ArrowDecimalGetIntUnsafe(const struct ArrowDecimal* decimal) { return (int64_t)decimal->words[decimal->low_word_index]; } /// \brief Copy the bytes of this decimal into a sufficiently large buffer /// \ingroup nanoarrow-utils static inline void ArrowDecimalGetBytes(const struct ArrowDecimal* decimal, uint8_t* out) { memcpy(out, decimal->words, decimal->n_words * sizeof(uint64_t)); } /// \brief Returns 1 if the value represented by decimal is >= 0 or -1 otherwise /// \ingroup nanoarrow-utils static inline int64_t ArrowDecimalSign(const struct ArrowDecimal* decimal) { return 1 | ((int64_t)(decimal->words[decimal->high_word_index]) >> 63); } /// \brief Sets the integer value of this decimal /// \ingroup nanoarrow-utils static inline void ArrowDecimalSetInt(struct ArrowDecimal* decimal, int64_t value) { if (value < 0) { memset(decimal->words, 0xff, decimal->n_words * sizeof(uint64_t)); } else { memset(decimal->words, 0, decimal->n_words * sizeof(uint64_t)); } decimal->words[decimal->low_word_index] = value; } /// \brief Negate the value of this decimal in place /// \ingroup nanoarrow-utils static inline void ArrowDecimalNegate(struct ArrowDecimal* decimal) { uint64_t carry = 1; if (decimal->low_word_index == 0) { for (int i = 0; i < decimal->n_words; i++) { uint64_t elem = decimal->words[i]; elem = ~elem + carry; carry &= (elem == 0); decimal->words[i] = elem; } } else { for (int i = decimal->low_word_index; i >= 0; i--) { uint64_t elem = decimal->words[i]; elem = ~elem + carry; carry &= (elem == 0); decimal->words[i] = elem; } } } /// \brief Copy bytes from a buffer into this decimal /// \ingroup nanoarrow-utils static inline void ArrowDecimalSetBytes(struct ArrowDecimal* decimal, const uint8_t* value) { memcpy(decimal->words, value, decimal->n_words * sizeof(uint64_t)); } #ifdef __cplusplus } #endif #endif // 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. #ifndef NANOARROW_H_INCLUDED #define NANOARROW_H_INCLUDED #include #include #include // If using CMake, optionally pass -DNANOARROW_NAMESPACE=MyNamespace which will set this // define in nanoarrow_config.h. If not, you can optionally #define NANOARROW_NAMESPACE // MyNamespace here. // This section remaps the non-prefixed symbols to the prefixed symbols so that // code written against this build can be used independent of the value of // NANOARROW_NAMESPACE. #ifdef NANOARROW_NAMESPACE #define NANOARROW_CAT(A, B) A##B #define NANOARROW_SYMBOL(A, B) NANOARROW_CAT(A, B) #define ArrowNanoarrowVersion NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowNanoarrowVersion) #define ArrowNanoarrowVersionInt \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowNanoarrowVersionInt) #define ArrowMalloc NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMalloc) #define ArrowRealloc NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowRealloc) #define ArrowFree NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowFree) #define ArrowBufferAllocatorDefault \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowBufferAllocatorDefault) #define ArrowBufferDeallocator \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowBufferDeallocator) #define ArrowErrorSet NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowErrorSet) #define ArrowLayoutInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowLayoutInit) #define ArrowDecimalSetDigits NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowDecimalSetDigits) #define ArrowDecimalAppendDigitsToBuffer \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowDecimalAppendDigitsToBuffer) #define ArrowSchemaInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaInit) #define ArrowSchemaInitFromType \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaInitFromType) #define ArrowSchemaSetType NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetType) #define ArrowSchemaSetTypeStruct \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetTypeStruct) #define ArrowSchemaSetTypeFixedSize \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetTypeFixedSize) #define ArrowSchemaSetTypeDecimal \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetTypeDecimal) #define ArrowSchemaSetTypeRunEndEncoded \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetTypeRunEndEncoded) #define ArrowSchemaSetTypeDateTime \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetTypeDateTime) #define ArrowSchemaSetTypeUnion \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetTypeUnion) #define ArrowSchemaDeepCopy NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaDeepCopy) #define ArrowSchemaSetFormat NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetFormat) #define ArrowSchemaSetName NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetName) #define ArrowSchemaSetMetadata \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaSetMetadata) #define ArrowSchemaAllocateChildren \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaAllocateChildren) #define ArrowSchemaAllocateDictionary \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaAllocateDictionary) #define ArrowMetadataReaderInit \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataReaderInit) #define ArrowMetadataReaderRead \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataReaderRead) #define ArrowMetadataSizeOf NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataSizeOf) #define ArrowMetadataHasKey NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataHasKey) #define ArrowMetadataGetValue NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataGetValue) #define ArrowMetadataBuilderInit \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataBuilderInit) #define ArrowMetadataBuilderAppend \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataBuilderAppend) #define ArrowMetadataBuilderSet \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataBuilderSet) #define ArrowMetadataBuilderRemove \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowMetadataBuilderRemove) #define ArrowSchemaViewInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaViewInit) #define ArrowSchemaToString NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowSchemaToString) #define ArrowArrayInitFromType \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayInitFromType) #define ArrowArrayInitFromSchema \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayInitFromSchema) #define ArrowArrayInitFromArrayView \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayInitFromArrayView) #define ArrowArrayInitFromArrayView \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayInitFromArrayView) #define ArrowArrayAllocateChildren \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayAllocateChildren) #define ArrowArrayAllocateDictionary \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayAllocateDictionary) #define ArrowArraySetValidityBitmap \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArraySetValidityBitmap) #define ArrowArraySetBuffer NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArraySetBuffer) #define ArrowArrayReserve NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayReserve) #define ArrowArrayFinishBuilding \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayFinishBuilding) #define ArrowArrayFinishBuildingDefault \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayFinishBuildingDefault) #define ArrowArrayViewInitFromType \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewInitFromType) #define ArrowArrayViewInitFromSchema \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewInitFromSchema) #define ArrowArrayViewAllocateChildren \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewAllocateChildren) #define ArrowArrayViewAllocateDictionary \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewAllocateDictionary) #define ArrowArrayViewSetLength \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewSetLength) #define ArrowArrayViewSetArray \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewSetArray) #define ArrowArrayViewSetArrayMinimal \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewSetArrayMinimal) #define ArrowArrayViewValidate \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewValidate) #define ArrowArrayViewCompare NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewCompare) #define ArrowArrayViewReset NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowArrayViewReset) #define ArrowBasicArrayStreamInit \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowBasicArrayStreamInit) #define ArrowBasicArrayStreamSetArray \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowBasicArrayStreamSetArray) #define ArrowBasicArrayStreamValidate \ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowBasicArrayStreamValidate) #endif #ifdef __cplusplus extern "C" { #endif /// \defgroup nanoarrow Nanoarrow C library /// /// Except where noted, objects are not thread-safe and clients should /// take care to serialize accesses to methods. /// /// Because this library is intended to be vendored, it provides full type /// definitions and encourages clients to stack or statically allocate /// where convenient. /// \defgroup nanoarrow-malloc Memory management /// /// Non-buffer members of a struct ArrowSchema and struct ArrowArray /// must be allocated using ArrowMalloc() or ArrowRealloc() and freed /// using ArrowFree() for schemas and arrays allocated here. Buffer members /// are allocated using an ArrowBufferAllocator. /// /// @{ /// \brief Allocate like malloc() void* ArrowMalloc(int64_t size); /// \brief Reallocate like realloc() void* ArrowRealloc(void* ptr, int64_t size); /// \brief Free a pointer allocated using ArrowMalloc() or ArrowRealloc(). void ArrowFree(void* ptr); /// \brief Return the default allocator /// /// The default allocator uses ArrowMalloc(), ArrowRealloc(), and /// ArrowFree(). struct ArrowBufferAllocator ArrowBufferAllocatorDefault(void); /// \brief Create a custom deallocator /// /// Creates a buffer allocator with only a free method that can be used to /// attach a custom deallocator to an ArrowBuffer. This may be used to /// avoid copying an existing buffer that was not allocated using the /// infrastructure provided here (e.g., by an R or Python object). struct ArrowBufferAllocator ArrowBufferDeallocator(ArrowBufferDeallocatorCallback, void* private_data); /// @} /// \brief Move the contents of an src ArrowSchema into dst and set src->release to NULL /// \ingroup nanoarrow-arrow-cdata static inline void ArrowSchemaMove(struct ArrowSchema* src, struct ArrowSchema* dst); /// \brief Call the release callback of an ArrowSchema /// \ingroup nanoarrow-arrow-cdata static inline void ArrowSchemaRelease(struct ArrowSchema* schema); /// \brief Move the contents of an src ArrowArray into dst and set src->release to NULL /// \ingroup nanoarrow-arrow-cdata static inline void ArrowArrayMove(struct ArrowArray* src, struct ArrowArray* dst); /// \brief Call the release callback of an ArrowArray static inline void ArrowArrayRelease(struct ArrowArray* array); /// \brief Move the contents of an src ArrowArrayStream into dst and set src->release to /// NULL \ingroup nanoarrow-arrow-cdata static inline void ArrowArrayStreamMove(struct ArrowArrayStream* src, struct ArrowArrayStream* dst); /// \brief Call the get_schema callback of an ArrowArrayStream /// \ingroup nanoarrow-arrow-cdata /// /// Unlike the get_schema callback, this wrapper checks the return code /// and propagates the error reported by get_last_error into error. This /// makes it significantly less verbose to iterate over array streams /// using NANOARROW_RETURN_NOT_OK()-style error handling. static inline ArrowErrorCode ArrowArrayStreamGetSchema( struct ArrowArrayStream* array_stream, struct ArrowSchema* out, struct ArrowError* error); /// \brief Call the get_schema callback of an ArrowArrayStream /// \ingroup nanoarrow-arrow-cdata /// /// Unlike the get_next callback, this wrapper checks the return code /// and propagates the error reported by get_last_error into error. This /// makes it significantly less verbose to iterate over array streams /// using NANOARROW_RETURN_NOT_OK()-style error handling. static inline ArrowErrorCode ArrowArrayStreamGetNext( struct ArrowArrayStream* array_stream, struct ArrowArray* out, struct ArrowError* error); /// \brief Call the get_next callback of an ArrowArrayStream /// \ingroup nanoarrow-arrow-cdata /// /// Unlike the get_next callback, this function never returns NULL (i.e., its /// result is safe to use in printf-style error formatters). Null values from the /// original callback are reported as "". static inline const char* ArrowArrayStreamGetLastError( struct ArrowArrayStream* array_stream); /// \brief Call the release callback of an ArrowArrayStream static inline void ArrowArrayStreamRelease(struct ArrowArrayStream* array_stream); /// \defgroup nanoarrow-errors Error handling /// /// Functions generally return an errno-compatible error code; functions that /// need to communicate more verbose error information accept a pointer /// to an ArrowError. This can be stack or statically allocated. The /// content of the message is undefined unless an error code has been /// returned. If a nanoarrow function is passed a non-null ArrowError pointer, the /// ArrowError pointed to by the argument will be propagated with a /// null-terminated error message. It is safe to pass a NULL ArrowError anywhere /// in the nanoarrow API. /// /// Except where documented, it is generally not safe to continue after a /// function has returned a non-zero ArrowErrorCode. The NANOARROW_RETURN_NOT_OK and /// NANOARROW_ASSERT_OK macros are provided to help propagate errors. C++ clients can use /// the helpers provided in the nanoarrow.hpp header to facilitate using C++ idioms /// for memory management and error propgagtion. /// /// @{ /// \brief Set the contents of an error using printf syntax. /// /// If error is NULL, this function does nothing and returns NANOARROW_OK. NANOARROW_CHECK_PRINTF_ATTRIBUTE int ArrowErrorSet(struct ArrowError* error, const char* fmt, ...); /// @} /// \defgroup nanoarrow-utils Utility data structures /// /// @{ /// \brief Return a version string in the form "major.minor.patch" const char* ArrowNanoarrowVersion(void); /// \brief Return an integer that can be used to compare versions sequentially int ArrowNanoarrowVersionInt(void); /// \brief Initialize a description of buffer arrangements from a storage type void ArrowLayoutInit(struct ArrowLayout* layout, enum ArrowType storage_type); /// \brief Create a string view from a null-terminated string static inline struct ArrowStringView ArrowCharView(const char* value); /// \brief Sets the integer value of an ArrowDecimal from a string ArrowErrorCode ArrowDecimalSetDigits(struct ArrowDecimal* decimal, struct ArrowStringView value); /// \brief Get the integer value of an ArrowDecimal as string ArrowErrorCode ArrowDecimalAppendDigitsToBuffer(const struct ArrowDecimal* decimal, struct ArrowBuffer* buffer); /// \brief Get the half float value of a float static inline uint16_t ArrowFloatToHalfFloat(float value); /// \brief Get the float value of a half float static inline float ArrowHalfFloatToFloat(uint16_t value); /// \brief Resolve a chunk index from increasing int64_t offsets /// /// Given a buffer of increasing int64_t offsets that begin with 0 (e.g., offset buffer /// of a large type, run ends of a chunked array implementation), resolve a value v /// where lo <= v < hi such that offsets[v] <= index < offsets[v + 1]. static inline int64_t ArrowResolveChunk64(int64_t index, const int64_t* offsets, int64_t lo, int64_t hi); /// @} /// \defgroup nanoarrow-schema Creating schemas /// /// These functions allocate, copy, and destroy ArrowSchema structures /// /// @{ /// \brief Initialize an ArrowSchema /// /// Initializes the fields and release callback of schema_out. Caller /// is responsible for calling the schema->release callback if /// NANOARROW_OK is returned. void ArrowSchemaInit(struct ArrowSchema* schema); /// \brief Initialize an ArrowSchema from an ArrowType /// /// A convenience constructor for that calls ArrowSchemaInit() and /// ArrowSchemaSetType() for the common case of constructing an /// unparameterized type. The caller is responsible for calling the schema->release /// callback if NANOARROW_OK is returned. ArrowErrorCode ArrowSchemaInitFromType(struct ArrowSchema* schema, enum ArrowType type); /// \brief Get a human-readable summary of a Schema /// /// Writes a summary of an ArrowSchema to out (up to n - 1 characters) /// and returns the number of characters required for the output if /// n were sufficiently large. If recursive is non-zero, the result will /// also include children. int64_t ArrowSchemaToString(const struct ArrowSchema* schema, char* out, int64_t n, char recursive); /// \brief Set the format field of a schema from an ArrowType /// /// Initializes the fields and release callback of schema_out. For /// NANOARROW_TYPE_LIST, NANOARROW_TYPE_LARGE_LIST, and /// NANOARROW_TYPE_MAP, the appropriate number of children are /// allocated, initialized, and named; however, the caller must /// ArrowSchemaSetType() on the preinitialized children. Schema must have been initialized /// using ArrowSchemaInit() or ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaSetType(struct ArrowSchema* schema, enum ArrowType type); /// \brief Set the format field and initialize children of a struct schema /// /// The specified number of children are initialized; however, the caller is responsible /// for calling ArrowSchemaSetType() and ArrowSchemaSetName() on each child. /// Schema must have been initialized using ArrowSchemaInit() or ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaSetTypeStruct(struct ArrowSchema* schema, int64_t n_children); /// \brief Set the format field of a fixed-size schema /// /// Returns EINVAL for fixed_size <= 0 or for type that is not /// NANOARROW_TYPE_FIXED_SIZE_BINARY or NANOARROW_TYPE_FIXED_SIZE_LIST. /// For NANOARROW_TYPE_FIXED_SIZE_LIST, the appropriate number of children are /// allocated, initialized, and named; however, the caller must /// ArrowSchemaSetType() the first child. Schema must have been initialized using /// ArrowSchemaInit() or ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaSetTypeFixedSize(struct ArrowSchema* schema, enum ArrowType type, int32_t fixed_size); /// \brief Set the format field of a decimal schema /// /// Returns EINVAL for scale <= 0 or for type that is not /// NANOARROW_TYPE_DECIMAL128 or NANOARROW_TYPE_DECIMAL256. Schema must have been /// initialized using ArrowSchemaInit() or ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaSetTypeDecimal(struct ArrowSchema* schema, enum ArrowType type, int32_t decimal_precision, int32_t decimal_scale); /// \brief Set the format field of a run-end encoded schema /// /// Returns EINVAL for run_end_type that is not /// NANOARROW_TYPE_INT16, NANOARROW_TYPE_INT32 or NANOARROW_TYPE_INT64. /// Schema must have been initialized using ArrowSchemaInit() or ArrowSchemaDeepCopy(). /// The caller must call `ArrowSchemaSetTypeXXX(schema->children[1])` to /// set the value type. Note that when building arrays using the `ArrowArrayAppendXXX()` /// functions, the run-end encoded array's logical length must be updated manually. ArrowErrorCode ArrowSchemaSetTypeRunEndEncoded(struct ArrowSchema* schema, enum ArrowType run_end_type); /// \brief Set the format field of a time, timestamp, or duration schema /// /// Returns EINVAL for type that is not /// NANOARROW_TYPE_TIME32, NANOARROW_TYPE_TIME64, /// NANOARROW_TYPE_TIMESTAMP, or NANOARROW_TYPE_DURATION. The /// timezone parameter must be NULL for a non-timestamp type. Schema must have been /// initialized using ArrowSchemaInit() or ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaSetTypeDateTime(struct ArrowSchema* schema, enum ArrowType type, enum ArrowTimeUnit time_unit, const char* timezone); /// \brief Set the format field of a union schema /// /// Returns EINVAL for a type that is not NANOARROW_TYPE_DENSE_UNION /// or NANOARROW_TYPE_SPARSE_UNION. The specified number of children are /// allocated, and initialized. ArrowErrorCode ArrowSchemaSetTypeUnion(struct ArrowSchema* schema, enum ArrowType type, int64_t n_children); /// \brief Make a (recursive) copy of a schema /// /// Allocates and copies fields of schema into schema_out. ArrowErrorCode ArrowSchemaDeepCopy(const struct ArrowSchema* schema, struct ArrowSchema* schema_out); /// \brief Copy format into schema->format /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaSetFormat(struct ArrowSchema* schema, const char* format); /// \brief Copy name into schema->name /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaSetName(struct ArrowSchema* schema, const char* name); /// \brief Copy metadata into schema->metadata /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy. ArrowErrorCode ArrowSchemaSetMetadata(struct ArrowSchema* schema, const char* metadata); /// \brief Allocate the schema->children array /// /// Includes the memory for each child struct ArrowSchema. /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaAllocateChildren(struct ArrowSchema* schema, int64_t n_children); /// \brief Allocate the schema->dictionary member /// /// schema must have been allocated using ArrowSchemaInitFromType() or /// ArrowSchemaDeepCopy(). ArrowErrorCode ArrowSchemaAllocateDictionary(struct ArrowSchema* schema); /// @} /// \defgroup nanoarrow-metadata Create, read, and modify schema metadata /// /// @{ /// \brief Reader for key/value pairs in schema metadata /// /// The ArrowMetadataReader does not own any data and is only valid /// for the lifetime of the underlying metadata pointer. struct ArrowMetadataReader { /// \brief A metadata string from a schema->metadata field. const char* metadata; /// \brief The current offset into the metadata string int64_t offset; /// \brief The number of remaining keys int32_t remaining_keys; }; /// \brief Initialize an ArrowMetadataReader ArrowErrorCode ArrowMetadataReaderInit(struct ArrowMetadataReader* reader, const char* metadata); /// \brief Read the next key/value pair from an ArrowMetadataReader ArrowErrorCode ArrowMetadataReaderRead(struct ArrowMetadataReader* reader, struct ArrowStringView* key_out, struct ArrowStringView* value_out); /// \brief The number of bytes in in a key/value metadata string int64_t ArrowMetadataSizeOf(const char* metadata); /// \brief Check for a key in schema metadata char ArrowMetadataHasKey(const char* metadata, struct ArrowStringView key); /// \brief Extract a value from schema metadata /// /// If key does not exist in metadata, value_out is unmodified ArrowErrorCode ArrowMetadataGetValue(const char* metadata, struct ArrowStringView key, struct ArrowStringView* value_out); /// \brief Initialize a builder for schema metadata from key/value pairs /// /// metadata can be an existing metadata string or NULL to initialize /// an empty metadata string. ArrowErrorCode ArrowMetadataBuilderInit(struct ArrowBuffer* buffer, const char* metadata); /// \brief Append a key/value pair to a buffer containing serialized metadata ArrowErrorCode ArrowMetadataBuilderAppend(struct ArrowBuffer* buffer, struct ArrowStringView key, struct ArrowStringView value); /// \brief Set a key/value pair to a buffer containing serialized metadata /// /// Ensures that the only entry for key in the metadata is set to value. /// This function maintains the existing position of (the first instance of) /// key if present in the data. ArrowErrorCode ArrowMetadataBuilderSet(struct ArrowBuffer* buffer, struct ArrowStringView key, struct ArrowStringView value); /// \brief Remove a key from a buffer containing serialized metadata ArrowErrorCode ArrowMetadataBuilderRemove(struct ArrowBuffer* buffer, struct ArrowStringView key); /// @} /// \defgroup nanoarrow-schema-view Reading schemas /// /// @{ /// \brief A non-owning view of a parsed ArrowSchema /// /// Contains more readily extractable values than a raw ArrowSchema. /// Clients can stack or statically allocate this structure but are /// encouraged to use the provided getters to ensure forward /// compatibility. struct ArrowSchemaView { /// \brief A pointer to the schema represented by this view const struct ArrowSchema* schema; /// \brief The data type represented by the schema /// /// This value may be NANOARROW_TYPE_DICTIONARY if the schema has a /// non-null dictionary member; datetime types are valid values. /// This value will never be NANOARROW_TYPE_EXTENSION (see /// extension_name and/or extension_metadata to check for /// an extension type). enum ArrowType type; /// \brief The storage data type represented by the schema /// /// This value will never be NANOARROW_TYPE_DICTIONARY, NANOARROW_TYPE_EXTENSION /// or any datetime type. This value represents only the type required to /// interpret the buffers in the array. enum ArrowType storage_type; /// \brief The storage layout represented by the schema struct ArrowLayout layout; /// \brief The extension type name if it exists /// /// If the ARROW:extension:name key is present in schema.metadata, /// extension_name.data will be non-NULL. struct ArrowStringView extension_name; /// \brief The extension type metadata if it exists /// /// If the ARROW:extension:metadata key is present in schema.metadata, /// extension_metadata.data will be non-NULL. struct ArrowStringView extension_metadata; /// \brief Format fixed size parameter /// /// This value is set when parsing a fixed-size binary or fixed-size /// list schema; this value is undefined for other types. For a /// fixed-size binary schema this value is in bytes; for a fixed-size /// list schema this value refers to the number of child elements for /// each element of the parent. int32_t fixed_size; /// \brief Decimal bitwidth /// /// This value is set when parsing a decimal type schema; /// this value is undefined for other types. int32_t decimal_bitwidth; /// \brief Decimal precision /// /// This value is set when parsing a decimal type schema; /// this value is undefined for other types. int32_t decimal_precision; /// \brief Decimal scale /// /// This value is set when parsing a decimal type schema; /// this value is undefined for other types. int32_t decimal_scale; /// \brief Format time unit parameter /// /// This value is set when parsing a date/time type. The value is /// undefined for other types. enum ArrowTimeUnit time_unit; /// \brief Format timezone parameter /// /// This value is set when parsing a timestamp type and represents /// the timezone format parameter. This value points to /// data within the schema and is undefined for other types. const char* timezone; /// \brief Union type ids parameter /// /// This value is set when parsing a union type and represents /// type ids parameter. This value points to /// data within the schema and is undefined for other types. const char* union_type_ids; }; /// \brief Initialize an ArrowSchemaView ArrowErrorCode ArrowSchemaViewInit(struct ArrowSchemaView* schema_view, const struct ArrowSchema* schema, struct ArrowError* error); /// @} /// \defgroup nanoarrow-buffer Owning, growable buffers /// /// @{ /// \brief Initialize an ArrowBuffer /// /// Initialize a buffer with a NULL, zero-size buffer using the default /// buffer allocator. static inline void ArrowBufferInit(struct ArrowBuffer* buffer); /// \brief Set a newly-initialized buffer's allocator /// /// Returns EINVAL if the buffer has already been allocated. static inline ArrowErrorCode ArrowBufferSetAllocator( struct ArrowBuffer* buffer, struct ArrowBufferAllocator allocator); /// \brief Reset an ArrowBuffer /// /// Releases the buffer using the allocator's free method if /// the buffer's data member is non-null, sets the data member /// to NULL, and sets the buffer's size and capacity to 0. static inline void ArrowBufferReset(struct ArrowBuffer* buffer); /// \brief Move an ArrowBuffer /// /// Transfers the buffer data and lifecycle management to another /// address and resets buffer. static inline void ArrowBufferMove(struct ArrowBuffer* src, struct ArrowBuffer* dst); /// \brief Grow or shrink a buffer to a given size /// /// When shrinking the size of the buffer, the buffer is only reallocated /// if shrink_to_fit is non-zero. static inline ArrowErrorCode ArrowBufferResize(struct ArrowBuffer* buffer, int64_t new_size_bytes, char shrink_to_fit); /// \brief Ensure a buffer has at least a given additional capacity /// /// Ensures that the buffer has space to append at least /// additional_size_bytes, overallocating when required. static inline ArrowErrorCode ArrowBufferReserve(struct ArrowBuffer* buffer, int64_t additional_size_bytes); /// \brief Write data to buffer and increment the buffer size /// /// This function does not check that buffer has the required capacity static inline void ArrowBufferAppendUnsafe(struct ArrowBuffer* buffer, const void* data, int64_t size_bytes); /// \brief Write data to buffer and increment the buffer size /// /// This function writes and ensures that the buffer has the required capacity, /// possibly by reallocating the buffer. Like ArrowBufferReserve, this will /// overallocate when reallocation is required. static inline ArrowErrorCode ArrowBufferAppend(struct ArrowBuffer* buffer, const void* data, int64_t size_bytes); /// \brief Write fill to buffer and increment the buffer size /// /// This function writes the specified number of fill bytes and /// ensures that the buffer has the required capacity, static inline ArrowErrorCode ArrowBufferAppendFill(struct ArrowBuffer* buffer, uint8_t value, int64_t size_bytes); /// \brief Write an 8-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendInt8(struct ArrowBuffer* buffer, int8_t value); /// \brief Write an unsigned 8-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendUInt8(struct ArrowBuffer* buffer, uint8_t value); /// \brief Write a 16-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendInt16(struct ArrowBuffer* buffer, int16_t value); /// \brief Write an unsigned 16-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendUInt16(struct ArrowBuffer* buffer, uint16_t value); /// \brief Write a 32-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendInt32(struct ArrowBuffer* buffer, int32_t value); /// \brief Write an unsigned 32-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendUInt32(struct ArrowBuffer* buffer, uint32_t value); /// \brief Write a 64-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendInt64(struct ArrowBuffer* buffer, int64_t value); /// \brief Write an unsigned 64-bit integer to a buffer static inline ArrowErrorCode ArrowBufferAppendUInt64(struct ArrowBuffer* buffer, uint64_t value); /// \brief Write a double to a buffer static inline ArrowErrorCode ArrowBufferAppendDouble(struct ArrowBuffer* buffer, double value); /// \brief Write a float to a buffer static inline ArrowErrorCode ArrowBufferAppendFloat(struct ArrowBuffer* buffer, float value); /// \brief Write an ArrowStringView to a buffer static inline ArrowErrorCode ArrowBufferAppendStringView(struct ArrowBuffer* buffer, struct ArrowStringView value); /// \brief Write an ArrowBufferView to a buffer static inline ArrowErrorCode ArrowBufferAppendBufferView(struct ArrowBuffer* buffer, struct ArrowBufferView value); /// @} /// \defgroup nanoarrow-bitmap Bitmap utilities /// /// @{ /// \brief Extract a boolean value from a bitmap static inline int8_t ArrowBitGet(const uint8_t* bits, int64_t i); /// \brief Set a boolean value to a bitmap to true static inline void ArrowBitSet(uint8_t* bits, int64_t i); /// \brief Set a boolean value to a bitmap to false static inline void ArrowBitClear(uint8_t* bits, int64_t i); /// \brief Set a boolean value to a bitmap static inline void ArrowBitSetTo(uint8_t* bits, int64_t i, uint8_t value); /// \brief Set a boolean value to a range in a bitmap static inline void ArrowBitsSetTo(uint8_t* bits, int64_t start_offset, int64_t length, uint8_t bits_are_set); /// \brief Count true values in a bitmap static inline int64_t ArrowBitCountSet(const uint8_t* bits, int64_t i_from, int64_t i_to); /// \brief Extract int8 boolean values from a range in a bitmap static inline void ArrowBitsUnpackInt8(const uint8_t* bits, int64_t start_offset, int64_t length, int8_t* out); /// \brief Extract int32 boolean values from a range in a bitmap static inline void ArrowBitsUnpackInt32(const uint8_t* bits, int64_t start_offset, int64_t length, int32_t* out); /// \brief Initialize an ArrowBitmap /// /// Initialize the builder's buffer, empty its cache, and reset the size to zero static inline void ArrowBitmapInit(struct ArrowBitmap* bitmap); /// \brief Move an ArrowBitmap /// /// Transfers the underlying buffer data and lifecycle management to another /// address and resets the bitmap. static inline void ArrowBitmapMove(struct ArrowBitmap* src, struct ArrowBitmap* dst); /// \brief Ensure a bitmap builder has at least a given additional capacity /// /// Ensures that the buffer has space to append at least /// additional_size_bits, overallocating when required. static inline ArrowErrorCode ArrowBitmapReserve(struct ArrowBitmap* bitmap, int64_t additional_size_bits); /// \brief Grow or shrink a bitmap to a given size /// /// When shrinking the size of the bitmap, the bitmap is only reallocated /// if shrink_to_fit is non-zero. static inline ArrowErrorCode ArrowBitmapResize(struct ArrowBitmap* bitmap, int64_t new_size_bits, char shrink_to_fit); /// \brief Reserve space for and append zero or more of the same boolean value to a bitmap static inline ArrowErrorCode ArrowBitmapAppend(struct ArrowBitmap* bitmap, uint8_t bits_are_set, int64_t length); /// \brief Append zero or more of the same boolean value to a bitmap static inline void ArrowBitmapAppendUnsafe(struct ArrowBitmap* bitmap, uint8_t bits_are_set, int64_t length); /// \brief Append boolean values encoded as int8_t to a bitmap /// /// The values must all be 0 or 1. static inline void ArrowBitmapAppendInt8Unsafe(struct ArrowBitmap* bitmap, const int8_t* values, int64_t n_values); /// \brief Append boolean values encoded as int32_t to a bitmap /// /// The values must all be 0 or 1. static inline void ArrowBitmapAppendInt32Unsafe(struct ArrowBitmap* bitmap, const int32_t* values, int64_t n_values); /// \brief Reset a bitmap builder /// /// Releases any memory held by buffer, empties the cache, and resets the size to zero static inline void ArrowBitmapReset(struct ArrowBitmap* bitmap); /// @} /// \defgroup nanoarrow-array Creating arrays /// /// These functions allocate, copy, and destroy ArrowArray structures. /// Once an ArrowArray has been initialized via ArrowArrayInitFromType() /// or ArrowArrayInitFromSchema(), the caller is responsible for releasing /// it using the embedded release callback. /// /// @{ /// \brief Initialize the fields of an array /// /// Initializes the fields and release callback of array. Caller /// is responsible for calling the array->release callback if /// NANOARROW_OK is returned. ArrowErrorCode ArrowArrayInitFromType(struct ArrowArray* array, enum ArrowType storage_type); /// \brief Initialize the contents of an ArrowArray from an ArrowSchema /// /// Caller is responsible for calling the array->release callback if /// NANOARROW_OK is returned. ArrowErrorCode ArrowArrayInitFromSchema(struct ArrowArray* array, const struct ArrowSchema* schema, struct ArrowError* error); /// \brief Initialize the contents of an ArrowArray from an ArrowArrayView /// /// Caller is responsible for calling the array->release callback if /// NANOARROW_OK is returned. ArrowErrorCode ArrowArrayInitFromArrayView(struct ArrowArray* array, const struct ArrowArrayView* array_view, struct ArrowError* error); /// \brief Allocate the array->children array /// /// Includes the memory for each child struct ArrowArray, /// whose members are marked as released and may be subsequently initialized /// with ArrowArrayInitFromType() or moved from an existing ArrowArray. /// schema must have been allocated using ArrowArrayInitFromType(). ArrowErrorCode ArrowArrayAllocateChildren(struct ArrowArray* array, int64_t n_children); /// \brief Allocate the array->dictionary member /// /// Includes the memory for the struct ArrowArray, whose contents /// is marked as released and may be subsequently initialized /// with ArrowArrayInitFromType() or moved from an existing ArrowArray. /// array must have been allocated using ArrowArrayInitFromType() ArrowErrorCode ArrowArrayAllocateDictionary(struct ArrowArray* array); /// \brief Set the validity bitmap of an ArrowArray /// /// array must have been allocated using ArrowArrayInitFromType() void ArrowArraySetValidityBitmap(struct ArrowArray* array, struct ArrowBitmap* bitmap); /// \brief Set a buffer of an ArrowArray /// /// array must have been allocated using ArrowArrayInitFromType() ArrowErrorCode ArrowArraySetBuffer(struct ArrowArray* array, int64_t i, struct ArrowBuffer* buffer); /// \brief Get the validity bitmap of an ArrowArray /// /// array must have been allocated using ArrowArrayInitFromType() static inline struct ArrowBitmap* ArrowArrayValidityBitmap(struct ArrowArray* array); /// \brief Get a buffer of an ArrowArray /// /// array must have been allocated using ArrowArrayInitFromType() static inline struct ArrowBuffer* ArrowArrayBuffer(struct ArrowArray* array, int64_t i); /// \brief Start element-wise appending to an ArrowArray /// /// Initializes any values needed to use ArrowArrayAppend*() functions. /// All element-wise appenders append by value and return EINVAL if the exact value /// cannot be represented by the underlying storage type. /// array must have been allocated using ArrowArrayInitFromType() static inline ArrowErrorCode ArrowArrayStartAppending(struct ArrowArray* array); /// \brief Reserve space for future appends /// /// For buffer sizes that can be calculated (i.e., not string data buffers or /// child array sizes for non-fixed-size arrays), recursively reserve space for /// additional elements. This is useful for reducing the number of reallocations /// that occur using the item-wise appenders. ArrowErrorCode ArrowArrayReserve(struct ArrowArray* array, int64_t additional_size_elements); /// \brief Append a null value to an array static inline ArrowErrorCode ArrowArrayAppendNull(struct ArrowArray* array, int64_t n); /// \brief Append an empty, non-null value to an array static inline ArrowErrorCode ArrowArrayAppendEmpty(struct ArrowArray* array, int64_t n); /// \brief Append a signed integer value to an array /// /// Returns NANOARROW_OK if value can be exactly represented by /// the underlying storage type or EINVAL otherwise (e.g., value /// is outside the valid array range). static inline ArrowErrorCode ArrowArrayAppendInt(struct ArrowArray* array, int64_t value); /// \brief Append an unsigned integer value to an array /// /// Returns NANOARROW_OK if value can be exactly represented by /// the underlying storage type or EINVAL otherwise (e.g., value /// is outside the valid array range). static inline ArrowErrorCode ArrowArrayAppendUInt(struct ArrowArray* array, uint64_t value); /// \brief Append a double value to an array /// /// Returns NANOARROW_OK if value can be exactly represented by /// the underlying storage type or EINVAL otherwise (e.g., value /// is outside the valid array range or there is an attempt to append /// a non-integer to an array with an integer storage type). static inline ArrowErrorCode ArrowArrayAppendDouble(struct ArrowArray* array, double value); /// \brief Append a string of bytes to an array /// /// Returns NANOARROW_OK if value can be exactly represented by /// the underlying storage type, EOVERFLOW if appending value would overflow /// the offset type (e.g., if the data buffer would be larger than 2 GB for a /// non-large string type), or EINVAL otherwise (e.g., the underlying array is not a /// binary, string, large binary, large string, or fixed-size binary array, or value is /// the wrong size for a fixed-size binary array). static inline ArrowErrorCode ArrowArrayAppendBytes(struct ArrowArray* array, struct ArrowBufferView value); /// \brief Append a string value to an array /// /// Returns NANOARROW_OK if value can be exactly represented by /// the underlying storage type, EOVERFLOW if appending value would overflow /// the offset type (e.g., if the data buffer would be larger than 2 GB for a /// non-large string type), or EINVAL otherwise (e.g., the underlying array is not a /// string or large string array). static inline ArrowErrorCode ArrowArrayAppendString(struct ArrowArray* array, struct ArrowStringView value); /// \brief Append a Interval to an array /// /// Returns NANOARROW_OK if value can be exactly represented by /// the underlying storage type or EINVAL otherwise. static inline ArrowErrorCode ArrowArrayAppendInterval(struct ArrowArray* array, const struct ArrowInterval* value); /// \brief Append a decimal value to an array /// /// Returns NANOARROW_OK if array is a decimal array with the appropriate /// bitwidth or EINVAL otherwise. static inline ArrowErrorCode ArrowArrayAppendDecimal(struct ArrowArray* array, const struct ArrowDecimal* value); /// \brief Finish a nested array element /// /// Appends a non-null element to the array based on the first child's current /// length. Returns NANOARROW_OK if the item was successfully added, EOVERFLOW /// if the child of a list or map array would exceed INT_MAX elements, or EINVAL /// if the underlying storage type is not a struct, list, large list, or fixed-size /// list, or if there was an attempt to add a struct or fixed-size list element where the /// length of the child array(s) did not match the expected length. static inline ArrowErrorCode ArrowArrayFinishElement(struct ArrowArray* array); /// \brief Finish a union array element /// /// Appends an element to the union type ids buffer and increments array->length. /// For sparse unions, up to one element is added to non type-id children. Returns /// EINVAL if the underlying storage type is not a union, if type_id is not valid, /// or if child sizes after appending are inconsistent. static inline ArrowErrorCode ArrowArrayFinishUnionElement(struct ArrowArray* array, int8_t type_id); /// \brief Shrink buffer capacity to the size required /// /// Also applies shrinking to any child arrays. array must have been allocated using /// ArrowArrayInitFromType static inline ArrowErrorCode ArrowArrayShrinkToFit(struct ArrowArray* array); /// \brief Finish building an ArrowArray /// /// Flushes any pointers from internal buffers that may have been reallocated /// into array->buffers and checks the actual size of the buffers /// against the expected size based on the final length. /// array must have been allocated using ArrowArrayInitFromType() ArrowErrorCode ArrowArrayFinishBuildingDefault(struct ArrowArray* array, struct ArrowError* error); /// \brief Finish building an ArrowArray with explicit validation /// /// Finish building with an explicit validation level. This could perform less validation /// (i.e. NANOARROW_VALIDATION_LEVEL_NONE or NANOARROW_VALIDATION_LEVEL_MINIMAL) if CPU /// buffer data access is not possible or more validation (i.e., /// NANOARROW_VALIDATION_LEVEL_FULL) if buffer content was obtained from an untrusted or /// corruptible source. ArrowErrorCode ArrowArrayFinishBuilding(struct ArrowArray* array, enum ArrowValidationLevel validation_level, struct ArrowError* error); /// @} /// \defgroup nanoarrow-array-view Reading arrays /// /// These functions read and validate the contents ArrowArray structures. /// /// @{ /// \brief Initialize the contents of an ArrowArrayView void ArrowArrayViewInitFromType(struct ArrowArrayView* array_view, enum ArrowType storage_type); /// \brief Move an ArrowArrayView /// /// Transfers the ArrowArrayView data and lifecycle management to another /// address and resets the contents of src. static inline void ArrowArrayViewMove(struct ArrowArrayView* src, struct ArrowArrayView* dst); /// \brief Initialize the contents of an ArrowArrayView from an ArrowSchema ArrowErrorCode ArrowArrayViewInitFromSchema(struct ArrowArrayView* array_view, const struct ArrowSchema* schema, struct ArrowError* error); /// \brief Allocate the array_view->children array /// /// Includes the memory for each child struct ArrowArrayView ArrowErrorCode ArrowArrayViewAllocateChildren(struct ArrowArrayView* array_view, int64_t n_children); /// \brief Allocate array_view->dictionary ArrowErrorCode ArrowArrayViewAllocateDictionary(struct ArrowArrayView* array_view); /// \brief Set data-independent buffer sizes from length void ArrowArrayViewSetLength(struct ArrowArrayView* array_view, int64_t length); /// \brief Set buffer sizes and data pointers from an ArrowArray ArrowErrorCode ArrowArrayViewSetArray(struct ArrowArrayView* array_view, const struct ArrowArray* array, struct ArrowError* error); /// \brief Set buffer sizes and data pointers from an ArrowArray except for those /// that require dereferencing buffer content. ArrowErrorCode ArrowArrayViewSetArrayMinimal(struct ArrowArrayView* array_view, const struct ArrowArray* array, struct ArrowError* error); /// \brief Get the number of buffers /// /// The number of buffers referred to by this ArrowArrayView. In may cases this can also /// be calculated from the ArrowLayout member of the ArrowArrayView or ArrowSchemaView; /// however, for binary view and string view types, the number of total buffers depends on /// the number of variadic buffers. static inline int64_t ArrowArrayViewGetNumBuffers(struct ArrowArrayView* array_view); /// \brief Get a view of a specific buffer from an ArrowArrayView /// /// This is the ArrowArrayView equivalent of ArrowArray::buffers[i] that includes /// size information (if known). static inline struct ArrowBufferView ArrowArrayViewGetBufferView( struct ArrowArrayView* array_view, int64_t i); /// \brief Get the function of a specific buffer in an ArrowArrayView /// /// In may cases this can also be obtained from the ArrowLayout member of the /// ArrowArrayView or ArrowSchemaView; however, for binary view and string view types, /// the function of each buffer may be different between two arrays of the same type /// depending on the number of variadic buffers. static inline enum ArrowBufferType ArrowArrayViewGetBufferType( struct ArrowArrayView* array_view, int64_t i); /// \brief Get the data type of a specific buffer in an ArrowArrayView /// /// In may cases this can also be obtained from the ArrowLayout member of the /// ArrowArrayView or ArrowSchemaView; however, for binary view and string view types, /// the data type of each buffer may be different between two arrays of the same type /// depending on the number of variadic buffers. static inline enum ArrowType ArrowArrayViewGetBufferDataType( struct ArrowArrayView* array_view, int64_t i); /// \brief Get the element size (in bits) of a specific buffer in an ArrowArrayView /// /// In may cases this can also be obtained from the ArrowLayout member of the /// ArrowArrayView or ArrowSchemaView; however, for binary view and string view types, /// the element width of each buffer may be different between two arrays of the same type /// depending on the number of variadic buffers. static inline int64_t ArrowArrayViewGetBufferElementSizeBits( struct ArrowArrayView* array_view, int64_t i); /// \brief Performs checks on the content of an ArrowArrayView /// /// If using ArrowArrayViewSetArray() to back array_view with an ArrowArray, /// the buffer sizes and some content (fist and last offset) have already /// been validated at the "default" level. If setting the buffer pointers /// and sizes otherwise, you may wish to perform checks at a different level. See /// documentation for ArrowValidationLevel for the details of checks performed /// at each level. ArrowErrorCode ArrowArrayViewValidate(struct ArrowArrayView* array_view, enum ArrowValidationLevel validation_level, struct ArrowError* error); /// \brief Compare two ArrowArrayView objects for equality /// /// Given two ArrowArrayView instances, place either 0 (not equal) and /// 1 (equal) at the address pointed to by out. If the comparison determines /// that actual and expected are not equal, a reason will be communicated via /// error if error is non-NULL. /// /// Returns NANOARROW_OK if the comparison completed successfully. ArrowErrorCode ArrowArrayViewCompare(const struct ArrowArrayView* actual, const struct ArrowArrayView* expected, enum ArrowCompareLevel level, int* out, struct ArrowError* reason); /// \brief Reset the contents of an ArrowArrayView and frees resources void ArrowArrayViewReset(struct ArrowArrayView* array_view); /// \brief Check for a null element in an ArrowArrayView static inline int8_t ArrowArrayViewIsNull(const struct ArrowArrayView* array_view, int64_t i); /// \brief Compute null count for an ArrowArrayView static inline int64_t ArrowArrayViewComputeNullCount( const struct ArrowArrayView* array_view); /// \brief Get the type id of a union array element static inline int8_t ArrowArrayViewUnionTypeId(const struct ArrowArrayView* array_view, int64_t i); /// \brief Get the child index of a union array element static inline int8_t ArrowArrayViewUnionChildIndex( const struct ArrowArrayView* array_view, int64_t i); /// \brief Get the index to use into the relevant union child array static inline int64_t ArrowArrayViewUnionChildOffset( const struct ArrowArrayView* array_view, int64_t i); /// \brief Get an element in an ArrowArrayView as an integer /// /// This function does not check for null values, that values are actually integers, or /// that values are within a valid range for an int64. static inline int64_t ArrowArrayViewGetIntUnsafe(const struct ArrowArrayView* array_view, int64_t i); /// \brief Get an element in an ArrowArrayView as an unsigned integer /// /// This function does not check for null values, that values are actually integers, or /// that values are within a valid range for a uint64. static inline uint64_t ArrowArrayViewGetUIntUnsafe( const struct ArrowArrayView* array_view, int64_t i); /// \brief Get an element in an ArrowArrayView as a double /// /// This function does not check for null values, or /// that values are within a valid range for a double. static inline double ArrowArrayViewGetDoubleUnsafe( const struct ArrowArrayView* array_view, int64_t i); /// \brief Get an element in an ArrowArrayView as an ArrowStringView /// /// This function does not check for null values. static inline struct ArrowStringView ArrowArrayViewGetStringUnsafe( const struct ArrowArrayView* array_view, int64_t i); /// \brief Get an element in an ArrowArrayView as an ArrowBufferView /// /// This function does not check for null values. static inline struct ArrowBufferView ArrowArrayViewGetBytesUnsafe( const struct ArrowArrayView* array_view, int64_t i); /// \brief Get an element in an ArrowArrayView as an ArrowDecimal /// /// This function does not check for null values. The out parameter must /// be initialized with ArrowDecimalInit() with the proper parameters for this /// type before calling this for the first time. static inline void ArrowArrayViewGetDecimalUnsafe(const struct ArrowArrayView* array_view, int64_t i, struct ArrowDecimal* out); /// @} /// \defgroup nanoarrow-basic-array-stream Basic ArrowArrayStream implementation /// /// An implementation of an ArrowArrayStream based on a collection of /// zero or more previously-existing ArrowArray objects. Users should /// initialize and/or validate the contents before transferring the /// responsibility of the ArrowArrayStream elsewhere. /// /// @{ /// \brief Initialize an ArrowArrayStream backed by this implementation /// /// This function moves the ownership of schema to the array_stream. If /// this function returns NANOARROW_OK, the caller is responsible for /// releasing the ArrowArrayStream. ArrowErrorCode ArrowBasicArrayStreamInit(struct ArrowArrayStream* array_stream, struct ArrowSchema* schema, int64_t n_arrays); /// \brief Set the ith ArrowArray in this ArrowArrayStream. /// /// array_stream must have been initialized with ArrowBasicArrayStreamInit(). /// This function move the ownership of array to the array_stream. i must /// be greater than zero and less than the value of n_arrays passed in /// ArrowBasicArrayStreamInit(). Callers are not required to fill all /// n_arrays members (i.e., n_arrays is a maximum bound). void ArrowBasicArrayStreamSetArray(struct ArrowArrayStream* array_stream, int64_t i, struct ArrowArray* array); /// \brief Validate the contents of this ArrowArrayStream /// /// array_stream must have been initialized with ArrowBasicArrayStreamInit(). /// This function uses ArrowArrayStreamInitFromSchema() and ArrowArrayStreamSetArray() /// to validate the contents of the arrays. ArrowErrorCode ArrowBasicArrayStreamValidate(const struct ArrowArrayStream* array_stream, struct ArrowError* error); /// @} // Undefine ArrowErrorCode, which may have been defined to annotate functions that return // it to warn for an unused result. #if defined(ArrowErrorCode) #undef ArrowErrorCode #endif // Inline function definitions #ifdef __cplusplus } #endif #endif // 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. #ifndef NANOARROW_BUFFER_INLINE_H_INCLUDED #define NANOARROW_BUFFER_INLINE_H_INCLUDED #include #include #include #ifdef __cplusplus extern "C" { #endif // Modified from Arrow C++ (1eb46f76) cpp/src/arrow/chunk_resolver.h#L133-L162 static inline int64_t ArrowResolveChunk64(int64_t index, const int64_t* offsets, int64_t lo, int64_t hi) { // Similar to std::upper_bound(), but slightly different as our offsets // array always starts with 0. int64_t n = hi - lo; // First iteration does not need to check for n > 1 // (lo < hi is guaranteed by the precondition). NANOARROW_DCHECK(n > 1); do { const int64_t m = n >> 1; const int64_t mid = lo + m; if (index >= offsets[mid]) { lo = mid; n -= m; } else { n = m; } } while (n > 1); return lo; } static inline int64_t ArrowResolveChunk32(int32_t index, const int32_t* offsets, int32_t lo, int32_t hi) { // Similar to std::upper_bound(), but slightly different as our offsets // array always starts with 0. int32_t n = hi - lo; // First iteration does not need to check for n > 1 // (lo < hi is guaranteed by the precondition). NANOARROW_DCHECK(n > 1); do { const int32_t m = n >> 1; const int32_t mid = lo + m; if (index >= offsets[mid]) { lo = mid; n -= m; } else { n = m; } } while (n > 1); return lo; } static inline int64_t _ArrowGrowByFactor(int64_t current_capacity, int64_t new_capacity) { int64_t doubled_capacity = current_capacity * 2; if (doubled_capacity > new_capacity) { return doubled_capacity; } else { return new_capacity; } } // float to half float conversion, adapted from Arrow Go // https://github.com/apache/arrow/blob/main/go/arrow/float16/float16.go static inline uint16_t ArrowFloatToHalfFloat(float value) { union { float f; uint32_t b; } u; u.f = value; uint16_t sn = (uint16_t)((u.b >> 31) & 0x1); uint16_t exp = (u.b >> 23) & 0xff; int16_t res = (int16_t)(exp - 127 + 15); uint16_t fc = (uint16_t)(u.b >> 13) & 0x3ff; if (exp == 0) { res = 0; } else if (exp == 0xff) { res = 0x1f; } else if (res > 0x1e) { res = 0x1f; fc = 0; } else if (res < 0x01) { res = 0; fc = 0; } return (uint16_t)((sn << 15) | (uint16_t)(res << 10) | fc); } // half float to float conversion, adapted from Arrow Go // https://github.com/apache/arrow/blob/main/go/arrow/float16/float16.go static inline float ArrowHalfFloatToFloat(uint16_t value) { uint32_t sn = (uint32_t)((value >> 15) & 0x1); uint32_t exp = (value >> 10) & 0x1f; uint32_t res = exp + 127 - 15; uint32_t fc = value & 0x3ff; if (exp == 0) { res = 0; } else if (exp == 0x1f) { res = 0xff; } union { float f; uint32_t b; } u; u.b = (uint32_t)(sn << 31) | (uint32_t)(res << 23) | (uint32_t)(fc << 13); return u.f; } static inline void ArrowBufferInit(struct ArrowBuffer* buffer) { buffer->data = NULL; buffer->size_bytes = 0; buffer->capacity_bytes = 0; buffer->allocator = ArrowBufferAllocatorDefault(); } static inline ArrowErrorCode ArrowBufferSetAllocator( struct ArrowBuffer* buffer, struct ArrowBufferAllocator allocator) { // This is not a perfect test for "has a buffer already been allocated" // but is likely to catch most cases. if (buffer->data == NULL) { buffer->allocator = allocator; return NANOARROW_OK; } else { return EINVAL; } } static inline void ArrowBufferReset(struct ArrowBuffer* buffer) { buffer->allocator.free(&buffer->allocator, (uint8_t*)buffer->data, buffer->capacity_bytes); ArrowBufferInit(buffer); } static inline void ArrowBufferMove(struct ArrowBuffer* src, struct ArrowBuffer* dst) { memcpy(dst, src, sizeof(struct ArrowBuffer)); src->data = NULL; ArrowBufferInit(src); } static inline ArrowErrorCode ArrowBufferResize(struct ArrowBuffer* buffer, int64_t new_size_bytes, char shrink_to_fit) { if (new_size_bytes < 0) { return EINVAL; } int needs_reallocation = new_size_bytes > buffer->capacity_bytes || (shrink_to_fit && new_size_bytes < buffer->capacity_bytes); if (needs_reallocation) { buffer->data = buffer->allocator.reallocate(&buffer->allocator, buffer->data, buffer->capacity_bytes, new_size_bytes); if (buffer->data == NULL && new_size_bytes > 0) { buffer->capacity_bytes = 0; buffer->size_bytes = 0; return ENOMEM; } buffer->capacity_bytes = new_size_bytes; } buffer->size_bytes = new_size_bytes; return NANOARROW_OK; } static inline ArrowErrorCode ArrowBufferReserve(struct ArrowBuffer* buffer, int64_t additional_size_bytes) { int64_t min_capacity_bytes = buffer->size_bytes + additional_size_bytes; if (min_capacity_bytes <= buffer->capacity_bytes) { return NANOARROW_OK; } int64_t new_capacity_bytes = _ArrowGrowByFactor(buffer->capacity_bytes, min_capacity_bytes); buffer->data = buffer->allocator.reallocate(&buffer->allocator, buffer->data, buffer->capacity_bytes, new_capacity_bytes); if (buffer->data == NULL && new_capacity_bytes > 0) { buffer->capacity_bytes = 0; buffer->size_bytes = 0; return ENOMEM; } buffer->capacity_bytes = new_capacity_bytes; return NANOARROW_OK; } static inline void ArrowBufferAppendUnsafe(struct ArrowBuffer* buffer, const void* data, int64_t size_bytes) { if (size_bytes > 0) { NANOARROW_DCHECK(buffer->data != NULL); memcpy(buffer->data + buffer->size_bytes, data, size_bytes); buffer->size_bytes += size_bytes; } } static inline ArrowErrorCode ArrowBufferAppend(struct ArrowBuffer* buffer, const void* data, int64_t size_bytes) { NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(buffer, size_bytes)); ArrowBufferAppendUnsafe(buffer, data, size_bytes); return NANOARROW_OK; } static inline ArrowErrorCode ArrowBufferAppendInt8(struct ArrowBuffer* buffer, int8_t value) { return ArrowBufferAppend(buffer, &value, sizeof(int8_t)); } static inline ArrowErrorCode ArrowBufferAppendUInt8(struct ArrowBuffer* buffer, uint8_t value) { return ArrowBufferAppend(buffer, &value, sizeof(uint8_t)); } static inline ArrowErrorCode ArrowBufferAppendInt16(struct ArrowBuffer* buffer, int16_t value) { return ArrowBufferAppend(buffer, &value, sizeof(int16_t)); } static inline ArrowErrorCode ArrowBufferAppendUInt16(struct ArrowBuffer* buffer, uint16_t value) { return ArrowBufferAppend(buffer, &value, sizeof(uint16_t)); } static inline ArrowErrorCode ArrowBufferAppendInt32(struct ArrowBuffer* buffer, int32_t value) { return ArrowBufferAppend(buffer, &value, sizeof(int32_t)); } static inline ArrowErrorCode ArrowBufferAppendUInt32(struct ArrowBuffer* buffer, uint32_t value) { return ArrowBufferAppend(buffer, &value, sizeof(uint32_t)); } static inline ArrowErrorCode ArrowBufferAppendInt64(struct ArrowBuffer* buffer, int64_t value) { return ArrowBufferAppend(buffer, &value, sizeof(int64_t)); } static inline ArrowErrorCode ArrowBufferAppendUInt64(struct ArrowBuffer* buffer, uint64_t value) { return ArrowBufferAppend(buffer, &value, sizeof(uint64_t)); } static inline ArrowErrorCode ArrowBufferAppendDouble(struct ArrowBuffer* buffer, double value) { return ArrowBufferAppend(buffer, &value, sizeof(double)); } static inline ArrowErrorCode ArrowBufferAppendFloat(struct ArrowBuffer* buffer, float value) { return ArrowBufferAppend(buffer, &value, sizeof(float)); } static inline ArrowErrorCode ArrowBufferAppendStringView(struct ArrowBuffer* buffer, struct ArrowStringView value) { return ArrowBufferAppend(buffer, value.data, value.size_bytes); } static inline ArrowErrorCode ArrowBufferAppendBufferView(struct ArrowBuffer* buffer, struct ArrowBufferView value) { return ArrowBufferAppend(buffer, value.data.data, value.size_bytes); } static inline ArrowErrorCode ArrowBufferAppendFill(struct ArrowBuffer* buffer, uint8_t value, int64_t size_bytes) { if (size_bytes == 0) { return NANOARROW_OK; } NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(buffer, size_bytes)); NANOARROW_DCHECK(buffer->data != NULL); // To help clang-tidy memset(buffer->data + buffer->size_bytes, value, size_bytes); buffer->size_bytes += size_bytes; return NANOARROW_OK; } static const uint8_t _ArrowkBitmask[] = {1, 2, 4, 8, 16, 32, 64, 128}; static const uint8_t _ArrowkFlippedBitmask[] = {254, 253, 251, 247, 239, 223, 191, 127}; static const uint8_t _ArrowkPrecedingBitmask[] = {0, 1, 3, 7, 15, 31, 63, 127}; static const uint8_t _ArrowkTrailingBitmask[] = {255, 254, 252, 248, 240, 224, 192, 128}; static const uint8_t _ArrowkBytePopcount[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}; static inline int64_t _ArrowRoundUpToMultipleOf8(int64_t value) { return (value + 7) & ~((int64_t)7); } static inline int64_t _ArrowRoundDownToMultipleOf8(int64_t value) { return (value / 8) * 8; } static inline int64_t _ArrowBytesForBits(int64_t bits) { return (bits >> 3) + ((bits & 7) != 0); } static inline void _ArrowBitsUnpackInt8(const uint8_t word, int8_t* out) { out[0] = (word & 0x1) != 0; out[1] = (word & 0x2) != 0; out[2] = (word & 0x4) != 0; out[3] = (word & 0x8) != 0; out[4] = (word & 0x10) != 0; out[5] = (word & 0x20) != 0; out[6] = (word & 0x40) != 0; out[7] = (word & 0x80) != 0; } static inline void _ArrowBitsUnpackInt32(const uint8_t word, int32_t* out) { out[0] = (word & 0x1) != 0; out[1] = (word & 0x2) != 0; out[2] = (word & 0x4) != 0; out[3] = (word & 0x8) != 0; out[4] = (word & 0x10) != 0; out[5] = (word & 0x20) != 0; out[6] = (word & 0x40) != 0; out[7] = (word & 0x80) != 0; } static inline void _ArrowBitmapPackInt8(const int8_t* values, uint8_t* out) { *out = (uint8_t)(values[0] | ((values[1] + 0x1) & 0x2) | ((values[2] + 0x3) & 0x4) | ((values[3] + 0x7) & 0x8) | ((values[4] + 0xf) & 0x10) | ((values[5] + 0x1f) & 0x20) | ((values[6] + 0x3f) & 0x40) | ((values[7] + 0x7f) & 0x80)); } static inline void _ArrowBitmapPackInt32(const int32_t* values, uint8_t* out) { *out = (uint8_t)(values[0] | ((values[1] + 0x1) & 0x2) | ((values[2] + 0x3) & 0x4) | ((values[3] + 0x7) & 0x8) | ((values[4] + 0xf) & 0x10) | ((values[5] + 0x1f) & 0x20) | ((values[6] + 0x3f) & 0x40) | ((values[7] + 0x7f) & 0x80)); } static inline int8_t ArrowBitGet(const uint8_t* bits, int64_t i) { return (bits[i >> 3] >> (i & 0x07)) & 1; } static inline void ArrowBitsUnpackInt8(const uint8_t* bits, int64_t start_offset, int64_t length, int8_t* out) { if (length == 0) { return; } const int64_t i_begin = start_offset; const int64_t i_end = start_offset + length; const int64_t i_last_valid = i_end - 1; const int64_t bytes_begin = i_begin / 8; const int64_t bytes_last_valid = i_last_valid / 8; if (bytes_begin == bytes_last_valid) { for (int i = 0; i < length; i++) { out[i] = ArrowBitGet(&bits[bytes_begin], i + i_begin % 8); } return; } // first byte for (int i = 0; i < 8 - (i_begin % 8); i++) { *out++ = ArrowBitGet(&bits[bytes_begin], i + i_begin % 8); } // middle bytes for (int64_t i = bytes_begin + 1; i < bytes_last_valid; i++) { _ArrowBitsUnpackInt8(bits[i], out); out += 8; } // last byte const int bits_remaining = (int)(i_end % 8 == 0 ? 8 : i_end % 8); for (int i = 0; i < bits_remaining; i++) { *out++ = ArrowBitGet(&bits[bytes_last_valid], i); } } static inline void ArrowBitsUnpackInt32(const uint8_t* bits, int64_t start_offset, int64_t length, int32_t* out) { if (length == 0) { return; } NANOARROW_DCHECK(bits != NULL && out != NULL); const int64_t i_begin = start_offset; const int64_t i_end = start_offset + length; const int64_t i_last_valid = i_end - 1; const int64_t bytes_begin = i_begin / 8; const int64_t bytes_last_valid = i_last_valid / 8; if (bytes_begin == bytes_last_valid) { for (int i = 0; i < length; i++) { out[i] = ArrowBitGet(&bits[bytes_begin], i + i_begin % 8); } return; } // first byte for (int i = 0; i < 8 - (i_begin % 8); i++) { *out++ = ArrowBitGet(&bits[bytes_begin], i + i_begin % 8); } // middle bytes for (int64_t i = bytes_begin + 1; i < bytes_last_valid; i++) { _ArrowBitsUnpackInt32(bits[i], out); out += 8; } // last byte const int bits_remaining = (int)(i_end % 8 == 0 ? 8 : i_end % 8); for (int i = 0; i < bits_remaining; i++) { *out++ = ArrowBitGet(&bits[bytes_last_valid], i); } } static inline void ArrowBitSet(uint8_t* bits, int64_t i) { bits[i / 8] |= _ArrowkBitmask[i % 8]; } static inline void ArrowBitClear(uint8_t* bits, int64_t i) { bits[i / 8] &= _ArrowkFlippedBitmask[i % 8]; } static inline void ArrowBitSetTo(uint8_t* bits, int64_t i, uint8_t bit_is_set) { bits[i / 8] ^= (uint8_t)(((uint8_t)(-((uint8_t)(bit_is_set != 0)) ^ bits[i / 8])) & _ArrowkBitmask[i % 8]); } static inline void ArrowBitsSetTo(uint8_t* bits, int64_t start_offset, int64_t length, uint8_t bits_are_set) { if (length == 0) { return; } NANOARROW_DCHECK(bits != NULL); const int64_t i_begin = start_offset; const int64_t i_end = start_offset + length; const uint8_t fill_byte = (uint8_t)(-bits_are_set); const int64_t bytes_begin = i_begin / 8; const int64_t bytes_end = i_end / 8 + 1; const uint8_t first_byte_mask = _ArrowkPrecedingBitmask[i_begin % 8]; const uint8_t last_byte_mask = _ArrowkTrailingBitmask[i_end % 8]; if (bytes_end == bytes_begin + 1) { // set bits within a single byte const uint8_t only_byte_mask = i_end % 8 == 0 ? first_byte_mask : (uint8_t)(first_byte_mask | last_byte_mask); bits[bytes_begin] &= only_byte_mask; bits[bytes_begin] |= (uint8_t)(fill_byte & ~only_byte_mask); return; } // set/clear trailing bits of first byte bits[bytes_begin] &= first_byte_mask; bits[bytes_begin] |= (uint8_t)(fill_byte & ~first_byte_mask); if (bytes_end - bytes_begin > 2) { // set/clear whole bytes memset(bits + bytes_begin + 1, fill_byte, (size_t)(bytes_end - bytes_begin - 2)); } if (i_end % 8 == 0) { return; } // set/clear leading bits of last byte bits[bytes_end - 1] &= last_byte_mask; bits[bytes_end - 1] |= (uint8_t)(fill_byte & ~last_byte_mask); } static inline int64_t ArrowBitCountSet(const uint8_t* bits, int64_t start_offset, int64_t length) { if (length == 0) { return 0; } NANOARROW_DCHECK(bits != NULL); const int64_t i_begin = start_offset; const int64_t i_end = start_offset + length; const int64_t i_last_valid = i_end - 1; const int64_t bytes_begin = i_begin / 8; const int64_t bytes_last_valid = i_last_valid / 8; if (bytes_begin == bytes_last_valid) { // count bits within a single byte const uint8_t first_byte_mask = _ArrowkPrecedingBitmask[i_end % 8]; const uint8_t last_byte_mask = _ArrowkTrailingBitmask[i_begin % 8]; const uint8_t only_byte_mask = i_end % 8 == 0 ? last_byte_mask : (uint8_t)(first_byte_mask & last_byte_mask); const uint8_t byte_masked = bits[bytes_begin] & only_byte_mask; return _ArrowkBytePopcount[byte_masked]; } const uint8_t first_byte_mask = _ArrowkPrecedingBitmask[i_begin % 8]; const uint8_t last_byte_mask = i_end % 8 == 0 ? 0 : _ArrowkTrailingBitmask[i_end % 8]; int64_t count = 0; // first byte count += _ArrowkBytePopcount[bits[bytes_begin] & ~first_byte_mask]; // middle bytes for (int64_t i = bytes_begin + 1; i < bytes_last_valid; i++) { count += _ArrowkBytePopcount[bits[i]]; } // last byte count += _ArrowkBytePopcount[bits[bytes_last_valid] & ~last_byte_mask]; return count; } static inline void ArrowBitmapInit(struct ArrowBitmap* bitmap) { ArrowBufferInit(&bitmap->buffer); bitmap->size_bits = 0; } static inline void ArrowBitmapMove(struct ArrowBitmap* src, struct ArrowBitmap* dst) { ArrowBufferMove(&src->buffer, &dst->buffer); dst->size_bits = src->size_bits; src->size_bits = 0; } static inline ArrowErrorCode ArrowBitmapReserve(struct ArrowBitmap* bitmap, int64_t additional_size_bits) { int64_t min_capacity_bits = bitmap->size_bits + additional_size_bits; int64_t min_capacity_bytes = _ArrowBytesForBits(min_capacity_bits); int64_t current_size_bytes = bitmap->buffer.size_bytes; int64_t current_capacity_bytes = bitmap->buffer.capacity_bytes; if (min_capacity_bytes <= current_capacity_bytes) { return NANOARROW_OK; } int64_t additional_capacity_bytes = min_capacity_bytes - current_size_bytes; NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(&bitmap->buffer, additional_capacity_bytes)); // Zero out the last byte for deterministic output in the common case // of reserving a known remaining size. We should have returned above // if there was not at least one additional byte to allocate; however, // DCHECK() just to be sure. NANOARROW_DCHECK(bitmap->buffer.capacity_bytes > current_capacity_bytes); bitmap->buffer.data[bitmap->buffer.capacity_bytes - 1] = 0; return NANOARROW_OK; } static inline ArrowErrorCode ArrowBitmapResize(struct ArrowBitmap* bitmap, int64_t new_size_bits, char shrink_to_fit) { if (new_size_bits < 0) { return EINVAL; } int64_t new_size_bytes = _ArrowBytesForBits(new_size_bits); NANOARROW_RETURN_NOT_OK( ArrowBufferResize(&bitmap->buffer, new_size_bytes, shrink_to_fit)); bitmap->size_bits = new_size_bits; return NANOARROW_OK; } static inline ArrowErrorCode ArrowBitmapAppend(struct ArrowBitmap* bitmap, uint8_t bits_are_set, int64_t length) { NANOARROW_RETURN_NOT_OK(ArrowBitmapReserve(bitmap, length)); ArrowBitmapAppendUnsafe(bitmap, bits_are_set, length); return NANOARROW_OK; } static inline void ArrowBitmapAppendUnsafe(struct ArrowBitmap* bitmap, uint8_t bits_are_set, int64_t length) { ArrowBitsSetTo(bitmap->buffer.data, bitmap->size_bits, length, bits_are_set); bitmap->size_bits += length; bitmap->buffer.size_bytes = _ArrowBytesForBits(bitmap->size_bits); } static inline void ArrowBitmapAppendInt8Unsafe(struct ArrowBitmap* bitmap, const int8_t* values, int64_t n_values) { if (n_values == 0) { return; } const int8_t* values_cursor = values; int64_t n_remaining = n_values; int64_t out_i_cursor = bitmap->size_bits; uint8_t* out_cursor = bitmap->buffer.data + bitmap->size_bits / 8; // First byte if ((out_i_cursor % 8) != 0) { int64_t n_partial_bits = _ArrowRoundUpToMultipleOf8(out_i_cursor) - out_i_cursor; for (int i = 0; i < n_partial_bits; i++) { ArrowBitSetTo(bitmap->buffer.data, out_i_cursor++, values[i]); } out_cursor++; values_cursor += n_partial_bits; n_remaining -= n_partial_bits; } // Middle bytes int64_t n_full_bytes = n_remaining / 8; for (int64_t i = 0; i < n_full_bytes; i++) { _ArrowBitmapPackInt8(values_cursor, out_cursor); values_cursor += 8; out_cursor++; } // Last byte out_i_cursor += n_full_bytes * 8; n_remaining -= n_full_bytes * 8; if (n_remaining > 0) { // Zero out the last byte *out_cursor = 0x00; for (int i = 0; i < n_remaining; i++) { ArrowBitSetTo(bitmap->buffer.data, out_i_cursor++, values_cursor[i]); } out_cursor++; } bitmap->size_bits += n_values; bitmap->buffer.size_bytes = out_cursor - bitmap->buffer.data; } static inline void ArrowBitmapAppendInt32Unsafe(struct ArrowBitmap* bitmap, const int32_t* values, int64_t n_values) { if (n_values == 0) { return; } const int32_t* values_cursor = values; int64_t n_remaining = n_values; int64_t out_i_cursor = bitmap->size_bits; uint8_t* out_cursor = bitmap->buffer.data + bitmap->size_bits / 8; // First byte if ((out_i_cursor % 8) != 0) { int64_t n_partial_bits = _ArrowRoundUpToMultipleOf8(out_i_cursor) - out_i_cursor; for (int i = 0; i < n_partial_bits; i++) { ArrowBitSetTo(bitmap->buffer.data, out_i_cursor++, (uint8_t)values[i]); } out_cursor++; values_cursor += n_partial_bits; n_remaining -= n_partial_bits; } // Middle bytes int64_t n_full_bytes = n_remaining / 8; for (int64_t i = 0; i < n_full_bytes; i++) { _ArrowBitmapPackInt32(values_cursor, out_cursor); values_cursor += 8; out_cursor++; } // Last byte out_i_cursor += n_full_bytes * 8; n_remaining -= n_full_bytes * 8; if (n_remaining > 0) { // Zero out the last byte *out_cursor = 0x00; for (int i = 0; i < n_remaining; i++) { ArrowBitSetTo(bitmap->buffer.data, out_i_cursor++, (uint8_t)values_cursor[i]); } out_cursor++; } bitmap->size_bits += n_values; bitmap->buffer.size_bytes = out_cursor - bitmap->buffer.data; } static inline void ArrowBitmapReset(struct ArrowBitmap* bitmap) { ArrowBufferReset(&bitmap->buffer); bitmap->size_bits = 0; } #ifdef __cplusplus } #endif #endif // 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. #ifndef NANOARROW_ARRAY_INLINE_H_INCLUDED #define NANOARROW_ARRAY_INLINE_H_INCLUDED #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static inline struct ArrowBitmap* ArrowArrayValidityBitmap(struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; return &private_data->bitmap; } static inline struct ArrowBuffer* ArrowArrayBuffer(struct ArrowArray* array, int64_t i) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; switch (i) { case 0: return &private_data->bitmap.buffer; default: return private_data->buffers + i - 1; } } // We don't currently support the case of unions where type_id != child_index; // however, these functions are used to keep track of where that assumption // is made. static inline int8_t _ArrowArrayUnionChildIndex(struct ArrowArray* array, int8_t type_id) { NANOARROW_UNUSED(array); return type_id; } static inline int8_t _ArrowArrayUnionTypeId(struct ArrowArray* array, int8_t child_index) { NANOARROW_UNUSED(array); return child_index; } static inline int32_t _ArrowParseUnionTypeIds(const char* type_ids, int8_t* out) { if (*type_ids == '\0') { return 0; } int32_t i = 0; long type_id; char* end_ptr; do { type_id = strtol(type_ids, &end_ptr, 10); if (end_ptr == type_ids || type_id < 0 || type_id > 127) { return -1; } if (out != NULL) { out[i] = (int8_t)type_id; } i++; type_ids = end_ptr; if (*type_ids == '\0') { return i; } else if (*type_ids != ',') { return -1; } else { type_ids++; } } while (1); return -1; } static inline int8_t _ArrowParsedUnionTypeIdsWillEqualChildIndices(const int8_t* type_ids, int64_t n_type_ids, int64_t n_children) { if (n_type_ids != n_children) { return 0; } for (int8_t i = 0; i < n_type_ids; i++) { if (type_ids[i] != i) { return 0; } } return 1; } static inline int8_t _ArrowUnionTypeIdsWillEqualChildIndices(const char* type_id_str, int64_t n_children) { int8_t type_ids[128]; int32_t n_type_ids = _ArrowParseUnionTypeIds(type_id_str, type_ids); return _ArrowParsedUnionTypeIdsWillEqualChildIndices(type_ids, n_type_ids, n_children); } static inline ArrowErrorCode ArrowArrayStartAppending(struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; switch (private_data->storage_type) { case NANOARROW_TYPE_UNINITIALIZED: return EINVAL; case NANOARROW_TYPE_SPARSE_UNION: case NANOARROW_TYPE_DENSE_UNION: // Note that this value could be -1 if the type_ids string was invalid if (private_data->union_type_id_is_child_index != 1) { return EINVAL; } else { break; } default: break; } if (private_data->storage_type == NANOARROW_TYPE_UNINITIALIZED) { return EINVAL; } // Initialize any data offset buffer with a single zero for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { if (private_data->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_DATA_OFFSET && private_data->layout.element_size_bits[i] == 64) { NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt64(ArrowArrayBuffer(array, i), 0)); } else if (private_data->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_DATA_OFFSET && private_data->layout.element_size_bits[i] == 32) { NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(ArrowArrayBuffer(array, i), 0)); } } // Start building any child arrays or dictionaries for (int64_t i = 0; i < array->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowArrayStartAppending(array->children[i])); } if (array->dictionary != NULL) { NANOARROW_RETURN_NOT_OK(ArrowArrayStartAppending(array->dictionary)); } return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayShrinkToFit(struct ArrowArray* array) { for (int64_t i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { struct ArrowBuffer* buffer = ArrowArrayBuffer(array, i); NANOARROW_RETURN_NOT_OK(ArrowBufferResize(buffer, buffer->size_bytes, 1)); } for (int64_t i = 0; i < array->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowArrayShrinkToFit(array->children[i])); } if (array->dictionary != NULL) { NANOARROW_RETURN_NOT_OK(ArrowArrayShrinkToFit(array->dictionary)); } return NANOARROW_OK; } static inline ArrowErrorCode _ArrowArrayAppendBits(struct ArrowArray* array, int64_t buffer_i, uint8_t value, int64_t n) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; struct ArrowBuffer* buffer = ArrowArrayBuffer(array, buffer_i); int64_t bytes_required = _ArrowRoundUpToMultipleOf8(private_data->layout.element_size_bits[buffer_i] * (array->length + 1)) / 8; if (bytes_required > buffer->size_bytes) { NANOARROW_RETURN_NOT_OK( ArrowBufferAppendFill(buffer, 0, bytes_required - buffer->size_bytes)); } ArrowBitsSetTo(buffer->data, array->length, n, value); return NANOARROW_OK; } static inline ArrowErrorCode _ArrowArrayAppendEmptyInternal(struct ArrowArray* array, int64_t n, uint8_t is_valid) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; if (n == 0) { return NANOARROW_OK; } // Some type-specific handling switch (private_data->storage_type) { case NANOARROW_TYPE_NA: // (An empty value for a null array *is* a null) array->null_count += n; array->length += n; return NANOARROW_OK; case NANOARROW_TYPE_DENSE_UNION: { // Add one null to the first child and append n references to that child int8_t type_id = _ArrowArrayUnionTypeId(array, 0); NANOARROW_RETURN_NOT_OK( _ArrowArrayAppendEmptyInternal(array->children[0], 1, is_valid)); NANOARROW_RETURN_NOT_OK( ArrowBufferAppendFill(ArrowArrayBuffer(array, 0), type_id, n)); for (int64_t i = 0; i < n; i++) { NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32( ArrowArrayBuffer(array, 1), (int32_t)array->children[0]->length - 1)); } // For the purposes of array->null_count, union elements are never considered "null" // even if some children contain nulls. array->length += n; return NANOARROW_OK; } case NANOARROW_TYPE_SPARSE_UNION: { // Add n nulls to the first child and append n references to that child int8_t type_id = _ArrowArrayUnionTypeId(array, 0); NANOARROW_RETURN_NOT_OK( _ArrowArrayAppendEmptyInternal(array->children[0], n, is_valid)); for (int64_t i = 1; i < array->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowArrayAppendEmpty(array->children[i], n)); } NANOARROW_RETURN_NOT_OK( ArrowBufferAppendFill(ArrowArrayBuffer(array, 0), type_id, n)); // For the purposes of array->null_count, union elements are never considered "null" // even if some children contain nulls. array->length += n; return NANOARROW_OK; } case NANOARROW_TYPE_FIXED_SIZE_LIST: NANOARROW_RETURN_NOT_OK(ArrowArrayAppendEmpty( array->children[0], n * private_data->layout.child_size_elements)); break; case NANOARROW_TYPE_STRUCT: for (int64_t i = 0; i < array->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowArrayAppendEmpty(array->children[i], n)); } break; default: break; } // Append n is_valid bits to the validity bitmap. If we haven't allocated a bitmap yet // and we need to append nulls, do it now. if (!is_valid && private_data->bitmap.buffer.data == NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapReserve(&private_data->bitmap, array->length + n)); ArrowBitmapAppendUnsafe(&private_data->bitmap, 1, array->length); ArrowBitmapAppendUnsafe(&private_data->bitmap, is_valid, n); } else if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapReserve(&private_data->bitmap, n)); ArrowBitmapAppendUnsafe(&private_data->bitmap, is_valid, n); } // Add appropriate buffer fill struct ArrowBuffer* buffer; int64_t size_bytes; for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { buffer = ArrowArrayBuffer(array, i); size_bytes = private_data->layout.element_size_bits[i] / 8; switch (private_data->layout.buffer_type[i]) { case NANOARROW_BUFFER_TYPE_NONE: case NANOARROW_BUFFER_TYPE_VARIADIC_DATA: case NANOARROW_BUFFER_TYPE_VARIADIC_SIZE: case NANOARROW_BUFFER_TYPE_VALIDITY: continue; case NANOARROW_BUFFER_TYPE_DATA_OFFSET: // Append the current value at the end of the offset buffer for each element NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(buffer, size_bytes * n)); for (int64_t j = 0; j < n; j++) { ArrowBufferAppendUnsafe(buffer, buffer->data + size_bytes * (array->length + j), size_bytes); } // Skip the data buffer i++; continue; case NANOARROW_BUFFER_TYPE_DATA: // Zero out the next bit of memory if (private_data->layout.element_size_bits[i] % 8 == 0) { NANOARROW_RETURN_NOT_OK(ArrowBufferAppendFill(buffer, 0, size_bytes * n)); } else { NANOARROW_RETURN_NOT_OK(_ArrowArrayAppendBits(array, i, 0, n)); } continue; case NANOARROW_BUFFER_TYPE_TYPE_ID: case NANOARROW_BUFFER_TYPE_UNION_OFFSET: // These cases return above return EINVAL; } } array->length += n; array->null_count += n * !is_valid; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayAppendNull(struct ArrowArray* array, int64_t n) { return _ArrowArrayAppendEmptyInternal(array, n, 0); } static inline ArrowErrorCode ArrowArrayAppendEmpty(struct ArrowArray* array, int64_t n) { return _ArrowArrayAppendEmptyInternal(array, n, 1); } static inline ArrowErrorCode ArrowArrayAppendInt(struct ArrowArray* array, int64_t value) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; struct ArrowBuffer* data_buffer = ArrowArrayBuffer(array, 1); switch (private_data->storage_type) { case NANOARROW_TYPE_INT64: NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(data_buffer, &value, sizeof(int64_t))); break; case NANOARROW_TYPE_INT32: _NANOARROW_CHECK_RANGE(value, INT32_MIN, INT32_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(data_buffer, (int32_t)value)); break; case NANOARROW_TYPE_INT16: _NANOARROW_CHECK_RANGE(value, INT16_MIN, INT16_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt16(data_buffer, (int16_t)value)); break; case NANOARROW_TYPE_INT8: _NANOARROW_CHECK_RANGE(value, INT8_MIN, INT8_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt8(data_buffer, (int8_t)value)); break; case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_UINT8: _NANOARROW_CHECK_RANGE(value, 0, INT64_MAX); return ArrowArrayAppendUInt(array, value); case NANOARROW_TYPE_DOUBLE: NANOARROW_RETURN_NOT_OK(ArrowBufferAppendDouble(data_buffer, (double)value)); break; case NANOARROW_TYPE_FLOAT: NANOARROW_RETURN_NOT_OK(ArrowBufferAppendFloat(data_buffer, (float)value)); break; case NANOARROW_TYPE_HALF_FLOAT: NANOARROW_RETURN_NOT_OK( ArrowBufferAppendUInt16(data_buffer, ArrowFloatToHalfFloat((float)value))); break; case NANOARROW_TYPE_BOOL: NANOARROW_RETURN_NOT_OK(_ArrowArrayAppendBits(array, 1, value != 0, 1)); break; default: return EINVAL; } if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapAppend(ArrowArrayValidityBitmap(array), 1, 1)); } array->length++; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayAppendUInt(struct ArrowArray* array, uint64_t value) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; struct ArrowBuffer* data_buffer = ArrowArrayBuffer(array, 1); switch (private_data->storage_type) { case NANOARROW_TYPE_UINT64: NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(data_buffer, &value, sizeof(uint64_t))); break; case NANOARROW_TYPE_UINT32: _NANOARROW_CHECK_UPPER_LIMIT(value, UINT32_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendUInt32(data_buffer, (uint32_t)value)); break; case NANOARROW_TYPE_UINT16: _NANOARROW_CHECK_UPPER_LIMIT(value, UINT16_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendUInt16(data_buffer, (uint16_t)value)); break; case NANOARROW_TYPE_UINT8: _NANOARROW_CHECK_UPPER_LIMIT(value, UINT8_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendUInt8(data_buffer, (uint8_t)value)); break; case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_INT8: _NANOARROW_CHECK_UPPER_LIMIT(value, INT64_MAX); return ArrowArrayAppendInt(array, value); case NANOARROW_TYPE_DOUBLE: NANOARROW_RETURN_NOT_OK(ArrowBufferAppendDouble(data_buffer, (double)value)); break; case NANOARROW_TYPE_FLOAT: NANOARROW_RETURN_NOT_OK(ArrowBufferAppendFloat(data_buffer, (float)value)); break; case NANOARROW_TYPE_HALF_FLOAT: NANOARROW_RETURN_NOT_OK( ArrowBufferAppendUInt16(data_buffer, ArrowFloatToHalfFloat((float)value))); break; case NANOARROW_TYPE_BOOL: NANOARROW_RETURN_NOT_OK(_ArrowArrayAppendBits(array, 1, value != 0, 1)); break; default: return EINVAL; } if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapAppend(ArrowArrayValidityBitmap(array), 1, 1)); } array->length++; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayAppendDouble(struct ArrowArray* array, double value) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; struct ArrowBuffer* data_buffer = ArrowArrayBuffer(array, 1); switch (private_data->storage_type) { case NANOARROW_TYPE_DOUBLE: NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(data_buffer, &value, sizeof(double))); break; case NANOARROW_TYPE_FLOAT: NANOARROW_RETURN_NOT_OK(ArrowBufferAppendFloat(data_buffer, (float)value)); break; case NANOARROW_TYPE_HALF_FLOAT: NANOARROW_RETURN_NOT_OK( ArrowBufferAppendUInt16(data_buffer, ArrowFloatToHalfFloat((float)value))); break; default: return EINVAL; } if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapAppend(ArrowArrayValidityBitmap(array), 1, 1)); } array->length++; return NANOARROW_OK; } // Binary views only have two fixed buffers, but be aware that they must also // always have more 1 buffer to store variadic buffer sizes (even if there are none) #define NANOARROW_BINARY_VIEW_FIXED_BUFFERS 2 #define NANOARROW_BINARY_VIEW_INLINE_SIZE 12 #define NANOARROW_BINARY_VIEW_PREFIX_SIZE 4 #define NANOARROW_BINARY_VIEW_BLOCK_SIZE (32 << 10) // 32KB // The Arrow C++ implementation uses anonymous structs as members // of the ArrowBinaryView. For Cython support in this library, we define // those structs outside of the ArrowBinaryView struct ArrowBinaryViewInlined { int32_t size; uint8_t data[NANOARROW_BINARY_VIEW_INLINE_SIZE]; }; struct ArrowBinaryViewRef { int32_t size; uint8_t prefix[NANOARROW_BINARY_VIEW_PREFIX_SIZE]; int32_t buffer_index; int32_t offset; }; union ArrowBinaryView { struct ArrowBinaryViewInlined inlined; struct ArrowBinaryViewRef ref; int64_t alignment_dummy; }; static inline int32_t ArrowArrayVariadicBufferCount(struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; return private_data->n_variadic_buffers; } static inline ArrowErrorCode ArrowArrayAddVariadicBuffers(struct ArrowArray* array, int32_t nbuffers) { const int32_t n_current_bufs = ArrowArrayVariadicBufferCount(array); const int32_t nvariadic_bufs_needed = n_current_bufs + nbuffers; struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; private_data->variadic_buffers = (struct ArrowBuffer*)ArrowRealloc( private_data->variadic_buffers, sizeof(struct ArrowBuffer) * nvariadic_bufs_needed); if (private_data->variadic_buffers == NULL) { return ENOMEM; } private_data->variadic_buffer_sizes = (int64_t*)ArrowRealloc( private_data->variadic_buffer_sizes, sizeof(int64_t) * nvariadic_bufs_needed); if (private_data->variadic_buffer_sizes == NULL) { return ENOMEM; } for (int32_t i = n_current_bufs; i < nvariadic_bufs_needed; i++) { ArrowBufferInit(&private_data->variadic_buffers[i]); private_data->variadic_buffer_sizes[i] = 0; } private_data->n_variadic_buffers = nvariadic_bufs_needed; array->n_buffers = NANOARROW_BINARY_VIEW_FIXED_BUFFERS + 1 + nvariadic_bufs_needed; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayAppendBytes(struct ArrowArray* array, struct ArrowBufferView value) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; if (private_data->storage_type == NANOARROW_TYPE_STRING_VIEW || private_data->storage_type == NANOARROW_TYPE_BINARY_VIEW) { struct ArrowBuffer* data_buffer = ArrowArrayBuffer(array, 1); union ArrowBinaryView bvt; bvt.inlined.size = (int32_t)value.size_bytes; if (value.size_bytes <= NANOARROW_BINARY_VIEW_INLINE_SIZE) { memcpy(bvt.inlined.data, value.data.as_char, value.size_bytes); memset(bvt.inlined.data + bvt.inlined.size, 0, NANOARROW_BINARY_VIEW_INLINE_SIZE - bvt.inlined.size); } else { int32_t current_n_vbufs = ArrowArrayVariadicBufferCount(array); if (current_n_vbufs == 0 || private_data->variadic_buffers[current_n_vbufs - 1].size_bytes + value.size_bytes > NANOARROW_BINARY_VIEW_BLOCK_SIZE) { const int32_t additional_bufs_needed = 1; NANOARROW_RETURN_NOT_OK( ArrowArrayAddVariadicBuffers(array, additional_bufs_needed)); current_n_vbufs += additional_bufs_needed; } const int32_t buf_index = current_n_vbufs - 1; struct ArrowBuffer* variadic_buf = &private_data->variadic_buffers[buf_index]; memcpy(bvt.ref.prefix, value.data.as_char, NANOARROW_BINARY_VIEW_PREFIX_SIZE); bvt.ref.buffer_index = (int32_t)buf_index; bvt.ref.offset = (int32_t)variadic_buf->size_bytes; NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(variadic_buf, value.data.as_char, value.size_bytes)); private_data->variadic_buffer_sizes[buf_index] = variadic_buf->size_bytes; } NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(data_buffer, &bvt, sizeof(bvt))); } else { struct ArrowBuffer* offset_buffer = ArrowArrayBuffer(array, 1); struct ArrowBuffer* data_buffer = ArrowArrayBuffer( array, 1 + (private_data->storage_type != NANOARROW_TYPE_FIXED_SIZE_BINARY)); int32_t offset; int64_t large_offset; int64_t fixed_size_bytes = private_data->layout.element_size_bits[1] / 8; switch (private_data->storage_type) { case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_BINARY: offset = ((int32_t*)offset_buffer->data)[array->length]; if ((((int64_t)offset) + value.size_bytes) > INT32_MAX) { return EOVERFLOW; } offset += (int32_t)value.size_bytes; NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(offset_buffer, &offset, sizeof(int32_t))); NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(data_buffer, value.data.data, value.size_bytes)); break; case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_LARGE_BINARY: large_offset = ((int64_t*)offset_buffer->data)[array->length]; large_offset += value.size_bytes; NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(offset_buffer, &large_offset, sizeof(int64_t))); NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(data_buffer, value.data.data, value.size_bytes)); break; case NANOARROW_TYPE_FIXED_SIZE_BINARY: if (value.size_bytes != fixed_size_bytes) { return EINVAL; } NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(data_buffer, value.data.data, value.size_bytes)); break; default: return EINVAL; } } if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapAppend(ArrowArrayValidityBitmap(array), 1, 1)); } array->length++; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayAppendString(struct ArrowArray* array, struct ArrowStringView value) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; struct ArrowBufferView buffer_view; buffer_view.data.data = value.data; buffer_view.size_bytes = value.size_bytes; switch (private_data->storage_type) { case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_STRING_VIEW: case NANOARROW_TYPE_BINARY: case NANOARROW_TYPE_LARGE_BINARY: case NANOARROW_TYPE_BINARY_VIEW: return ArrowArrayAppendBytes(array, buffer_view); default: return EINVAL; } } static inline ArrowErrorCode ArrowArrayAppendInterval(struct ArrowArray* array, const struct ArrowInterval* value) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; struct ArrowBuffer* data_buffer = ArrowArrayBuffer(array, 1); switch (private_data->storage_type) { case NANOARROW_TYPE_INTERVAL_MONTHS: { if (value->type != NANOARROW_TYPE_INTERVAL_MONTHS) { return EINVAL; } NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(data_buffer, value->months)); break; } case NANOARROW_TYPE_INTERVAL_DAY_TIME: { if (value->type != NANOARROW_TYPE_INTERVAL_DAY_TIME) { return EINVAL; } NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(data_buffer, value->days)); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(data_buffer, value->ms)); break; } case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: { if (value->type != NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO) { return EINVAL; } NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(data_buffer, value->months)); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(data_buffer, value->days)); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt64(data_buffer, value->ns)); break; } default: return EINVAL; } if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapAppend(ArrowArrayValidityBitmap(array), 1, 1)); } array->length++; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayAppendDecimal(struct ArrowArray* array, const struct ArrowDecimal* value) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; struct ArrowBuffer* data_buffer = ArrowArrayBuffer(array, 1); switch (private_data->storage_type) { case NANOARROW_TYPE_DECIMAL128: if (value->n_words != 2) { return EINVAL; } else { NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(data_buffer, value->words, 2 * sizeof(uint64_t))); break; } case NANOARROW_TYPE_DECIMAL256: if (value->n_words != 4) { return EINVAL; } else { NANOARROW_RETURN_NOT_OK( ArrowBufferAppend(data_buffer, value->words, 4 * sizeof(uint64_t))); break; } default: return EINVAL; } if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapAppend(ArrowArrayValidityBitmap(array), 1, 1)); } array->length++; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayFinishElement(struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; int64_t child_length; switch (private_data->storage_type) { case NANOARROW_TYPE_LIST: case NANOARROW_TYPE_MAP: child_length = array->children[0]->length; if (child_length > INT32_MAX) { return EOVERFLOW; } NANOARROW_RETURN_NOT_OK( ArrowBufferAppendInt32(ArrowArrayBuffer(array, 1), (int32_t)child_length)); break; case NANOARROW_TYPE_LARGE_LIST: child_length = array->children[0]->length; NANOARROW_RETURN_NOT_OK( ArrowBufferAppendInt64(ArrowArrayBuffer(array, 1), child_length)); break; case NANOARROW_TYPE_FIXED_SIZE_LIST: child_length = array->children[0]->length; if (child_length != ((array->length + 1) * private_data->layout.child_size_elements)) { return EINVAL; } break; case NANOARROW_TYPE_STRUCT: for (int64_t i = 0; i < array->n_children; i++) { child_length = array->children[i]->length; if (child_length != (array->length + 1)) { return EINVAL; } } break; default: return EINVAL; } if (private_data->bitmap.buffer.data != NULL) { NANOARROW_RETURN_NOT_OK(ArrowBitmapAppend(ArrowArrayValidityBitmap(array), 1, 1)); } array->length++; return NANOARROW_OK; } static inline ArrowErrorCode ArrowArrayFinishUnionElement(struct ArrowArray* array, int8_t type_id) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; int64_t child_index = _ArrowArrayUnionChildIndex(array, type_id); if (child_index < 0 || child_index >= array->n_children) { return EINVAL; } switch (private_data->storage_type) { case NANOARROW_TYPE_DENSE_UNION: // Append the target child length to the union offsets buffer _NANOARROW_CHECK_RANGE(array->children[child_index]->length, 0, INT32_MAX); NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32( ArrowArrayBuffer(array, 1), (int32_t)array->children[child_index]->length - 1)); break; case NANOARROW_TYPE_SPARSE_UNION: // Append one empty to any non-target column that isn't already the right length // or abort if appending a null will result in a column with invalid length for (int64_t i = 0; i < array->n_children; i++) { if (i == child_index || array->children[i]->length == (array->length + 1)) { continue; } if (array->children[i]->length != array->length) { return EINVAL; } NANOARROW_RETURN_NOT_OK(ArrowArrayAppendEmpty(array->children[i], 1)); } break; default: return EINVAL; } // Write to the type_ids buffer NANOARROW_RETURN_NOT_OK( ArrowBufferAppendInt8(ArrowArrayBuffer(array, 0), (int8_t)type_id)); array->length++; return NANOARROW_OK; } static inline void ArrowArrayViewMove(struct ArrowArrayView* src, struct ArrowArrayView* dst) { memcpy(dst, src, sizeof(struct ArrowArrayView)); ArrowArrayViewInitFromType(src, NANOARROW_TYPE_UNINITIALIZED); } static inline int64_t ArrowArrayViewGetNumBuffers(struct ArrowArrayView* array_view) { switch (array_view->storage_type) { case NANOARROW_TYPE_BINARY_VIEW: case NANOARROW_TYPE_STRING_VIEW: return NANOARROW_BINARY_VIEW_FIXED_BUFFERS + array_view->n_variadic_buffers + 1; default: break; } int64_t n_buffers = 0; for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { if (array_view->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_NONE) { break; } n_buffers++; } return n_buffers; } static inline struct ArrowBufferView ArrowArrayViewGetBufferView( struct ArrowArrayView* array_view, int64_t i) { switch (array_view->storage_type) { case NANOARROW_TYPE_BINARY_VIEW: case NANOARROW_TYPE_STRING_VIEW: if (i < NANOARROW_BINARY_VIEW_FIXED_BUFFERS) { return array_view->buffer_views[i]; } else if (i >= (array_view->n_variadic_buffers + NANOARROW_BINARY_VIEW_FIXED_BUFFERS)) { struct ArrowBufferView view; view.data.as_int64 = array_view->variadic_buffer_sizes; view.size_bytes = array_view->n_variadic_buffers * sizeof(double); return view; } else { struct ArrowBufferView view; view.data.data = array_view->variadic_buffers[i - NANOARROW_BINARY_VIEW_FIXED_BUFFERS]; view.size_bytes = array_view->variadic_buffer_sizes[i - NANOARROW_BINARY_VIEW_FIXED_BUFFERS]; return view; } default: // We need this check to avoid -Warray-bounds from complaining if (i >= NANOARROW_MAX_FIXED_BUFFERS) { struct ArrowBufferView view; view.data.data = NULL; view.size_bytes = 0; return view; } else { return array_view->buffer_views[i]; } } } enum ArrowBufferType ArrowArrayViewGetBufferType(struct ArrowArrayView* array_view, int64_t i) { switch (array_view->storage_type) { case NANOARROW_TYPE_BINARY_VIEW: case NANOARROW_TYPE_STRING_VIEW: if (i < NANOARROW_BINARY_VIEW_FIXED_BUFFERS) { return array_view->layout.buffer_type[i]; } else if (i == (array_view->n_variadic_buffers + NANOARROW_BINARY_VIEW_FIXED_BUFFERS)) { return NANOARROW_BUFFER_TYPE_VARIADIC_SIZE; } else { return NANOARROW_BUFFER_TYPE_VARIADIC_DATA; } default: // We need this check to avoid -Warray-bounds from complaining if (i >= NANOARROW_MAX_FIXED_BUFFERS) { return NANOARROW_BUFFER_TYPE_NONE; } else { return array_view->layout.buffer_type[i]; } } } static inline enum ArrowType ArrowArrayViewGetBufferDataType( struct ArrowArrayView* array_view, int64_t i) { switch (array_view->storage_type) { case NANOARROW_TYPE_BINARY_VIEW: case NANOARROW_TYPE_STRING_VIEW: if (i < NANOARROW_BINARY_VIEW_FIXED_BUFFERS) { return array_view->layout.buffer_data_type[i]; } else if (i >= (array_view->n_variadic_buffers + NANOARROW_BINARY_VIEW_FIXED_BUFFERS)) { return NANOARROW_TYPE_INT64; } else if (array_view->storage_type == NANOARROW_TYPE_BINARY_VIEW) { return NANOARROW_TYPE_BINARY; } else { return NANOARROW_TYPE_STRING; } default: // We need this check to avoid -Warray-bounds from complaining if (i >= NANOARROW_MAX_FIXED_BUFFERS) { return NANOARROW_TYPE_UNINITIALIZED; } else { return array_view->layout.buffer_data_type[i]; } } } static inline int64_t ArrowArrayViewGetBufferElementSizeBits( struct ArrowArrayView* array_view, int64_t i) { switch (array_view->storage_type) { case NANOARROW_TYPE_BINARY_VIEW: case NANOARROW_TYPE_STRING_VIEW: if (i < NANOARROW_BINARY_VIEW_FIXED_BUFFERS) { return array_view->layout.element_size_bits[i]; } else if (i >= (array_view->n_variadic_buffers + NANOARROW_BINARY_VIEW_FIXED_BUFFERS)) { return sizeof(int64_t) * 8; } else { return 0; } default: // We need this check to avoid -Warray-bounds from complaining if (i >= NANOARROW_MAX_FIXED_BUFFERS) { return 0; } else { return array_view->layout.element_size_bits[i]; } } } static inline int8_t ArrowArrayViewIsNull(const struct ArrowArrayView* array_view, int64_t i) { const uint8_t* validity_buffer = array_view->buffer_views[0].data.as_uint8; i += array_view->offset; switch (array_view->storage_type) { case NANOARROW_TYPE_NA: return 0x01; case NANOARROW_TYPE_DENSE_UNION: case NANOARROW_TYPE_SPARSE_UNION: // Unions are "never null" in Arrow land return 0x00; default: return validity_buffer != NULL && !ArrowBitGet(validity_buffer, i); } } static inline int64_t ArrowArrayViewComputeNullCount( const struct ArrowArrayView* array_view) { if (array_view->length == 0) { return 0; } switch (array_view->storage_type) { case NANOARROW_TYPE_NA: return array_view->length; case NANOARROW_TYPE_DENSE_UNION: case NANOARROW_TYPE_SPARSE_UNION: // Unions are "never null" in Arrow land return 0; default: break; } const uint8_t* validity_buffer = array_view->buffer_views[0].data.as_uint8; if (validity_buffer == NULL) { return 0; } return array_view->length - ArrowBitCountSet(validity_buffer, array_view->offset, array_view->length); } static inline int8_t ArrowArrayViewUnionTypeId(const struct ArrowArrayView* array_view, int64_t i) { switch (array_view->storage_type) { case NANOARROW_TYPE_DENSE_UNION: case NANOARROW_TYPE_SPARSE_UNION: return array_view->buffer_views[0].data.as_int8[array_view->offset + i]; default: return -1; } } static inline int8_t ArrowArrayViewUnionChildIndex( const struct ArrowArrayView* array_view, int64_t i) { int8_t type_id = ArrowArrayViewUnionTypeId(array_view, i); if (array_view->union_type_id_map == NULL) { return type_id; } else { return array_view->union_type_id_map[type_id]; } } static inline int64_t ArrowArrayViewUnionChildOffset( const struct ArrowArrayView* array_view, int64_t i) { switch (array_view->storage_type) { case NANOARROW_TYPE_DENSE_UNION: return array_view->buffer_views[1].data.as_int32[array_view->offset + i]; case NANOARROW_TYPE_SPARSE_UNION: return array_view->offset + i; default: return -1; } } static inline int64_t ArrowArrayViewListChildOffset( const struct ArrowArrayView* array_view, int64_t i) { switch (array_view->storage_type) { case NANOARROW_TYPE_LIST: return array_view->buffer_views[1].data.as_int32[i]; case NANOARROW_TYPE_LARGE_LIST: return array_view->buffer_views[1].data.as_int64[i]; default: return -1; } } static struct ArrowBufferView ArrowArrayViewGetBytesFromViewArrayUnsafe( const struct ArrowArrayView* array_view, int64_t i) { const union ArrowBinaryView* bv = &array_view->buffer_views[1].data.as_binary_view[i]; struct ArrowBufferView out = {{NULL}, bv->inlined.size}; if (bv->inlined.size <= NANOARROW_BINARY_VIEW_INLINE_SIZE) { out.data.as_uint8 = bv->inlined.data; return out; } out.data.data = array_view->variadic_buffers[bv->ref.buffer_index]; out.data.as_uint8 += bv->ref.offset; return out; } static inline int64_t ArrowArrayViewGetIntUnsafe(const struct ArrowArrayView* array_view, int64_t i) { const struct ArrowBufferView* data_view = &array_view->buffer_views[1]; i += array_view->offset; switch (array_view->storage_type) { case NANOARROW_TYPE_INT64: return data_view->data.as_int64[i]; case NANOARROW_TYPE_UINT64: return data_view->data.as_uint64[i]; case NANOARROW_TYPE_INTERVAL_MONTHS: case NANOARROW_TYPE_INT32: return data_view->data.as_int32[i]; case NANOARROW_TYPE_UINT32: return data_view->data.as_uint32[i]; case NANOARROW_TYPE_INT16: return data_view->data.as_int16[i]; case NANOARROW_TYPE_UINT16: return data_view->data.as_uint16[i]; case NANOARROW_TYPE_INT8: return data_view->data.as_int8[i]; case NANOARROW_TYPE_UINT8: return data_view->data.as_uint8[i]; case NANOARROW_TYPE_DOUBLE: return (int64_t)data_view->data.as_double[i]; case NANOARROW_TYPE_FLOAT: return (int64_t)data_view->data.as_float[i]; case NANOARROW_TYPE_HALF_FLOAT: return (int64_t)ArrowHalfFloatToFloat(data_view->data.as_uint16[i]); case NANOARROW_TYPE_BOOL: return ArrowBitGet(data_view->data.as_uint8, i); default: return INT64_MAX; } } static inline uint64_t ArrowArrayViewGetUIntUnsafe( const struct ArrowArrayView* array_view, int64_t i) { i += array_view->offset; const struct ArrowBufferView* data_view = &array_view->buffer_views[1]; switch (array_view->storage_type) { case NANOARROW_TYPE_INT64: return data_view->data.as_int64[i]; case NANOARROW_TYPE_UINT64: return data_view->data.as_uint64[i]; case NANOARROW_TYPE_INTERVAL_MONTHS: case NANOARROW_TYPE_INT32: return data_view->data.as_int32[i]; case NANOARROW_TYPE_UINT32: return data_view->data.as_uint32[i]; case NANOARROW_TYPE_INT16: return data_view->data.as_int16[i]; case NANOARROW_TYPE_UINT16: return data_view->data.as_uint16[i]; case NANOARROW_TYPE_INT8: return data_view->data.as_int8[i]; case NANOARROW_TYPE_UINT8: return data_view->data.as_uint8[i]; case NANOARROW_TYPE_DOUBLE: return (uint64_t)data_view->data.as_double[i]; case NANOARROW_TYPE_FLOAT: return (uint64_t)data_view->data.as_float[i]; case NANOARROW_TYPE_HALF_FLOAT: return (uint64_t)ArrowHalfFloatToFloat(data_view->data.as_uint16[i]); case NANOARROW_TYPE_BOOL: return ArrowBitGet(data_view->data.as_uint8, i); default: return UINT64_MAX; } } static inline double ArrowArrayViewGetDoubleUnsafe( const struct ArrowArrayView* array_view, int64_t i) { i += array_view->offset; const struct ArrowBufferView* data_view = &array_view->buffer_views[1]; switch (array_view->storage_type) { case NANOARROW_TYPE_INT64: return (double)data_view->data.as_int64[i]; case NANOARROW_TYPE_UINT64: return (double)data_view->data.as_uint64[i]; case NANOARROW_TYPE_INT32: return data_view->data.as_int32[i]; case NANOARROW_TYPE_UINT32: return data_view->data.as_uint32[i]; case NANOARROW_TYPE_INT16: return data_view->data.as_int16[i]; case NANOARROW_TYPE_UINT16: return data_view->data.as_uint16[i]; case NANOARROW_TYPE_INT8: return data_view->data.as_int8[i]; case NANOARROW_TYPE_UINT8: return data_view->data.as_uint8[i]; case NANOARROW_TYPE_DOUBLE: return data_view->data.as_double[i]; case NANOARROW_TYPE_FLOAT: return data_view->data.as_float[i]; case NANOARROW_TYPE_HALF_FLOAT: return ArrowHalfFloatToFloat(data_view->data.as_uint16[i]); case NANOARROW_TYPE_BOOL: return ArrowBitGet(data_view->data.as_uint8, i); default: return DBL_MAX; } } static inline struct ArrowStringView ArrowArrayViewGetStringUnsafe( const struct ArrowArrayView* array_view, int64_t i) { i += array_view->offset; const struct ArrowBufferView* offsets_view = &array_view->buffer_views[1]; const char* data_view = array_view->buffer_views[2].data.as_char; struct ArrowStringView view; switch (array_view->storage_type) { case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_BINARY: view.data = data_view + offsets_view->data.as_int32[i]; view.size_bytes = offsets_view->data.as_int32[i + 1] - offsets_view->data.as_int32[i]; break; case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_LARGE_BINARY: view.data = data_view + offsets_view->data.as_int64[i]; view.size_bytes = offsets_view->data.as_int64[i + 1] - offsets_view->data.as_int64[i]; break; case NANOARROW_TYPE_FIXED_SIZE_BINARY: view.size_bytes = array_view->layout.element_size_bits[1] / 8; view.data = array_view->buffer_views[1].data.as_char + (i * view.size_bytes); break; case NANOARROW_TYPE_STRING_VIEW: case NANOARROW_TYPE_BINARY_VIEW: { struct ArrowBufferView buf_view = ArrowArrayViewGetBytesFromViewArrayUnsafe(array_view, i); view.data = buf_view.data.as_char; view.size_bytes = buf_view.size_bytes; break; } default: view.data = NULL; view.size_bytes = 0; break; } return view; } static inline struct ArrowBufferView ArrowArrayViewGetBytesUnsafe( const struct ArrowArrayView* array_view, int64_t i) { i += array_view->offset; const struct ArrowBufferView* offsets_view = &array_view->buffer_views[1]; const uint8_t* data_view = array_view->buffer_views[2].data.as_uint8; struct ArrowBufferView view; switch (array_view->storage_type) { case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_BINARY: view.size_bytes = offsets_view->data.as_int32[i + 1] - offsets_view->data.as_int32[i]; view.data.as_uint8 = data_view + offsets_view->data.as_int32[i]; break; case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_LARGE_BINARY: view.size_bytes = offsets_view->data.as_int64[i + 1] - offsets_view->data.as_int64[i]; view.data.as_uint8 = data_view + offsets_view->data.as_int64[i]; break; case NANOARROW_TYPE_FIXED_SIZE_BINARY: view.size_bytes = array_view->layout.element_size_bits[1] / 8; view.data.as_uint8 = array_view->buffer_views[1].data.as_uint8 + (i * view.size_bytes); break; case NANOARROW_TYPE_STRING_VIEW: case NANOARROW_TYPE_BINARY_VIEW: view = ArrowArrayViewGetBytesFromViewArrayUnsafe(array_view, i); break; default: view.data.data = NULL; view.size_bytes = 0; break; } return view; } static inline void ArrowArrayViewGetIntervalUnsafe( const struct ArrowArrayView* array_view, int64_t i, struct ArrowInterval* out) { const uint8_t* data_view = array_view->buffer_views[1].data.as_uint8; switch (array_view->storage_type) { case NANOARROW_TYPE_INTERVAL_MONTHS: { const size_t size = sizeof(int32_t); memcpy(&out->months, data_view + i * size, sizeof(int32_t)); break; } case NANOARROW_TYPE_INTERVAL_DAY_TIME: { const size_t size = sizeof(int32_t) + sizeof(int32_t); memcpy(&out->days, data_view + i * size, sizeof(int32_t)); memcpy(&out->ms, data_view + i * size + 4, sizeof(int32_t)); break; } case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: { const size_t size = sizeof(int32_t) + sizeof(int32_t) + sizeof(int64_t); memcpy(&out->months, data_view + i * size, sizeof(int32_t)); memcpy(&out->days, data_view + i * size + 4, sizeof(int32_t)); memcpy(&out->ns, data_view + i * size + 8, sizeof(int64_t)); break; } default: break; } } static inline void ArrowArrayViewGetDecimalUnsafe(const struct ArrowArrayView* array_view, int64_t i, struct ArrowDecimal* out) { i += array_view->offset; const uint8_t* data_view = array_view->buffer_views[1].data.as_uint8; switch (array_view->storage_type) { case NANOARROW_TYPE_DECIMAL128: ArrowDecimalSetBytes(out, data_view + (i * 16)); break; case NANOARROW_TYPE_DECIMAL256: ArrowDecimalSetBytes(out, data_view + (i * 32)); break; default: memset(out->words, 0, sizeof(out->words)); break; } } #ifdef __cplusplus } #endif #endif nanoarrow/src/materialize_common.h0000644000176200001440000000700414643132461017103 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_COMMON_H_INCLUDED #define R_MATERIALIZE_COMMON_H_INCLUDED #include #include #include "nanoarrow.h" #include "util.h" // Vector types that have some special casing internally to avoid unnecessary allocations // or looping at the R level. Some of these types also need an SEXP ptype to communicate // additional information. enum VectorType { VECTOR_TYPE_UNINITIALIZED, VECTOR_TYPE_NULL, VECTOR_TYPE_UNSPECIFIED, VECTOR_TYPE_LGL, VECTOR_TYPE_INT, VECTOR_TYPE_DBL, VECTOR_TYPE_ALTREP_CHR, VECTOR_TYPE_CHR, VECTOR_TYPE_POSIXCT, VECTOR_TYPE_DATE, VECTOR_TYPE_DIFFTIME, VECTOR_TYPE_INTEGER64, VECTOR_TYPE_BLOB, VECTOR_TYPE_LIST_OF, VECTOR_TYPE_DATA_FRAME, VECTOR_TYPE_OTHER }; // More easily switch()able version of attr(difftime_obj, "units") enum RTimeUnits { R_TIME_UNIT_SECONDS, R_TIME_UNIT_MINUTES, R_TIME_UNIT_HOURS, R_TIME_UNIT_DAYS, R_TIME_UNIT_WEEKS }; // A "parsed" version of an SEXP ptype (like a SchemaView but for // R objects)) struct PTypeView { enum VectorType vector_type; int sexp_type; enum RTimeUnits r_time_units; SEXP ptype; }; // A wrapper around the ArrayView with an additional offset + length // representing a source of a materialization struct ArrayViewSlice { struct ArrowArrayView* array_view; int64_t offset; int64_t length; }; // A wapper around an SEXP vector with an additional offset + length. // This can be both a source and/or a target for copying from/to. struct VectorSlice { SEXP vec_sexp; R_xlen_t offset; R_xlen_t length; }; // Options for resolving a ptype and for materializing values. These are // currently unused but this struct is a placeholder for them when they // are implemented. struct MaterializeOptions { double scale; }; // A house for a conversion operation (i.e., zero or more arrays // getting converted into an R vector)). The structure of this // may change in the future but the API below should be relatively stable. // This is typically accessed via the external pointer whose API is defined // in convert.h struct RConverter { struct PTypeView ptype_view; struct ArrowSchemaView schema_view; struct ArrowArrayView array_view; struct ArrayViewSlice src; struct VectorSlice dst; struct MaterializeOptions* options; struct ArrowError error; R_xlen_t size; R_xlen_t capacity; R_xlen_t n_children; struct RConverter** children; }; static inline void warn_lossy_conversion(int64_t count, const char* msg) { SEXP fun = PROTECT(Rf_install("warn_lossy_conversion")); SEXP count_sexp = PROTECT(Rf_ScalarReal((double)count)); SEXP msg_sexp = PROTECT(Rf_mkString(msg)); SEXP call = PROTECT(Rf_lang3(fun, count_sexp, msg_sexp)); Rf_eval(call, nanoarrow_ns_pkg); UNPROTECT(4); } #endif nanoarrow/src/schema.h0000644000176200001440000000362714547575511014506 0ustar liggesusers// 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. #ifndef R_NANOARROW_SCHEMA_H_INCLUDED #define R_NANOARROW_SCHEMA_H_INCLUDED #include #include #include #include "nanoarrow.h" #include "util.h" // Returns an external pointer to a schema child. The returned pointer will keep its // parent alive: this is typically what you want when printing or performing a conversion, // where the borrowed external pointer is ephemeral. SEXP borrow_schema_child_xptr(SEXP schema_xptr, int64_t i); // Returns the underlying struct ArrowSchema* from an external pointer, // checking and erroring for invalid objects, pointers, and arrays, but // allowing for R_NilValue to signify a NULL return. static inline struct ArrowSchema* nullable_schema_from_xptr(SEXP schema_xptr) { if (schema_xptr == R_NilValue) { return NULL; } else { return nanoarrow_schema_from_xptr(schema_xptr); } } static inline void schema_export(SEXP schema_xptr, struct ArrowSchema* schema_copy) { int result = ArrowSchemaDeepCopy(nanoarrow_schema_from_xptr(schema_xptr), schema_copy); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaDeepCopy() failed"); } } #endif nanoarrow/src/convert.h0000644000176200001440000000534614502402562014710 0ustar liggesusers// 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. #ifndef R_CONVERT_H_INCLUDED #define R_CONVERT_H_INCLUDED #include #include #include "nanoarrow.h" #include "materialize.h" // Create and initialize a converter. A converter's output R vector type // never changes once it has been created. SEXP nanoarrow_converter_from_type(enum VectorType vector_type); SEXP nanoarrow_converter_from_ptype(SEXP ptype); // Set the schema for the next array that will be materialized into // the R vector. In theory this could change although this has not been // implemented. This will also validate the schema. Returns an errno code. int nanoarrow_converter_set_schema(SEXP converter_xptr, SEXP schema_xptr); // Set the array target. This will also validate the array against the last // schema that was set. Returns an errno code. int nanoarrow_converter_set_array(SEXP converter_xptr, SEXP array_xptr); // Reserve space in the R vector output for additional elements. In theory // this could be used to provide growable behaviour; however, this is not // implemented. Returns an errno code. int nanoarrow_converter_reserve(SEXP converter_xptr, R_xlen_t additional_size); // Materialize the next n elements into the output. Returns the number of elements // that were actually materialized which may be less than n. R_xlen_t nanoarrow_converter_materialize_n(SEXP converter_xptr, R_xlen_t n); // Materialize the entire array into the output. Returns an errno code. int nanoarrow_converter_materialize_all(SEXP converter_xptr); // Finalize the output. Currently this just validates the length of the // output. Returns an errno code. int nanoarrow_converter_finalize(SEXP converter_xptr); // Returns the resulting SEXP and moves the result out of the protection // of the converter. SEXP nanoarrow_converter_release_result(SEXP converter_xptr); // Calls Rf_error() with the internal error buffer populated by above calls // that return a non-zero errno value. void nanoarrow_converter_stop(SEXP converter_xptr); #endif nanoarrow/src/util.h0000644000176200001440000000464714672714403014220 0ustar liggesusers// 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. #ifndef R_UTIL_H_INCLUDED #define R_UTIL_H_INCLUDED #include #include #include extern SEXP nanoarrow_ns_pkg; extern SEXP nanoarrow_cls_array; extern SEXP nanoarrow_cls_altrep_chr; extern SEXP nanoarrow_cls_array_view; extern SEXP nanoarrow_cls_data_frame; extern SEXP nanoarrow_cls_schema; extern SEXP nanoarrow_cls_array_stream; extern SEXP nanoarrow_cls_buffer; extern SEXP nanoarrow_sym_readbin; extern SEXP nanoarrow_sym_writebin; extern SEXP nanoarrow_ptype_raw; void nanoarrow_init_cached_sexps(void); // Internal abstractions for R_PreserveObject and R_ReleaseObject // that provide an opportunity for debugging information about // preserved object lifecycle and possible future optimizations. // These implementations use C++ and live in nanoarrow_cpp.cc void nanoarrow_preserve_init(void); void nanoarrow_preserve_sexp(SEXP obj); void nanoarrow_release_sexp(SEXP obj); int64_t nanoarrow_preserved_count(void); int64_t nanoarrow_preserved_empty(void); int nanoarrow_is_main_thread(void); // For testing void nanoarrow_preserve_and_release_on_other_thread(SEXP obj); // Checker for very small mallocs() static inline void check_trivial_alloc(const void* ptr, const char* ptr_type) { if (ptr == NULL) { Rf_error("ArrowMalloc(sizeof(%s)) failed", ptr_type); // # nocov } } // So that lengths >INT_MAX do not overflow an INTSXP. Most places // in R return an integer length except for lengths where this is not // possible. static inline SEXP length_sexp_from_int64(int64_t value) { if (value < INT_MAX) { return Rf_ScalarInteger((int)value); } else { return Rf_ScalarReal((double)value); } } #endif nanoarrow/src/ipc.c0000644000176200001440000002442714672714403014007 0ustar liggesusers// 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 #define R_NO_REMAP #include #include #include "nanoarrow_ipc.h" #include "buffer.h" #include "nanoarrow/r.h" #include "util.h" static void finalize_input_stream_xptr(SEXP input_stream_xptr) { struct ArrowIpcInputStream* input_stream = (struct ArrowIpcInputStream*)R_ExternalPtrAddr(input_stream_xptr); if (input_stream != NULL && input_stream->release != NULL) { input_stream->release(input_stream); } if (input_stream != NULL) { ArrowFree(input_stream); } } static SEXP input_stream_owning_xptr(void) { struct ArrowIpcInputStream* input_stream = (struct ArrowIpcInputStream*)ArrowMalloc(sizeof(struct ArrowIpcInputStream)); input_stream->release = NULL; SEXP input_stream_xptr = PROTECT(R_MakeExternalPtr(input_stream, R_NilValue, R_NilValue)); R_RegisterCFinalizer(input_stream_xptr, &finalize_input_stream_xptr); UNPROTECT(1); return input_stream_xptr; } static void finalize_output_stream_xptr(SEXP output_stream_xptr) { struct ArrowIpcOutputStream* output_stream = (struct ArrowIpcOutputStream*)R_ExternalPtrAddr(output_stream_xptr); if (output_stream != NULL && output_stream->release != NULL) { output_stream->release(output_stream); } if (output_stream != NULL) { ArrowFree(output_stream); } } static SEXP output_stream_owning_xptr(void) { struct ArrowIpcOutputStream* output_stream = (struct ArrowIpcOutputStream*)ArrowMalloc(sizeof(struct ArrowIpcOutputStream)); output_stream->release = NULL; SEXP output_stream_xptr = PROTECT(R_MakeExternalPtr(output_stream, R_NilValue, R_NilValue)); R_RegisterCFinalizer(output_stream_xptr, &finalize_output_stream_xptr); UNPROTECT(1); return output_stream_xptr; } static void finalize_writer_xptr(SEXP writer_xptr) { struct ArrowIpcWriter* writer = (struct ArrowIpcWriter*)R_ExternalPtrAddr(writer_xptr); if (writer != NULL && writer->private_data != NULL) { ArrowIpcWriterReset(writer); } if (writer != NULL) { ArrowFree(writer); } } static SEXP writer_owning_xptr(void) { struct ArrowIpcWriter* writer = (struct ArrowIpcWriter*)ArrowMalloc(sizeof(struct ArrowIpcWriter)); writer->private_data = NULL; SEXP writer_xptr = PROTECT(R_MakeExternalPtr(writer, R_NilValue, R_NilValue)); R_RegisterCFinalizer(writer_xptr, &finalize_writer_xptr); UNPROTECT(1); return writer_xptr; } SEXP nanoarrow_c_ipc_array_reader_buffer(SEXP buffer_xptr) { struct ArrowBuffer* buffer = buffer_from_xptr(buffer_xptr); SEXP array_stream_xptr = PROTECT(nanoarrow_array_stream_owning_xptr()); struct ArrowArrayStream* array_stream = nanoarrow_output_array_stream_from_xptr(array_stream_xptr); SEXP input_stream_xptr = PROTECT(input_stream_owning_xptr()); struct ArrowIpcInputStream* input_stream = (struct ArrowIpcInputStream*)R_ExternalPtrAddr(input_stream_xptr); int code = ArrowIpcInputStreamInitBuffer(input_stream, buffer); if (code != NANOARROW_OK) { Rf_error("ArrowIpcInputStreamInitBuffer() failed"); } code = ArrowIpcArrayStreamReaderInit(array_stream, input_stream, NULL); if (code != NANOARROW_OK) { Rf_error("ArrowIpcArrayStreamReaderInit() failed"); } UNPROTECT(2); return array_stream_xptr; } struct ConnectionInputStreamHandler { SEXP con; uint8_t* buf; int64_t buf_size_bytes; int64_t* size_read_out; struct ArrowError* error; int return_code; }; static SEXP handle_readbin_writebin_error(SEXP cond, void* hdata) { struct ConnectionInputStreamHandler* data = (struct ConnectionInputStreamHandler*)hdata; SEXP fun = PROTECT(Rf_install("conditionMessage")); SEXP call = PROTECT(Rf_lang2(fun, cond)); SEXP result = PROTECT(Rf_eval(call, R_BaseEnv)); SEXP result0 = STRING_ELT(result, 0); const char* cond_msg = Rf_translateCharUTF8(result0); ArrowErrorSet(data->error, "R execution error: %s", cond_msg); data->return_code = EIO; UNPROTECT(3); return R_NilValue; } static SEXP call_readbin(void* hdata) { struct ConnectionInputStreamHandler* data = (struct ConnectionInputStreamHandler*)hdata; SEXP n = PROTECT(Rf_ScalarReal((double)data->buf_size_bytes)); SEXP call = PROTECT(Rf_lang4(nanoarrow_sym_readbin, data->con, nanoarrow_ptype_raw, n)); SEXP result = PROTECT(Rf_eval(call, nanoarrow_ns_pkg)); R_xlen_t bytes_read = Rf_xlength(result); memcpy(data->buf, RAW(result), bytes_read); *(data->size_read_out) = bytes_read; UNPROTECT(3); return R_NilValue; } static SEXP call_writebin(void* hdata) { struct ConnectionInputStreamHandler* data = (struct ConnectionInputStreamHandler*)hdata; // Write 16MB chunks. This a balance between being small enough not to // copy too much of the source unnecessarily and big enough to avoid // unnecessary R evaluation overhead. int64_t chunk_buffer_size = 16777216; SEXP chunk_buffer = PROTECT(Rf_allocVector(RAWSXP, chunk_buffer_size)); SEXP call = PROTECT(Rf_lang3(nanoarrow_sym_writebin, chunk_buffer, data->con)); while (data->buf_size_bytes > chunk_buffer_size) { memcpy(RAW(chunk_buffer), data->buf, chunk_buffer_size); Rf_eval(call, nanoarrow_ns_pkg); data->buf_size_bytes -= chunk_buffer_size; data->buf += chunk_buffer_size; } UNPROTECT(2); // Write remaining bytes if (data->buf_size_bytes > 0) { chunk_buffer = PROTECT(Rf_allocVector(RAWSXP, data->buf_size_bytes)); call = PROTECT(Rf_lang3(nanoarrow_sym_writebin, chunk_buffer, data->con)); memcpy(RAW(chunk_buffer), data->buf, data->buf_size_bytes); Rf_eval(call, nanoarrow_ns_pkg); UNPROTECT(2); } return R_NilValue; } static ArrowErrorCode read_con_input_stream(struct ArrowIpcInputStream* stream, uint8_t* buf, int64_t buf_size_bytes, int64_t* size_read_out, struct ArrowError* error) { if (!nanoarrow_is_main_thread()) { ArrowErrorSet(error, "Can't read from R connection on a non-R thread"); return EIO; } struct ConnectionInputStreamHandler data; data.con = (SEXP)stream->private_data; data.buf = buf; data.buf_size_bytes = buf_size_bytes; data.size_read_out = size_read_out; data.error = error; data.return_code = NANOARROW_OK; R_tryCatchError(&call_readbin, &data, &handle_readbin_writebin_error, &data); return data.return_code; } static ArrowErrorCode write_con_output_stream(struct ArrowIpcOutputStream* stream, const void* buf, int64_t buf_size_bytes, int64_t* size_write_out, struct ArrowError* error) { if (!nanoarrow_is_main_thread()) { ArrowErrorSet(error, "Can't read from R connection on a non-R thread"); return EIO; } struct ConnectionInputStreamHandler data; data.con = (SEXP)stream->private_data; data.buf = (void*)buf; data.buf_size_bytes = buf_size_bytes; data.size_read_out = NULL; data.error = error; data.return_code = NANOARROW_OK; R_tryCatchError(&call_writebin, &data, &handle_readbin_writebin_error, &data); // This implementation always blocks until all bytes have been written *size_write_out = buf_size_bytes; return data.return_code; } static void release_con_input_stream(struct ArrowIpcInputStream* stream) { nanoarrow_release_sexp((SEXP)stream->private_data); } static void release_con_output_stream(struct ArrowIpcOutputStream* stream) { nanoarrow_release_sexp((SEXP)stream->private_data); } SEXP nanoarrow_c_ipc_array_reader_connection(SEXP con) { SEXP array_stream_xptr = PROTECT(nanoarrow_array_stream_owning_xptr()); struct ArrowArrayStream* array_stream = nanoarrow_output_array_stream_from_xptr(array_stream_xptr); SEXP input_stream_xptr = PROTECT(input_stream_owning_xptr()); struct ArrowIpcInputStream* input_stream = (struct ArrowIpcInputStream*)R_ExternalPtrAddr(input_stream_xptr); input_stream->read = &read_con_input_stream; input_stream->release = &release_con_input_stream; input_stream->private_data = (SEXP)con; nanoarrow_preserve_sexp(con); int code = ArrowIpcArrayStreamReaderInit(array_stream, input_stream, NULL); if (code != NANOARROW_OK) { Rf_error("ArrowIpcArrayStreamReaderInit() failed with errno %d", code); } UNPROTECT(2); return array_stream_xptr; } SEXP nanoarrow_c_ipc_writer_connection(SEXP con) { SEXP output_stream_xptr = PROTECT(output_stream_owning_xptr()); struct ArrowIpcOutputStream* output_stream = (struct ArrowIpcOutputStream*)R_ExternalPtrAddr(output_stream_xptr); output_stream->write = &write_con_output_stream; output_stream->release = &release_con_output_stream; output_stream->private_data = (SEXP)con; nanoarrow_preserve_sexp(con); SEXP writer_xptr = PROTECT(writer_owning_xptr()); struct ArrowIpcWriter* writer = (struct ArrowIpcWriter*)R_ExternalPtrAddr(writer_xptr); int code = ArrowIpcWriterInit(writer, output_stream); if (code != NANOARROW_OK) { Rf_error("ArrowIpcWriterInit() failed with errno %d", code); } UNPROTECT(2); return writer_xptr; } SEXP nanoarrow_c_ipc_writer_write_stream(SEXP writer_xptr, SEXP array_stream_xptr) { struct ArrowIpcWriter* writer = (struct ArrowIpcWriter*)R_ExternalPtrAddr(writer_xptr); struct ArrowArrayStream* array_stream = nanoarrow_array_stream_from_xptr(array_stream_xptr); struct ArrowError error; ArrowErrorInit(&error); int code = ArrowIpcWriterWriteArrayStream(writer, array_stream, &error); if (code != NANOARROW_OK) { Rf_error("ArrowIpcWriterWriteArrayStream() failed: %s", error.message); } return R_NilValue; } nanoarrow/src/convert_array_stream.c0000644000176200001440000000740514672341746017470 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" #include "array.h" #include "array_stream.h" #include "convert.h" #include "schema.h" static int convert_next(SEXP converter_xptr, struct ArrowArrayStream* stream, SEXP schema_xptr, int64_t* n_batches) { SEXP array_xptr = PROTECT(nanoarrow_array_owning_xptr()); struct ArrowArray* array = nanoarrow_output_array_from_xptr(array_xptr); // Fetch the next array int result = ArrowArrayStreamGetNext(stream, array, NULL); if (result != NANOARROW_OK) { Rf_error("ArrowArrayStream::get_next(): %s", ArrowArrayStreamGetLastError(stream)); } // Check if the stream is finished if (array->release == NULL) { UNPROTECT(1); return 0; } // Bump the batch counter (*n_batches)++; // Set the schema of the allocated array and pass it to the converter R_SetExternalPtrTag(array_xptr, schema_xptr); if (nanoarrow_converter_set_array(converter_xptr, array_xptr) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } // After set_array, the converter is responsible for the array_xptr UNPROTECT(1); // Materialize the array into the converter int64_t n_materialized = nanoarrow_converter_materialize_n(converter_xptr, array->length); if (n_materialized != array->length) { Rf_error("Expected to materialize %ld values in batch %ld but materialized %ld", (long)array->length, (long)(*n_batches), (long)n_materialized); } return 1; } SEXP nanoarrow_c_convert_array_stream(SEXP array_stream_xptr, SEXP ptype_sexp, SEXP size_sexp, SEXP n_sexp) { struct ArrowArrayStream* array_stream = nanoarrow_array_stream_from_xptr(array_stream_xptr); int64_t size = (int64_t)(REAL(size_sexp)[0]); double n_real = REAL(n_sexp)[0]; int n; if (R_FINITE(n_real)) { n = (int)n_real; } else { n = INT_MAX; } SEXP schema_xptr = PROTECT(nanoarrow_schema_owning_xptr()); struct ArrowSchema* schema = nanoarrow_output_schema_from_xptr(schema_xptr); int result = ArrowArrayStreamGetSchema(array_stream, schema, NULL); if (result != NANOARROW_OK) { Rf_error("ArrowArrayStream::get_schema(): %s", ArrowArrayStreamGetLastError(array_stream)); } SEXP converter_xptr = PROTECT(nanoarrow_converter_from_ptype(ptype_sexp)); if (nanoarrow_converter_set_schema(converter_xptr, schema_xptr) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } if (nanoarrow_converter_reserve(converter_xptr, size) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } int64_t n_batches = 0; do { if (n_batches >= n) { break; } } while (convert_next(converter_xptr, array_stream, schema_xptr, &n_batches)); if (nanoarrow_converter_finalize(converter_xptr) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } SEXP result_sexp = PROTECT(nanoarrow_converter_release_result(converter_xptr)); UNPROTECT(3); return result_sexp; } nanoarrow/src/nanoarrow_cpp.cc0000644000176200001440000001361114672341746016246 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include #include #include #include #include #include // Without this infrastructure, it's possible to check that all objects // are released by running devtools::test(); gc() in a fresh session and // making sure that nanoarrow:::preserved_count() is zero afterward. // When this isn't the case the process of debugging unreleased SEXPs // is almost impossible without the bookkeeping below. #if defined(NANOARROW_DEBUG_PRESERVE) #include #endif extern "C" void intptr_as_string(intptr_t ptr_int, char* buf) { std::string ptr_str = std::to_string(ptr_int); memcpy(buf, ptr_str.data(), ptr_str.size()); } #if defined(NANOARROW_DEBUG_PRESERVE) static std::string get_r_traceback(void) { SEXP fun = PROTECT(Rf_install("current_stack_trace_chr")); SEXP call = PROTECT(Rf_lang1(fun)); SEXP nanoarrow_str = PROTECT(Rf_mkString("nanoarrow")); SEXP nanoarrow_ns = PROTECT(R_FindNamespace(nanoarrow_str)); SEXP result = PROTECT(Rf_eval(call, nanoarrow_ns)); const char* traceback_chr = Rf_translateCharUTF8(STRING_ELT(result, 0)); std::string traceback_str(traceback_chr); UNPROTECT(5); return traceback_str; } #endif class PreservedSEXPRegistry { public: PreservedSEXPRegistry() : preserved_count_(0), main_thread_id_(std::this_thread::get_id()) {} int64_t size() { return preserved_count_; } bool is_main_thread() { return std::this_thread::get_id() == main_thread_id_; } void preserve(SEXP obj) { if (obj == R_NilValue) { return; } #if defined(NANOARROW_DEBUG_PRESERVE) Rprintf("PreservedSEXPRegistry::preserve(%p)\n", obj); #endif R_PreserveObject(obj); preserved_count_++; #if defined(NANOARROW_DEBUG_PRESERVE) if (tracebacks_.find(obj) != tracebacks_.end()) { tracebacks_[obj].first++; } else { tracebacks_[obj] = {1, get_r_traceback()}; } #endif } bool release(SEXP obj) { if (obj == R_NilValue) { return true; } #if defined(NANOARROW_DEBUG_PRESERVE) Rprintf("PreservedSEXPRegistry::release(%p)\n", obj); #endif // If there is an attempt to delete this object from another thread, // R_ReleaseObject() will almost certainly crash R or corrupt memory // leading to confusing errors. Instead, save a reference to the object // and provide an opportunity to delete it later. if (std::this_thread::get_id() != main_thread_id_) { std::lock_guard lock(trash_can_lock_); trash_can_.push_back(obj); return false; } else { R_ReleaseObject(obj); preserved_count_--; #if defined(NANOARROW_DEBUG_PRESERVE) if (tracebacks_.find(obj) != tracebacks_.end()) { tracebacks_[obj].first--; if (tracebacks_[obj].first == 0) { tracebacks_.erase(obj); } } #endif return true; } } int64_t empty_trash() { std::lock_guard lock(trash_can_lock_); int64_t trash_size = trash_can_.size(); for (SEXP obj : trash_can_) { R_ReleaseObject(obj); preserved_count_--; #if defined(NANOARROW_DEBUG_PRESERVE) if (tracebacks_.find(obj) != tracebacks_.end()) { tracebacks_[obj].first--; if (tracebacks_[obj].first == 0) { tracebacks_.erase(obj); } } #endif } trash_can_.clear(); #if defined(NANOARROW_DEBUG_PRESERVE) if (preserved_count_ > 0) { Rprintf("%ld unreleased SEXP(s) after emptying the trash:\n", (long)preserved_count_); for (const auto& item : tracebacks_) { Rprintf("----%p---- (%ld reference(s) remaining)\nFirst preserved at\n%s\n\n", item.first, item.second.first, item.second.second.c_str()); } } #endif return trash_size; } static PreservedSEXPRegistry& GetInstance() { static PreservedSEXPRegistry singleton; return singleton; } private: int64_t preserved_count_; std::thread::id main_thread_id_; std::vector trash_can_; std::mutex trash_can_lock_; #if defined(NANOARROW_DEBUG_PRESERVE) std::unordered_map> tracebacks_; #endif }; extern "C" void nanoarrow_preserve_init(void) { PreservedSEXPRegistry::GetInstance(); } extern "C" void nanoarrow_preserve_sexp(SEXP obj) { PreservedSEXPRegistry::GetInstance().preserve(obj); } extern "C" void nanoarrow_release_sexp(SEXP obj) { try { PreservedSEXPRegistry::GetInstance().release(obj); } catch (std::exception& e) { // Just for safety...we really don't want to crash here } } extern "C" int64_t nanoarrow_preserved_count(void) { return PreservedSEXPRegistry::GetInstance().size(); } extern "C" int64_t nanoarrow_preserved_empty(void) { try { return PreservedSEXPRegistry::GetInstance().empty_trash(); } catch (std::exception& e) { return 0; } } extern "C" int nanoarrow_is_main_thread(void) { return PreservedSEXPRegistry::GetInstance().is_main_thread(); } extern "C" void nanoarrow_preserve_and_release_on_other_thread(SEXP obj) { nanoarrow_preserve_sexp(obj); std::thread worker([obj] { nanoarrow_release_sexp(obj); }); worker.join(); } nanoarrow/src/array_stream.h0000644000176200001440000000214514547575511015731 0ustar liggesusers// 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. #ifndef R_NANOARROW_ARRAY_STREAM_H_INCLUDED #define R_NANOARROW_ARRAY_STREAM_H_INCLUDED #include #include #include #include "nanoarrow.h" #include "util.h" void array_stream_export(SEXP array_stream_xptr, struct ArrowArrayStream* array_stream_copy); #endif nanoarrow/src/convert_array.c0000644000176200001440000002426114547575511016114 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" #include "altrep.h" #include "array.h" #include "array_view.h" #include "convert.h" #include "util.h" // The common case of converting a single array into a single vector is // defined here, powered by the generic conversion available via // convert.h but special-casing the common case of "just use the defaults" // (i.e., no need to allocate a zero-size ptype) and returning ALTREP // where possible. // borrow nanoarrow_c_infer_ptype() from infer_ptype.c SEXP nanoarrow_c_infer_ptype(SEXP schema_xptr); enum VectorType nanoarrow_infer_vector_type_array(SEXP array_xptr); // This calls nanoarrow::convert_array() (via a package helper) to try S3 // dispatch to find a convert_array() method (or error if there // isn't one) static SEXP call_convert_array(SEXP array_xptr, SEXP ptype_sexp) { SEXP fun = PROTECT(Rf_install("convert_fallback_other")); // offset/length don't need to be modified in this case SEXP call = PROTECT(Rf_lang5(fun, array_xptr, R_NilValue, R_NilValue, ptype_sexp)); SEXP result = PROTECT(Rf_eval(call, nanoarrow_ns_pkg)); UNPROTECT(3); return result; } // Call stop_cant_convert_array(), which gives a more informative error // message than we can provide in a reasonable amount of C code here. // Because we opportunistically avoid allocating a ptype object, we might // have to allocate one here. static void call_stop_cant_convert_array(SEXP array_xptr, enum VectorType type, SEXP ptype_sexp) { SEXP fun = PROTECT(Rf_install("stop_cant_convert_array")); if (ptype_sexp == R_NilValue) { ptype_sexp = PROTECT(nanoarrow_alloc_type(type, 0)); SEXP call = PROTECT(Rf_lang3(fun, array_xptr, ptype_sexp)); Rf_eval(call, nanoarrow_ns_pkg); UNPROTECT(3); } else { SEXP call = PROTECT(Rf_lang3(fun, array_xptr, ptype_sexp)); Rf_eval(call, nanoarrow_ns_pkg); UNPROTECT(2); } } static SEXP convert_array_default(SEXP array_xptr, enum VectorType vector_type, SEXP ptype) { SEXP converter_xptr; if (ptype == R_NilValue) { converter_xptr = PROTECT(nanoarrow_converter_from_type(vector_type)); } else { converter_xptr = PROTECT(nanoarrow_converter_from_ptype(ptype)); } if (nanoarrow_converter_set_schema(converter_xptr, array_xptr_get_schema(array_xptr)) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } if (nanoarrow_converter_set_array(converter_xptr, array_xptr) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } if (nanoarrow_converter_materialize_all(converter_xptr) != NANOARROW_OK) { call_stop_cant_convert_array(array_xptr, vector_type, ptype); } if (nanoarrow_converter_finalize(converter_xptr) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } SEXP result = PROTECT(nanoarrow_converter_release_result(converter_xptr)); UNPROTECT(2); return result; } static SEXP convert_array_chr(SEXP array_xptr, SEXP ptype_sexp) { struct ArrowSchema* schema = schema_from_array_xptr(array_xptr); struct ArrowSchemaView schema_view; if (ArrowSchemaViewInit(&schema_view, schema, NULL) != NANOARROW_OK) { Rf_error("Invalid schema"); } // If array_xptr is an extension, use default conversion int source_can_altrep; switch (schema_view.type) { case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: source_can_altrep = 1; break; default: source_can_altrep = 0; } if (!source_can_altrep || schema_view.extension_name.size_bytes > 0) { // Default conversion requires a ptype: resolve it if not already specified if (ptype_sexp == R_NilValue) { ptype_sexp = PROTECT(nanoarrow_c_infer_ptype(array_xptr_get_schema(array_xptr))); SEXP default_result = PROTECT(convert_array_default(array_xptr, VECTOR_TYPE_CHR, ptype_sexp)); UNPROTECT(2); return default_result; } else { return convert_array_default(array_xptr, VECTOR_TYPE_CHR, ptype_sexp); } } struct ArrowArray* array = (struct ArrowArray*)R_ExternalPtrAddr(array_xptr); if (array->dictionary == NULL) { SEXP result = PROTECT(nanoarrow_c_make_altrep_chr(array_xptr)); if (result == R_NilValue) { call_stop_cant_convert_array(array_xptr, VECTOR_TYPE_CHR, R_NilValue); } UNPROTECT(1); return result; } else { return convert_array_default(array_xptr, VECTOR_TYPE_CHR, R_NilValue); } } SEXP nanoarrow_c_convert_array(SEXP array_xptr, SEXP ptype_sexp); static SEXP convert_array_data_frame(SEXP array_xptr, SEXP ptype_sexp) { struct ArrowSchema* schema = schema_from_array_xptr(array_xptr); struct ArrowSchemaView schema_view; if (ArrowSchemaViewInit(&schema_view, schema, NULL) != NANOARROW_OK) { Rf_error("Invalid schema"); } // If array_xptr is an extension, union, or the ptype isn't a data.frame // use convert/materialize convert behaviour. // Default conversion requires a ptype: resolve it if not already specified if (schema_view.storage_type != NANOARROW_TYPE_STRUCT || schema_view.extension_name.size_bytes > 0 || (ptype_sexp != R_NilValue && !Rf_inherits(ptype_sexp, "data.frame"))) { if (ptype_sexp == R_NilValue) { ptype_sexp = PROTECT(nanoarrow_c_infer_ptype(array_xptr_get_schema(array_xptr))); SEXP default_result = PROTECT(convert_array_default(array_xptr, VECTOR_TYPE_OTHER, ptype_sexp)); UNPROTECT(2); return default_result; } else { return convert_array_default(array_xptr, VECTOR_TYPE_DATA_FRAME, ptype_sexp); } } struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); R_xlen_t n_col = array->n_children; SEXP result = PROTECT(Rf_allocVector(VECSXP, n_col)); if (ptype_sexp == R_NilValue) { SEXP result_names = PROTECT(Rf_allocVector(STRSXP, n_col)); for (R_xlen_t i = 0; i < n_col; i++) { SEXP child_xptr = PROTECT(borrow_array_child_xptr(array_xptr, i)); SET_VECTOR_ELT(result, i, nanoarrow_c_convert_array(child_xptr, R_NilValue)); UNPROTECT(1); struct ArrowSchema* schema = schema_from_array_xptr(child_xptr); if (schema->name != NULL) { SET_STRING_ELT(result_names, i, Rf_mkCharCE(schema->name, CE_UTF8)); } else { SET_STRING_ELT(result_names, i, Rf_mkChar("")); } } Rf_setAttrib(result, R_NamesSymbol, result_names); Rf_setAttrib(result, R_ClassSymbol, nanoarrow_cls_data_frame); UNPROTECT(1); } else { if (n_col != Rf_xlength(ptype_sexp)) { Rf_error("Expected data.frame() ptype with %ld column(s) but found %ld column(s)", (long)n_col, (long)Rf_xlength(ptype_sexp)); } for (R_xlen_t i = 0; i < n_col; i++) { SEXP child_xptr = PROTECT(borrow_array_child_xptr(array_xptr, i)); SEXP child_ptype = VECTOR_ELT(ptype_sexp, i); SET_VECTOR_ELT(result, i, nanoarrow_c_convert_array(child_xptr, child_ptype)); UNPROTECT(1); } Rf_setAttrib(result, R_NamesSymbol, Rf_getAttrib(ptype_sexp, R_NamesSymbol)); Rf_copyMostAttrib(ptype_sexp, result); } if (Rf_inherits(result, "data.frame")) { nanoarrow_set_rownames(result, array->length); } UNPROTECT(1); return result; } SEXP nanoarrow_c_convert_array(SEXP array_xptr, SEXP ptype_sexp) { // See if we can skip any ptype resolution at all if (ptype_sexp == R_NilValue) { enum VectorType vector_type = nanoarrow_infer_vector_type_array(array_xptr); switch (vector_type) { case VECTOR_TYPE_LGL: case VECTOR_TYPE_INT: case VECTOR_TYPE_DBL: return convert_array_default(array_xptr, vector_type, R_NilValue); case VECTOR_TYPE_CHR: return convert_array_chr(array_xptr, ptype_sexp); case VECTOR_TYPE_DATA_FRAME: return convert_array_data_frame(array_xptr, R_NilValue); default: break; } // Otherwise, resolve the ptype and use it (this will also error // for ptypes that can't be resolved) ptype_sexp = PROTECT(nanoarrow_c_infer_ptype(array_xptr_get_schema(array_xptr))); SEXP result = nanoarrow_c_convert_array(array_xptr, ptype_sexp); UNPROTECT(1); return result; } // Handle some S3 objects internally to avoid S3 dispatch // (e.g., when looping over a data frame with a lot of columns) if (Rf_isObject(ptype_sexp)) { if (nanoarrow_ptype_is_data_frame(ptype_sexp)) { return convert_array_data_frame(array_xptr, ptype_sexp); } else if (Rf_inherits(ptype_sexp, "vctrs_unspecified") || Rf_inherits(ptype_sexp, "blob") || Rf_inherits(ptype_sexp, "vctrs_list_of") || Rf_inherits(ptype_sexp, "Date") || Rf_inherits(ptype_sexp, "hms") || Rf_inherits(ptype_sexp, "POSIXct") || Rf_inherits(ptype_sexp, "difftime") || Rf_inherits(ptype_sexp, "integer64")) { return convert_array_default(array_xptr, VECTOR_TYPE_UNINITIALIZED, ptype_sexp); } else { return call_convert_array(array_xptr, ptype_sexp); } } // If we're here, these are non-S3 objects switch (TYPEOF(ptype_sexp)) { case LGLSXP: return convert_array_default(array_xptr, VECTOR_TYPE_LGL, ptype_sexp); case INTSXP: return convert_array_default(array_xptr, VECTOR_TYPE_INT, ptype_sexp); case REALSXP: return convert_array_default(array_xptr, VECTOR_TYPE_DBL, ptype_sexp); case STRSXP: return convert_array_chr(array_xptr, ptype_sexp); default: return call_convert_array(array_xptr, ptype_sexp); } } nanoarrow/src/altrep.c0000644000176200001440000002045514547575511014526 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include #include #include "altrep.h" #include "array.h" #include "convert.h" #include "nanoarrow.h" #include "util.h" #ifdef HAS_ALTREP // This file defines all ALTREP classes used to speed up conversion // from an arrow_array to an R vector. Currently only string and // large string arrays are converted to ALTREP. // // All ALTREP classes follow some common patterns: // // - R_altrep_data1() holds an external pointer to a struct RConverter. // - R_altrep_data2() holds the materialized version of the vector. // - When materialization happens, we set R_altrep_data1() to R_NilValue // to ensure we don't hold on to any more resources than needed. static R_xlen_t nanoarrow_altrep_length(SEXP altrep_sexp) { SEXP converter_xptr = R_altrep_data1(altrep_sexp); if (converter_xptr == R_NilValue) { return Rf_xlength(R_altrep_data2(altrep_sexp)); } struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); return converter->array_view.array->length; } static Rboolean nanoarrow_altrep_inspect(SEXP altrep_sexp, int pre, int deep, int pvec, void (*inspect_subtree)(SEXP, int, int, int)) { SEXP converter_xptr = R_altrep_data1(altrep_sexp); const char* materialized = ""; if (converter_xptr == R_NilValue) { materialized = "materialized "; } R_xlen_t len = nanoarrow_altrep_length(altrep_sexp); const char* class_name = nanoarrow_altrep_class(altrep_sexp); Rprintf("<%s%s[%ld]>\n", materialized, class_name, (long)len); return TRUE; } static SEXP nanoarrow_altstring_elt(SEXP altrep_sexp, R_xlen_t i) { SEXP converter_xptr = R_altrep_data1(altrep_sexp); if (converter_xptr == R_NilValue) { return STRING_ELT(R_altrep_data2(altrep_sexp), i); } struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); if (ArrowArrayViewIsNull(&converter->array_view, i)) { return NA_STRING; } struct ArrowStringView item = ArrowArrayViewGetStringUnsafe(&converter->array_view, i); return Rf_mkCharLenCE(item.data, (int)item.size_bytes, CE_UTF8); } static SEXP nanoarrow_altstring_materialize(SEXP altrep_sexp) { SEXP converter_xptr = R_altrep_data1(altrep_sexp); if (converter_xptr == R_NilValue) { return R_altrep_data2(altrep_sexp); } if (nanoarrow_converter_materialize_all(converter_xptr) != NANOARROW_OK) { Rf_error("Error materializing altstring"); } if (nanoarrow_converter_finalize(converter_xptr) != NANOARROW_OK) { Rf_error("Error finalizing materialized altstring"); } SEXP result_sexp = PROTECT(nanoarrow_converter_release_result(converter_xptr)); R_set_altrep_data2(altrep_sexp, result_sexp); R_set_altrep_data1(altrep_sexp, R_NilValue); UNPROTECT(1); return result_sexp; } static void* nanoarrow_altrep_dataptr(SEXP altrep_sexp, Rboolean writable) { return DATAPTR(nanoarrow_altstring_materialize(altrep_sexp)); } static const void* nanoarrow_altrep_dataptr_or_null(SEXP altrep_sexp) { SEXP converter_xptr = R_altrep_data1(altrep_sexp); if (converter_xptr == R_NilValue) { return DATAPTR_OR_NULL(R_altrep_data2(altrep_sexp)); } return NULL; } static R_altrep_class_t nanoarrow_altrep_chr_cls; #endif static void register_nanoarrow_altstring(DllInfo* info) { #ifdef HAS_ALTREP nanoarrow_altrep_chr_cls = R_make_altstring_class("nanoarrow::altrep_chr", "nanoarrow", info); R_set_altrep_Length_method(nanoarrow_altrep_chr_cls, &nanoarrow_altrep_length); R_set_altrep_Inspect_method(nanoarrow_altrep_chr_cls, &nanoarrow_altrep_inspect); R_set_altvec_Dataptr_or_null_method(nanoarrow_altrep_chr_cls, &nanoarrow_altrep_dataptr_or_null); R_set_altvec_Dataptr_method(nanoarrow_altrep_chr_cls, &nanoarrow_altrep_dataptr); R_set_altstring_Elt_method(nanoarrow_altrep_chr_cls, &nanoarrow_altstring_elt); // Notes about other available methods: // // - The no_na method never seems to get called (anyNA() doesn't seem to // use it) // - Because set_Elt is not defined, SET_STRING_ELT() will modify the // technically modify the materialized value. The object has been marked // immutable but in the case of a string this is fine because we materialize // when this happens (via Dataptr). // - It may be beneficial to implement the Extract_subset method to defer string // conversion even longer since this is expensive compared to rearranging integer // indices. // - The duplicate method may be useful because it's used when setting attributes // or unclassing the vector. #endif } void register_nanoarrow_altrep(DllInfo* info) { register_nanoarrow_altstring(info); } SEXP nanoarrow_c_make_altrep_chr(SEXP array_xptr) { #ifdef HAS_ALTREP SEXP schema_xptr = array_xptr_get_schema(array_xptr); // Create the converter SEXP converter_xptr = PROTECT(nanoarrow_converter_from_type(VECTOR_TYPE_CHR)); if (nanoarrow_converter_set_schema(converter_xptr, schema_xptr) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } struct RConverter* converter = (struct RConverter*)R_ExternalPtrAddr(converter_xptr); switch (converter->array_view.storage_type) { case NANOARROW_TYPE_NA: case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: break; default: UNPROTECT(1); return R_NilValue; } // Ensure the array that we're attaching to this ALTREP object does not keep its // parent struct alive unnecessarily (i.e., a user can select only a few columns // and the memory for the unused columns will be released). SEXP array_xptr_independent = PROTECT(array_xptr_ensure_independent(array_xptr)); if (nanoarrow_converter_set_array(converter_xptr, array_xptr_independent) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } Rf_setAttrib(converter_xptr, R_ClassSymbol, nanoarrow_cls_altrep_chr); SEXP out = PROTECT(R_new_altrep(nanoarrow_altrep_chr_cls, converter_xptr, R_NilValue)); MARK_NOT_MUTABLE(out); UNPROTECT(3); return out; #else return R_NilValue; #endif } SEXP nanoarrow_c_is_altrep(SEXP x_sexp) { return Rf_ScalarLogical(is_nanoarrow_altrep(x_sexp)); } SEXP nanoarrow_c_altrep_is_materialized(SEXP x_sexp) { const char* class_name = nanoarrow_altrep_class(x_sexp); if (class_name == NULL || strncmp(class_name, "nanoarrow::", 11) != 0) { return Rf_ScalarLogical(NA_LOGICAL); } else { return Rf_ScalarLogical(R_altrep_data1(x_sexp) == R_NilValue); } } SEXP nanoarrow_c_altrep_force_materialize(SEXP x_sexp, SEXP recursive_sexp) { // The recursive flag lets a developer/user force materialization of any // string columns in a data.frame that came from nanoarrow. if (Rf_inherits(x_sexp, "data.frame") && LOGICAL(recursive_sexp)[0]) { int n_materialized = 0; for (R_xlen_t i = 0; i < Rf_xlength(x_sexp); i++) { SEXP n_materialized_sexp = PROTECT( nanoarrow_c_altrep_force_materialize(VECTOR_ELT(x_sexp, i), recursive_sexp)); n_materialized += INTEGER(n_materialized_sexp)[0]; UNPROTECT(1); } return Rf_ScalarInteger(n_materialized); } const char* class_name = nanoarrow_altrep_class(x_sexp); if (class_name && strcmp(class_name, "nanoarrow::altrep_chr") == 0) { // Force materialization even if already materialized (the method // should be safe to call more than once as written here) int already_materialized = R_altrep_data1(x_sexp) == R_NilValue; nanoarrow_altstring_materialize(x_sexp); return Rf_ScalarInteger(!already_materialized); } else { return Rf_ScalarInteger(0); } } nanoarrow/src/buffer.h0000644000176200001440000000716514672341746014520 0ustar liggesusers// 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. #ifndef R_NANOARROW_BUFFER_H_INCLUDED #define R_NANOARROW_BUFFER_H_INCLUDED #include #include #include "nanoarrow.h" #include "util.h" void finalize_buffer_xptr(SEXP buffer_xptr); void nanoarrow_sexp_deallocator(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t size); // Create an external pointer with the proper class and that will release any // non-null, non-released pointer when garbage collected. static inline SEXP buffer_owning_xptr(void) { struct ArrowBuffer* buffer = (struct ArrowBuffer*)ArrowMalloc(sizeof(struct ArrowBuffer)); ArrowBufferInit(buffer); SEXP buffer_xptr = PROTECT(R_MakeExternalPtr(buffer, R_NilValue, R_NilValue)); Rf_setAttrib(buffer_xptr, R_ClassSymbol, nanoarrow_cls_buffer); R_RegisterCFinalizer(buffer_xptr, &finalize_buffer_xptr); UNPROTECT(1); return buffer_xptr; } // Create an arrow_buffer with a deallocator that will release shelter when // the buffer is no longer needed. static inline void buffer_borrowed(struct ArrowBuffer* buffer, const void* addr, int64_t size_bytes, SEXP shelter) { buffer->allocator = ArrowBufferDeallocator(&nanoarrow_sexp_deallocator, shelter); buffer->data = (uint8_t*)addr; buffer->size_bytes = size_bytes; buffer->capacity_bytes = size_bytes; nanoarrow_preserve_sexp(shelter); } static inline SEXP buffer_borrowed_xptr(const void* addr, int64_t size_bytes, SEXP shelter) { SEXP buffer_xptr = PROTECT(buffer_owning_xptr()); // Don't bother with a preserve/release if the buffer is NULL if (addr == NULL) { UNPROTECT(1); return buffer_xptr; } struct ArrowBuffer* buffer = (struct ArrowBuffer*)R_ExternalPtrAddr(buffer_xptr); buffer_borrowed(buffer, addr, size_bytes, shelter); UNPROTECT(1); return buffer_xptr; } static inline void buffer_borrowed_xptr_set_type(SEXP buffer_xptr, enum ArrowBufferType buffer_type, enum ArrowType buffer_data_type, int64_t element_size_bits) { SEXP buffer_types_sexp = PROTECT(Rf_allocVector(INTSXP, 3)); INTEGER(buffer_types_sexp)[0] = buffer_type; INTEGER(buffer_types_sexp)[1] = buffer_data_type; INTEGER(buffer_types_sexp)[2] = (int32_t)element_size_bits; R_SetExternalPtrTag(buffer_xptr, buffer_types_sexp); UNPROTECT(1); } static inline struct ArrowBuffer* buffer_from_xptr(SEXP buffer_xptr) { if (!Rf_inherits(buffer_xptr, "nanoarrow_buffer")) { Rf_error("`buffer` argument that is not a nanoarrow_buffer()"); } struct ArrowBuffer* buffer = (struct ArrowBuffer*)R_ExternalPtrAddr(buffer_xptr); if (buffer == NULL) { Rf_error("nanoarrow_buffer is an external pointer to NULL"); } return buffer; } #endif nanoarrow/src/nanoarrow.c0000644000176200001440000040721114702632113015225 0ustar liggesusers// 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 #include #include #include #include #include #include "nanoarrow.h" const char* ArrowNanoarrowVersion(void) { return NANOARROW_VERSION; } int ArrowNanoarrowVersionInt(void) { return NANOARROW_VERSION_INT; } ArrowErrorCode ArrowErrorSet(struct ArrowError* error, const char* fmt, ...) { if (error == NULL) { return NANOARROW_OK; } memset(error->message, 0, sizeof(error->message)); va_list args; va_start(args, fmt); int chars_needed = vsnprintf(error->message, sizeof(error->message), fmt, args); va_end(args); if (chars_needed < 0) { return EINVAL; } else if (((size_t)chars_needed) >= sizeof(error->message)) { return ERANGE; } else { return NANOARROW_OK; } } void ArrowLayoutInit(struct ArrowLayout* layout, enum ArrowType storage_type) { layout->buffer_type[0] = NANOARROW_BUFFER_TYPE_VALIDITY; layout->buffer_data_type[0] = NANOARROW_TYPE_BOOL; layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA; layout->buffer_data_type[1] = storage_type; layout->buffer_type[2] = NANOARROW_BUFFER_TYPE_NONE; layout->buffer_data_type[2] = NANOARROW_TYPE_UNINITIALIZED; layout->element_size_bits[0] = 1; layout->element_size_bits[1] = 0; layout->element_size_bits[2] = 0; layout->child_size_elements = 0; switch (storage_type) { case NANOARROW_TYPE_UNINITIALIZED: case NANOARROW_TYPE_NA: case NANOARROW_TYPE_RUN_END_ENCODED: layout->buffer_type[0] = NANOARROW_BUFFER_TYPE_NONE; layout->buffer_data_type[0] = NANOARROW_TYPE_UNINITIALIZED; layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_NONE; layout->buffer_data_type[1] = NANOARROW_TYPE_UNINITIALIZED; layout->element_size_bits[0] = 0; break; case NANOARROW_TYPE_LIST: case NANOARROW_TYPE_MAP: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA_OFFSET; layout->buffer_data_type[1] = NANOARROW_TYPE_INT32; layout->element_size_bits[1] = 32; break; case NANOARROW_TYPE_LARGE_LIST: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA_OFFSET; layout->buffer_data_type[1] = NANOARROW_TYPE_INT64; layout->element_size_bits[1] = 64; break; case NANOARROW_TYPE_STRUCT: case NANOARROW_TYPE_FIXED_SIZE_LIST: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_NONE; layout->buffer_data_type[1] = NANOARROW_TYPE_UNINITIALIZED; break; case NANOARROW_TYPE_BOOL: layout->element_size_bits[1] = 1; break; case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT8: layout->element_size_bits[1] = 8; break; case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_HALF_FLOAT: layout->element_size_bits[1] = 16; break; case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_FLOAT: layout->element_size_bits[1] = 32; break; case NANOARROW_TYPE_INTERVAL_MONTHS: layout->buffer_data_type[1] = NANOARROW_TYPE_INT32; layout->element_size_bits[1] = 32; break; case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_DOUBLE: case NANOARROW_TYPE_INTERVAL_DAY_TIME: layout->element_size_bits[1] = 64; break; case NANOARROW_TYPE_DECIMAL128: case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: layout->element_size_bits[1] = 128; break; case NANOARROW_TYPE_DECIMAL256: layout->element_size_bits[1] = 256; break; case NANOARROW_TYPE_FIXED_SIZE_BINARY: layout->buffer_data_type[1] = NANOARROW_TYPE_BINARY; break; case NANOARROW_TYPE_DENSE_UNION: layout->buffer_type[0] = NANOARROW_BUFFER_TYPE_TYPE_ID; layout->buffer_data_type[0] = NANOARROW_TYPE_INT8; layout->element_size_bits[0] = 8; layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_UNION_OFFSET; layout->buffer_data_type[1] = NANOARROW_TYPE_INT32; layout->element_size_bits[1] = 32; break; case NANOARROW_TYPE_SPARSE_UNION: layout->buffer_type[0] = NANOARROW_BUFFER_TYPE_TYPE_ID; layout->buffer_data_type[0] = NANOARROW_TYPE_INT8; layout->element_size_bits[0] = 8; layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_NONE; layout->buffer_data_type[1] = NANOARROW_TYPE_UNINITIALIZED; break; case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_BINARY: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA_OFFSET; layout->buffer_data_type[1] = NANOARROW_TYPE_INT32; layout->element_size_bits[1] = 32; layout->buffer_type[2] = NANOARROW_BUFFER_TYPE_DATA; layout->buffer_data_type[2] = storage_type; break; case NANOARROW_TYPE_LARGE_STRING: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA_OFFSET; layout->buffer_data_type[1] = NANOARROW_TYPE_INT64; layout->element_size_bits[1] = 64; layout->buffer_type[2] = NANOARROW_BUFFER_TYPE_DATA; layout->buffer_data_type[2] = NANOARROW_TYPE_STRING; break; case NANOARROW_TYPE_LARGE_BINARY: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA_OFFSET; layout->buffer_data_type[1] = NANOARROW_TYPE_INT64; layout->element_size_bits[1] = 64; layout->buffer_type[2] = NANOARROW_BUFFER_TYPE_DATA; layout->buffer_data_type[2] = NANOARROW_TYPE_BINARY; break; case NANOARROW_TYPE_BINARY_VIEW: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA; layout->buffer_data_type[1] = NANOARROW_TYPE_BINARY_VIEW; layout->element_size_bits[1] = 128; break; case NANOARROW_TYPE_STRING_VIEW: layout->buffer_type[1] = NANOARROW_BUFFER_TYPE_DATA; layout->buffer_data_type[1] = NANOARROW_TYPE_STRING_VIEW; layout->element_size_bits[1] = 128; default: break; } } void* ArrowMalloc(int64_t size) { return malloc(size); } void* ArrowRealloc(void* ptr, int64_t size) { return realloc(ptr, size); } void ArrowFree(void* ptr) { free(ptr); } static uint8_t* ArrowBufferAllocatorMallocReallocate( struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t old_size, int64_t new_size) { NANOARROW_UNUSED(allocator); NANOARROW_UNUSED(old_size); return (uint8_t*)ArrowRealloc(ptr, new_size); } static void ArrowBufferAllocatorMallocFree(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t size) { NANOARROW_UNUSED(allocator); NANOARROW_UNUSED(size); if (ptr != NULL) { ArrowFree(ptr); } } static struct ArrowBufferAllocator ArrowBufferAllocatorMalloc = { &ArrowBufferAllocatorMallocReallocate, &ArrowBufferAllocatorMallocFree, NULL}; struct ArrowBufferAllocator ArrowBufferAllocatorDefault(void) { return ArrowBufferAllocatorMalloc; } static uint8_t* ArrowBufferDeallocatorReallocate(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t old_size, int64_t new_size) { NANOARROW_UNUSED(new_size); // Attempting to reallocate a buffer with a custom deallocator is // a programming error. In debug mode, crash here. #if defined(NANOARROW_DEBUG) NANOARROW_PRINT_AND_DIE(ENOMEM, "It is an error to reallocate a buffer whose allocator is " "ArrowBufferDeallocator()"); #endif // In release mode, ensure the the deallocator is called exactly // once using the pointer it was given and return NULL, which // will trigger the caller to return ENOMEM. allocator->free(allocator, ptr, old_size); *allocator = ArrowBufferAllocatorDefault(); return NULL; } struct ArrowBufferAllocator ArrowBufferDeallocator( void (*custom_free)(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t size), void* private_data) { struct ArrowBufferAllocator allocator; allocator.reallocate = &ArrowBufferDeallocatorReallocate; allocator.free = custom_free; allocator.private_data = private_data; return allocator; } static const int kInt32DecimalDigits = 9; static const uint64_t kUInt32PowersOfTen[] = { 1ULL, 10ULL, 100ULL, 1000ULL, 10000ULL, 100000ULL, 1000000ULL, 10000000ULL, 100000000ULL, 1000000000ULL}; // Adapted from Arrow C++ to use 32-bit words for better C portability // https://github.com/apache/arrow/blob/cd3321b28b0c9703e5d7105d6146c1270bbadd7f/cpp/src/arrow/util/decimal.cc#L524-L544 static void ShiftAndAdd(struct ArrowStringView value, uint32_t* out, int64_t out_size) { // We use strtoll for parsing, which needs input that is null-terminated char chunk_string[16]; for (int64_t posn = 0; posn < value.size_bytes;) { int64_t remaining = value.size_bytes - posn; int64_t group_size; if (remaining > kInt32DecimalDigits) { group_size = kInt32DecimalDigits; } else { group_size = remaining; } const uint64_t multiple = kUInt32PowersOfTen[group_size]; memcpy(chunk_string, value.data + posn, group_size); chunk_string[group_size] = '\0'; uint32_t chunk = (uint32_t)strtoll(chunk_string, NULL, 10); for (int64_t i = 0; i < out_size; i++) { uint64_t tmp = out[i]; tmp *= multiple; tmp += chunk; out[i] = (uint32_t)(tmp & 0xFFFFFFFFULL); chunk = (uint32_t)(tmp >> 32); } posn += group_size; } } ArrowErrorCode ArrowDecimalSetDigits(struct ArrowDecimal* decimal, struct ArrowStringView value) { // Check for sign int is_negative = value.data[0] == '-'; int has_sign = is_negative || value.data[0] == '+'; value.data += has_sign; value.size_bytes -= has_sign; // Check all characters are digits that are not the negative sign for (int64_t i = 0; i < value.size_bytes; i++) { char c = value.data[i]; if (c < '0' || c > '9') { return EINVAL; } } // Skip over leading 0s int64_t n_leading_zeroes = 0; for (int64_t i = 0; i < value.size_bytes; i++) { if (value.data[i] == '0') { n_leading_zeroes++; } else { break; } } value.data += n_leading_zeroes; value.size_bytes -= n_leading_zeroes; // Use 32-bit words for portability uint32_t words32[8]; int n_words32 = decimal->n_words * 2; NANOARROW_DCHECK(n_words32 <= 8); memset(words32, 0, sizeof(words32)); ShiftAndAdd(value, words32, n_words32); if (decimal->low_word_index == 0) { memcpy(decimal->words, words32, sizeof(uint32_t) * n_words32); } else { uint64_t lo; uint64_t hi; for (int i = 0; i < decimal->n_words; i++) { lo = (uint64_t)words32[i * 2]; hi = (uint64_t)words32[i * 2 + 1] << 32; decimal->words[decimal->n_words - i - 1] = lo | hi; } } if (is_negative) { ArrowDecimalNegate(decimal); } return NANOARROW_OK; } // Adapted from Arrow C++ for C // https://github.com/apache/arrow/blob/cd3321b28b0c9703e5d7105d6146c1270bbadd7f/cpp/src/arrow/util/decimal.cc#L365 ArrowErrorCode ArrowDecimalAppendDigitsToBuffer(const struct ArrowDecimal* decimal, struct ArrowBuffer* buffer) { NANOARROW_DCHECK(decimal->n_words == 2 || decimal->n_words == 4); int is_negative = ArrowDecimalSign(decimal) < 0; uint64_t words_little_endian[4]; if (decimal->low_word_index == 0) { memcpy(words_little_endian, decimal->words, decimal->n_words * sizeof(uint64_t)); } else { for (int i = 0; i < decimal->n_words; i++) { words_little_endian[i] = decimal->words[decimal->n_words - i - 1]; } } // We've already made a copy, so negate that if needed if (is_negative) { uint64_t carry = 1; for (int i = 0; i < decimal->n_words; i++) { uint64_t elem = words_little_endian[i]; elem = ~elem + carry; carry &= (elem == 0); words_little_endian[i] = elem; } } // Find the most significant word that is non-zero int most_significant_elem_idx = -1; for (int i = decimal->n_words - 1; i >= 0; i--) { if (words_little_endian[i] != 0) { most_significant_elem_idx = i; break; } } // If they are all zero, the output is just '0' if (most_significant_elem_idx == -1) { NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt8(buffer, '0')); return NANOARROW_OK; } // Define segments such that each segment represents 9 digits with the // least significant group of 9 digits first. For example, if the input represents // 9876543210123456789, then segments will be [123456789, 876543210, 9]. // We handle at most a signed 256 bit integer, whose maximum value occupies 77 // characters. Thus, we need at most 9 segments. const uint32_t k1e9 = 1000000000U; int num_segments = 0; uint32_t segments[9]; memset(segments, 0, sizeof(segments)); uint64_t* most_significant_elem = words_little_endian + most_significant_elem_idx; do { // Compute remainder = words_little_endian % 1e9 and words_little_endian = // words_little_endian / 1e9. uint32_t remainder = 0; uint64_t* elem = most_significant_elem; do { // Compute dividend = (remainder << 32) | *elem (a virtual 96-bit integer); // *elem = dividend / 1e9; // remainder = dividend % 1e9. uint32_t hi = (uint32_t)(*elem >> 32); uint32_t lo = (uint32_t)(*elem & 0xFFFFFFFFULL); uint64_t dividend_hi = ((uint64_t)(remainder) << 32) | hi; uint64_t quotient_hi = dividend_hi / k1e9; remainder = (uint32_t)(dividend_hi % k1e9); uint64_t dividend_lo = ((uint64_t)(remainder) << 32) | lo; uint64_t quotient_lo = dividend_lo / k1e9; remainder = (uint32_t)(dividend_lo % k1e9); *elem = (quotient_hi << 32) | quotient_lo; } while (elem-- != words_little_endian); segments[num_segments++] = remainder; } while (*most_significant_elem != 0 || most_significant_elem-- != words_little_endian); // We know our output has no more than 9 digits per segment, plus a negative sign, // plus any further digits between our output of 9 digits plus enough // extra characters to ensure that snprintf() with n = 21 (maximum length of %lu // including a the null terminator) is bounded properly. NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(buffer, num_segments * 9 + 1 + 21 - 9)); if (is_negative) { buffer->data[buffer->size_bytes++] = '-'; } // The most significant segment should have no leading zeroes int n_chars = snprintf((char*)buffer->data + buffer->size_bytes, 21, "%lu", (unsigned long)segments[num_segments - 1]); // Ensure that an encoding error from snprintf() does not result // in an out-of-bounds access. if (n_chars < 0) { return ERANGE; } buffer->size_bytes += n_chars; // Subsequent output needs to be left-padded with zeroes such that each segment // takes up exactly 9 digits. for (int i = num_segments - 2; i >= 0; i--) { int n_chars = snprintf((char*)buffer->data + buffer->size_bytes, 21, "%09lu", (unsigned long)segments[i]); buffer->size_bytes += n_chars; NANOARROW_DCHECK(buffer->size_bytes <= buffer->capacity_bytes); } return NANOARROW_OK; } // 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 #include #include #include #include #include "nanoarrow.h" static void ArrowSchemaReleaseInternal(struct ArrowSchema* schema) { if (schema->format != NULL) ArrowFree((void*)schema->format); if (schema->name != NULL) ArrowFree((void*)schema->name); if (schema->metadata != NULL) ArrowFree((void*)schema->metadata); // This object owns the memory for all the children, but those // children may have been generated elsewhere and might have // their own release() callback. if (schema->children != NULL) { for (int64_t i = 0; i < schema->n_children; i++) { if (schema->children[i] != NULL) { if (schema->children[i]->release != NULL) { ArrowSchemaRelease(schema->children[i]); } ArrowFree(schema->children[i]); } } ArrowFree(schema->children); } // This object owns the memory for the dictionary but it // may have been generated somewhere else and have its own // release() callback. if (schema->dictionary != NULL) { if (schema->dictionary->release != NULL) { ArrowSchemaRelease(schema->dictionary); } ArrowFree(schema->dictionary); } // private data not currently used if (schema->private_data != NULL) { ArrowFree(schema->private_data); } schema->release = NULL; } static const char* ArrowSchemaFormatTemplate(enum ArrowType type) { switch (type) { case NANOARROW_TYPE_UNINITIALIZED: return NULL; case NANOARROW_TYPE_NA: return "n"; case NANOARROW_TYPE_BOOL: return "b"; case NANOARROW_TYPE_UINT8: return "C"; case NANOARROW_TYPE_INT8: return "c"; case NANOARROW_TYPE_UINT16: return "S"; case NANOARROW_TYPE_INT16: return "s"; case NANOARROW_TYPE_UINT32: return "I"; case NANOARROW_TYPE_INT32: return "i"; case NANOARROW_TYPE_UINT64: return "L"; case NANOARROW_TYPE_INT64: return "l"; case NANOARROW_TYPE_HALF_FLOAT: return "e"; case NANOARROW_TYPE_FLOAT: return "f"; case NANOARROW_TYPE_DOUBLE: return "g"; case NANOARROW_TYPE_STRING: return "u"; case NANOARROW_TYPE_LARGE_STRING: return "U"; case NANOARROW_TYPE_STRING_VIEW: return "vu"; case NANOARROW_TYPE_BINARY: return "z"; case NANOARROW_TYPE_BINARY_VIEW: return "vz"; case NANOARROW_TYPE_LARGE_BINARY: return "Z"; case NANOARROW_TYPE_DATE32: return "tdD"; case NANOARROW_TYPE_DATE64: return "tdm"; case NANOARROW_TYPE_INTERVAL_MONTHS: return "tiM"; case NANOARROW_TYPE_INTERVAL_DAY_TIME: return "tiD"; case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: return "tin"; case NANOARROW_TYPE_LIST: return "+l"; case NANOARROW_TYPE_LARGE_LIST: return "+L"; case NANOARROW_TYPE_STRUCT: return "+s"; case NANOARROW_TYPE_MAP: return "+m"; case NANOARROW_TYPE_RUN_END_ENCODED: return "+r"; default: return NULL; } } static int ArrowSchemaInitChildrenIfNeeded(struct ArrowSchema* schema, enum ArrowType type) { switch (type) { case NANOARROW_TYPE_LIST: case NANOARROW_TYPE_LARGE_LIST: case NANOARROW_TYPE_FIXED_SIZE_LIST: NANOARROW_RETURN_NOT_OK(ArrowSchemaAllocateChildren(schema, 1)); ArrowSchemaInit(schema->children[0]); NANOARROW_RETURN_NOT_OK(ArrowSchemaSetName(schema->children[0], "item")); break; case NANOARROW_TYPE_MAP: NANOARROW_RETURN_NOT_OK(ArrowSchemaAllocateChildren(schema, 1)); NANOARROW_RETURN_NOT_OK( ArrowSchemaInitFromType(schema->children[0], NANOARROW_TYPE_STRUCT)); NANOARROW_RETURN_NOT_OK(ArrowSchemaSetName(schema->children[0], "entries")); schema->children[0]->flags &= ~ARROW_FLAG_NULLABLE; NANOARROW_RETURN_NOT_OK(ArrowSchemaAllocateChildren(schema->children[0], 2)); ArrowSchemaInit(schema->children[0]->children[0]); ArrowSchemaInit(schema->children[0]->children[1]); NANOARROW_RETURN_NOT_OK( ArrowSchemaSetName(schema->children[0]->children[0], "key")); schema->children[0]->children[0]->flags &= ~ARROW_FLAG_NULLABLE; NANOARROW_RETURN_NOT_OK( ArrowSchemaSetName(schema->children[0]->children[1], "value")); break; case NANOARROW_TYPE_RUN_END_ENCODED: NANOARROW_RETURN_NOT_OK(ArrowSchemaAllocateChildren(schema, 2)); ArrowSchemaInit(schema->children[0]); NANOARROW_RETURN_NOT_OK(ArrowSchemaSetName(schema->children[0], "run_ends")); schema->children[0]->flags &= ~ARROW_FLAG_NULLABLE; ArrowSchemaInit(schema->children[1]); NANOARROW_RETURN_NOT_OK(ArrowSchemaSetName(schema->children[1], "values")); default: break; } return NANOARROW_OK; } void ArrowSchemaInit(struct ArrowSchema* schema) { schema->format = NULL; schema->name = NULL; schema->metadata = NULL; schema->flags = ARROW_FLAG_NULLABLE; schema->n_children = 0; schema->children = NULL; schema->dictionary = NULL; schema->private_data = NULL; schema->release = &ArrowSchemaReleaseInternal; } ArrowErrorCode ArrowSchemaSetType(struct ArrowSchema* schema, enum ArrowType type) { // We don't allocate the dictionary because it has to be nullptr // for non-dictionary-encoded arrays. // Set the format to a valid format string for type const char* template_format = ArrowSchemaFormatTemplate(type); // If type isn't recognized and not explicitly unset if (template_format == NULL && type != NANOARROW_TYPE_UNINITIALIZED) { return EINVAL; } NANOARROW_RETURN_NOT_OK(ArrowSchemaSetFormat(schema, template_format)); // For types with an umabiguous child structure, allocate children return ArrowSchemaInitChildrenIfNeeded(schema, type); } ArrowErrorCode ArrowSchemaSetTypeStruct(struct ArrowSchema* schema, int64_t n_children) { NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_STRUCT)); NANOARROW_RETURN_NOT_OK(ArrowSchemaAllocateChildren(schema, n_children)); for (int64_t i = 0; i < n_children; i++) { ArrowSchemaInit(schema->children[i]); } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaInitFromType(struct ArrowSchema* schema, enum ArrowType type) { ArrowSchemaInit(schema); int result = ArrowSchemaSetType(schema, type); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema); return result; } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaSetTypeFixedSize(struct ArrowSchema* schema, enum ArrowType type, int32_t fixed_size) { if (fixed_size <= 0) { return EINVAL; } char buffer[64]; int n_chars; switch (type) { case NANOARROW_TYPE_FIXED_SIZE_BINARY: n_chars = snprintf(buffer, sizeof(buffer), "w:%" PRId32, fixed_size); break; case NANOARROW_TYPE_FIXED_SIZE_LIST: n_chars = snprintf(buffer, sizeof(buffer), "+w:%" PRId32, fixed_size); break; default: return EINVAL; } if (((size_t)n_chars) >= sizeof(buffer) || n_chars < 0) { return ERANGE; } buffer[n_chars] = '\0'; NANOARROW_RETURN_NOT_OK(ArrowSchemaSetFormat(schema, buffer)); if (type == NANOARROW_TYPE_FIXED_SIZE_LIST) { NANOARROW_RETURN_NOT_OK(ArrowSchemaInitChildrenIfNeeded(schema, type)); } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaSetTypeDecimal(struct ArrowSchema* schema, enum ArrowType type, int32_t decimal_precision, int32_t decimal_scale) { if (decimal_precision <= 0) { return EINVAL; } char buffer[64]; int n_chars; switch (type) { case NANOARROW_TYPE_DECIMAL128: n_chars = snprintf(buffer, sizeof(buffer), "d:%d,%d", decimal_precision, decimal_scale); break; case NANOARROW_TYPE_DECIMAL256: n_chars = snprintf(buffer, sizeof(buffer), "d:%d,%d,256", decimal_precision, decimal_scale); break; default: return EINVAL; } if (((size_t)n_chars) >= sizeof(buffer) || n_chars < 0) { return ERANGE; } buffer[n_chars] = '\0'; return ArrowSchemaSetFormat(schema, buffer); } ArrowErrorCode ArrowSchemaSetTypeRunEndEncoded(struct ArrowSchema* schema, enum ArrowType run_end_type) { switch (run_end_type) { case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_INT64: break; default: return EINVAL; } NANOARROW_RETURN_NOT_OK(ArrowSchemaSetFormat( schema, ArrowSchemaFormatTemplate(NANOARROW_TYPE_RUN_END_ENCODED))); NANOARROW_RETURN_NOT_OK( ArrowSchemaInitChildrenIfNeeded(schema, NANOARROW_TYPE_RUN_END_ENCODED)); NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema->children[0], run_end_type)); NANOARROW_RETURN_NOT_OK( ArrowSchemaSetType(schema->children[1], NANOARROW_TYPE_UNINITIALIZED)); return NANOARROW_OK; } static const char* ArrowTimeUnitFormatString(enum ArrowTimeUnit time_unit) { switch (time_unit) { case NANOARROW_TIME_UNIT_SECOND: return "s"; case NANOARROW_TIME_UNIT_MILLI: return "m"; case NANOARROW_TIME_UNIT_MICRO: return "u"; case NANOARROW_TIME_UNIT_NANO: return "n"; default: return NULL; } } ArrowErrorCode ArrowSchemaSetTypeDateTime(struct ArrowSchema* schema, enum ArrowType type, enum ArrowTimeUnit time_unit, const char* timezone) { const char* time_unit_str = ArrowTimeUnitFormatString(time_unit); if (time_unit_str == NULL) { return EINVAL; } char buffer[128]; int n_chars; switch (type) { case NANOARROW_TYPE_TIME32: if (timezone != NULL) { return EINVAL; } switch (time_unit) { case NANOARROW_TIME_UNIT_MICRO: case NANOARROW_TIME_UNIT_NANO: return EINVAL; default: break; } n_chars = snprintf(buffer, sizeof(buffer), "tt%s", time_unit_str); break; case NANOARROW_TYPE_TIME64: if (timezone != NULL) { return EINVAL; } switch (time_unit) { case NANOARROW_TIME_UNIT_SECOND: case NANOARROW_TIME_UNIT_MILLI: return EINVAL; default: break; } n_chars = snprintf(buffer, sizeof(buffer), "tt%s", time_unit_str); break; case NANOARROW_TYPE_TIMESTAMP: if (timezone == NULL) { timezone = ""; } n_chars = snprintf(buffer, sizeof(buffer), "ts%s:%s", time_unit_str, timezone); break; case NANOARROW_TYPE_DURATION: if (timezone != NULL) { return EINVAL; } n_chars = snprintf(buffer, sizeof(buffer), "tD%s", time_unit_str); break; default: return EINVAL; } if (((size_t)n_chars) >= sizeof(buffer) || n_chars < 0) { return ERANGE; } buffer[n_chars] = '\0'; return ArrowSchemaSetFormat(schema, buffer); } ArrowErrorCode ArrowSchemaSetTypeUnion(struct ArrowSchema* schema, enum ArrowType type, int64_t n_children) { if (n_children < 0 || n_children > 127) { return EINVAL; } // Max valid size would be +ud:0,1,...126 = 401 characters + null terminator char format_out[512]; int64_t format_out_size = 512; memset(format_out, 0, format_out_size); int n_chars; char* format_cursor = format_out; switch (type) { case NANOARROW_TYPE_SPARSE_UNION: n_chars = snprintf(format_cursor, format_out_size, "+us:"); format_cursor += n_chars; format_out_size -= n_chars; break; case NANOARROW_TYPE_DENSE_UNION: n_chars = snprintf(format_cursor, format_out_size, "+ud:"); format_cursor += n_chars; format_out_size -= n_chars; break; default: return EINVAL; } // Ensure that an encoding error from snprintf() does not result // in an out-of-bounds access. if (n_chars < 0) { return ERANGE; } if (n_children > 0) { n_chars = snprintf(format_cursor, format_out_size, "0"); format_cursor += n_chars; format_out_size -= n_chars; for (int64_t i = 1; i < n_children; i++) { n_chars = snprintf(format_cursor, format_out_size, ",%" PRId64, i); format_cursor += n_chars; format_out_size -= n_chars; } } // Ensure that an encoding error from snprintf() does not result // in an out-of-bounds access. if (n_chars < 0) { return ERANGE; } NANOARROW_RETURN_NOT_OK(ArrowSchemaSetFormat(schema, format_out)); NANOARROW_RETURN_NOT_OK(ArrowSchemaAllocateChildren(schema, n_children)); for (int64_t i = 0; i < n_children; i++) { ArrowSchemaInit(schema->children[i]); } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaSetFormat(struct ArrowSchema* schema, const char* format) { if (schema->format != NULL) { ArrowFree((void*)schema->format); } if (format != NULL) { size_t format_size = strlen(format) + 1; schema->format = (const char*)ArrowMalloc(format_size); if (schema->format == NULL) { return ENOMEM; } memcpy((void*)schema->format, format, format_size); } else { schema->format = NULL; } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaSetName(struct ArrowSchema* schema, const char* name) { if (schema->name != NULL) { ArrowFree((void*)schema->name); } if (name != NULL) { size_t name_size = strlen(name) + 1; schema->name = (const char*)ArrowMalloc(name_size); if (schema->name == NULL) { return ENOMEM; } memcpy((void*)schema->name, name, name_size); } else { schema->name = NULL; } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaSetMetadata(struct ArrowSchema* schema, const char* metadata) { if (schema->metadata != NULL) { ArrowFree((void*)schema->metadata); } if (metadata != NULL) { size_t metadata_size = ArrowMetadataSizeOf(metadata); schema->metadata = (const char*)ArrowMalloc(metadata_size); if (schema->metadata == NULL) { return ENOMEM; } memcpy((void*)schema->metadata, metadata, metadata_size); } else { schema->metadata = NULL; } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaAllocateChildren(struct ArrowSchema* schema, int64_t n_children) { if (schema->children != NULL) { return EEXIST; } if (n_children > 0) { schema->children = (struct ArrowSchema**)ArrowMalloc(n_children * sizeof(struct ArrowSchema*)); if (schema->children == NULL) { return ENOMEM; } schema->n_children = n_children; memset(schema->children, 0, n_children * sizeof(struct ArrowSchema*)); for (int64_t i = 0; i < n_children; i++) { schema->children[i] = (struct ArrowSchema*)ArrowMalloc(sizeof(struct ArrowSchema)); if (schema->children[i] == NULL) { return ENOMEM; } schema->children[i]->release = NULL; } } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaAllocateDictionary(struct ArrowSchema* schema) { if (schema->dictionary != NULL) { return EEXIST; } schema->dictionary = (struct ArrowSchema*)ArrowMalloc(sizeof(struct ArrowSchema)); if (schema->dictionary == NULL) { return ENOMEM; } schema->dictionary->release = NULL; return NANOARROW_OK; } ArrowErrorCode ArrowSchemaDeepCopy(const struct ArrowSchema* schema, struct ArrowSchema* schema_out) { ArrowSchemaInit(schema_out); int result = ArrowSchemaSetFormat(schema_out, schema->format); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema_out); return result; } schema_out->flags = schema->flags; result = ArrowSchemaSetName(schema_out, schema->name); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema_out); return result; } result = ArrowSchemaSetMetadata(schema_out, schema->metadata); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema_out); return result; } result = ArrowSchemaAllocateChildren(schema_out, schema->n_children); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema_out); return result; } for (int64_t i = 0; i < schema->n_children; i++) { result = ArrowSchemaDeepCopy(schema->children[i], schema_out->children[i]); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema_out); return result; } } if (schema->dictionary != NULL) { result = ArrowSchemaAllocateDictionary(schema_out); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema_out); return result; } result = ArrowSchemaDeepCopy(schema->dictionary, schema_out->dictionary); if (result != NANOARROW_OK) { ArrowSchemaRelease(schema_out); return result; } } return NANOARROW_OK; } static void ArrowSchemaViewSetPrimitive(struct ArrowSchemaView* schema_view, enum ArrowType type) { schema_view->type = type; schema_view->storage_type = type; } static ArrowErrorCode ArrowSchemaViewParse(struct ArrowSchemaView* schema_view, const char* format, const char** format_end_out, struct ArrowError* error) { *format_end_out = format; // needed for decimal parsing const char* parse_start; char* parse_end; switch (format[0]) { case 'n': schema_view->type = NANOARROW_TYPE_NA; schema_view->storage_type = NANOARROW_TYPE_NA; *format_end_out = format + 1; return NANOARROW_OK; case 'b': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_BOOL); *format_end_out = format + 1; return NANOARROW_OK; case 'c': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT8); *format_end_out = format + 1; return NANOARROW_OK; case 'C': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_UINT8); *format_end_out = format + 1; return NANOARROW_OK; case 's': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT16); *format_end_out = format + 1; return NANOARROW_OK; case 'S': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_UINT16); *format_end_out = format + 1; return NANOARROW_OK; case 'i': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT32); *format_end_out = format + 1; return NANOARROW_OK; case 'I': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_UINT32); *format_end_out = format + 1; return NANOARROW_OK; case 'l': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); *format_end_out = format + 1; return NANOARROW_OK; case 'L': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_UINT64); *format_end_out = format + 1; return NANOARROW_OK; case 'e': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_HALF_FLOAT); *format_end_out = format + 1; return NANOARROW_OK; case 'f': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_FLOAT); *format_end_out = format + 1; return NANOARROW_OK; case 'g': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_DOUBLE); *format_end_out = format + 1; return NANOARROW_OK; // decimal case 'd': if (format[1] != ':' || format[2] == '\0') { ArrowErrorSet(error, "Expected ':precision,scale[,bitwidth]' following 'd'"); return EINVAL; } parse_start = format + 2; schema_view->decimal_precision = (int32_t)strtol(parse_start, &parse_end, 10); if (parse_end == parse_start || parse_end[0] != ',') { ArrowErrorSet(error, "Expected 'precision,scale[,bitwidth]' following 'd:'"); return EINVAL; } parse_start = parse_end + 1; schema_view->decimal_scale = (int32_t)strtol(parse_start, &parse_end, 10); if (parse_end == parse_start) { ArrowErrorSet(error, "Expected 'scale[,bitwidth]' following 'd:precision,'"); return EINVAL; } else if (parse_end[0] != ',') { schema_view->decimal_bitwidth = 128; } else { parse_start = parse_end + 1; schema_view->decimal_bitwidth = (int32_t)strtol(parse_start, &parse_end, 10); if (parse_start == parse_end) { ArrowErrorSet(error, "Expected precision following 'd:precision,scale,'"); return EINVAL; } } *format_end_out = parse_end; switch (schema_view->decimal_bitwidth) { case 128: ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_DECIMAL128); return NANOARROW_OK; case 256: ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_DECIMAL256); return NANOARROW_OK; default: ArrowErrorSet(error, "Expected decimal bitwidth of 128 or 256 but found %" PRId32, schema_view->decimal_bitwidth); return EINVAL; } // validity + data case 'w': schema_view->type = NANOARROW_TYPE_FIXED_SIZE_BINARY; schema_view->storage_type = NANOARROW_TYPE_FIXED_SIZE_BINARY; if (format[1] != ':' || format[2] == '\0') { ArrowErrorSet(error, "Expected ':' following 'w'"); return EINVAL; } schema_view->fixed_size = (int32_t)strtol(format + 2, (char**)format_end_out, 10); return NANOARROW_OK; // validity + offset + data case 'z': schema_view->type = NANOARROW_TYPE_BINARY; schema_view->storage_type = NANOARROW_TYPE_BINARY; *format_end_out = format + 1; return NANOARROW_OK; case 'u': schema_view->type = NANOARROW_TYPE_STRING; schema_view->storage_type = NANOARROW_TYPE_STRING; *format_end_out = format + 1; return NANOARROW_OK; // validity + large_offset + data case 'Z': schema_view->type = NANOARROW_TYPE_LARGE_BINARY; schema_view->storage_type = NANOARROW_TYPE_LARGE_BINARY; *format_end_out = format + 1; return NANOARROW_OK; case 'U': schema_view->type = NANOARROW_TYPE_LARGE_STRING; schema_view->storage_type = NANOARROW_TYPE_LARGE_STRING; *format_end_out = format + 1; return NANOARROW_OK; // nested types case '+': switch (format[1]) { // list has validity + offset or offset case 'l': schema_view->storage_type = NANOARROW_TYPE_LIST; schema_view->type = NANOARROW_TYPE_LIST; *format_end_out = format + 2; return NANOARROW_OK; // large list has validity + large_offset or large_offset case 'L': schema_view->storage_type = NANOARROW_TYPE_LARGE_LIST; schema_view->type = NANOARROW_TYPE_LARGE_LIST; *format_end_out = format + 2; return NANOARROW_OK; // run end encoded has no buffer at all case 'r': schema_view->storage_type = NANOARROW_TYPE_RUN_END_ENCODED; schema_view->type = NANOARROW_TYPE_RUN_END_ENCODED; *format_end_out = format + 2; return NANOARROW_OK; // just validity buffer case 'w': if (format[2] != ':' || format[3] == '\0') { ArrowErrorSet(error, "Expected ':' following '+w'"); return EINVAL; } schema_view->storage_type = NANOARROW_TYPE_FIXED_SIZE_LIST; schema_view->type = NANOARROW_TYPE_FIXED_SIZE_LIST; schema_view->fixed_size = (int32_t)strtol(format + 3, (char**)format_end_out, 10); return NANOARROW_OK; case 's': schema_view->storage_type = NANOARROW_TYPE_STRUCT; schema_view->type = NANOARROW_TYPE_STRUCT; *format_end_out = format + 2; return NANOARROW_OK; case 'm': schema_view->storage_type = NANOARROW_TYPE_MAP; schema_view->type = NANOARROW_TYPE_MAP; *format_end_out = format + 2; return NANOARROW_OK; // unions case 'u': switch (format[2]) { case 'd': schema_view->storage_type = NANOARROW_TYPE_DENSE_UNION; schema_view->type = NANOARROW_TYPE_DENSE_UNION; break; case 's': schema_view->storage_type = NANOARROW_TYPE_SPARSE_UNION; schema_view->type = NANOARROW_TYPE_SPARSE_UNION; break; default: ArrowErrorSet(error, "Expected union format string +us: or " "+ud: but found '%s'", format); return EINVAL; } if (format[3] == ':') { schema_view->union_type_ids = format + 4; int64_t n_type_ids = _ArrowParseUnionTypeIds(schema_view->union_type_ids, NULL); if (n_type_ids != schema_view->schema->n_children) { ArrowErrorSet(error, "Expected union type_ids parameter to be a comma-separated " "list of %" PRId64 " values between 0 and 127 but found '%s'", schema_view->schema->n_children, schema_view->union_type_ids); return EINVAL; } *format_end_out = format + strlen(format); return NANOARROW_OK; } else { ArrowErrorSet(error, "Expected union format string +us: or +ud: " "but found '%s'", format); return EINVAL; } default: ArrowErrorSet(error, "Expected nested type format string but found '%s'", format); return EINVAL; } // date/time types case 't': switch (format[1]) { // date case 'd': switch (format[2]) { case 'D': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT32); schema_view->type = NANOARROW_TYPE_DATE32; *format_end_out = format + 3; return NANOARROW_OK; case 'm': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_DATE64; *format_end_out = format + 3; return NANOARROW_OK; default: ArrowErrorSet(error, "Expected 'D' or 'm' following 'td' but found '%s'", format + 2); return EINVAL; } // time of day case 't': switch (format[2]) { case 's': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT32); schema_view->type = NANOARROW_TYPE_TIME32; schema_view->time_unit = NANOARROW_TIME_UNIT_SECOND; *format_end_out = format + 3; return NANOARROW_OK; case 'm': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT32); schema_view->type = NANOARROW_TYPE_TIME32; schema_view->time_unit = NANOARROW_TIME_UNIT_MILLI; *format_end_out = format + 3; return NANOARROW_OK; case 'u': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_TIME64; schema_view->time_unit = NANOARROW_TIME_UNIT_MICRO; *format_end_out = format + 3; return NANOARROW_OK; case 'n': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_TIME64; schema_view->time_unit = NANOARROW_TIME_UNIT_NANO; *format_end_out = format + 3; return NANOARROW_OK; default: ArrowErrorSet( error, "Expected 's', 'm', 'u', or 'n' following 'tt' but found '%s'", format + 2); return EINVAL; } // timestamp case 's': switch (format[2]) { case 's': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_TIMESTAMP; schema_view->time_unit = NANOARROW_TIME_UNIT_SECOND; break; case 'm': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_TIMESTAMP; schema_view->time_unit = NANOARROW_TIME_UNIT_MILLI; break; case 'u': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_TIMESTAMP; schema_view->time_unit = NANOARROW_TIME_UNIT_MICRO; break; case 'n': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_TIMESTAMP; schema_view->time_unit = NANOARROW_TIME_UNIT_NANO; break; default: ArrowErrorSet( error, "Expected 's', 'm', 'u', or 'n' following 'ts' but found '%s'", format + 2); return EINVAL; } if (format[3] != ':') { ArrowErrorSet(error, "Expected ':' following '%.3s' but found '%s'", format, format + 3); return EINVAL; } schema_view->timezone = format + 4; *format_end_out = format + strlen(format); return NANOARROW_OK; // duration case 'D': switch (format[2]) { case 's': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_DURATION; schema_view->time_unit = NANOARROW_TIME_UNIT_SECOND; *format_end_out = format + 3; return NANOARROW_OK; case 'm': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_DURATION; schema_view->time_unit = NANOARROW_TIME_UNIT_MILLI; *format_end_out = format + 3; return NANOARROW_OK; case 'u': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_DURATION; schema_view->time_unit = NANOARROW_TIME_UNIT_MICRO; *format_end_out = format + 3; return NANOARROW_OK; case 'n': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INT64); schema_view->type = NANOARROW_TYPE_DURATION; schema_view->time_unit = NANOARROW_TIME_UNIT_NANO; *format_end_out = format + 3; return NANOARROW_OK; default: ArrowErrorSet(error, "Expected 's', 'm', u', or 'n' following 'tD' but found '%s'", format + 2); return EINVAL; } // interval case 'i': switch (format[2]) { case 'M': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INTERVAL_MONTHS); *format_end_out = format + 3; return NANOARROW_OK; case 'D': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INTERVAL_DAY_TIME); *format_end_out = format + 3; return NANOARROW_OK; case 'n': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO); *format_end_out = format + 3; return NANOARROW_OK; default: ArrowErrorSet(error, "Expected 'M', 'D', or 'n' following 'ti' but found '%s'", format + 2); return EINVAL; } default: ArrowErrorSet( error, "Expected 'd', 't', 's', 'D', or 'i' following 't' but found '%s'", format + 1); return EINVAL; } // view types case 'v': { switch (format[1]) { case 'u': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_STRING_VIEW); *format_end_out = format + 2; return NANOARROW_OK; case 'z': ArrowSchemaViewSetPrimitive(schema_view, NANOARROW_TYPE_BINARY_VIEW); *format_end_out = format + 2; return NANOARROW_OK; default: ArrowErrorSet(error, "Expected 'u', or 'z' following 'v' but found '%s'", format + 1); return EINVAL; } } default: ArrowErrorSet(error, "Unknown format: '%s'", format); return EINVAL; } } static ArrowErrorCode ArrowSchemaViewValidateNChildren( struct ArrowSchemaView* schema_view, int64_t n_children, struct ArrowError* error) { if (n_children != -1 && schema_view->schema->n_children != n_children) { ArrowErrorSet( error, "Expected schema with %" PRId64 " children but found %" PRId64 " children", n_children, schema_view->schema->n_children); return EINVAL; } // Don't do a full validation of children but do check that they won't // segfault if inspected struct ArrowSchema* child; for (int64_t i = 0; i < schema_view->schema->n_children; i++) { child = schema_view->schema->children[i]; if (child == NULL) { ArrowErrorSet( error, "Expected valid schema at schema->children[%" PRId64 "] but found NULL", i); return EINVAL; } else if (child->release == NULL) { ArrowErrorSet(error, "Expected valid schema at schema->children[%" PRId64 "] but found a released schema", i); return EINVAL; } } return NANOARROW_OK; } static ArrowErrorCode ArrowSchemaViewValidateUnion(struct ArrowSchemaView* schema_view, struct ArrowError* error) { return ArrowSchemaViewValidateNChildren(schema_view, -1, error); } static ArrowErrorCode ArrowSchemaViewValidateMap(struct ArrowSchemaView* schema_view, struct ArrowError* error) { NANOARROW_RETURN_NOT_OK(ArrowSchemaViewValidateNChildren(schema_view, 1, error)); if (schema_view->schema->children[0]->n_children != 2) { ArrowErrorSet(error, "Expected child of map type to have 2 children but found %" PRId64, schema_view->schema->children[0]->n_children); return EINVAL; } if (strcmp(schema_view->schema->children[0]->format, "+s") != 0) { ArrowErrorSet(error, "Expected format of child of map type to be '+s' but found '%s'", schema_view->schema->children[0]->format); return EINVAL; } if (schema_view->schema->children[0]->flags & ARROW_FLAG_NULLABLE) { ArrowErrorSet(error, "Expected child of map type to be non-nullable but was nullable"); return EINVAL; } if (schema_view->schema->children[0]->children[0]->flags & ARROW_FLAG_NULLABLE) { ArrowErrorSet(error, "Expected key of map type to be non-nullable but was nullable"); return EINVAL; } return NANOARROW_OK; } static ArrowErrorCode ArrowSchemaViewValidateDictionary( struct ArrowSchemaView* schema_view, struct ArrowError* error) { // check for valid index type switch (schema_view->storage_type) { case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_INT64: break; default: ArrowErrorSet( error, "Expected dictionary schema index type to be an integral type but found '%s'", schema_view->schema->format); return EINVAL; } struct ArrowSchemaView dictionary_schema_view; return ArrowSchemaViewInit(&dictionary_schema_view, schema_view->schema->dictionary, error); } static ArrowErrorCode ArrowSchemaViewValidate(struct ArrowSchemaView* schema_view, enum ArrowType type, struct ArrowError* error) { switch (type) { case NANOARROW_TYPE_NA: case NANOARROW_TYPE_BOOL: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_HALF_FLOAT: case NANOARROW_TYPE_FLOAT: case NANOARROW_TYPE_DOUBLE: case NANOARROW_TYPE_DECIMAL128: case NANOARROW_TYPE_DECIMAL256: case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_BINARY: case NANOARROW_TYPE_LARGE_BINARY: case NANOARROW_TYPE_DATE32: case NANOARROW_TYPE_DATE64: case NANOARROW_TYPE_INTERVAL_MONTHS: case NANOARROW_TYPE_INTERVAL_DAY_TIME: case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: case NANOARROW_TYPE_TIMESTAMP: case NANOARROW_TYPE_TIME32: case NANOARROW_TYPE_TIME64: case NANOARROW_TYPE_DURATION: case NANOARROW_TYPE_BINARY_VIEW: case NANOARROW_TYPE_STRING_VIEW: return ArrowSchemaViewValidateNChildren(schema_view, 0, error); case NANOARROW_TYPE_FIXED_SIZE_BINARY: if (schema_view->fixed_size <= 0) { ArrowErrorSet(error, "Expected size > 0 for fixed size binary but found size %d", schema_view->fixed_size); return EINVAL; } return ArrowSchemaViewValidateNChildren(schema_view, 0, error); case NANOARROW_TYPE_LIST: case NANOARROW_TYPE_LARGE_LIST: case NANOARROW_TYPE_FIXED_SIZE_LIST: return ArrowSchemaViewValidateNChildren(schema_view, 1, error); case NANOARROW_TYPE_RUN_END_ENCODED: return ArrowSchemaViewValidateNChildren(schema_view, 2, error); case NANOARROW_TYPE_STRUCT: return ArrowSchemaViewValidateNChildren(schema_view, -1, error); case NANOARROW_TYPE_SPARSE_UNION: case NANOARROW_TYPE_DENSE_UNION: return ArrowSchemaViewValidateUnion(schema_view, error); case NANOARROW_TYPE_MAP: return ArrowSchemaViewValidateMap(schema_view, error); case NANOARROW_TYPE_DICTIONARY: return ArrowSchemaViewValidateDictionary(schema_view, error); default: ArrowErrorSet(error, "Expected a valid enum ArrowType value but found %d", schema_view->type); return EINVAL; } return NANOARROW_OK; } ArrowErrorCode ArrowSchemaViewInit(struct ArrowSchemaView* schema_view, const struct ArrowSchema* schema, struct ArrowError* error) { if (schema == NULL) { ArrowErrorSet(error, "Expected non-NULL schema"); return EINVAL; } if (schema->release == NULL) { ArrowErrorSet(error, "Expected non-released schema"); return EINVAL; } schema_view->schema = schema; const char* format = schema->format; if (format == NULL) { ArrowErrorSet( error, "Error parsing schema->format: Expected a null-terminated string but found NULL"); return EINVAL; } size_t format_len = strlen(format); if (format_len == 0) { ArrowErrorSet(error, "Error parsing schema->format: Expected a string with size > 0"); return EINVAL; } const char* format_end_out; int result = ArrowSchemaViewParse(schema_view, format, &format_end_out, error); if (result != NANOARROW_OK) { if (error != NULL) { char child_error[1024]; memcpy(child_error, ArrowErrorMessage(error), 1024); ArrowErrorSet(error, "Error parsing schema->format: %s", child_error); } return result; } if ((format + format_len) != format_end_out) { ArrowErrorSet(error, "Error parsing schema->format '%s': parsed %d/%zu characters", format, (int)(format_end_out - format), format_len); return EINVAL; } if (schema->dictionary != NULL) { schema_view->type = NANOARROW_TYPE_DICTIONARY; } NANOARROW_RETURN_NOT_OK( ArrowSchemaViewValidate(schema_view, schema_view->storage_type, error)); if (schema_view->storage_type != schema_view->type) { NANOARROW_RETURN_NOT_OK( ArrowSchemaViewValidate(schema_view, schema_view->type, error)); } int64_t unknown_flags = schema->flags & ~NANOARROW_FLAG_ALL_SUPPORTED; if (unknown_flags != 0) { ArrowErrorSet(error, "Unknown ArrowSchema flag"); return EINVAL; } if (schema->flags & ARROW_FLAG_DICTIONARY_ORDERED && schema_view->type != NANOARROW_TYPE_DICTIONARY) { ArrowErrorSet(error, "ARROW_FLAG_DICTIONARY_ORDERED is only relevant for dictionaries"); return EINVAL; } if (schema->flags & ARROW_FLAG_MAP_KEYS_SORTED && schema_view->type != NANOARROW_TYPE_MAP) { ArrowErrorSet(error, "ARROW_FLAG_MAP_KEYS_SORTED is only relevant for a map type"); return EINVAL; } ArrowLayoutInit(&schema_view->layout, schema_view->storage_type); if (schema_view->storage_type == NANOARROW_TYPE_FIXED_SIZE_BINARY) { schema_view->layout.element_size_bits[1] = schema_view->fixed_size * 8; } else if (schema_view->storage_type == NANOARROW_TYPE_FIXED_SIZE_LIST) { schema_view->layout.child_size_elements = schema_view->fixed_size; } schema_view->extension_name = ArrowCharView(NULL); schema_view->extension_metadata = ArrowCharView(NULL); NANOARROW_RETURN_NOT_OK(ArrowMetadataGetValue(schema->metadata, ArrowCharView("ARROW:extension:name"), &schema_view->extension_name)); NANOARROW_RETURN_NOT_OK(ArrowMetadataGetValue(schema->metadata, ArrowCharView("ARROW:extension:metadata"), &schema_view->extension_metadata)); return NANOARROW_OK; } static int64_t ArrowSchemaTypeToStringInternal(struct ArrowSchemaView* schema_view, char* out, int64_t n) { const char* type_string = ArrowTypeString(schema_view->type); switch (schema_view->type) { case NANOARROW_TYPE_DECIMAL128: case NANOARROW_TYPE_DECIMAL256: return snprintf(out, n, "%s(%" PRId32 ", %" PRId32 ")", type_string, schema_view->decimal_precision, schema_view->decimal_scale); case NANOARROW_TYPE_TIMESTAMP: return snprintf(out, n, "%s('%s', '%s')", type_string, ArrowTimeUnitString(schema_view->time_unit), schema_view->timezone); case NANOARROW_TYPE_TIME32: case NANOARROW_TYPE_TIME64: case NANOARROW_TYPE_DURATION: return snprintf(out, n, "%s('%s')", type_string, ArrowTimeUnitString(schema_view->time_unit)); case NANOARROW_TYPE_FIXED_SIZE_BINARY: case NANOARROW_TYPE_FIXED_SIZE_LIST: return snprintf(out, n, "%s(%" PRId32 ")", type_string, schema_view->fixed_size); case NANOARROW_TYPE_SPARSE_UNION: case NANOARROW_TYPE_DENSE_UNION: return snprintf(out, n, "%s([%s])", type_string, schema_view->union_type_ids); default: return snprintf(out, n, "%s", type_string); } } // Helper for bookkeeping to emulate sprintf()-like behaviour spread // among multiple sprintf calls. static inline void ArrowToStringLogChars(char** out, int64_t n_chars_last, int64_t* n_remaining, int64_t* n_chars) { // In the unlikely snprintf() returning a negative value (encoding error), // ensure the result won't cause an out-of-bounds access. if (n_chars_last < 0) { n_chars_last = 0; } *n_chars += n_chars_last; *n_remaining -= n_chars_last; // n_remaining is never less than 0 if (*n_remaining < 0) { *n_remaining = 0; } // Can't do math on a NULL pointer if (*out != NULL) { *out += n_chars_last; } } int64_t ArrowSchemaToString(const struct ArrowSchema* schema, char* out, int64_t n, char recursive) { if (schema == NULL) { return snprintf(out, n, "[invalid: pointer is null]"); } if (schema->release == NULL) { return snprintf(out, n, "[invalid: schema is released]"); } struct ArrowSchemaView schema_view; struct ArrowError error; if (ArrowSchemaViewInit(&schema_view, schema, &error) != NANOARROW_OK) { return snprintf(out, n, "[invalid: %s]", ArrowErrorMessage(&error)); } // Extension type and dictionary should include both the top-level type // and the storage type. int is_extension = schema_view.extension_name.size_bytes > 0; int is_dictionary = schema->dictionary != NULL; int64_t n_chars = 0; int64_t n_chars_last = 0; // Uncommon but not technically impossible that both are true if (is_extension && is_dictionary) { n_chars_last = snprintf( out, n, "%.*s{dictionary(%s)<", (int)schema_view.extension_name.size_bytes, schema_view.extension_name.data, ArrowTypeString(schema_view.storage_type)); } else if (is_extension) { n_chars_last = snprintf(out, n, "%.*s{", (int)schema_view.extension_name.size_bytes, schema_view.extension_name.data); } else if (is_dictionary) { n_chars_last = snprintf(out, n, "dictionary(%s)<", ArrowTypeString(schema_view.storage_type)); } ArrowToStringLogChars(&out, n_chars_last, &n, &n_chars); if (!is_dictionary) { n_chars_last = ArrowSchemaTypeToStringInternal(&schema_view, out, n); } else { n_chars_last = ArrowSchemaToString(schema->dictionary, out, n, recursive); } ArrowToStringLogChars(&out, n_chars_last, &n, &n_chars); if (recursive && schema->format[0] == '+') { n_chars_last = snprintf(out, n, "<"); ArrowToStringLogChars(&out, n_chars_last, &n, &n_chars); for (int64_t i = 0; i < schema->n_children; i++) { if (i > 0) { n_chars_last = snprintf(out, n, ", "); ArrowToStringLogChars(&out, n_chars_last, &n, &n_chars); } // ArrowSchemaToStringInternal() will validate the child and print the error, // but we need the name first if (schema->children[i] != NULL && schema->children[i]->release != NULL && schema->children[i]->name != NULL) { n_chars_last = snprintf(out, n, "%s: ", schema->children[i]->name); ArrowToStringLogChars(&out, n_chars_last, &n, &n_chars); } n_chars_last = ArrowSchemaToString(schema->children[i], out, n, recursive); ArrowToStringLogChars(&out, n_chars_last, &n, &n_chars); } n_chars_last = snprintf(out, n, ">"); ArrowToStringLogChars(&out, n_chars_last, &n, &n_chars); } if (is_extension && is_dictionary) { n_chars += snprintf(out, n, ">}"); } else if (is_extension) { n_chars += snprintf(out, n, "}"); } else if (is_dictionary) { n_chars += snprintf(out, n, ">"); } // Ensure that we always return a positive result if (n_chars > 0) { return n_chars; } else { return 0; } } ArrowErrorCode ArrowMetadataReaderInit(struct ArrowMetadataReader* reader, const char* metadata) { reader->metadata = metadata; if (reader->metadata == NULL) { reader->offset = 0; reader->remaining_keys = 0; } else { memcpy(&reader->remaining_keys, reader->metadata, sizeof(int32_t)); reader->offset = sizeof(int32_t); } return NANOARROW_OK; } ArrowErrorCode ArrowMetadataReaderRead(struct ArrowMetadataReader* reader, struct ArrowStringView* key_out, struct ArrowStringView* value_out) { if (reader->remaining_keys <= 0) { return EINVAL; } int64_t pos = 0; int32_t key_size; memcpy(&key_size, reader->metadata + reader->offset + pos, sizeof(int32_t)); pos += sizeof(int32_t); key_out->data = reader->metadata + reader->offset + pos; key_out->size_bytes = key_size; pos += key_size; int32_t value_size; memcpy(&value_size, reader->metadata + reader->offset + pos, sizeof(int32_t)); pos += sizeof(int32_t); value_out->data = reader->metadata + reader->offset + pos; value_out->size_bytes = value_size; pos += value_size; reader->offset += pos; reader->remaining_keys--; return NANOARROW_OK; } int64_t ArrowMetadataSizeOf(const char* metadata) { if (metadata == NULL) { return 0; } struct ArrowMetadataReader reader; struct ArrowStringView key; struct ArrowStringView value; if (ArrowMetadataReaderInit(&reader, metadata) != NANOARROW_OK) { return 0; } int64_t size = sizeof(int32_t); while (ArrowMetadataReaderRead(&reader, &key, &value) == NANOARROW_OK) { size += sizeof(int32_t) + key.size_bytes + sizeof(int32_t) + value.size_bytes; } return size; } static ArrowErrorCode ArrowMetadataGetValueInternal(const char* metadata, struct ArrowStringView* key, struct ArrowStringView* value_out) { struct ArrowMetadataReader reader; struct ArrowStringView existing_key; struct ArrowStringView existing_value; NANOARROW_RETURN_NOT_OK(ArrowMetadataReaderInit(&reader, metadata)); while (ArrowMetadataReaderRead(&reader, &existing_key, &existing_value) == NANOARROW_OK) { int key_equal = key->size_bytes == existing_key.size_bytes && strncmp(key->data, existing_key.data, existing_key.size_bytes) == 0; if (key_equal) { value_out->data = existing_value.data; value_out->size_bytes = existing_value.size_bytes; break; } } return NANOARROW_OK; } ArrowErrorCode ArrowMetadataGetValue(const char* metadata, struct ArrowStringView key, struct ArrowStringView* value_out) { if (value_out == NULL) { return EINVAL; } return ArrowMetadataGetValueInternal(metadata, &key, value_out); } char ArrowMetadataHasKey(const char* metadata, struct ArrowStringView key) { struct ArrowStringView value = ArrowCharView(NULL); if (ArrowMetadataGetValue(metadata, key, &value) != NANOARROW_OK) { return 0; } return value.data != NULL; } ArrowErrorCode ArrowMetadataBuilderInit(struct ArrowBuffer* buffer, const char* metadata) { ArrowBufferInit(buffer); return ArrowBufferAppend(buffer, metadata, ArrowMetadataSizeOf(metadata)); } static ArrowErrorCode ArrowMetadataBuilderAppendInternal(struct ArrowBuffer* buffer, struct ArrowStringView* key, struct ArrowStringView* value) { if (value == NULL) { return NANOARROW_OK; } if (buffer->capacity_bytes == 0) { NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(buffer, 0)); } if (((size_t)buffer->capacity_bytes) < sizeof(int32_t)) { return EINVAL; } int32_t n_keys; memcpy(&n_keys, buffer->data, sizeof(int32_t)); int32_t key_size = (int32_t)key->size_bytes; int32_t value_size = (int32_t)value->size_bytes; NANOARROW_RETURN_NOT_OK(ArrowBufferReserve( buffer, sizeof(int32_t) + key_size + sizeof(int32_t) + value_size)); ArrowBufferAppendUnsafe(buffer, &key_size, sizeof(int32_t)); ArrowBufferAppendUnsafe(buffer, key->data, key_size); ArrowBufferAppendUnsafe(buffer, &value_size, sizeof(int32_t)); ArrowBufferAppendUnsafe(buffer, value->data, value_size); n_keys++; memcpy(buffer->data, &n_keys, sizeof(int32_t)); return NANOARROW_OK; } static ArrowErrorCode ArrowMetadataBuilderSetInternal(struct ArrowBuffer* buffer, struct ArrowStringView* key, struct ArrowStringView* value) { // Inspect the current value to see if we can avoid copying the buffer struct ArrowStringView current_value = ArrowCharView(NULL); NANOARROW_RETURN_NOT_OK( ArrowMetadataGetValueInternal((const char*)buffer->data, key, ¤t_value)); // The key should be removed but no key exists if (value == NULL && current_value.data == NULL) { return NANOARROW_OK; } // The key/value can be appended because no key exists if (value != NULL && current_value.data == NULL) { return ArrowMetadataBuilderAppendInternal(buffer, key, value); } struct ArrowMetadataReader reader; struct ArrowStringView existing_key; struct ArrowStringView existing_value; NANOARROW_RETURN_NOT_OK(ArrowMetadataReaderInit(&reader, (const char*)buffer->data)); struct ArrowBuffer new_buffer; NANOARROW_RETURN_NOT_OK(ArrowMetadataBuilderInit(&new_buffer, NULL)); while (reader.remaining_keys > 0) { int result = ArrowMetadataReaderRead(&reader, &existing_key, &existing_value); if (result != NANOARROW_OK) { ArrowBufferReset(&new_buffer); return result; } if (key->size_bytes == existing_key.size_bytes && strncmp((const char*)key->data, (const char*)existing_key.data, existing_key.size_bytes) == 0) { result = ArrowMetadataBuilderAppendInternal(&new_buffer, key, value); value = NULL; } else { result = ArrowMetadataBuilderAppendInternal(&new_buffer, &existing_key, &existing_value); } if (result != NANOARROW_OK) { ArrowBufferReset(&new_buffer); return result; } } ArrowBufferReset(buffer); ArrowBufferMove(&new_buffer, buffer); return NANOARROW_OK; } ArrowErrorCode ArrowMetadataBuilderAppend(struct ArrowBuffer* buffer, struct ArrowStringView key, struct ArrowStringView value) { return ArrowMetadataBuilderAppendInternal(buffer, &key, &value); } ArrowErrorCode ArrowMetadataBuilderSet(struct ArrowBuffer* buffer, struct ArrowStringView key, struct ArrowStringView value) { return ArrowMetadataBuilderSetInternal(buffer, &key, &value); } ArrowErrorCode ArrowMetadataBuilderRemove(struct ArrowBuffer* buffer, struct ArrowStringView key) { return ArrowMetadataBuilderSetInternal(buffer, &key, NULL); } // 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 #include #include #include #include #include #include #include "nanoarrow.h" static void ArrowArrayReleaseInternal(struct ArrowArray* array) { // Release buffers held by this array struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; if (private_data != NULL) { ArrowBitmapReset(&private_data->bitmap); ArrowBufferReset(&private_data->buffers[0]); ArrowBufferReset(&private_data->buffers[1]); ArrowFree(private_data->buffer_data); for (int32_t i = 0; i < private_data->n_variadic_buffers; ++i) { ArrowBufferReset(&private_data->variadic_buffers[i]); } ArrowFree(private_data->variadic_buffers); ArrowFree(private_data->variadic_buffer_sizes); ArrowFree(private_data); } // This object owns the memory for all the children, but those // children may have been generated elsewhere and might have // their own release() callback. if (array->children != NULL) { for (int64_t i = 0; i < array->n_children; i++) { if (array->children[i] != NULL) { if (array->children[i]->release != NULL) { ArrowArrayRelease(array->children[i]); } ArrowFree(array->children[i]); } } ArrowFree(array->children); } // This object owns the memory for the dictionary but it // may have been generated somewhere else and have its own // release() callback. if (array->dictionary != NULL) { if (array->dictionary->release != NULL) { ArrowArrayRelease(array->dictionary); } ArrowFree(array->dictionary); } // Mark released array->release = NULL; } static ArrowErrorCode ArrowArraySetStorageType(struct ArrowArray* array, enum ArrowType storage_type) { switch (storage_type) { case NANOARROW_TYPE_UNINITIALIZED: case NANOARROW_TYPE_NA: case NANOARROW_TYPE_RUN_END_ENCODED: array->n_buffers = 0; break; case NANOARROW_TYPE_FIXED_SIZE_LIST: case NANOARROW_TYPE_STRUCT: case NANOARROW_TYPE_SPARSE_UNION: array->n_buffers = 1; break; case NANOARROW_TYPE_LIST: case NANOARROW_TYPE_LARGE_LIST: case NANOARROW_TYPE_MAP: case NANOARROW_TYPE_BOOL: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_HALF_FLOAT: case NANOARROW_TYPE_FLOAT: case NANOARROW_TYPE_DOUBLE: case NANOARROW_TYPE_DECIMAL128: case NANOARROW_TYPE_DECIMAL256: case NANOARROW_TYPE_INTERVAL_MONTHS: case NANOARROW_TYPE_INTERVAL_DAY_TIME: case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: case NANOARROW_TYPE_FIXED_SIZE_BINARY: case NANOARROW_TYPE_DENSE_UNION: array->n_buffers = 2; break; case NANOARROW_TYPE_BINARY_VIEW: case NANOARROW_TYPE_STRING_VIEW: array->n_buffers = NANOARROW_BINARY_VIEW_FIXED_BUFFERS + 1; break; case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_BINARY: case NANOARROW_TYPE_LARGE_BINARY: array->n_buffers = 3; break; default: return EINVAL; return NANOARROW_OK; } struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; private_data->storage_type = storage_type; return NANOARROW_OK; } ArrowErrorCode ArrowArrayInitFromType(struct ArrowArray* array, enum ArrowType storage_type) { array->length = 0; array->null_count = 0; array->offset = 0; array->n_buffers = 0; array->n_children = 0; array->buffers = NULL; array->children = NULL; array->dictionary = NULL; array->release = &ArrowArrayReleaseInternal; array->private_data = NULL; struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)ArrowMalloc(sizeof(struct ArrowArrayPrivateData)); if (private_data == NULL) { array->release = NULL; return ENOMEM; } ArrowBitmapInit(&private_data->bitmap); ArrowBufferInit(&private_data->buffers[0]); ArrowBufferInit(&private_data->buffers[1]); private_data->buffer_data = (const void**)ArrowMalloc(sizeof(void*) * NANOARROW_MAX_FIXED_BUFFERS); for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; ++i) { private_data->buffer_data[i] = NULL; } private_data->n_variadic_buffers = 0; private_data->variadic_buffers = NULL; private_data->variadic_buffer_sizes = NULL; array->private_data = private_data; array->buffers = (const void**)(private_data->buffer_data); // These are not technically "storage" in the sense that they do not appear // in the ArrowSchemaView's storage_type member; however, allowing them here // is helpful to maximize the number of types that can avoid going through // ArrowArrayInitFromSchema(). switch (storage_type) { case NANOARROW_TYPE_DURATION: case NANOARROW_TYPE_TIMESTAMP: case NANOARROW_TYPE_TIME64: case NANOARROW_TYPE_DATE64: storage_type = NANOARROW_TYPE_INT64; break; case NANOARROW_TYPE_TIME32: case NANOARROW_TYPE_DATE32: storage_type = NANOARROW_TYPE_INT32; break; default: break; } int result = ArrowArraySetStorageType(array, storage_type); if (result != NANOARROW_OK) { ArrowArrayRelease(array); return result; } ArrowLayoutInit(&private_data->layout, storage_type); // We can only know this not to be true when initializing based on a schema // so assume this to be true. private_data->union_type_id_is_child_index = 1; return NANOARROW_OK; } ArrowErrorCode ArrowArrayInitFromArrayView(struct ArrowArray* array, const struct ArrowArrayView* array_view, struct ArrowError* error) { NANOARROW_RETURN_NOT_OK_WITH_ERROR( ArrowArrayInitFromType(array, array_view->storage_type), error); int result; struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; private_data->layout = array_view->layout; if (array_view->n_children > 0) { result = ArrowArrayAllocateChildren(array, array_view->n_children); if (result != NANOARROW_OK) { ArrowArrayRelease(array); return result; } for (int64_t i = 0; i < array_view->n_children; i++) { result = ArrowArrayInitFromArrayView(array->children[i], array_view->children[i], error); if (result != NANOARROW_OK) { ArrowArrayRelease(array); return result; } } } if (array_view->dictionary != NULL) { result = ArrowArrayAllocateDictionary(array); if (result != NANOARROW_OK) { ArrowArrayRelease(array); return result; } result = ArrowArrayInitFromArrayView(array->dictionary, array_view->dictionary, error); if (result != NANOARROW_OK) { ArrowArrayRelease(array); return result; } } return NANOARROW_OK; } ArrowErrorCode ArrowArrayInitFromSchema(struct ArrowArray* array, const struct ArrowSchema* schema, struct ArrowError* error) { struct ArrowArrayView array_view; NANOARROW_RETURN_NOT_OK(ArrowArrayViewInitFromSchema(&array_view, schema, error)); NANOARROW_RETURN_NOT_OK(ArrowArrayInitFromArrayView(array, &array_view, error)); if (array_view.storage_type == NANOARROW_TYPE_DENSE_UNION || array_view.storage_type == NANOARROW_TYPE_SPARSE_UNION) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; // We can still build arrays if this isn't true; however, the append // functions won't work. Instead, we store this value and error only // when StartAppending is called. private_data->union_type_id_is_child_index = _ArrowUnionTypeIdsWillEqualChildIndices(schema->format + 4, schema->n_children); } ArrowArrayViewReset(&array_view); return NANOARROW_OK; } ArrowErrorCode ArrowArrayAllocateChildren(struct ArrowArray* array, int64_t n_children) { if (array->children != NULL) { return EINVAL; } if (n_children == 0) { return NANOARROW_OK; } array->children = (struct ArrowArray**)ArrowMalloc(n_children * sizeof(struct ArrowArray*)); if (array->children == NULL) { return ENOMEM; } memset(array->children, 0, n_children * sizeof(struct ArrowArray*)); for (int64_t i = 0; i < n_children; i++) { array->children[i] = (struct ArrowArray*)ArrowMalloc(sizeof(struct ArrowArray)); if (array->children[i] == NULL) { return ENOMEM; } array->children[i]->release = NULL; } array->n_children = n_children; return NANOARROW_OK; } ArrowErrorCode ArrowArrayAllocateDictionary(struct ArrowArray* array) { if (array->dictionary != NULL) { return EINVAL; } array->dictionary = (struct ArrowArray*)ArrowMalloc(sizeof(struct ArrowArray)); if (array->dictionary == NULL) { return ENOMEM; } array->dictionary->release = NULL; return NANOARROW_OK; } void ArrowArraySetValidityBitmap(struct ArrowArray* array, struct ArrowBitmap* bitmap) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; ArrowBufferMove(&bitmap->buffer, &private_data->bitmap.buffer); private_data->bitmap.size_bits = bitmap->size_bits; bitmap->size_bits = 0; private_data->buffer_data[0] = private_data->bitmap.buffer.data; array->null_count = -1; } ArrowErrorCode ArrowArraySetBuffer(struct ArrowArray* array, int64_t i, struct ArrowBuffer* buffer) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; switch (i) { case 0: ArrowBufferMove(buffer, &private_data->bitmap.buffer); private_data->buffer_data[i] = private_data->bitmap.buffer.data; break; case 1: case 2: ArrowBufferMove(buffer, &private_data->buffers[i - 1]); private_data->buffer_data[i] = private_data->buffers[i - 1].data; break; default: return EINVAL; } return NANOARROW_OK; } static ArrowErrorCode ArrowArrayViewInitFromArray(struct ArrowArrayView* array_view, struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; ArrowArrayViewInitFromType(array_view, private_data->storage_type); array_view->layout = private_data->layout; array_view->array = array; array_view->length = array->length; array_view->offset = array->offset; array_view->null_count = array->null_count; array_view->buffer_views[0].data.as_uint8 = private_data->bitmap.buffer.data; array_view->buffer_views[0].size_bytes = private_data->bitmap.buffer.size_bytes; array_view->buffer_views[1].data.as_uint8 = private_data->buffers[0].data; array_view->buffer_views[1].size_bytes = private_data->buffers[0].size_bytes; array_view->buffer_views[2].data.as_uint8 = private_data->buffers[1].data; array_view->buffer_views[2].size_bytes = private_data->buffers[1].size_bytes; int result = ArrowArrayViewAllocateChildren(array_view, array->n_children); if (result != NANOARROW_OK) { ArrowArrayViewReset(array_view); return result; } for (int64_t i = 0; i < array->n_children; i++) { result = ArrowArrayViewInitFromArray(array_view->children[i], array->children[i]); if (result != NANOARROW_OK) { ArrowArrayViewReset(array_view); return result; } } if (array->dictionary != NULL) { result = ArrowArrayViewAllocateDictionary(array_view); if (result != NANOARROW_OK) { ArrowArrayViewReset(array_view); return result; } result = ArrowArrayViewInitFromArray(array_view->dictionary, array->dictionary); if (result != NANOARROW_OK) { ArrowArrayViewReset(array_view); return result; } } return NANOARROW_OK; } static ArrowErrorCode ArrowArrayReserveInternal(struct ArrowArray* array, struct ArrowArrayView* array_view) { // Loop through buffers and reserve the extra space that we know about for (int64_t i = 0; i < array->n_buffers; i++) { // Don't reserve on a validity buffer that hasn't been allocated yet if (array_view->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_VALIDITY && ArrowArrayBuffer(array, i)->data == NULL) { continue; } int64_t additional_size_bytes = array_view->buffer_views[i].size_bytes - ArrowArrayBuffer(array, i)->size_bytes; if (additional_size_bytes > 0) { NANOARROW_RETURN_NOT_OK( ArrowBufferReserve(ArrowArrayBuffer(array, i), additional_size_bytes)); } } // Recursively reserve children for (int64_t i = 0; i < array->n_children; i++) { NANOARROW_RETURN_NOT_OK( ArrowArrayReserveInternal(array->children[i], array_view->children[i])); } return NANOARROW_OK; } ArrowErrorCode ArrowArrayReserve(struct ArrowArray* array, int64_t additional_size_elements) { struct ArrowArrayView array_view; NANOARROW_RETURN_NOT_OK(ArrowArrayViewInitFromArray(&array_view, array)); // Calculate theoretical buffer sizes (recursively) ArrowArrayViewSetLength(&array_view, array->length + additional_size_elements); // Walk the structure (recursively) int result = ArrowArrayReserveInternal(array, &array_view); ArrowArrayViewReset(&array_view); if (result != NANOARROW_OK) { return result; } return NANOARROW_OK; } static ArrowErrorCode ArrowArrayFinalizeBuffers(struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { if (private_data->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_VALIDITY || private_data->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_NONE) { continue; } struct ArrowBuffer* buffer = ArrowArrayBuffer(array, i); if (buffer->data == NULL) { NANOARROW_RETURN_NOT_OK((ArrowBufferReserve(buffer, 1))); } } for (int64_t i = 0; i < array->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowArrayFinalizeBuffers(array->children[i])); } if (array->dictionary != NULL) { NANOARROW_RETURN_NOT_OK(ArrowArrayFinalizeBuffers(array->dictionary)); } return NANOARROW_OK; } static void ArrowArrayFlushInternalPointers(struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; const bool is_binary_view = private_data->storage_type == NANOARROW_TYPE_STRING_VIEW || private_data->storage_type == NANOARROW_TYPE_BINARY_VIEW; const int32_t nfixed_buf = is_binary_view ? 2 : NANOARROW_MAX_FIXED_BUFFERS; for (int32_t i = 0; i < nfixed_buf; i++) { private_data->buffer_data[i] = ArrowArrayBuffer(array, i)->data; } if (is_binary_view) { const int32_t nvirt_buf = private_data->n_variadic_buffers; private_data->buffer_data = (const void**)ArrowRealloc( private_data->buffer_data, sizeof(void*) * (nfixed_buf + nvirt_buf + 1)); for (int32_t i = 0; i < nvirt_buf; i++) { private_data->buffer_data[nfixed_buf + i] = private_data->variadic_buffers[i].data; } private_data->buffer_data[nfixed_buf + nvirt_buf] = private_data->variadic_buffer_sizes; array->buffers = (const void**)(private_data->buffer_data); } for (int64_t i = 0; i < array->n_children; i++) { ArrowArrayFlushInternalPointers(array->children[i]); } if (array->dictionary != NULL) { ArrowArrayFlushInternalPointers(array->dictionary); } } ArrowErrorCode ArrowArrayFinishBuilding(struct ArrowArray* array, enum ArrowValidationLevel validation_level, struct ArrowError* error) { // Even if the data buffer is size zero, the pointer value needed to be non-null // in some implementations (at least one version of Arrow C++ at the time this // was added and C# as later discovered). Only do this fix if we can assume // CPU data access. if (validation_level >= NANOARROW_VALIDATION_LEVEL_DEFAULT) { NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowArrayFinalizeBuffers(array), error); } // Make sure the value we get with array->buffers[i] is set to the actual // pointer (which may have changed from the original due to reallocation) ArrowArrayFlushInternalPointers(array); if (validation_level == NANOARROW_VALIDATION_LEVEL_NONE) { return NANOARROW_OK; } // For validation, initialize an ArrowArrayView with our known buffer sizes struct ArrowArrayView array_view; NANOARROW_RETURN_NOT_OK_WITH_ERROR(ArrowArrayViewInitFromArray(&array_view, array), error); int result = ArrowArrayViewValidate(&array_view, validation_level, error); ArrowArrayViewReset(&array_view); return result; } ArrowErrorCode ArrowArrayFinishBuildingDefault(struct ArrowArray* array, struct ArrowError* error) { return ArrowArrayFinishBuilding(array, NANOARROW_VALIDATION_LEVEL_DEFAULT, error); } void ArrowArrayViewInitFromType(struct ArrowArrayView* array_view, enum ArrowType storage_type) { memset(array_view, 0, sizeof(struct ArrowArrayView)); array_view->storage_type = storage_type; ArrowLayoutInit(&array_view->layout, storage_type); } ArrowErrorCode ArrowArrayViewAllocateChildren(struct ArrowArrayView* array_view, int64_t n_children) { if (array_view->children != NULL) { return EINVAL; } if (n_children == 0) { array_view->n_children = 0; return NANOARROW_OK; } array_view->children = (struct ArrowArrayView**)ArrowMalloc(n_children * sizeof(struct ArrowArrayView*)); if (array_view->children == NULL) { return ENOMEM; } for (int64_t i = 0; i < n_children; i++) { array_view->children[i] = NULL; } array_view->n_children = n_children; for (int64_t i = 0; i < n_children; i++) { array_view->children[i] = (struct ArrowArrayView*)ArrowMalloc(sizeof(struct ArrowArrayView)); if (array_view->children[i] == NULL) { return ENOMEM; } ArrowArrayViewInitFromType(array_view->children[i], NANOARROW_TYPE_UNINITIALIZED); } return NANOARROW_OK; } ArrowErrorCode ArrowArrayViewAllocateDictionary(struct ArrowArrayView* array_view) { if (array_view->dictionary != NULL) { return EINVAL; } array_view->dictionary = (struct ArrowArrayView*)ArrowMalloc(sizeof(struct ArrowArrayView)); if (array_view->dictionary == NULL) { return ENOMEM; } ArrowArrayViewInitFromType(array_view->dictionary, NANOARROW_TYPE_UNINITIALIZED); return NANOARROW_OK; } ArrowErrorCode ArrowArrayViewInitFromSchema(struct ArrowArrayView* array_view, const struct ArrowSchema* schema, struct ArrowError* error) { struct ArrowSchemaView schema_view; int result = ArrowSchemaViewInit(&schema_view, schema, error); if (result != NANOARROW_OK) { return result; } ArrowArrayViewInitFromType(array_view, schema_view.storage_type); array_view->layout = schema_view.layout; result = ArrowArrayViewAllocateChildren(array_view, schema->n_children); if (result != NANOARROW_OK) { ArrowErrorSet(error, "ArrowArrayViewAllocateChildren() failed"); ArrowArrayViewReset(array_view); return result; } for (int64_t i = 0; i < schema->n_children; i++) { result = ArrowArrayViewInitFromSchema(array_view->children[i], schema->children[i], error); if (result != NANOARROW_OK) { ArrowArrayViewReset(array_view); return result; } } if (schema->dictionary != NULL) { result = ArrowArrayViewAllocateDictionary(array_view); if (result != NANOARROW_OK) { ArrowArrayViewReset(array_view); return result; } result = ArrowArrayViewInitFromSchema(array_view->dictionary, schema->dictionary, error); if (result != NANOARROW_OK) { ArrowArrayViewReset(array_view); return result; } } if (array_view->storage_type == NANOARROW_TYPE_SPARSE_UNION || array_view->storage_type == NANOARROW_TYPE_DENSE_UNION) { array_view->union_type_id_map = (int8_t*)ArrowMalloc(256 * sizeof(int8_t)); if (array_view->union_type_id_map == NULL) { return ENOMEM; } memset(array_view->union_type_id_map, -1, 256); int32_t n_type_ids = _ArrowParseUnionTypeIds(schema_view.union_type_ids, array_view->union_type_id_map + 128); for (int8_t child_index = 0; child_index < n_type_ids; child_index++) { int8_t type_id = array_view->union_type_id_map[128 + child_index]; array_view->union_type_id_map[type_id] = child_index; } } return NANOARROW_OK; } void ArrowArrayViewReset(struct ArrowArrayView* array_view) { if (array_view->children != NULL) { for (int64_t i = 0; i < array_view->n_children; i++) { if (array_view->children[i] != NULL) { ArrowArrayViewReset(array_view->children[i]); ArrowFree(array_view->children[i]); } } ArrowFree(array_view->children); } if (array_view->dictionary != NULL) { ArrowArrayViewReset(array_view->dictionary); ArrowFree(array_view->dictionary); } if (array_view->union_type_id_map != NULL) { ArrowFree(array_view->union_type_id_map); } ArrowArrayViewInitFromType(array_view, NANOARROW_TYPE_UNINITIALIZED); } void ArrowArrayViewSetLength(struct ArrowArrayView* array_view, int64_t length) { for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { int64_t element_size_bytes = array_view->layout.element_size_bits[i] / 8; switch (array_view->layout.buffer_type[i]) { case NANOARROW_BUFFER_TYPE_VALIDITY: array_view->buffer_views[i].size_bytes = _ArrowBytesForBits(length); continue; case NANOARROW_BUFFER_TYPE_DATA_OFFSET: // Probably don't want/need to rely on the producer to have allocated an // offsets buffer of length 1 for a zero-size array array_view->buffer_views[i].size_bytes = (length != 0) * element_size_bytes * (length + 1); continue; case NANOARROW_BUFFER_TYPE_DATA: array_view->buffer_views[i].size_bytes = _ArrowRoundUpToMultipleOf8(array_view->layout.element_size_bits[i] * length) / 8; continue; case NANOARROW_BUFFER_TYPE_TYPE_ID: case NANOARROW_BUFFER_TYPE_UNION_OFFSET: array_view->buffer_views[i].size_bytes = element_size_bytes * length; continue; case NANOARROW_BUFFER_TYPE_VARIADIC_DATA: case NANOARROW_BUFFER_TYPE_VARIADIC_SIZE: case NANOARROW_BUFFER_TYPE_NONE: array_view->buffer_views[i].size_bytes = 0; continue; } } switch (array_view->storage_type) { case NANOARROW_TYPE_STRUCT: case NANOARROW_TYPE_SPARSE_UNION: for (int64_t i = 0; i < array_view->n_children; i++) { ArrowArrayViewSetLength(array_view->children[i], length); } break; case NANOARROW_TYPE_FIXED_SIZE_LIST: if (array_view->n_children >= 1) { ArrowArrayViewSetLength(array_view->children[0], length * array_view->layout.child_size_elements); } default: break; } } // This version recursively extracts information from the array and stores it // in the array view, performing any checks that require the original array. static int ArrowArrayViewSetArrayInternal(struct ArrowArrayView* array_view, const struct ArrowArray* array, struct ArrowError* error) { array_view->array = array; array_view->offset = array->offset; array_view->length = array->length; array_view->null_count = array->null_count; array_view->variadic_buffer_sizes = NULL; array_view->variadic_buffers = NULL; array_view->n_variadic_buffers = 0; int64_t buffers_required = 0; const int nfixed_buf = array_view->storage_type == NANOARROW_TYPE_STRING_VIEW || array_view->storage_type == NANOARROW_TYPE_BINARY_VIEW ? NANOARROW_BINARY_VIEW_FIXED_BUFFERS : NANOARROW_MAX_FIXED_BUFFERS; for (int i = 0; i < nfixed_buf; i++) { if (array_view->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_NONE) { break; } buffers_required++; // Set buffer pointer array_view->buffer_views[i].data.data = array->buffers[i]; // If non-null, set buffer size to unknown. if (array->buffers[i] == NULL) { array_view->buffer_views[i].size_bytes = 0; } else { array_view->buffer_views[i].size_bytes = -1; } } if (array_view->storage_type == NANOARROW_TYPE_STRING_VIEW || array_view->storage_type == NANOARROW_TYPE_BINARY_VIEW) { const int64_t n_buffers = array->n_buffers; const int32_t nfixed_buf = NANOARROW_BINARY_VIEW_FIXED_BUFFERS; const int32_t nvariadic_buf = (int32_t)(n_buffers - nfixed_buf - 1); array_view->n_variadic_buffers = nvariadic_buf; buffers_required += nvariadic_buf + 1; array_view->variadic_buffers = array->buffers + NANOARROW_BINARY_VIEW_FIXED_BUFFERS; array_view->variadic_buffer_sizes = (int64_t*)array->buffers[n_buffers - 1]; } if (buffers_required != array->n_buffers) { ArrowErrorSet(error, "Expected array with %" PRId64 " buffer(s) but found %" PRId64 " buffer(s)", buffers_required, array->n_buffers); return EINVAL; } // Check number of children if (array_view->n_children != array->n_children) { ArrowErrorSet(error, "Expected %" PRId64 " children but found %" PRId64 " children", array_view->n_children, array->n_children); return EINVAL; } // Recurse for children for (int64_t i = 0; i < array_view->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowArrayViewSetArrayInternal(array_view->children[i], array->children[i], error)); } // Check dictionary if (array->dictionary == NULL && array_view->dictionary != NULL) { ArrowErrorSet(error, "Expected dictionary but found NULL"); return EINVAL; } if (array->dictionary != NULL && array_view->dictionary == NULL) { ArrowErrorSet(error, "Expected NULL dictionary but found dictionary member"); return EINVAL; } if (array->dictionary != NULL) { NANOARROW_RETURN_NOT_OK( ArrowArrayViewSetArrayInternal(array_view->dictionary, array->dictionary, error)); } return NANOARROW_OK; } static int ArrowArrayViewValidateMinimal(struct ArrowArrayView* array_view, struct ArrowError* error) { if (array_view->length < 0) { ArrowErrorSet(error, "Expected length >= 0 but found length %" PRId64, array_view->length); return EINVAL; } if (array_view->offset < 0) { ArrowErrorSet(error, "Expected offset >= 0 but found offset %" PRId64, array_view->offset); return EINVAL; } // Ensure that offset + length fits within an int64 before a possible overflow if ((uint64_t)array_view->offset + (uint64_t)array_view->length > (uint64_t)INT64_MAX) { ArrowErrorSet(error, "Offset + length is > INT64_MAX"); return EINVAL; } // Calculate buffer sizes that do not require buffer access. If marked as // unknown, assign the buffer size; otherwise, validate it. int64_t offset_plus_length = array_view->offset + array_view->length; // Only loop over the first two buffers because the size of the third buffer // is always data dependent for all current Arrow types. for (int i = 0; i < 2; i++) { int64_t element_size_bytes = array_view->layout.element_size_bits[i] / 8; // Initialize with a value that will cause an error if accidentally used uninitialized // Need to suppress the clang-tidy warning because gcc warns for possible use int64_t min_buffer_size_bytes = // NOLINT(clang-analyzer-deadcode.DeadStores) array_view->buffer_views[i].size_bytes + 1; switch (array_view->layout.buffer_type[i]) { case NANOARROW_BUFFER_TYPE_VALIDITY: if (array_view->null_count == 0 && array_view->buffer_views[i].size_bytes == 0) { continue; } min_buffer_size_bytes = _ArrowBytesForBits(offset_plus_length); break; case NANOARROW_BUFFER_TYPE_DATA_OFFSET: // Probably don't want/need to rely on the producer to have allocated an // offsets buffer of length 1 for a zero-size array min_buffer_size_bytes = (offset_plus_length != 0) * element_size_bytes * (offset_plus_length + 1); break; case NANOARROW_BUFFER_TYPE_DATA: min_buffer_size_bytes = _ArrowRoundUpToMultipleOf8(array_view->layout.element_size_bits[i] * offset_plus_length) / 8; break; case NANOARROW_BUFFER_TYPE_TYPE_ID: case NANOARROW_BUFFER_TYPE_UNION_OFFSET: min_buffer_size_bytes = element_size_bytes * offset_plus_length; break; case NANOARROW_BUFFER_TYPE_VARIADIC_DATA: case NANOARROW_BUFFER_TYPE_VARIADIC_SIZE: case NANOARROW_BUFFER_TYPE_NONE: continue; } // Assign or validate buffer size if (array_view->buffer_views[i].size_bytes == -1) { array_view->buffer_views[i].size_bytes = min_buffer_size_bytes; } else if (array_view->buffer_views[i].size_bytes < min_buffer_size_bytes) { ArrowErrorSet(error, "Expected %s array buffer %d to have size >= %" PRId64 " bytes but found " "buffer with %" PRId64 " bytes", ArrowTypeString(array_view->storage_type), i, min_buffer_size_bytes, array_view->buffer_views[i].size_bytes); return EINVAL; } } // For list, fixed-size list and map views, we can validate the number of children switch (array_view->storage_type) { case NANOARROW_TYPE_LIST: case NANOARROW_TYPE_LARGE_LIST: case NANOARROW_TYPE_FIXED_SIZE_LIST: case NANOARROW_TYPE_MAP: if (array_view->n_children != 1) { ArrowErrorSet(error, "Expected 1 child of %s array but found %" PRId64 " child arrays", ArrowTypeString(array_view->storage_type), array_view->n_children); return EINVAL; } break; case NANOARROW_TYPE_RUN_END_ENCODED: if (array_view->n_children != 2) { ArrowErrorSet( error, "Expected 2 children for %s array but found %" PRId64 " child arrays", ArrowTypeString(array_view->storage_type), array_view->n_children); return EINVAL; } break; default: break; } // For struct, the sparse union, and the fixed-size list views, we can validate child // lengths. int64_t child_min_length; switch (array_view->storage_type) { case NANOARROW_TYPE_SPARSE_UNION: case NANOARROW_TYPE_STRUCT: child_min_length = (array_view->offset + array_view->length); for (int64_t i = 0; i < array_view->n_children; i++) { if (array_view->children[i]->length < child_min_length) { ArrowErrorSet(error, "Expected struct child %" PRId64 " to have length >= %" PRId64 " but found child with " "length %" PRId64, i + 1, child_min_length, array_view->children[i]->length); return EINVAL; } } break; case NANOARROW_TYPE_FIXED_SIZE_LIST: child_min_length = (array_view->offset + array_view->length) * array_view->layout.child_size_elements; if (array_view->children[0]->length < child_min_length) { ArrowErrorSet(error, "Expected child of fixed_size_list array to have length >= %" PRId64 " but " "found array with length %" PRId64, child_min_length, array_view->children[0]->length); return EINVAL; } break; case NANOARROW_TYPE_RUN_END_ENCODED: { if (array_view->n_children != 2) { ArrowErrorSet(error, "Expected 2 children for run-end encoded array but found %" PRId64, array_view->n_children); return EINVAL; } struct ArrowArrayView* run_ends_view = array_view->children[0]; struct ArrowArrayView* values_view = array_view->children[1]; int64_t max_length; switch (run_ends_view->storage_type) { case NANOARROW_TYPE_INT16: max_length = INT16_MAX; break; case NANOARROW_TYPE_INT32: max_length = INT32_MAX; break; case NANOARROW_TYPE_INT64: max_length = INT64_MAX; break; default: ArrowErrorSet( error, "Run-end encoded array only supports INT16, INT32 or INT64 run-ends " "but found run-ends type %s", ArrowTypeString(run_ends_view->storage_type)); return EINVAL; } // There is already a check above that offset_plus_length < INT64_MAX if (offset_plus_length > max_length) { ArrowErrorSet(error, "Offset + length of a run-end encoded array must fit in a value" " of the run end type %s but is %" PRId64 " + %" PRId64, ArrowTypeString(run_ends_view->storage_type), array_view->offset, array_view->length); return EINVAL; } if (run_ends_view->length > values_view->length) { ArrowErrorSet(error, "Length of run_ends is greater than the length of values: %" PRId64 " > %" PRId64, run_ends_view->length, values_view->length); return EINVAL; } if (run_ends_view->length == 0 && values_view->length != 0) { ArrowErrorSet(error, "Run-end encoded array has zero length %" PRId64 ", but values array has " "non-zero length", values_view->length); return EINVAL; } if (run_ends_view->null_count != 0) { ArrowErrorSet(error, "Null count must be 0 for run ends array, but is %" PRId64, run_ends_view->null_count); return EINVAL; } break; } default: break; } // Recurse for children for (int64_t i = 0; i < array_view->n_children; i++) { NANOARROW_RETURN_NOT_OK( ArrowArrayViewValidateMinimal(array_view->children[i], error)); } // Recurse for dictionary if (array_view->dictionary != NULL) { NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateMinimal(array_view->dictionary, error)); } return NANOARROW_OK; } static int ArrowArrayViewValidateDefault(struct ArrowArrayView* array_view, struct ArrowError* error) { // Perform minimal validation. This will validate or assign // buffer sizes as long as buffer access is not required. NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateMinimal(array_view, error)); // Calculate buffer sizes or child lengths that require accessing the offsets // buffer. Where appropriate, validate that the first offset is >= 0. // If a buffer size is marked as unknown, assign it; otherwise, validate it. int64_t offset_plus_length = array_view->offset + array_view->length; int64_t first_offset; int64_t last_offset; switch (array_view->storage_type) { case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_BINARY: if (array_view->buffer_views[1].size_bytes != 0) { first_offset = array_view->buffer_views[1].data.as_int32[array_view->offset]; if (first_offset < 0) { ArrowErrorSet(error, "Expected first offset >= 0 but found %" PRId64, first_offset); return EINVAL; } last_offset = array_view->buffer_views[1].data.as_int32[offset_plus_length]; if (last_offset < 0) { ArrowErrorSet(error, "Expected last offset >= 0 but found %" PRId64, last_offset); return EINVAL; } // If the data buffer size is unknown, assign it; otherwise, check it if (array_view->buffer_views[2].size_bytes == -1) { array_view->buffer_views[2].size_bytes = last_offset; } else if (array_view->buffer_views[2].size_bytes < last_offset) { ArrowErrorSet(error, "Expected %s array buffer 2 to have size >= %" PRId64 " bytes but found " "buffer with %" PRId64 " bytes", ArrowTypeString(array_view->storage_type), last_offset, array_view->buffer_views[2].size_bytes); return EINVAL; } } else if (array_view->buffer_views[2].size_bytes == -1) { // If the data buffer size is unknown and there are no bytes in the offset buffer, // set the data buffer size to 0. array_view->buffer_views[2].size_bytes = 0; } break; case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_LARGE_BINARY: if (array_view->buffer_views[1].size_bytes != 0) { first_offset = array_view->buffer_views[1].data.as_int64[array_view->offset]; if (first_offset < 0) { ArrowErrorSet(error, "Expected first offset >= 0 but found %" PRId64, first_offset); return EINVAL; } last_offset = array_view->buffer_views[1].data.as_int64[offset_plus_length]; if (last_offset < 0) { ArrowErrorSet(error, "Expected last offset >= 0 but found %" PRId64, last_offset); return EINVAL; } // If the data buffer size is unknown, assign it; otherwise, check it if (array_view->buffer_views[2].size_bytes == -1) { array_view->buffer_views[2].size_bytes = last_offset; } else if (array_view->buffer_views[2].size_bytes < last_offset) { ArrowErrorSet(error, "Expected %s array buffer 2 to have size >= %" PRId64 " bytes but found " "buffer with %" PRId64 " bytes", ArrowTypeString(array_view->storage_type), last_offset, array_view->buffer_views[2].size_bytes); return EINVAL; } } else if (array_view->buffer_views[2].size_bytes == -1) { // If the data buffer size is unknown and there are no bytes in the offset // buffer, set the data buffer size to 0. array_view->buffer_views[2].size_bytes = 0; } break; case NANOARROW_TYPE_STRUCT: for (int64_t i = 0; i < array_view->n_children; i++) { if (array_view->children[i]->length < offset_plus_length) { ArrowErrorSet(error, "Expected struct child %" PRId64 " to have length >= %" PRId64 " but found child with " "length %" PRId64, i + 1, offset_plus_length, array_view->children[i]->length); return EINVAL; } } break; case NANOARROW_TYPE_LIST: case NANOARROW_TYPE_MAP: if (array_view->buffer_views[1].size_bytes != 0) { first_offset = array_view->buffer_views[1].data.as_int32[array_view->offset]; if (first_offset < 0) { ArrowErrorSet(error, "Expected first offset >= 0 but found %" PRId64, first_offset); return EINVAL; } last_offset = array_view->buffer_views[1].data.as_int32[offset_plus_length]; if (last_offset < 0) { ArrowErrorSet(error, "Expected last offset >= 0 but found %" PRId64, last_offset); return EINVAL; } if (array_view->children[0]->length < last_offset) { ArrowErrorSet(error, "Expected child of %s array to have length >= %" PRId64 " but found array with " "length %" PRId64, ArrowTypeString(array_view->storage_type), last_offset, array_view->children[0]->length); return EINVAL; } } break; case NANOARROW_TYPE_LARGE_LIST: if (array_view->buffer_views[1].size_bytes != 0) { first_offset = array_view->buffer_views[1].data.as_int64[array_view->offset]; if (first_offset < 0) { ArrowErrorSet(error, "Expected first offset >= 0 but found %" PRId64, first_offset); return EINVAL; } last_offset = array_view->buffer_views[1].data.as_int64[offset_plus_length]; if (last_offset < 0) { ArrowErrorSet(error, "Expected last offset >= 0 but found %" PRId64, last_offset); return EINVAL; } if (array_view->children[0]->length < last_offset) { ArrowErrorSet(error, "Expected child of large list array to have length >= %" PRId64 " but found array " "with length %" PRId64, last_offset, array_view->children[0]->length); return EINVAL; } } break; case NANOARROW_TYPE_RUN_END_ENCODED: { struct ArrowArrayView* run_ends_view = array_view->children[0]; if (run_ends_view->length == 0) { break; } int64_t first_run_end = ArrowArrayViewGetIntUnsafe(run_ends_view, 0); if (first_run_end < 1) { ArrowErrorSet( error, "All run ends must be greater than 0 but the first run end is %" PRId64, first_run_end); return EINVAL; } // offset + length < INT64_MAX is checked in ArrowArrayViewValidateMinimal() int64_t last_run_end = ArrowArrayViewGetIntUnsafe(run_ends_view, run_ends_view->length - 1); if (last_run_end < offset_plus_length) { ArrowErrorSet(error, "Last run end is %" PRId64 " but it should be >= (%" PRId64 " + %" PRId64 ")", last_run_end, array_view->offset, array_view->length); return EINVAL; } break; } default: break; } // Recurse for children for (int64_t i = 0; i < array_view->n_children; i++) { NANOARROW_RETURN_NOT_OK( ArrowArrayViewValidateDefault(array_view->children[i], error)); } // Recurse for dictionary if (array_view->dictionary != NULL) { NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateDefault(array_view->dictionary, error)); } return NANOARROW_OK; } ArrowErrorCode ArrowArrayViewSetArray(struct ArrowArrayView* array_view, const struct ArrowArray* array, struct ArrowError* error) { // Extract information from the array into the array view NANOARROW_RETURN_NOT_OK(ArrowArrayViewSetArrayInternal(array_view, array, error)); // Run default validation. Because we've marked all non-NULL buffers as having unknown // size, validation will also update the buffer sizes as it goes. NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateDefault(array_view, error)); return NANOARROW_OK; } ArrowErrorCode ArrowArrayViewSetArrayMinimal(struct ArrowArrayView* array_view, const struct ArrowArray* array, struct ArrowError* error) { // Extract information from the array into the array view NANOARROW_RETURN_NOT_OK(ArrowArrayViewSetArrayInternal(array_view, array, error)); // Run default validation. Because we've marked all non-NULL buffers as having unknown // size, validation will also update the buffer sizes as it goes. NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateMinimal(array_view, error)); return NANOARROW_OK; } static int ArrowAssertIncreasingInt32(struct ArrowBufferView view, struct ArrowError* error) { if (view.size_bytes <= (int64_t)sizeof(int32_t)) { return NANOARROW_OK; } for (int64_t i = 1; i < view.size_bytes / (int64_t)sizeof(int32_t); i++) { if (view.data.as_int32[i] < view.data.as_int32[i - 1]) { ArrowErrorSet(error, "[%" PRId64 "] Expected element size >= 0", i); return EINVAL; } } return NANOARROW_OK; } static int ArrowAssertIncreasingInt64(struct ArrowBufferView view, struct ArrowError* error) { if (view.size_bytes <= (int64_t)sizeof(int64_t)) { return NANOARROW_OK; } for (int64_t i = 1; i < view.size_bytes / (int64_t)sizeof(int64_t); i++) { if (view.data.as_int64[i] < view.data.as_int64[i - 1]) { ArrowErrorSet(error, "[%" PRId64 "] Expected element size >= 0", i); return EINVAL; } } return NANOARROW_OK; } static int ArrowAssertRangeInt8(struct ArrowBufferView view, int8_t min_value, int8_t max_value, struct ArrowError* error) { for (int64_t i = 0; i < view.size_bytes; i++) { if (view.data.as_int8[i] < min_value || view.data.as_int8[i] > max_value) { ArrowErrorSet(error, "[%" PRId64 "] Expected buffer value between %" PRId8 " and %" PRId8 " but found value %" PRId8, i, min_value, max_value, view.data.as_int8[i]); return EINVAL; } } return NANOARROW_OK; } static int ArrowAssertInt8In(struct ArrowBufferView view, const int8_t* values, int64_t n_values, struct ArrowError* error) { for (int64_t i = 0; i < view.size_bytes; i++) { int item_found = 0; for (int64_t j = 0; j < n_values; j++) { if (view.data.as_int8[i] == values[j]) { item_found = 1; break; } } if (!item_found) { ArrowErrorSet(error, "[%" PRId64 "] Unexpected buffer value %" PRId8, i, view.data.as_int8[i]); return EINVAL; } } return NANOARROW_OK; } static int ArrowArrayViewValidateFull(struct ArrowArrayView* array_view, struct ArrowError* error) { for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { switch (array_view->layout.buffer_type[i]) { // Only validate the portion of the buffer that is strictly required, // which includes not validating the offset buffer of a zero-length array. case NANOARROW_BUFFER_TYPE_DATA_OFFSET: if (array_view->length == 0) { continue; } if (array_view->layout.element_size_bits[i] == 32) { struct ArrowBufferView sliced_offsets; sliced_offsets.data.as_int32 = array_view->buffer_views[i].data.as_int32 + array_view->offset; sliced_offsets.size_bytes = (array_view->length + 1) * sizeof(int32_t); NANOARROW_RETURN_NOT_OK(ArrowAssertIncreasingInt32(sliced_offsets, error)); } else { struct ArrowBufferView sliced_offsets; sliced_offsets.data.as_int64 = array_view->buffer_views[i].data.as_int64 + array_view->offset; sliced_offsets.size_bytes = (array_view->length + 1) * sizeof(int64_t); NANOARROW_RETURN_NOT_OK(ArrowAssertIncreasingInt64(sliced_offsets, error)); } break; default: break; } } if (array_view->storage_type == NANOARROW_TYPE_DENSE_UNION || array_view->storage_type == NANOARROW_TYPE_SPARSE_UNION) { struct ArrowBufferView sliced_type_ids; sliced_type_ids.size_bytes = array_view->length * sizeof(int8_t); if (array_view->length > 0) { sliced_type_ids.data.as_int8 = array_view->buffer_views[0].data.as_int8 + array_view->offset; } else { sliced_type_ids.data.as_int8 = NULL; } if (array_view->union_type_id_map == NULL) { // If the union_type_id map is NULL (e.g., when using ArrowArrayInitFromType() + // ArrowArrayAllocateChildren() + ArrowArrayFinishBuilding()), we don't have enough // information to validate this buffer. ArrowErrorSet(error, "Insufficient information provided for validation of union array"); return EINVAL; } else if (_ArrowParsedUnionTypeIdsWillEqualChildIndices( array_view->union_type_id_map, array_view->n_children, array_view->n_children)) { NANOARROW_RETURN_NOT_OK(ArrowAssertRangeInt8( sliced_type_ids, 0, (int8_t)(array_view->n_children - 1), error)); } else { NANOARROW_RETURN_NOT_OK(ArrowAssertInt8In(sliced_type_ids, array_view->union_type_id_map + 128, array_view->n_children, error)); } } if (array_view->storage_type == NANOARROW_TYPE_DENSE_UNION && array_view->union_type_id_map != NULL) { // Check that offsets refer to child elements that actually exist for (int64_t i = 0; i < array_view->length; i++) { int8_t child_id = ArrowArrayViewUnionChildIndex(array_view, i); int64_t offset = ArrowArrayViewUnionChildOffset(array_view, i); int64_t child_length = array_view->children[child_id]->length; if (offset < 0 || offset > child_length) { ArrowErrorSet(error, "[%" PRId64 "] Expected union offset for child id %" PRId8 " to be between 0 and %" PRId64 " but " "found offset value %" PRId64, i, child_id, child_length, offset); return EINVAL; } } } if (array_view->storage_type == NANOARROW_TYPE_RUN_END_ENCODED) { struct ArrowArrayView* run_ends_view = array_view->children[0]; if (run_ends_view->length > 0) { int64_t last_run_end = ArrowArrayViewGetIntUnsafe(run_ends_view, 0); for (int64_t i = 1; i < run_ends_view->length; i++) { const int64_t run_end = ArrowArrayViewGetIntUnsafe(run_ends_view, i); if (run_end <= last_run_end) { ArrowErrorSet( error, "Every run end must be strictly greater than the previous run end, " "but run_ends[%" PRId64 " is %" PRId64 " and run_ends[%" PRId64 "] is %" PRId64, i, run_end, i - 1, last_run_end); return EINVAL; } last_run_end = run_end; } } } // Recurse for children for (int64_t i = 0; i < array_view->n_children; i++) { NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateFull(array_view->children[i], error)); } // Dictionary valiation not implemented if (array_view->dictionary != NULL) { NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateFull(array_view->dictionary, error)); // TODO: validate the indices } return NANOARROW_OK; } ArrowErrorCode ArrowArrayViewValidate(struct ArrowArrayView* array_view, enum ArrowValidationLevel validation_level, struct ArrowError* error) { switch (validation_level) { case NANOARROW_VALIDATION_LEVEL_NONE: return NANOARROW_OK; case NANOARROW_VALIDATION_LEVEL_MINIMAL: return ArrowArrayViewValidateMinimal(array_view, error); case NANOARROW_VALIDATION_LEVEL_DEFAULT: return ArrowArrayViewValidateDefault(array_view, error); case NANOARROW_VALIDATION_LEVEL_FULL: NANOARROW_RETURN_NOT_OK(ArrowArrayViewValidateDefault(array_view, error)); return ArrowArrayViewValidateFull(array_view, error); } ArrowErrorSet(error, "validation_level not recognized"); return EINVAL; } struct ArrowComparisonInternalState { enum ArrowCompareLevel level; int is_equal; struct ArrowError* reason; }; NANOARROW_CHECK_PRINTF_ATTRIBUTE static void ArrowComparePrependPath( struct ArrowError* out, const char* fmt, ...) { if (out == NULL) { return; } char prefix[128]; prefix[0] = '\0'; va_list args; va_start(args, fmt); int prefix_len = vsnprintf(prefix, sizeof(prefix), fmt, args); va_end(args); if (prefix_len <= 0) { return; } size_t out_len = strlen(out->message); size_t out_len_to_move = sizeof(struct ArrowError) - prefix_len - 1; if (out_len_to_move > out_len) { out_len_to_move = out_len; } memmove(out->message + prefix_len, out->message, out_len_to_move); memcpy(out->message, prefix, prefix_len); out->message[out_len + prefix_len] = '\0'; } #define SET_NOT_EQUAL_AND_RETURN_IF_IMPL(cond_, state_, reason_) \ do { \ if (cond_) { \ ArrowErrorSet(state_->reason, ": %s", reason_); \ state_->is_equal = 0; \ return; \ } \ } while (0) #define SET_NOT_EQUAL_AND_RETURN_IF(condition_, state_) \ SET_NOT_EQUAL_AND_RETURN_IF_IMPL(condition_, state_, #condition_) static void ArrowArrayViewCompareBuffer(const struct ArrowArrayView* actual, const struct ArrowArrayView* expected, int i, struct ArrowComparisonInternalState* state) { SET_NOT_EQUAL_AND_RETURN_IF( actual->buffer_views[i].size_bytes != expected->buffer_views[i].size_bytes, state); int64_t buffer_size = actual->buffer_views[i].size_bytes; if (buffer_size > 0) { SET_NOT_EQUAL_AND_RETURN_IF( memcmp(actual->buffer_views[i].data.data, expected->buffer_views[i].data.data, buffer_size) != 0, state); } } static void ArrowArrayViewCompareIdentical(const struct ArrowArrayView* actual, const struct ArrowArrayView* expected, struct ArrowComparisonInternalState* state) { SET_NOT_EQUAL_AND_RETURN_IF(actual->storage_type != expected->storage_type, state); SET_NOT_EQUAL_AND_RETURN_IF(actual->n_children != expected->n_children, state); SET_NOT_EQUAL_AND_RETURN_IF(actual->dictionary == NULL && expected->dictionary != NULL, state); SET_NOT_EQUAL_AND_RETURN_IF(actual->dictionary != NULL && expected->dictionary == NULL, state); SET_NOT_EQUAL_AND_RETURN_IF(actual->length != expected->length, state); SET_NOT_EQUAL_AND_RETURN_IF(actual->offset != expected->offset, state); SET_NOT_EQUAL_AND_RETURN_IF(actual->null_count != expected->null_count, state); for (int i = 0; i < NANOARROW_MAX_FIXED_BUFFERS; i++) { ArrowArrayViewCompareBuffer(actual, expected, i, state); if (!state->is_equal) { ArrowComparePrependPath(state->reason, ".buffers[%d]", i); return; } } for (int64_t i = 0; i < actual->n_children; i++) { ArrowArrayViewCompareIdentical(actual->children[i], expected->children[i], state); if (!state->is_equal) { ArrowComparePrependPath(state->reason, ".children[%" PRId64 "]", i); return; } } if (actual->dictionary != NULL) { ArrowArrayViewCompareIdentical(actual->dictionary, expected->dictionary, state); if (!state->is_equal) { ArrowComparePrependPath(state->reason, ".dictionary"); return; } } } // Top-level entry point to take care of creating, cleaning up, and // propagating the ArrowComparisonInternalState to the caller ArrowErrorCode ArrowArrayViewCompare(const struct ArrowArrayView* actual, const struct ArrowArrayView* expected, enum ArrowCompareLevel level, int* out, struct ArrowError* reason) { struct ArrowComparisonInternalState state; state.level = level; state.is_equal = 1; state.reason = reason; switch (level) { case NANOARROW_COMPARE_IDENTICAL: ArrowArrayViewCompareIdentical(actual, expected, &state); break; default: return EINVAL; } *out = state.is_equal; if (!state.is_equal) { ArrowComparePrependPath(state.reason, "root"); } return NANOARROW_OK; } #undef SET_NOT_EQUAL_AND_RETURN_IF #undef SET_NOT_EQUAL_AND_RETURN_IF_IMPL // 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 #include "nanoarrow.h" struct BasicArrayStreamPrivate { struct ArrowSchema schema; int64_t n_arrays; struct ArrowArray* arrays; int64_t arrays_i; }; static int ArrowBasicArrayStreamGetSchema(struct ArrowArrayStream* array_stream, struct ArrowSchema* schema) { if (array_stream == NULL || array_stream->release == NULL) { return EINVAL; } struct BasicArrayStreamPrivate* private_data = (struct BasicArrayStreamPrivate*)array_stream->private_data; return ArrowSchemaDeepCopy(&private_data->schema, schema); } static int ArrowBasicArrayStreamGetNext(struct ArrowArrayStream* array_stream, struct ArrowArray* array) { if (array_stream == NULL || array_stream->release == NULL) { return EINVAL; } struct BasicArrayStreamPrivate* private_data = (struct BasicArrayStreamPrivate*)array_stream->private_data; if (private_data->arrays_i == private_data->n_arrays) { array->release = NULL; return NANOARROW_OK; } ArrowArrayMove(&private_data->arrays[private_data->arrays_i++], array); return NANOARROW_OK; } static const char* ArrowBasicArrayStreamGetLastError( struct ArrowArrayStream* array_stream) { NANOARROW_UNUSED(array_stream); return NULL; } static void ArrowBasicArrayStreamRelease(struct ArrowArrayStream* array_stream) { if (array_stream == NULL || array_stream->release == NULL) { return; } struct BasicArrayStreamPrivate* private_data = (struct BasicArrayStreamPrivate*)array_stream->private_data; if (private_data->schema.release != NULL) { ArrowSchemaRelease(&private_data->schema); } for (int64_t i = 0; i < private_data->n_arrays; i++) { if (private_data->arrays[i].release != NULL) { ArrowArrayRelease(&private_data->arrays[i]); } } if (private_data->arrays != NULL) { ArrowFree(private_data->arrays); } ArrowFree(private_data); array_stream->release = NULL; } ArrowErrorCode ArrowBasicArrayStreamInit(struct ArrowArrayStream* array_stream, struct ArrowSchema* schema, int64_t n_arrays) { struct BasicArrayStreamPrivate* private_data = (struct BasicArrayStreamPrivate*)ArrowMalloc( sizeof(struct BasicArrayStreamPrivate)); if (private_data == NULL) { return ENOMEM; } ArrowSchemaMove(schema, &private_data->schema); private_data->n_arrays = n_arrays; private_data->arrays = NULL; private_data->arrays_i = 0; if (n_arrays > 0) { private_data->arrays = (struct ArrowArray*)ArrowMalloc(n_arrays * sizeof(struct ArrowArray)); if (private_data->arrays == NULL) { ArrowBasicArrayStreamRelease(array_stream); return ENOMEM; } } for (int64_t i = 0; i < private_data->n_arrays; i++) { private_data->arrays[i].release = NULL; } array_stream->get_schema = &ArrowBasicArrayStreamGetSchema; array_stream->get_next = &ArrowBasicArrayStreamGetNext; array_stream->get_last_error = ArrowBasicArrayStreamGetLastError; array_stream->release = ArrowBasicArrayStreamRelease; array_stream->private_data = private_data; return NANOARROW_OK; } void ArrowBasicArrayStreamSetArray(struct ArrowArrayStream* array_stream, int64_t i, struct ArrowArray* array) { struct BasicArrayStreamPrivate* private_data = (struct BasicArrayStreamPrivate*)array_stream->private_data; ArrowArrayMove(array, &private_data->arrays[i]); } ArrowErrorCode ArrowBasicArrayStreamValidate(const struct ArrowArrayStream* array_stream, struct ArrowError* error) { struct BasicArrayStreamPrivate* private_data = (struct BasicArrayStreamPrivate*)array_stream->private_data; struct ArrowArrayView array_view; NANOARROW_RETURN_NOT_OK( ArrowArrayViewInitFromSchema(&array_view, &private_data->schema, error)); for (int64_t i = 0; i < private_data->n_arrays; i++) { if (private_data->arrays[i].release != NULL) { int result = ArrowArrayViewSetArray(&array_view, &private_data->arrays[i], error); if (result != NANOARROW_OK) { ArrowArrayViewReset(&array_view); return result; } } } ArrowArrayViewReset(&array_view); return NANOARROW_OK; } nanoarrow/src/infer_ptype.c0000644000176200001440000001214014701301265015534 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" #include "altrep.h" #include "array.h" #include "array_view.h" #include "materialize.h" #include "schema.h" #include "util.h" // These conversions are the default R-native type guesses for // an array that don't require extra information from the ptype (e.g., // factor with levels). Some of these guesses may result in a conversion // that later warns for out-of-range values (e.g., int64 to double()); // however, a user can use the convert_array(x, ptype = something_safer()) // when this occurs. enum VectorType nanoarrow_infer_vector_type(enum ArrowType type) { switch (type) { case NANOARROW_TYPE_BOOL: return VECTOR_TYPE_LGL; case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT32: return VECTOR_TYPE_INT; case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_HALF_FLOAT: case NANOARROW_TYPE_FLOAT: case NANOARROW_TYPE_DOUBLE: case NANOARROW_TYPE_DECIMAL128: return VECTOR_TYPE_DBL; case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_STRING_VIEW: return VECTOR_TYPE_CHR; case NANOARROW_TYPE_DENSE_UNION: case NANOARROW_TYPE_SPARSE_UNION: case NANOARROW_TYPE_STRUCT: return VECTOR_TYPE_DATA_FRAME; default: return VECTOR_TYPE_OTHER; } } // The same as the above, but from a nanoarrow_schema() enum VectorType nanoarrow_infer_vector_type_schema(SEXP schema_xptr) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); struct ArrowSchemaView schema_view; struct ArrowError error; if (ArrowSchemaViewInit(&schema_view, schema, &error) != NANOARROW_OK) { Rf_error("nanoarrow_infer_vector_type_schema(): %s", ArrowErrorMessage(&error)); } if (schema_view.extension_name.size_bytes > 0) { return VECTOR_TYPE_OTHER; } else { return nanoarrow_infer_vector_type(schema_view.type); } } // The same as the above, but from a nanoarrow_array() enum VectorType nanoarrow_infer_vector_type_array(SEXP array_xptr) { return nanoarrow_infer_vector_type_schema(array_xptr_get_schema(array_xptr)); } // Call nanoarrow::infer_ptype_other(), which handles less common types that // are easier to compute in R or gives an informative error if this is // not possible. static SEXP call_infer_ptype_other(SEXP schema_xptr) { SEXP fun = PROTECT(Rf_install("infer_ptype_other")); SEXP call = PROTECT(Rf_lang2(fun, schema_xptr)); SEXP result = PROTECT(Rf_eval(call, nanoarrow_ns_pkg)); UNPROTECT(3); return result; } SEXP nanoarrow_c_infer_ptype(SEXP schema_xptr); static SEXP infer_ptype_data_frame(SEXP schema_xptr) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); SEXP result = PROTECT(Rf_allocVector(VECSXP, schema->n_children)); SEXP result_names = PROTECT(Rf_allocVector(STRSXP, schema->n_children)); for (R_xlen_t i = 0; i < schema->n_children; i++) { SEXP child_xptr = PROTECT(borrow_schema_child_xptr(schema_xptr, i)); SET_VECTOR_ELT(result, i, nanoarrow_c_infer_ptype(child_xptr)); UNPROTECT(1); struct ArrowSchema* child = schema->children[i]; if (child->name != NULL) { SET_STRING_ELT(result_names, i, Rf_mkCharCE(child->name, CE_UTF8)); } else { SET_STRING_ELT(result_names, i, Rf_mkChar("")); } } Rf_setAttrib(result, R_ClassSymbol, nanoarrow_cls_data_frame); Rf_setAttrib(result, R_NamesSymbol, result_names); SEXP rownames = PROTECT(Rf_allocVector(INTSXP, 2)); INTEGER(rownames)[0] = NA_INTEGER; INTEGER(rownames)[1] = 0; Rf_setAttrib(result, R_RowNamesSymbol, rownames); UNPROTECT(3); return result; } SEXP nanoarrow_c_infer_ptype(SEXP schema_xptr) { enum VectorType vector_type = nanoarrow_infer_vector_type_schema(schema_xptr); SEXP ptype = R_NilValue; switch (vector_type) { case VECTOR_TYPE_LGL: case VECTOR_TYPE_INT: case VECTOR_TYPE_DBL: case VECTOR_TYPE_CHR: ptype = PROTECT(nanoarrow_alloc_type(vector_type, 0)); break; case VECTOR_TYPE_DATA_FRAME: ptype = PROTECT(infer_ptype_data_frame(schema_xptr)); break; default: ptype = PROTECT(call_infer_ptype_other(schema_xptr)); break; } UNPROTECT(1); return ptype; } nanoarrow/src/pointers.c0000644000176200001440000002333714643132461015072 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "array.h" #include "array_stream.h" #include "schema.h" // More reliable way to stringify intptr_t on Windows using C++ void intptr_as_string(intptr_t ptr_int, char* buf); SEXP nanoarrow_c_allocate_schema(void) { return nanoarrow_schema_owning_xptr(); } SEXP nanoarrow_c_allocate_array(void) { return nanoarrow_array_owning_xptr(); } SEXP nanoarrow_c_allocate_array_stream(void) { return nanoarrow_array_stream_owning_xptr(); } SEXP nanoarrow_c_pointer(SEXP obj_sexp) { if (TYPEOF(obj_sexp) == EXTPTRSXP) { return obj_sexp; } else if (TYPEOF(obj_sexp) == REALSXP && Rf_length(obj_sexp) == 1) { // Note that this is not a good idea to actually do; however, is provided for // backward compatibility with early versions of the arrow R package. intptr_t ptr_int = (intptr_t)(REAL(obj_sexp)[0]); return R_MakeExternalPtr((void*)ptr_int, R_NilValue, R_NilValue); } else if (TYPEOF(obj_sexp) == STRSXP && Rf_length(obj_sexp) == 1) { const char* text = CHAR(STRING_ELT(obj_sexp, 0)); char* end_ptr; intptr_t ptr_int = strtoll(text, &end_ptr, 10); if (end_ptr != (text + strlen(text))) { Rf_error("'%s' could not be interpreted as an unsigned 64-bit integer", text); } return R_MakeExternalPtr((void*)ptr_int, R_NilValue, R_NilValue); } Rf_error("Pointer must be chr[1], dbl[1], or external pointer"); return R_NilValue; } SEXP nanoarrow_c_pointer_addr_dbl(SEXP ptr) { // Note that this is not a good idea to actually do; however, is provided for // backward compatibility with early versions of the arrow R package. uintptr_t ptr_int = (uintptr_t)R_ExternalPtrAddr(nanoarrow_c_pointer(ptr)); return Rf_ScalarReal((double)ptr_int); } SEXP nanoarrow_c_pointer_addr_chr(SEXP ptr) { intptr_t ptr_int = (intptr_t)R_ExternalPtrAddr(nanoarrow_c_pointer(ptr)); char addr_chars[100]; memset(addr_chars, 0, 100); intptr_as_string(ptr_int, addr_chars); return Rf_mkString(addr_chars); } SEXP nanoarrow_c_pointer_addr_pretty(SEXP ptr) { char addr_chars[100]; memset(addr_chars, 0, 100); snprintf(addr_chars, sizeof(addr_chars), "%p", R_ExternalPtrAddr(nanoarrow_c_pointer(ptr))); return Rf_mkString(addr_chars); } SEXP nanoarrow_c_pointer_is_valid(SEXP ptr) { if (Rf_inherits(ptr, "nanoarrow_schema")) { struct ArrowSchema* obj = (struct ArrowSchema*)R_ExternalPtrAddr(ptr); return Rf_ScalarLogical(obj != NULL && obj->release != NULL); } else if (Rf_inherits(ptr, "nanoarrow_array")) { struct ArrowArray* obj = (struct ArrowArray*)R_ExternalPtrAddr(ptr); return Rf_ScalarLogical(obj != NULL && obj->release != NULL); } else if (Rf_inherits(ptr, "nanoarrow_array_stream")) { struct ArrowArrayStream* obj = (struct ArrowArrayStream*)R_ExternalPtrAddr(ptr); return Rf_ScalarLogical(obj != NULL && obj->release != NULL); } else { Rf_error( "`ptr` must inherit from 'nanoarrow_schema', 'nanoarrow_array', or " "'nanoarrow_array_stream'"); } return R_NilValue; } SEXP nanoarrow_c_pointer_release(SEXP ptr) { if (Rf_inherits(ptr, "nanoarrow_schema")) { struct ArrowSchema* obj = (struct ArrowSchema*)R_ExternalPtrAddr(ptr); if (obj != NULL && obj->release != NULL) { obj->release(obj); obj->release = NULL; } } else if (Rf_inherits(ptr, "nanoarrow_array")) { struct ArrowArray* obj = (struct ArrowArray*)R_ExternalPtrAddr(ptr); if (obj != NULL && obj->release != NULL) { obj->release(obj); obj->release = NULL; } } else if (Rf_inherits(ptr, "nanoarrow_array_stream")) { struct ArrowArrayStream* obj = (struct ArrowArrayStream*)R_ExternalPtrAddr(ptr); if (obj != NULL && obj->release != NULL) { obj->release(obj); obj->release = NULL; } } else { Rf_error( "`ptr` must inherit from 'nanoarrow_schema', 'nanoarrow_array', or " "'nanoarrow_array_stream'"); } return R_NilValue; } SEXP nanoarrow_c_pointer_move(SEXP ptr_src, SEXP ptr_dst) { SEXP xptr_src = PROTECT(nanoarrow_c_pointer(ptr_src)); if (Rf_inherits(ptr_dst, "nanoarrow_schema")) { struct ArrowSchema* obj_dst = (struct ArrowSchema*)R_ExternalPtrAddr(ptr_dst); if (obj_dst == NULL) { Rf_error("`ptr_dst` is a pointer to NULL"); } if (obj_dst->release != NULL) { Rf_error("`ptr_dst` is a valid struct ArrowSchema"); } struct ArrowSchema* obj_src = (struct ArrowSchema*)R_ExternalPtrAddr(xptr_src); if (obj_src == NULL || obj_src->release == NULL) { Rf_error("`ptr_src` is not a valid struct ArrowSchema"); } ArrowSchemaMove(obj_src, obj_dst); } else if (Rf_inherits(ptr_dst, "nanoarrow_array")) { struct ArrowArray* obj_dst = (struct ArrowArray*)R_ExternalPtrAddr(ptr_dst); if (obj_dst == NULL) { Rf_error("`ptr_dst` is a pointer to NULL"); } if (obj_dst->release != NULL) { Rf_error("`ptr_dst` is a valid struct ArrowArray"); } struct ArrowArray* obj_src = (struct ArrowArray*)R_ExternalPtrAddr(xptr_src); if (obj_src == NULL || obj_src->release == NULL) { Rf_error("`ptr_src` is not a valid struct ArrowArray"); } ArrowArrayMove(obj_src, obj_dst); } else if (Rf_inherits(ptr_dst, "nanoarrow_array_stream")) { struct ArrowArrayStream* obj_dst = (struct ArrowArrayStream*)R_ExternalPtrAddr(ptr_dst); if (obj_dst == NULL) { Rf_error("`ptr_dst` is a pointer to NULL"); } if (obj_dst->release != NULL) { Rf_error("`ptr_dst` is a valid struct ArrowArrayStream"); } struct ArrowArrayStream* obj_src = (struct ArrowArrayStream*)R_ExternalPtrAddr(xptr_src); if (obj_src == NULL || obj_src->release == NULL) { Rf_error("`ptr_src` is not a valid struct ArrowArrayStream"); } ArrowArrayStreamMove(obj_src, obj_dst); } else { Rf_error( "`ptr_dst` must inherit from 'nanoarrow_schema', 'nanoarrow_array', or " "'nanoarrow_array_stream'"); } // also move SEXP dependencies R_SetExternalPtrProtected(ptr_dst, R_ExternalPtrProtected(xptr_src)); R_SetExternalPtrTag(ptr_dst, R_ExternalPtrTag(xptr_src)); R_SetExternalPtrProtected(xptr_src, R_NilValue); R_SetExternalPtrTag(xptr_src, R_NilValue); UNPROTECT(1); return R_NilValue; } // The rest of this package operates under the assumption that references // to a schema/array external pointer are kept by anything that needs // the underlying memory to persist. When the reference count reaches 0, // R calls the release callback (and nobody else). // When exporting to something that is expecting to call the release callback // itself (e.g., Arrow C++ via the arrow R package or pyarrow Python package), // the structure and the release callback need to keep the information. // schemas are less frequently iterated over and it's much simpler to // (recursively) copy the whole object and export it rather than try to // keep all the object dependencies alive and/or risk moving a dependency // of some other R object. SEXP nanoarrow_c_export_schema(SEXP schema_xptr, SEXP ptr_dst) { struct ArrowSchema* obj_src = nanoarrow_schema_from_xptr(schema_xptr); SEXP xptr_dst = PROTECT(nanoarrow_c_pointer(ptr_dst)); struct ArrowSchema* obj_dst = (struct ArrowSchema*)R_ExternalPtrAddr(xptr_dst); if (obj_dst == NULL) { Rf_error("`ptr_dst` is a pointer to NULL"); } if (obj_dst->release != NULL) { Rf_error("`ptr_dst` is a valid struct ArrowSchema"); } int result = ArrowSchemaDeepCopy(obj_src, obj_dst); if (result != NANOARROW_OK) { Rf_error("Failed to deep copy struct ArrowSchema"); } UNPROTECT(1); return R_NilValue; } SEXP nanoarrow_c_export_array(SEXP array_xptr, SEXP ptr_dst) { SEXP xptr_dst = PROTECT(nanoarrow_c_pointer(ptr_dst)); struct ArrowArray* obj_dst = (struct ArrowArray*)R_ExternalPtrAddr(xptr_dst); if (obj_dst == NULL) { Rf_error("`ptr_dst` is a pointer to NULL"); } if (obj_dst->release != NULL) { Rf_error("`ptr_dst` is a valid struct ArrowArray"); } array_export(array_xptr, obj_dst); UNPROTECT(1); return R_NilValue; } SEXP nanoarrow_c_export_array_stream(SEXP array_stream_xptr, SEXP ptr_dst) { SEXP xptr_dst = PROTECT(nanoarrow_c_pointer(ptr_dst)); struct ArrowArrayStream* obj_dst = (struct ArrowArrayStream*)R_ExternalPtrAddr(xptr_dst); if (obj_dst == NULL) { Rf_error("`ptr_dst` is a pointer to NULL"); } if (obj_dst->release != NULL) { Rf_error("`ptr_dst` is a valid struct ArrowArrayStream"); } array_stream_export(array_stream_xptr, obj_dst); // Remove SEXP dependencies (if important they are kept alive by array_stream_export) R_SetExternalPtrProtected(array_stream_xptr, R_NilValue); R_SetExternalPtrTag(array_stream_xptr, R_NilValue); UNPROTECT(1); return R_NilValue; } SEXP nanoarrow_c_pointer_set_protected(SEXP ptr_src, SEXP protected_sexp) { if (R_ExternalPtrProtected(ptr_src) != R_NilValue) { Rf_error("External pointer protected value has already been set"); } R_SetExternalPtrProtected(ptr_src, protected_sexp); return R_NilValue; } nanoarrow/src/materialize_lgl.h0000644000176200001440000000603114502402562016364 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_LGL_H_INCLUDED #define R_MATERIALIZE_LGL_H_INCLUDED #include #include #include "materialize_common.h" #include "nanoarrow.h" static int nanoarrow_materialize_lgl(struct ArrayViewSlice* src, struct VectorSlice* dst, struct MaterializeOptions* options) { if (src->array_view->array->dictionary != NULL) { return ENOTSUP; } // True for all the types supported here const uint8_t* is_valid = src->array_view->buffer_views[0].data.as_uint8; const uint8_t* data_buffer = src->array_view->buffer_views[1].data.as_uint8; int64_t raw_src_offset = src->array_view->array->offset + src->offset; int* result = LOGICAL(dst->vec_sexp); // Fill the buffer switch (src->array_view->storage_type) { case NANOARROW_TYPE_NA: for (R_xlen_t i = 0; i < dst->length; i++) { result[dst->offset + i] = NA_LOGICAL; } break; case NANOARROW_TYPE_BOOL: ArrowBitsUnpackInt32(data_buffer, raw_src_offset, dst->length, result + dst->offset); // Set any nulls to NA_LOGICAL if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_LOGICAL; } } } break; case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_FLOAT: case NANOARROW_TYPE_DOUBLE: for (R_xlen_t i = 0; i < src->array_view->array->length; i++) { result[dst->offset + i] = ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i) != 0; } // Set any nulls to NA_LOGICAL if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_LOGICAL; } } } break; default: return EINVAL; } return NANOARROW_OK; } #endif nanoarrow/src/array_view.h0000644000176200001440000000406014502402562015370 0ustar liggesusers// 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. #ifndef R_NANOARROW_ARRAY_VIEW_H_INCLUDED #define R_NANOARROW_ARRAY_VIEW_H_INCLUDED #include #include #include "nanoarrow.h" // Creates an external pointer to a struct ArrowArrayView, erroring // if the validation inherent in its creation fails (i.e., calling // this will also validate the array). This requires that array_xptr // has a schema attached. The ArrowArrayView is an augmented structure // provided by the nanoarrow C library that makes it easier to access // elements and buffers. This is not currently exposed at the R // level but is used at the C level to make validation and conversion // to R easier to write. SEXP array_view_xptr_from_array_xptr(SEXP array_xptr); // Returns the struct ArrowArrayView underlying an external pointer, // erroring for invalid objects and NULL pointers. static inline struct ArrowArrayView* array_view_from_xptr(SEXP array_view_xptr) { if (!Rf_inherits(array_view_xptr, "nanoarrow_array_view")) { Rf_error("`array_view` argument that is not a nanoarrow_array_view()"); } struct ArrowArrayView* array_view = (struct ArrowArrayView*)R_ExternalPtrAddr(array_view_xptr); if (array_view == NULL) { Rf_error("nanoarrow_array_view() is an external pointer to NULL"); } return array_view; } #endif nanoarrow/src/materialize_unspecified.h0000644000176200001440000000424014502402562020104 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_UNSPECIFIED_H_INCLUDED #define R_MATERIALIZE_UNSPECIFIED_H_INCLUDED #include #include #include "materialize_common.h" #include "nanoarrow.h" static inline int nanoarrow_materialize_unspecified(struct ArrayViewSlice* src, struct VectorSlice* dst, struct MaterializeOptions* options) { if (src->array_view->array->dictionary != NULL) { return ENOTSUP; } int* result = LOGICAL(dst->vec_sexp); int64_t total_offset = src->array_view->array->offset + src->offset; int64_t length = src->length; const uint8_t* bits = src->array_view->buffer_views[0].data.as_uint8; if (length == 0 || src->array_view->storage_type == NANOARROW_TYPE_NA || ArrowBitCountSet(bits, total_offset, length) == 0) { // We can blindly set all the values to NA_LOGICAL without checking for (int64_t i = 0; i < length; i++) { result[dst->offset + i] = NA_LOGICAL; } } else { // Count non-null values and warn int64_t n_bad_values = 0; for (int64_t i = 0; i < length; i++) { n_bad_values += ArrowBitGet(bits, total_offset + i); result[dst->offset + i] = NA_LOGICAL; } if (n_bad_values > 0) { warn_lossy_conversion(n_bad_values, "that were non-null set to NA"); } } return NANOARROW_OK; } #endif nanoarrow/src/util.c0000644000176200001440000000563614672714403014212 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "util.h" SEXP nanoarrow_ns_pkg = NULL; SEXP nanoarrow_cls_array = NULL; SEXP nanoarrow_cls_altrep_chr = NULL; SEXP nanoarrow_cls_array_view = NULL; SEXP nanoarrow_cls_data_frame = NULL; SEXP nanoarrow_cls_schema = NULL; SEXP nanoarrow_cls_array_stream = NULL; SEXP nanoarrow_cls_buffer = NULL; SEXP nanoarrow_sym_readbin = NULL; SEXP nanoarrow_sym_writebin = NULL; SEXP nanoarrow_ptype_raw = NULL; void nanoarrow_init_cached_sexps(void) { SEXP nanoarrow_str = PROTECT(Rf_mkString("nanoarrow")); nanoarrow_ns_pkg = PROTECT(R_FindNamespace(nanoarrow_str)); nanoarrow_cls_array = PROTECT(Rf_mkString("nanoarrow_array")); nanoarrow_cls_altrep_chr = PROTECT(Rf_mkString("nanoarrow::altrep_chr")); nanoarrow_cls_array_view = PROTECT(Rf_mkString("nanoarrow_array_view")); nanoarrow_cls_data_frame = PROTECT(Rf_mkString("data.frame")); nanoarrow_cls_schema = PROTECT(Rf_mkString("nanoarrow_schema")); nanoarrow_cls_array_stream = PROTECT(Rf_mkString("nanoarrow_array_stream")); nanoarrow_cls_buffer = PROTECT(Rf_mkString("nanoarrow_buffer")); nanoarrow_sym_readbin = PROTECT(Rf_install("read_bin_wrapper")); nanoarrow_sym_writebin = PROTECT(Rf_install("write_bin_wrapper")); nanoarrow_ptype_raw = PROTECT(Rf_allocVector(RAWSXP, 0)); R_PreserveObject(nanoarrow_ns_pkg); R_PreserveObject(nanoarrow_cls_array); R_PreserveObject(nanoarrow_cls_altrep_chr); R_PreserveObject(nanoarrow_cls_array_view); R_PreserveObject(nanoarrow_cls_data_frame); R_PreserveObject(nanoarrow_cls_schema); R_PreserveObject(nanoarrow_cls_array_stream); R_PreserveObject(nanoarrow_cls_buffer); R_PreserveObject(nanoarrow_sym_readbin); R_PreserveObject(nanoarrow_sym_writebin); R_PreserveObject(nanoarrow_ptype_raw); UNPROTECT(12); } SEXP nanoarrow_c_preserved_count(void) { return Rf_ScalarReal((double)nanoarrow_preserved_count()); } SEXP nanoarrow_c_preserved_empty(void) { return Rf_ScalarReal((double)nanoarrow_preserved_empty()); } SEXP nanoarrow_c_preserve_and_release_on_other_thread(SEXP obj) { nanoarrow_preserve_and_release_on_other_thread(obj); return R_NilValue; } nanoarrow/src/materialize_dbl.h0000644000176200001440000000776514701301265016365 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_DBL_H_INCLUDED #define R_MATERIALIZE_DBL_H_INCLUDED #include #include #include "materialize_common.h" #include "nanoarrow.h" // bit64::as.integer64(2^53) #define MAX_DBL_AS_INTEGER 9007199254740992 static inline int nanoarrow_materialize_dbl(struct RConverter* converter) { if (converter->src.array_view->array->dictionary != NULL) { return ENOTSUP; } struct ArrayViewSlice* src = &converter->src; struct VectorSlice* dst = &converter->dst; double* result = REAL(dst->vec_sexp); int64_t n_bad_values = 0; // True for all the types supported here const uint8_t* is_valid = src->array_view->buffer_views[0].data.as_uint8; int64_t raw_src_offset = src->array_view->array->offset + src->offset; // Fill the buffer switch (src->array_view->storage_type) { case NANOARROW_TYPE_NA: for (R_xlen_t i = 0; i < dst->length; i++) { result[dst->offset + i] = NA_REAL; } break; case NANOARROW_TYPE_DOUBLE: memcpy(result + dst->offset, src->array_view->buffer_views[1].data.as_double + raw_src_offset, dst->length * sizeof(double)); // Set any nulls to NA_REAL if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_REAL; } } } break; case NANOARROW_TYPE_BOOL: case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_HALF_FLOAT: case NANOARROW_TYPE_FLOAT: // No need to bounds check these types for (R_xlen_t i = 0; i < dst->length; i++) { result[dst->offset + i] = ArrowArrayViewGetDoubleUnsafe(src->array_view, src->offset + i); } // Set any nulls to NA_REAL if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_REAL; } } } break; case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_UINT64: for (R_xlen_t i = 0; i < dst->length; i++) { double value = ArrowArrayViewGetDoubleUnsafe(src->array_view, src->offset + i); if (value > MAX_DBL_AS_INTEGER || value < -MAX_DBL_AS_INTEGER) { // Content of null slot is undefined n_bad_values += is_valid == NULL || ArrowBitGet(is_valid, raw_src_offset + i); } result[dst->offset + i] = value; } // Set any nulls to NA_REAL if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_REAL; } } } break; default: return EINVAL; } if (n_bad_values > 0) { warn_lossy_conversion( n_bad_values, "may have incurred loss of precision in conversion to double()"); } return NANOARROW_OK; } #endif nanoarrow/src/init.c0000644000176200001440000002755314672714403014202 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "altrep.h" #include "util.h" /* generated by tools/make-callentries.R */ extern SEXP nanoarrow_c_make_altrep_chr(SEXP array_xptr); extern SEXP nanoarrow_c_is_altrep(SEXP x_sexp); extern SEXP nanoarrow_c_altrep_is_materialized(SEXP x_sexp); extern SEXP nanoarrow_c_altrep_force_materialize(SEXP x_sexp, SEXP recursive_sexp); extern SEXP nanoarrow_c_array_stream_get_schema(SEXP array_stream_xptr); extern SEXP nanoarrow_c_array_stream_get_next(SEXP array_stream_xptr); extern SEXP nanoarrow_c_basic_array_stream(SEXP batches_sexp, SEXP schema_xptr, SEXP validate_sexp); extern SEXP nanoarrow_c_array_list_total_length(SEXP list_of_array_xptr); extern SEXP nanoarrow_c_array_view(SEXP array_xptr, SEXP schema_xptr); extern SEXP nanoarrow_c_array_init(SEXP schema_xptr); extern SEXP nanoarrow_c_array_set_length(SEXP array_xptr, SEXP length_sexp); extern SEXP nanoarrow_c_array_set_null_count(SEXP array_xptr, SEXP null_count_sexp); extern SEXP nanoarrow_c_array_set_offset(SEXP array_xptr, SEXP offset_sexp); extern SEXP nanoarrow_c_array_set_buffers(SEXP array_xptr, SEXP buffers_sexp); extern SEXP nanoarrow_c_array_set_children(SEXP array_xptr, SEXP children_sexp); extern SEXP nanoarrow_c_array_set_dictionary(SEXP array_xptr, SEXP dictionary_xptr); extern SEXP nanoarrow_c_array_validate_after_modify(SEXP array_xptr, SEXP schema_xptr); extern SEXP nanoarrow_c_array_set_schema(SEXP array_xptr, SEXP schema_xptr, SEXP validate_sexp); extern SEXP nanoarrow_c_infer_schema_array(SEXP array_xptr); extern SEXP nanoarrow_c_array_proxy(SEXP array_xptr, SEXP array_view_xptr, SEXP recursive_sexp); extern SEXP nanoarrow_c_as_array_default(SEXP x_sexp, SEXP schema_xptr); extern SEXP nanoarrow_c_as_buffer_default(SEXP x_sexp); extern SEXP nanoarrow_c_buffer_append(SEXP buffer_xptr, SEXP new_buffer_xptr); extern SEXP nanoarrow_c_buffer_info(SEXP buffer_xptr); extern SEXP nanoarrow_c_buffer_head_bytes(SEXP buffer_xptr, SEXP max_bytes_sexp); extern SEXP nanoarrow_c_buffer_as_raw(SEXP buffer_xptr); extern SEXP nanoarrow_c_convert_array_stream(SEXP array_stream_xptr, SEXP ptype_sexp, SEXP size_sexp, SEXP n_sexp); extern SEXP nanoarrow_c_infer_ptype(SEXP schema_xptr); extern SEXP nanoarrow_c_convert_array(SEXP array_xptr, SEXP ptype_sexp); extern SEXP nanoarrow_c_ipc_array_reader_buffer(SEXP buffer_xptr); extern SEXP nanoarrow_c_ipc_array_reader_connection(SEXP con); extern SEXP nanoarrow_c_ipc_writer_connection(SEXP con); extern SEXP nanoarrow_c_ipc_writer_write_stream(SEXP writer_xptr, SEXP array_stream_xptr); extern SEXP nanoarrow_c_allocate_schema(void); extern SEXP nanoarrow_c_allocate_array(void); extern SEXP nanoarrow_c_allocate_array_stream(void); extern SEXP nanoarrow_c_pointer(SEXP obj_sexp); extern SEXP nanoarrow_c_pointer_addr_dbl(SEXP ptr); extern SEXP nanoarrow_c_pointer_addr_chr(SEXP ptr); extern SEXP nanoarrow_c_pointer_addr_pretty(SEXP ptr); extern SEXP nanoarrow_c_pointer_is_valid(SEXP ptr); extern SEXP nanoarrow_c_pointer_release(SEXP ptr); extern SEXP nanoarrow_c_pointer_move(SEXP ptr_src, SEXP ptr_dst); extern SEXP nanoarrow_c_export_schema(SEXP schema_xptr, SEXP ptr_dst); extern SEXP nanoarrow_c_export_array(SEXP array_xptr, SEXP ptr_dst); extern SEXP nanoarrow_c_export_array_stream(SEXP array_stream_xptr, SEXP ptr_dst); extern SEXP nanoarrow_c_pointer_set_protected(SEXP ptr_src, SEXP protected_sexp); extern SEXP nanoarrow_c_schema_init(SEXP type_id_sexp, SEXP nullable_sexp); extern SEXP nanoarrow_c_schema_init_date_time(SEXP type_id_sexp, SEXP time_unit_sexp, SEXP timezone_sexp, SEXP nullable_sexp); extern SEXP nanoarrow_c_schema_init_decimal(SEXP type_id_sexp, SEXP precision_sexp, SEXP scale_sexp, SEXP nullable_sexp); extern SEXP nanoarrow_c_schema_init_fixed_size(SEXP type_id_sexp, SEXP fixed_size_sexp, SEXP nullable_sexp); extern SEXP nanoarrow_c_schema_to_list(SEXP schema_xptr); extern SEXP nanoarrow_c_schema_parse(SEXP schema_xptr); extern SEXP nanoarrow_c_schema_format(SEXP schema_xptr, SEXP recursive_sexp); extern SEXP nanoarrow_c_schema_set_format(SEXP schema_mut_xptr, SEXP format_sexp); extern SEXP nanoarrow_c_schema_set_name(SEXP schema_mut_xptr, SEXP name_sexp); extern SEXP nanoarrow_c_schema_set_metadata(SEXP schema_mut_xptr, SEXP metadata_sexp); extern SEXP nanoarrow_c_schema_set_flags(SEXP schema_mut_xptr, SEXP flags_sexp); extern SEXP nanoarrow_c_schema_set_children(SEXP schema_mut_xptr, SEXP children_sexp); extern SEXP nanoarrow_c_schema_set_dictionary(SEXP schema_mut_xptr, SEXP dictionary_xptr); extern SEXP nanoarrow_c_preserved_count(void); extern SEXP nanoarrow_c_preserved_empty(void); extern SEXP nanoarrow_c_preserve_and_release_on_other_thread(SEXP obj); extern SEXP nanoarrow_c_vctr_chunk_offsets(SEXP array_list); extern SEXP nanoarrow_c_vctr_chunk_resolve(SEXP indices_sexp, SEXP offsets_sexp); extern SEXP nanoarrow_c_vctr_as_slice(SEXP indices_sexp); extern SEXP nanoarrow_c_version(void); extern SEXP nanoarrow_c_version_runtime(void); static const R_CallMethodDef CallEntries[] = { {"nanoarrow_c_make_altrep_chr", (DL_FUNC)&nanoarrow_c_make_altrep_chr, 1}, {"nanoarrow_c_is_altrep", (DL_FUNC)&nanoarrow_c_is_altrep, 1}, {"nanoarrow_c_altrep_is_materialized", (DL_FUNC)&nanoarrow_c_altrep_is_materialized, 1}, {"nanoarrow_c_altrep_force_materialize", (DL_FUNC)&nanoarrow_c_altrep_force_materialize, 2}, {"nanoarrow_c_array_stream_get_schema", (DL_FUNC)&nanoarrow_c_array_stream_get_schema, 1}, {"nanoarrow_c_array_stream_get_next", (DL_FUNC)&nanoarrow_c_array_stream_get_next, 1}, {"nanoarrow_c_basic_array_stream", (DL_FUNC)&nanoarrow_c_basic_array_stream, 3}, {"nanoarrow_c_array_list_total_length", (DL_FUNC)&nanoarrow_c_array_list_total_length, 1}, {"nanoarrow_c_array_view", (DL_FUNC)&nanoarrow_c_array_view, 2}, {"nanoarrow_c_array_init", (DL_FUNC)&nanoarrow_c_array_init, 1}, {"nanoarrow_c_array_set_length", (DL_FUNC)&nanoarrow_c_array_set_length, 2}, {"nanoarrow_c_array_set_null_count", (DL_FUNC)&nanoarrow_c_array_set_null_count, 2}, {"nanoarrow_c_array_set_offset", (DL_FUNC)&nanoarrow_c_array_set_offset, 2}, {"nanoarrow_c_array_set_buffers", (DL_FUNC)&nanoarrow_c_array_set_buffers, 2}, {"nanoarrow_c_array_set_children", (DL_FUNC)&nanoarrow_c_array_set_children, 2}, {"nanoarrow_c_array_set_dictionary", (DL_FUNC)&nanoarrow_c_array_set_dictionary, 2}, {"nanoarrow_c_array_validate_after_modify", (DL_FUNC)&nanoarrow_c_array_validate_after_modify, 2}, {"nanoarrow_c_array_set_schema", (DL_FUNC)&nanoarrow_c_array_set_schema, 3}, {"nanoarrow_c_infer_schema_array", (DL_FUNC)&nanoarrow_c_infer_schema_array, 1}, {"nanoarrow_c_array_proxy", (DL_FUNC)&nanoarrow_c_array_proxy, 3}, {"nanoarrow_c_as_array_default", (DL_FUNC)&nanoarrow_c_as_array_default, 2}, {"nanoarrow_c_as_buffer_default", (DL_FUNC)&nanoarrow_c_as_buffer_default, 1}, {"nanoarrow_c_buffer_append", (DL_FUNC)&nanoarrow_c_buffer_append, 2}, {"nanoarrow_c_buffer_info", (DL_FUNC)&nanoarrow_c_buffer_info, 1}, {"nanoarrow_c_buffer_head_bytes", (DL_FUNC)&nanoarrow_c_buffer_head_bytes, 2}, {"nanoarrow_c_buffer_as_raw", (DL_FUNC)&nanoarrow_c_buffer_as_raw, 1}, {"nanoarrow_c_convert_array_stream", (DL_FUNC)&nanoarrow_c_convert_array_stream, 4}, {"nanoarrow_c_infer_ptype", (DL_FUNC)&nanoarrow_c_infer_ptype, 1}, {"nanoarrow_c_convert_array", (DL_FUNC)&nanoarrow_c_convert_array, 2}, {"nanoarrow_c_ipc_array_reader_buffer", (DL_FUNC)&nanoarrow_c_ipc_array_reader_buffer, 1}, {"nanoarrow_c_ipc_array_reader_connection", (DL_FUNC)&nanoarrow_c_ipc_array_reader_connection, 1}, {"nanoarrow_c_ipc_writer_connection", (DL_FUNC)&nanoarrow_c_ipc_writer_connection, 1}, {"nanoarrow_c_ipc_writer_write_stream", (DL_FUNC)&nanoarrow_c_ipc_writer_write_stream, 2}, {"nanoarrow_c_allocate_schema", (DL_FUNC)&nanoarrow_c_allocate_schema, 0}, {"nanoarrow_c_allocate_array", (DL_FUNC)&nanoarrow_c_allocate_array, 0}, {"nanoarrow_c_allocate_array_stream", (DL_FUNC)&nanoarrow_c_allocate_array_stream, 0}, {"nanoarrow_c_pointer", (DL_FUNC)&nanoarrow_c_pointer, 1}, {"nanoarrow_c_pointer_addr_dbl", (DL_FUNC)&nanoarrow_c_pointer_addr_dbl, 1}, {"nanoarrow_c_pointer_addr_chr", (DL_FUNC)&nanoarrow_c_pointer_addr_chr, 1}, {"nanoarrow_c_pointer_addr_pretty", (DL_FUNC)&nanoarrow_c_pointer_addr_pretty, 1}, {"nanoarrow_c_pointer_is_valid", (DL_FUNC)&nanoarrow_c_pointer_is_valid, 1}, {"nanoarrow_c_pointer_release", (DL_FUNC)&nanoarrow_c_pointer_release, 1}, {"nanoarrow_c_pointer_move", (DL_FUNC)&nanoarrow_c_pointer_move, 2}, {"nanoarrow_c_export_schema", (DL_FUNC)&nanoarrow_c_export_schema, 2}, {"nanoarrow_c_export_array", (DL_FUNC)&nanoarrow_c_export_array, 2}, {"nanoarrow_c_export_array_stream", (DL_FUNC)&nanoarrow_c_export_array_stream, 2}, {"nanoarrow_c_pointer_set_protected", (DL_FUNC)&nanoarrow_c_pointer_set_protected, 2}, {"nanoarrow_c_schema_init", (DL_FUNC)&nanoarrow_c_schema_init, 2}, {"nanoarrow_c_schema_init_date_time", (DL_FUNC)&nanoarrow_c_schema_init_date_time, 4}, {"nanoarrow_c_schema_init_decimal", (DL_FUNC)&nanoarrow_c_schema_init_decimal, 4}, {"nanoarrow_c_schema_init_fixed_size", (DL_FUNC)&nanoarrow_c_schema_init_fixed_size, 3}, {"nanoarrow_c_schema_to_list", (DL_FUNC)&nanoarrow_c_schema_to_list, 1}, {"nanoarrow_c_schema_parse", (DL_FUNC)&nanoarrow_c_schema_parse, 1}, {"nanoarrow_c_schema_format", (DL_FUNC)&nanoarrow_c_schema_format, 2}, {"nanoarrow_c_schema_set_format", (DL_FUNC)&nanoarrow_c_schema_set_format, 2}, {"nanoarrow_c_schema_set_name", (DL_FUNC)&nanoarrow_c_schema_set_name, 2}, {"nanoarrow_c_schema_set_metadata", (DL_FUNC)&nanoarrow_c_schema_set_metadata, 2}, {"nanoarrow_c_schema_set_flags", (DL_FUNC)&nanoarrow_c_schema_set_flags, 2}, {"nanoarrow_c_schema_set_children", (DL_FUNC)&nanoarrow_c_schema_set_children, 2}, {"nanoarrow_c_schema_set_dictionary", (DL_FUNC)&nanoarrow_c_schema_set_dictionary, 2}, {"nanoarrow_c_preserved_count", (DL_FUNC)&nanoarrow_c_preserved_count, 0}, {"nanoarrow_c_preserved_empty", (DL_FUNC)&nanoarrow_c_preserved_empty, 0}, {"nanoarrow_c_preserve_and_release_on_other_thread", (DL_FUNC)&nanoarrow_c_preserve_and_release_on_other_thread, 1}, {"nanoarrow_c_vctr_chunk_offsets", (DL_FUNC)&nanoarrow_c_vctr_chunk_offsets, 1}, {"nanoarrow_c_vctr_chunk_resolve", (DL_FUNC)&nanoarrow_c_vctr_chunk_resolve, 2}, {"nanoarrow_c_vctr_as_slice", (DL_FUNC)&nanoarrow_c_vctr_as_slice, 1}, {"nanoarrow_c_version", (DL_FUNC)&nanoarrow_c_version, 0}, {"nanoarrow_c_version_runtime", (DL_FUNC)&nanoarrow_c_version_runtime, 0}, {NULL, NULL, 0}}; /* end generated by tools/make-callentries.R */ void R_init_nanoarrow(DllInfo* dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE); nanoarrow_init_cached_sexps(); nanoarrow_preserve_init(); register_nanoarrow_altrep(dll); } nanoarrow/src/version.c0000644000176200001440000000203014405371036014676 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" SEXP nanoarrow_c_version(void) { return Rf_mkString(NANOARROW_VERSION); } SEXP nanoarrow_c_version_runtime(void) { return Rf_mkString(ArrowNanoarrowVersion()); } nanoarrow/src/Makevars0000644000176200001440000000216714672341746014567 0ustar liggesusers# 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. # -DFLATCC_USE_GENERIC_ALIGNED_ALLOC is needed to support compilation on systems # that do not provide aligned_alloc. Allocating flatbuffers memory is not # performance-critical for what we do in the nanoarrow R package (and may not # occur at all until IPC write support is added) PKG_CPPFLAGS=-I../inst/include -I../src -DFLATCC_USE_GENERIC_ALIGNED_ALLOC nanoarrow/src/array.h0000644000176200001440000001654614672341746014370 0ustar liggesusers// 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. #ifndef R_NANOARROW_ARRAY_H_INCLUDED #define R_NANOARROW_ARRAY_H_INCLUDED #include #include #include #include "buffer.h" #include "nanoarrow.h" #include "util.h" // Returns an external pointer to an array child with a schema attached. // The returned pointer will keep its parent alive unless passed through // array_xptr_ensure_independent(). This is typically what you want when // printing or performing a conversion, where the borrowed external pointer // is ephemeral. SEXP borrow_array_child_xptr(SEXP array_xptr, int64_t i); // Returns the underlying struct ArrowArray* from an external pointer, // checking and erroring for invalid objects, pointers, and arrays, but // allowing for R_NilValue to signify a NULL return. static inline struct ArrowArray* nullable_nanoarrow_array_from_xptr(SEXP array_xptr) { if (array_xptr == R_NilValue) { return NULL; } else { return nanoarrow_array_from_xptr(array_xptr); } } // Attaches a schema to an array external pointer. The nanoarrow R package // attempts to do this whenever possible to avoid misinterpreting arrays. static inline void array_xptr_set_schema(SEXP array_xptr, SEXP schema_xptr) { R_SetExternalPtrTag(array_xptr, schema_xptr); } static inline SEXP array_xptr_get_schema(SEXP array_xptr) { return R_ExternalPtrTag(array_xptr); } // Retrieves a schema from an array external pointer if it exists or returns // NULL otherwise. static inline struct ArrowSchema* schema_from_array_xptr(SEXP array_xptr) { SEXP maybe_schema_xptr = R_ExternalPtrTag(array_xptr); if (Rf_inherits(maybe_schema_xptr, "nanoarrow_schema")) { return (struct ArrowSchema*)R_ExternalPtrAddr(maybe_schema_xptr); } else { return NULL; } } static inline SEXP array_ensure_independent(struct ArrowArray* array); static inline SEXP array_xptr_ensure_independent(SEXP array_xptr); // Exports a version of the array pointed to by array_xptr to array_copy // such that (1) any R references to array_xptr are not invalidated if they exist // and (2) array_copy->release() can be called independently without invalidating // R references to array_xptr. This is a recursive operation (i.e., it will // "explode" the array's children into reference-counted entities where the // reference counting is handled by R's preserve/release infrastructure). // Exported arrays and their children have the important property that they // (and their children) are allocated using nanoarrow's ArrowArrayInit, meaning // we can modify them safely (i.e., using ArrowArraySetBuffer()). static inline void array_export(SEXP array_xptr, struct ArrowArray* array_copy) { // If array_xptr has SEXP dependencies (most commonly this would occur if it's // a borrowed child of a struct array), this will ensure a version that can be // released independently of its parent. SEXP independent_array_xptr = PROTECT(array_xptr_ensure_independent(array_xptr)); struct ArrowArray* array = nanoarrow_array_from_xptr(independent_array_xptr); int result = ArrowArrayInitFromType(array_copy, NANOARROW_TYPE_UNINITIALIZED); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromType() failed"); } array_copy->length = array->length; array_copy->null_count = array->null_count; array_copy->offset = array->offset; // Get buffer references, each of which preserve a reference to independent_array_xptr array_copy->n_buffers = array->n_buffers; for (int64_t i = 0; i < array->n_buffers; i++) { SEXP borrowed_buffer = PROTECT(buffer_borrowed_xptr(array->buffers[i], 0, independent_array_xptr)); result = ArrowArraySetBuffer(array_copy, i, (struct ArrowBuffer*)R_ExternalPtrAddr(borrowed_buffer)); if (result != NANOARROW_OK) { array_copy->release(array_copy); Rf_error("ArrowArraySetBuffer() failed"); } UNPROTECT(1); } // Swap out any children for independently releasable children and export them // into array_copy->children result = ArrowArrayAllocateChildren(array_copy, array->n_children); if (result != NANOARROW_OK) { array_copy->release(array_copy); Rf_error("ArrowArrayAllocateChildren() failed"); } for (int64_t i = 0; i < array->n_children; i++) { SEXP independent_child = PROTECT(array_ensure_independent(array->children[i])); array_export(independent_child, array_copy->children[i]); UNPROTECT(1); } if (array->dictionary != NULL) { result = ArrowArrayAllocateDictionary(array_copy); if (result != NANOARROW_OK) { array_copy->release(array_copy); Rf_error("ArrowArrayAllocateDictionary() failed"); } SEXP independent_dictionary = PROTECT(array_ensure_independent(array->dictionary)); array_export(independent_dictionary, array_copy->dictionary); UNPROTECT(1); } UNPROTECT(1); } // When arrays arrive as a nanoarrow_array, they are responsible for // releasing their children. This is fine until we need to keep one // child alive (e.g., a column of a data frame that we attach to an // ALTREP array) or until we need to export it (i.e., comply with // https://arrow.apache.org/docs/format/CDataInterface.html#moving-child-arrays // where child arrays must be movable). To make this work we need to do a shuffle: we // move the child array to a new owning external pointer and // give an exported version back to the original object. This only // applies if the array_xptr has the external pointer 'prot' field // set (if it doesn't have that set, it is already independent). static inline SEXP array_ensure_independent(struct ArrowArray* array) { SEXP original_array_xptr = PROTECT(nanoarrow_array_owning_xptr()); // Move array to the newly created owner struct ArrowArray* original_array = nanoarrow_output_array_from_xptr(original_array_xptr); memcpy(original_array, array, sizeof(struct ArrowArray)); array->release = NULL; // Export the independent array (which keeps a reference to original_array_xptr) // back to the original home array_export(original_array_xptr, array); // Return the external pointer of the independent array UNPROTECT(1); return original_array_xptr; } // This version is like the version that operates on a raw struct ArrowArray* // except it checks if this array has any array dependencies by inspecing the 'Protected' // field of the external pointer: if it that field is R_NilValue, it is already // independent. static inline SEXP array_xptr_ensure_independent(SEXP array_xptr) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); if (R_ExternalPtrProtected(array_xptr) == R_NilValue) { return array_xptr; } return array_ensure_independent(array); } #endif nanoarrow/src/materialize.h0000644000176200001440000000373414672341746015553 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_H_INCLUDED #define R_MATERIALIZE_H_INCLUDED #include #include #include "materialize_common.h" // A heuristic to identify prototypes that should be treated like data frames // (i.e., including record-style vectors like POSIXct). This heuristic returns // true if ptype is a data.frame or is an S3 list with names. int nanoarrow_ptype_is_data_frame(SEXP ptype); // Returns the number of rows in a data.frame in a way that is least likely to // expand the attr(x, "row.names") R_xlen_t nanoarrow_data_frame_size(SEXP x); // Set rownames of a data.frame (with special handling if len > INT_MAX) void nanoarrow_set_rownames(SEXP x, R_xlen_t len); // Perform actual materializing of values (e.g., loop through buffers) int nanoarrow_materialize(struct RConverter* converter, SEXP converter_xptr); // Shortcut to allocate a vector based on a vector type or ptype SEXP nanoarrow_alloc_type(enum VectorType vector_type, R_xlen_t len); SEXP nanoarrow_materialize_realloc(SEXP ptype, R_xlen_t len); // Finalize an object before returning to R. Currently only used for // nanoarrow_vctr conversion. int nanoarrow_materialize_finalize_result(SEXP converter_xptr); #endif nanoarrow/src/altrep.h0000644000176200001440000000365114355103326014516 0ustar liggesusers// 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. #ifndef R_ALTREP_H_INCLUDED #define R_ALTREP_H_INCLUDED #include "Rversion.h" #include // ALTREP available in R >= 3.5 #if defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0) #define HAS_ALTREP #include // Returns the ALTREP class name or NULL if x is not an altrep // object. static inline const char* nanoarrow_altrep_class(SEXP x) { if (ALTREP(x)) { SEXP data_class_sym = CAR(ATTRIB(ALTREP_CLASS(x))); return CHAR(PRINTNAME(data_class_sym)); } else { return NULL; } } #else static inline const char* nanoarrow_altrep_class(SEXP x) { return NULL; } #endif // Performs the ALTREP type registration and should be called on package load void register_nanoarrow_altrep(DllInfo* info); // Checks if an object is an ALTREP object created by this package static inline int is_nanoarrow_altrep(SEXP x) { const char* class_name = nanoarrow_altrep_class(x); return class_name && strncmp(class_name, "nanoarrow::", 11) == 0; } // Creates an altstring vector backed by a nanoarrow array or returns // R_NilValue if the conversion is not possible. SEXP nanoarrow_c_make_altrep_chr(SEXP array_xptr); #endif nanoarrow/src/schema.c0000644000176200001440000004766114547575511014507 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" #include "schema.h" #include "util.h" SEXP nanoarrow_c_schema_init(SEXP type_id_sexp, SEXP nullable_sexp) { int type_id = INTEGER(type_id_sexp)[0]; SEXP schema_xptr = PROTECT(nanoarrow_schema_owning_xptr()); struct ArrowSchema* schema = nanoarrow_output_schema_from_xptr(schema_xptr); int result = ArrowSchemaInitFromType(schema, type_id); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaInitFromType() failed"); } result = ArrowSchemaSetName(schema, ""); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetName() failed"); } if (!LOGICAL(nullable_sexp)[0]) { schema->flags &= ~ARROW_FLAG_NULLABLE; } UNPROTECT(1); return schema_xptr; } SEXP nanoarrow_c_schema_init_date_time(SEXP type_id_sexp, SEXP time_unit_sexp, SEXP timezone_sexp, SEXP nullable_sexp) { int type_id = INTEGER(type_id_sexp)[0]; int time_unit = INTEGER(time_unit_sexp)[0]; const char* timezone = NULL; if (timezone_sexp != R_NilValue) { timezone = Rf_translateCharUTF8(STRING_ELT(timezone_sexp, 0)); } else { timezone = NULL; } SEXP schema_xptr = PROTECT(nanoarrow_schema_owning_xptr()); struct ArrowSchema* schema = nanoarrow_output_schema_from_xptr(schema_xptr); ArrowSchemaInit(schema); int result = ArrowSchemaSetTypeDateTime(schema, type_id, time_unit, timezone); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetTypeDateTime() failed"); } result = ArrowSchemaSetName(schema, ""); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetName() failed"); } if (!LOGICAL(nullable_sexp)[0]) { schema->flags &= ~ARROW_FLAG_NULLABLE; } UNPROTECT(1); return schema_xptr; } SEXP nanoarrow_c_schema_init_decimal(SEXP type_id_sexp, SEXP precision_sexp, SEXP scale_sexp, SEXP nullable_sexp) { int type_id = INTEGER(type_id_sexp)[0]; int precision = INTEGER(precision_sexp)[0]; int scale = INTEGER(scale_sexp)[0]; SEXP schema_xptr = PROTECT(nanoarrow_schema_owning_xptr()); struct ArrowSchema* schema = nanoarrow_output_schema_from_xptr(schema_xptr); ArrowSchemaInit(schema); int result = ArrowSchemaSetTypeDecimal(schema, type_id, precision, scale); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetTypeDecimal() failed"); } result = ArrowSchemaSetName(schema, ""); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetName() failed"); } if (!LOGICAL(nullable_sexp)[0]) { schema->flags &= ~ARROW_FLAG_NULLABLE; } UNPROTECT(1); return schema_xptr; } SEXP nanoarrow_c_schema_init_fixed_size(SEXP type_id_sexp, SEXP fixed_size_sexp, SEXP nullable_sexp) { int type_id = INTEGER(type_id_sexp)[0]; int fixed_size = INTEGER(fixed_size_sexp)[0]; SEXP schema_xptr = PROTECT(nanoarrow_schema_owning_xptr()); struct ArrowSchema* schema = nanoarrow_output_schema_from_xptr(schema_xptr); ArrowSchemaInit(schema); int result = ArrowSchemaSetTypeFixedSize(schema, type_id, fixed_size); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetTypeFixedSize() failed"); } result = ArrowSchemaSetName(schema, ""); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetName() failed"); } if (!LOGICAL(nullable_sexp)[0]) { schema->flags &= ~ARROW_FLAG_NULLABLE; } UNPROTECT(1); return schema_xptr; } static SEXP schema_metadata_to_list(const char* metadata) { if (metadata == NULL) { return R_NilValue; } struct ArrowMetadataReader reader; int result = ArrowMetadataReaderInit(&reader, metadata); if (result != NANOARROW_OK) { Rf_error("ArrowMetadataReaderInit() failed"); } SEXP names = PROTECT(Rf_allocVector(STRSXP, reader.remaining_keys)); SEXP values = PROTECT(Rf_allocVector(VECSXP, reader.remaining_keys)); struct ArrowStringView key; struct ArrowStringView value; R_xlen_t i = 0; while (reader.remaining_keys > 0) { result = ArrowMetadataReaderRead(&reader, &key, &value); if (result != NANOARROW_OK) { Rf_error("ArrowMetadataReaderRead() failed"); } SET_STRING_ELT(names, i, Rf_mkCharLenCE(key.data, (int)key.size_bytes, CE_UTF8)); SEXP value_raw = PROTECT(Rf_allocVector(RAWSXP, value.size_bytes)); memcpy(RAW(value_raw), value.data, value.size_bytes); SET_VECTOR_ELT(values, i, value_raw); UNPROTECT(1); i++; } Rf_setAttrib(values, R_NamesSymbol, names); UNPROTECT(2); return values; } static SEXP borrow_schema_xptr(struct ArrowSchema* schema, SEXP shelter) { SEXP schema_xptr = PROTECT(R_MakeExternalPtr(schema, R_NilValue, shelter)); Rf_setAttrib(schema_xptr, R_ClassSymbol, nanoarrow_cls_schema); UNPROTECT(1); return schema_xptr; } SEXP borrow_schema_child_xptr(SEXP schema_xptr, int64_t i) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); return borrow_schema_xptr(schema->children[i], schema_xptr); } SEXP nanoarrow_c_schema_to_list(SEXP schema_xptr) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); const char* names[] = {"format", "name", "metadata", "flags", "children", "dictionary", ""}; SEXP result = PROTECT(Rf_mkNamed(VECSXP, names)); SEXP format_sexp = PROTECT(Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(format_sexp, 0, Rf_mkCharCE(schema->format, CE_UTF8)); SET_VECTOR_ELT(result, 0, format_sexp); UNPROTECT(1); if (schema->name != NULL) { SEXP name_sexp = PROTECT(Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(name_sexp, 0, Rf_mkCharCE(schema->name, CE_UTF8)); SET_VECTOR_ELT(result, 1, name_sexp); UNPROTECT(1); } else { SET_VECTOR_ELT(result, 1, R_NilValue); } SET_VECTOR_ELT(result, 2, schema_metadata_to_list(schema->metadata)); SET_VECTOR_ELT(result, 3, Rf_ScalarInteger((int)schema->flags)); if (schema->n_children > 0) { SEXP children_sexp = PROTECT(Rf_allocVector(VECSXP, schema->n_children)); SEXP children_names_sexp = PROTECT(Rf_allocVector(STRSXP, schema->n_children)); for (R_xlen_t i = 0; i < schema->n_children; i++) { SEXP child_xptr = PROTECT(borrow_schema_xptr(schema->children[i], schema_xptr)); SET_VECTOR_ELT(children_sexp, i, child_xptr); if (schema->children[i]->name != NULL) { SET_STRING_ELT(children_names_sexp, i, Rf_mkCharCE(schema->children[i]->name, CE_UTF8)); } else { SET_STRING_ELT(children_names_sexp, i, Rf_mkCharCE("", CE_UTF8)); } UNPROTECT(1); } Rf_setAttrib(children_sexp, R_NamesSymbol, children_names_sexp); SET_VECTOR_ELT(result, 4, children_sexp); UNPROTECT(2); } else { SET_VECTOR_ELT(result, 4, Rf_allocVector(VECSXP, schema->n_children)); } if (schema->dictionary != NULL) { SEXP dictionary_xptr = PROTECT(borrow_schema_xptr(schema->dictionary, schema_xptr)); SET_VECTOR_ELT(result, 5, dictionary_xptr); UNPROTECT(1); } else { SET_VECTOR_ELT(result, 5, R_NilValue); } UNPROTECT(1); return result; } static SEXP mkStringView(struct ArrowStringView* view) { if (view->data == NULL) { return R_NilValue; } SEXP chr = PROTECT(Rf_mkCharLenCE(view->data, (int)view->size_bytes, CE_UTF8)); SEXP str = PROTECT(Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(str, 0, chr); UNPROTECT(2); return str; } SEXP nanoarrow_c_schema_parse(SEXP schema_xptr) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); struct ArrowSchemaView schema_view; struct ArrowError error; int status = ArrowSchemaViewInit(&schema_view, schema, &error); if (status != NANOARROW_OK) { Rf_error("ArrowSchemaViewInit(): %s", ArrowErrorMessage(&error)); } const char* names[] = { "type", "storage_type", "extension_name", "extension_metadata", "fixed_size", "decimal_bitwidth", "decimal_precision", "decimal_scale", "time_unit", "timezone", "union_type_ids", ""}; SEXP result = PROTECT(Rf_mkNamed(VECSXP, names)); SET_VECTOR_ELT(result, 0, Rf_mkString(ArrowTypeString((schema_view.type)))); SET_VECTOR_ELT(result, 1, Rf_mkString(ArrowTypeString((schema_view.storage_type)))); if (schema_view.extension_name.data != NULL) { SET_VECTOR_ELT(result, 2, mkStringView(&schema_view.extension_name)); } if (schema_view.extension_metadata.data != NULL) { SEXP metadata_sexp = PROTECT(Rf_allocVector(RAWSXP, schema_view.extension_metadata.size_bytes)); memcpy(RAW(metadata_sexp), schema_view.extension_metadata.data, schema_view.extension_metadata.size_bytes); SET_VECTOR_ELT(result, 3, metadata_sexp); UNPROTECT(1); } if (schema_view.type == NANOARROW_TYPE_FIXED_SIZE_LIST || schema_view.type == NANOARROW_TYPE_FIXED_SIZE_BINARY) { SET_VECTOR_ELT(result, 4, Rf_ScalarInteger(schema_view.fixed_size)); } if (schema_view.type == NANOARROW_TYPE_DECIMAL128 || schema_view.type == NANOARROW_TYPE_DECIMAL256) { SET_VECTOR_ELT(result, 5, Rf_ScalarInteger(schema_view.decimal_bitwidth)); SET_VECTOR_ELT(result, 6, Rf_ScalarInteger(schema_view.decimal_precision)); SET_VECTOR_ELT(result, 7, Rf_ScalarInteger(schema_view.decimal_scale)); } if (schema_view.type == NANOARROW_TYPE_TIME32 || schema_view.type == NANOARROW_TYPE_TIME64 || schema_view.type == NANOARROW_TYPE_TIMESTAMP || schema_view.type == NANOARROW_TYPE_DURATION) { SET_VECTOR_ELT(result, 8, Rf_mkString(ArrowTimeUnitString((schema_view.time_unit)))); } if (schema_view.type == NANOARROW_TYPE_TIMESTAMP) { SET_VECTOR_ELT(result, 9, Rf_mkString(schema_view.timezone)); } if (schema_view.type == NANOARROW_TYPE_DENSE_UNION || schema_view.type == NANOARROW_TYPE_SPARSE_UNION) { int8_t type_ids[128]; int num_type_ids = _ArrowParseUnionTypeIds(schema_view.union_type_ids, type_ids); if (num_type_ids == -1 || num_type_ids > 127) { Rf_error("Invalid type IDs in union type: '%s'", schema_view.union_type_ids); } SEXP union_type_ids = PROTECT(Rf_allocVector(INTSXP, num_type_ids)); for (int i = 0; i < num_type_ids; i++) { INTEGER(union_type_ids)[i] = type_ids[i]; } SET_VECTOR_ELT(result, 10, union_type_ids); UNPROTECT(1); } UNPROTECT(1); return result; } SEXP nanoarrow_c_schema_format(SEXP schema_xptr, SEXP recursive_sexp) { int recursive = LOGICAL(recursive_sexp)[0]; // Be extra safe here (errors during formatting are hard to work around) if (!Rf_inherits(schema_xptr, "nanoarrow_schema")) { return Rf_mkString("[invalid: schema is not a nanoarrow_schema]"); } if (TYPEOF(schema_xptr) != EXTPTRSXP) { return Rf_mkString("[invalid: schema is not an external pointer]"); } struct ArrowSchema* schema = (struct ArrowSchema*)R_ExternalPtrAddr(schema_xptr); int64_t size_needed = ArrowSchemaToString(schema, NULL, 0, recursive != 0); if (size_needed >= INT_MAX) { size_needed = INT_MAX - 1; } // Using an SEXP because Rf_mkCharLenCE could jump SEXP formatted_sexp = PROTECT(Rf_allocVector(RAWSXP, size_needed + 1)); ArrowSchemaToString(schema, (char*)RAW(formatted_sexp), size_needed + 1, recursive != 0); SEXP result_sexp = PROTECT(Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(result_sexp, 0, Rf_mkCharLenCE((char*)RAW(formatted_sexp), (int)size_needed, CE_UTF8)); UNPROTECT(2); return result_sexp; } SEXP nanoarrow_c_schema_set_format(SEXP schema_mut_xptr, SEXP format_sexp) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_mut_xptr); if (TYPEOF(format_sexp) != STRSXP || Rf_length(format_sexp) != 1) { Rf_error("schema$format must be character(1)"); } const char* format = Rf_translateCharUTF8(STRING_ELT(format_sexp, 0)); if (ArrowSchemaSetFormat(schema, format) != NANOARROW_OK) { Rf_error("Error setting schema$format"); } return R_NilValue; } SEXP nanoarrow_c_schema_set_name(SEXP schema_mut_xptr, SEXP name_sexp) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_mut_xptr); int result; if (name_sexp == R_NilValue) { result = ArrowSchemaSetName(schema, NULL); } else { if (TYPEOF(name_sexp) != STRSXP || Rf_length(name_sexp) != 1) { Rf_error("schema$name must be NULL or character(1)"); } const char* name = Rf_translateCharUTF8(STRING_ELT(name_sexp, 0)); result = ArrowSchemaSetName(schema, name); } if (result != NANOARROW_OK) { Rf_error("Error setting schema$name"); } return R_NilValue; } static void finalize_buffer_xptr(SEXP buffer_xptr) { struct ArrowBuffer* buffer = (struct ArrowBuffer*)R_ExternalPtrAddr(buffer_xptr); if (buffer != NULL) { ArrowBufferReset(buffer); ArrowFree(buffer); } } static SEXP buffer_owning_xptr(void) { struct ArrowBuffer* buffer = (struct ArrowBuffer*)ArrowMalloc(sizeof(struct ArrowBuffer)); if (buffer == NULL) { Rf_error("Failed to allocate ArrowBuffer"); } SEXP buffer_xptr = PROTECT(R_MakeExternalPtr(buffer, R_NilValue, R_NilValue)); R_RegisterCFinalizer(buffer_xptr, &finalize_buffer_xptr); UNPROTECT(1); return buffer_xptr; } SEXP nanoarrow_c_schema_set_metadata(SEXP schema_mut_xptr, SEXP metadata_sexp) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_mut_xptr); int result; if (Rf_xlength(metadata_sexp) == 0) { result = ArrowSchemaSetMetadata(schema, NULL); if (result != NANOARROW_OK) { Rf_error("Failed to set schema$metadata"); } return R_NilValue; } // We need this to ensure buffer gets cleaned up amongst the potential longjmp // possibilities below. SEXP buffer_xptr = PROTECT(buffer_owning_xptr()); struct ArrowBuffer* buffer = (struct ArrowBuffer*)R_ExternalPtrAddr(buffer_xptr); result = ArrowMetadataBuilderInit(buffer, NULL); if (result != NANOARROW_OK) { Rf_error("ArrowMetadataBuilderInit() failed"); } SEXP metadata_names = PROTECT(Rf_getAttrib(metadata_sexp, R_NamesSymbol)); if (metadata_names == R_NilValue) { Rf_error("schema$metadata must be named"); } struct ArrowStringView key; struct ArrowStringView value; for (R_xlen_t i = 0; i < Rf_xlength(metadata_sexp); i++) { SEXP name_sexp = STRING_ELT(metadata_names, i); if (name_sexp == NA_STRING) { Rf_error("schema$metadata[[%ld]] must be named", (long)i + 1); } const void* vmax = vmaxget(); key = ArrowCharView(Rf_translateCharUTF8(name_sexp)); if (key.size_bytes == 0) { Rf_error("schema$metadata[[%ld]] must be named", (long)i + 1); } SEXP value_sexp = VECTOR_ELT(metadata_sexp, i); if (TYPEOF(value_sexp) == STRSXP && Rf_xlength(value_sexp) == 1) { SEXP value_chr = STRING_ELT(value_sexp, 0); if (value_chr == NA_STRING) { Rf_error("schema$metadata[[%ld]] must not be NA_character_", (long)i + 1); } value = ArrowCharView(Rf_translateCharUTF8(value_chr)); } else if (TYPEOF(value_sexp) == RAWSXP) { value.data = (const char*)RAW(value_sexp); value.size_bytes = Rf_xlength(value_sexp); } else { Rf_error("schema$metadata[[%ld]] must be character(1) or raw()", (long)i + 1); } result = ArrowMetadataBuilderAppend(buffer, key, value); if (result != NANOARROW_OK) { Rf_error("ArrowMetadataBuilderAppend() failed"); } vmaxset(vmax); } UNPROTECT(1); result = ArrowSchemaSetMetadata(schema, (const char*)buffer->data); ArrowBufferReset(buffer); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaSetMetadata() failed"); } UNPROTECT(1); return R_NilValue; } SEXP nanoarrow_c_schema_set_flags(SEXP schema_mut_xptr, SEXP flags_sexp) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_mut_xptr); if (TYPEOF(flags_sexp) != INTSXP || Rf_length(flags_sexp) != 1) { Rf_error("schema$flags must be integer(1)"); } int flags = INTEGER(flags_sexp)[0]; schema->flags = flags; return R_NilValue; } static void release_all_children(struct ArrowSchema* schema) { for (int64_t i = 0; i < schema->n_children; i++) { if (schema->children[i]->release != NULL) { schema->children[i]->release(schema->children[i]); } } } static void free_all_children(struct ArrowSchema* schema) { for (int64_t i = 0; i < schema->n_children; i++) { if (schema->children[i] != NULL) { ArrowFree(schema->children[i]); schema->children[i] = NULL; } } if (schema->children != NULL) { ArrowFree(schema->children); schema->children = NULL; } schema->n_children = 0; } SEXP nanoarrow_c_schema_set_children(SEXP schema_mut_xptr, SEXP children_sexp) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_mut_xptr); release_all_children(schema); if (Rf_xlength(children_sexp) == 0) { free_all_children(schema); return R_NilValue; } int result; if (Rf_xlength(children_sexp) != schema->n_children) { free_all_children(schema); result = ArrowSchemaAllocateChildren(schema, Rf_xlength(children_sexp)); if (result != NANOARROW_OK) { Rf_error("Error allocating schema$children of size %ld", (long)Rf_xlength(children_sexp)); } } // Names come from names(children) so that we can do // names(schema$children)[3] <- "something else" or // schema$children[[3]] <- some_unrelated_schema. On the flip // side, this makes schema$children[[3]]$name <- "something else" // have no effect, which is possibly confusing. SEXP children_names = PROTECT(Rf_getAttrib(children_sexp, R_NamesSymbol)); for (int64_t i = 0; i < schema->n_children; i++) { struct ArrowSchema* child = nanoarrow_schema_from_xptr(VECTOR_ELT(children_sexp, i)); result = ArrowSchemaDeepCopy(child, schema->children[i]); if (result != NANOARROW_OK) { Rf_error("Error copying new_values$children[[%ld]]", (long)i); } if (children_names != R_NilValue) { SEXP name_sexp = STRING_ELT(children_names, i); if (name_sexp == NA_STRING) { result = ArrowSchemaSetName(schema->children[i], ""); } else { const void* vmax = vmaxget(); const char* name = Rf_translateCharUTF8(name_sexp); result = ArrowSchemaSetName(schema->children[i], name); vmaxset(vmax); } } else { result = ArrowSchemaSetName(schema->children[i], ""); } if (result != NANOARROW_OK) { Rf_error("Error copying new_values$children[[%ld]]$name", (long)i); } } UNPROTECT(1); return R_NilValue; } SEXP nanoarrow_c_schema_set_dictionary(SEXP schema_mut_xptr, SEXP dictionary_xptr) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_mut_xptr); // If there's already a dictionary, make sure we release it if (schema->dictionary != NULL) { if (schema->dictionary->release != NULL) { schema->dictionary->release(schema->dictionary); } } if (dictionary_xptr == R_NilValue) { if (schema->dictionary != NULL) { ArrowFree(schema->dictionary); schema->dictionary = NULL; } } else { int result; if (schema->dictionary == NULL) { result = ArrowSchemaAllocateDictionary(schema); if (result != NANOARROW_OK) { Rf_error("Error allocating schema$dictionary"); } } struct ArrowSchema* dictionary = nanoarrow_schema_from_xptr(dictionary_xptr); result = ArrowSchemaDeepCopy(dictionary, schema->dictionary); if (result != NANOARROW_OK) { Rf_error("Error copying schema$dictionary"); } } return R_NilValue; } nanoarrow/src/materialize_blob.h0000644000176200001440000000412114676554240016537 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_BLOB_H_INCLUDED #define R_MATERIALIZE_BLOB_H_INCLUDED #include #include #include "materialize_common.h" #include "nanoarrow.h" static inline int nanoarrow_materialize_blob(struct ArrayViewSlice* src, struct VectorSlice* dst, struct MaterializeOptions* options) { switch (src->array_view->storage_type) { case NANOARROW_TYPE_NA: case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_BINARY: case NANOARROW_TYPE_LARGE_BINARY: case NANOARROW_TYPE_STRING_VIEW: case NANOARROW_TYPE_BINARY_VIEW: break; default: return ENOTSUP; } if (src->array_view->storage_type == NANOARROW_TYPE_NA) { return NANOARROW_OK; } struct ArrowBufferView item; SEXP item_sexp; for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowArrayViewIsNull(src->array_view, src->offset + i)) { item = ArrowArrayViewGetBytesUnsafe(src->array_view, src->offset + i); item_sexp = PROTECT(Rf_allocVector(RAWSXP, item.size_bytes)); memcpy(RAW(item_sexp), item.data.data, item.size_bytes); SET_VECTOR_ELT(dst->vec_sexp, dst->offset + i, item_sexp); UNPROTECT(1); } } return NANOARROW_OK; } #endif nanoarrow/src/materialize_chr.h0000644000176200001440000000555014676554240016404 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_CHR_H_INCLUDED #define R_MATERIALIZE_CHR_H_INCLUDED #include #include #include #include #include "materialize_common.h" #include "nanoarrow.h" static inline int nanoarrow_materialize_chr(struct RConverter* converter) { if (converter->src.array_view->array->dictionary != NULL) { return ENOTSUP; } struct ArrayViewSlice* src = &converter->src; struct VectorSlice* dst = &converter->dst; switch (src->array_view->storage_type) { case NANOARROW_TYPE_NA: for (R_xlen_t i = 0; i < dst->length; i++) { SET_STRING_ELT(dst->vec_sexp, dst->offset + i, NA_STRING); } return NANOARROW_OK; case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT64: { char buf[64]; for (R_xlen_t i = 0; i < dst->length; i++) { if (ArrowArrayViewIsNull(src->array_view, src->offset + i)) { SET_STRING_ELT(dst->vec_sexp, dst->offset + i, NA_STRING); } else { int n_chars = snprintf(buf, sizeof(buf), "%" PRId64, ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i)); SET_STRING_ELT(dst->vec_sexp, dst->offset + i, Rf_mkCharLenCE(buf, n_chars, CE_UTF8)); } } return NANOARROW_OK; } case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_STRING_VIEW: break; default: return ENOTSUP; } struct ArrowStringView item; for (R_xlen_t i = 0; i < dst->length; i++) { if (ArrowArrayViewIsNull(src->array_view, src->offset + i)) { SET_STRING_ELT(dst->vec_sexp, dst->offset + i, NA_STRING); } else { item = ArrowArrayViewGetStringUnsafe(src->array_view, src->offset + i); SET_STRING_ELT(dst->vec_sexp, dst->offset + i, Rf_mkCharLenCE(item.data, (int)item.size_bytes, CE_UTF8)); } } return NANOARROW_OK; } #endif nanoarrow/src/buffer.c0000644000176200001440000001562414677134124014505 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include #include "buffer.h" #include "nanoarrow.h" void finalize_buffer_xptr(SEXP buffer_xptr) { struct ArrowBuffer* buffer = (struct ArrowBuffer*)R_ExternalPtrAddr(buffer_xptr); if (buffer != NULL) { ArrowBufferReset(buffer); ArrowFree(buffer); } } void nanoarrow_sexp_deallocator(struct ArrowBufferAllocator* allocator, uint8_t* ptr, int64_t size) { nanoarrow_release_sexp((SEXP)allocator->private_data); } SEXP nanoarrow_c_as_buffer_default(SEXP x_sexp) { R_xlen_t len = Rf_xlength(x_sexp); const void* data = NULL; int64_t size_bytes = 0; int32_t element_size_bits = 0; enum ArrowType buffer_data_type = NANOARROW_TYPE_UNINITIALIZED; // For non-NA character(1), we use the first element if (TYPEOF(x_sexp) == STRSXP && len == 1) { return nanoarrow_c_as_buffer_default(STRING_ELT(x_sexp, 0)); } switch (TYPEOF(x_sexp)) { case NILSXP: data = NULL; break; case RAWSXP: case LGLSXP: case INTSXP: case REALSXP: case CPLXSXP: data = DATAPTR_RO(x_sexp); break; case CHARSXP: if (x_sexp != NA_STRING) { data = CHAR(x_sexp); break; } else { Rf_error("NA_character_ not supported in as_nanoarrow_buffer()"); } break; default: Rf_error("Unsupported type"); } switch (TYPEOF(x_sexp)) { case NILSXP: case RAWSXP: buffer_data_type = NANOARROW_TYPE_BINARY; size_bytes = len; element_size_bits = 8; break; case LGLSXP: case INTSXP: buffer_data_type = NANOARROW_TYPE_INT32; size_bytes = len * sizeof(int); element_size_bits = 8 * sizeof(int); break; case REALSXP: buffer_data_type = NANOARROW_TYPE_DOUBLE; size_bytes = len * sizeof(double); element_size_bits = 8 * sizeof(double); break; case CPLXSXP: buffer_data_type = NANOARROW_TYPE_DOUBLE; size_bytes = len * 2 * sizeof(double); element_size_bits = 8 * sizeof(double); break; case CHARSXP: buffer_data_type = NANOARROW_TYPE_STRING; size_bytes = Rf_xlength(x_sexp); element_size_bits = 8; break; default: break; } // Don't bother borrowing a zero-size buffer SEXP buffer_xptr; if (size_bytes == 0) { buffer_xptr = PROTECT(buffer_owning_xptr()); } else { buffer_xptr = PROTECT(buffer_borrowed_xptr(data, size_bytes, x_sexp)); } buffer_borrowed_xptr_set_type(buffer_xptr, NANOARROW_BUFFER_TYPE_DATA, buffer_data_type, element_size_bits); UNPROTECT(1); return buffer_xptr; } SEXP nanoarrow_c_buffer_append(SEXP buffer_xptr, SEXP new_buffer_xptr) { struct ArrowBuffer* buffer = buffer_from_xptr(buffer_xptr); struct ArrowBuffer* new_buffer = buffer_from_xptr(new_buffer_xptr); int result = ArrowBufferAppend(buffer, new_buffer->data, new_buffer->size_bytes); if (result != NANOARROW_OK) { Rf_error("ArrowBufferAppend() failed"); } return R_NilValue; } SEXP nanoarrow_c_buffer_info(SEXP buffer_xptr) { struct ArrowBuffer* buffer = buffer_from_xptr(buffer_xptr); SEXP buffer_types_sexp = R_ExternalPtrTag(buffer_xptr); SEXP buffer_type_sexp; SEXP buffer_data_type_sexp; int32_t element_size_bits; if (buffer_types_sexp == R_NilValue) { buffer_type_sexp = PROTECT(Rf_mkString("unknown")); buffer_data_type_sexp = PROTECT(Rf_mkString("unknown")); element_size_bits = 0; } else { enum ArrowBufferType buffer_type = INTEGER(buffer_types_sexp)[0]; const char* buffer_type_string; switch (buffer_type) { case NANOARROW_BUFFER_TYPE_VALIDITY: buffer_type_string = "validity"; break; case NANOARROW_BUFFER_TYPE_DATA_OFFSET: buffer_type_string = "data_offset"; break; case NANOARROW_BUFFER_TYPE_DATA: buffer_type_string = "data"; break; case NANOARROW_BUFFER_TYPE_TYPE_ID: buffer_type_string = "type_id"; break; case NANOARROW_BUFFER_TYPE_UNION_OFFSET: buffer_type_string = "union_offset"; break; case NANOARROW_BUFFER_TYPE_VARIADIC_DATA: buffer_type_string = "variadic_data"; break; case NANOARROW_BUFFER_TYPE_VARIADIC_SIZE: buffer_type_string = "variadic_size"; break; default: buffer_type_string = "unknown"; break; } enum ArrowType buffer_data_type = INTEGER(buffer_types_sexp)[1]; const char* buffer_data_type_string = ArrowTypeString(buffer_data_type); buffer_type_sexp = PROTECT(Rf_mkString(buffer_type_string)); buffer_data_type_sexp = PROTECT(Rf_mkString(buffer_data_type_string)); element_size_bits = INTEGER(buffer_types_sexp)[2]; } const char* names[] = {"data", "size_bytes", "capacity_bytes", "type", "data_type", "element_size_bits", ""}; SEXP info = PROTECT(Rf_mkNamed(VECSXP, names)); SET_VECTOR_ELT(info, 0, R_MakeExternalPtr(buffer->data, NULL, buffer_xptr)); SET_VECTOR_ELT(info, 1, Rf_ScalarReal((double)buffer->size_bytes)); SET_VECTOR_ELT(info, 2, Rf_ScalarReal((double)buffer->capacity_bytes)); SET_VECTOR_ELT(info, 3, buffer_type_sexp); SET_VECTOR_ELT(info, 4, buffer_data_type_sexp); SET_VECTOR_ELT(info, 5, Rf_ScalarInteger(element_size_bits)); UNPROTECT(3); return info; } SEXP nanoarrow_c_buffer_head_bytes(SEXP buffer_xptr, SEXP max_bytes_sexp) { struct ArrowBuffer* buffer = buffer_from_xptr(buffer_xptr); int64_t max_bytes = (int64_t)REAL(max_bytes_sexp)[0]; if (buffer->size_bytes <= max_bytes) { return buffer_xptr; } SEXP buffer_clone_xptr = PROTECT(buffer_borrowed_xptr(buffer->data, max_bytes, buffer_xptr)); R_SetExternalPtrTag(buffer_clone_xptr, Rf_duplicate(R_ExternalPtrTag(buffer_xptr))); UNPROTECT(1); return buffer_clone_xptr; } SEXP nanoarrow_c_buffer_as_raw(SEXP buffer_xptr) { struct ArrowBuffer* buffer = buffer_from_xptr(buffer_xptr); SEXP result = PROTECT(Rf_allocVector(RAWSXP, buffer->size_bytes)); if (buffer->size_bytes > 0) { memcpy(RAW(result), buffer->data, buffer->size_bytes); } UNPROTECT(1); return result; } nanoarrow/src/as_array.c0000644000176200001440000004165514701301265015026 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include #include "array.h" #include "buffer.h" #include "materialize.h" #include "nanoarrow.h" #include "schema.h" #include "util.h" static void call_as_nanoarrow_array(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, const char* fun_name) { SEXP fun = PROTECT(Rf_install(fun_name)); SEXP call = PROTECT(Rf_lang3(fun, x_sexp, schema_xptr)); SEXP result = PROTECT(Rf_eval(call, nanoarrow_ns_pkg)); // In many cases we can skip the array_export() step (which adds some complexity // and an additional R object to the mix) if (Rf_inherits(result, "nanoarrow_array_dont_export")) { struct ArrowArray* array_result = nanoarrow_array_from_xptr(result); ArrowArrayMove(array_result, array); } else { array_export(result, array); } UNPROTECT(3); } static void as_array_int(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowSchemaView* schema_view, struct ArrowError* error) { // Only consider the default create for now if (schema_view->type != NANOARROW_TYPE_INT32) { call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } // We don't consider altrep for now: we need an array of int32_t, and while we // *could* avoid materializing, there's no point because the source altrep // object almost certainly knows how to do this faster than we do. int* x_data = INTEGER(x_sexp); int64_t len = Rf_xlength(x_sexp); int result = ArrowArrayInitFromType(array, NANOARROW_TYPE_INT32); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromType() failed"); } // Borrow the data buffer buffer_borrowed(ArrowArrayBuffer(array, 1), x_data, len * sizeof(int32_t), x_sexp); // Set the array fields array->length = len; array->offset = 0; int64_t null_count = 0; // Look for the first null (will be the last index if there are none) int64_t first_null = -1; for (int64_t i = 0; i < len; i++) { if (x_data[i] == NA_INTEGER) { first_null = i; break; } } // If there are nulls, pack the validity buffer if (first_null != -1) { struct ArrowBitmap bitmap; ArrowBitmapInit(&bitmap); result = ArrowBitmapReserve(&bitmap, len); if (result != NANOARROW_OK) { Rf_error("ArrowBitmapReserve() failed"); } ArrowBitmapAppendUnsafe(&bitmap, 1, first_null); for (int64_t i = first_null; i < len; i++) { uint8_t is_valid = x_data[i] != NA_INTEGER; null_count += !is_valid; ArrowBitmapAppendUnsafe(&bitmap, is_valid, 1); } ArrowArraySetValidityBitmap(array, &bitmap); } array->null_count = null_count; result = ArrowArrayFinishBuildingDefault(array, error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayFinishBuildingDefault(): %s", error->message); } } static void as_array_lgl(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowSchemaView* schema_view, struct ArrowError* error) { // We can zero-copy convert to int32 if (schema_view->type == NANOARROW_TYPE_INT32) { as_array_int(x_sexp, array, schema_xptr, schema_view, error); return; } // Only consider bool for now if (schema_view->type != NANOARROW_TYPE_BOOL) { call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } int* x_data = INTEGER(x_sexp); int64_t len = Rf_xlength(x_sexp); int result = ArrowArrayInitFromType(array, NANOARROW_TYPE_BOOL); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromType() failed"); } struct ArrowBitmap value_bitmap; ArrowBitmapInit(&value_bitmap); result = ArrowBitmapReserve(&value_bitmap, len); if (result != NANOARROW_OK) { Rf_error("ArrowBitmapReserve() failed"); } int has_nulls = 0; for (int64_t i = 0; i < len; i++) { if (x_data[i] == NA_INTEGER) { has_nulls = 1; ArrowBitmapAppendUnsafe(&value_bitmap, 0, 1); } else { ArrowBitmapAppendUnsafe(&value_bitmap, x_data[i] != 0, 1); } } result = ArrowArraySetBuffer(array, 1, &value_bitmap.buffer); if (result != NANOARROW_OK) { Rf_error("ArrowArraySetBuffer() failed"); } // Set the array fields array->length = len; array->offset = 0; int64_t null_count = 0; // If there are nulls, pack the validity buffer if (has_nulls) { struct ArrowBitmap bitmap; ArrowBitmapInit(&bitmap); result = ArrowBitmapReserve(&bitmap, len); if (result != NANOARROW_OK) { Rf_error("ArrowBitmapReserve() failed"); } for (int64_t i = 0; i < len; i++) { uint8_t is_valid = x_data[i] != NA_INTEGER; null_count += !is_valid; ArrowBitmapAppendUnsafe(&bitmap, is_valid, 1); } ArrowArraySetValidityBitmap(array, &bitmap); } array->null_count = null_count; result = ArrowArrayFinishBuildingDefault(array, error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayFinishBuildingDefault(): %s", error->message); } } static void as_array_dbl(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowSchemaView* schema_view, struct ArrowError* error) { // Consider double -> na_double() and double -> na_int64()/na_int32() // (mostly so that we can support date/time types with various units) switch (schema_view->type) { case NANOARROW_TYPE_DOUBLE: case NANOARROW_TYPE_FLOAT: case NANOARROW_TYPE_HALF_FLOAT: case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_INT32: break; default: call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } double* x_data = REAL(x_sexp); int64_t len = Rf_xlength(x_sexp); int result = ArrowArrayInitFromType(array, schema_view->type); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromType() failed"); } if (schema_view->type == NANOARROW_TYPE_DOUBLE) { // Just borrow the data buffer (zero-copy) buffer_borrowed(ArrowArrayBuffer(array, 1), x_data, len * sizeof(double), x_sexp); } else if (schema_view->type == NANOARROW_TYPE_INT64) { // double -> int64_t struct ArrowBuffer* buffer = ArrowArrayBuffer(array, 1); result = ArrowBufferReserve(buffer, len * sizeof(int64_t)); if (result != NANOARROW_OK) { Rf_error("ArrowBufferReserve() failed"); } int64_t* buffer_data = (int64_t*)buffer->data; for (int64_t i = 0; i < len; i++) { // UBSAN warns for buffer_data[i] = nan if (R_IsNA(x_data[i]) || R_IsNaN(x_data[i])) { buffer_data[i] = 0; } else { buffer_data[i] = (int64_t)x_data[i]; } } buffer->size_bytes = len * sizeof(int64_t); } else if (schema_view->type == NANOARROW_TYPE_INT32) { // double -> int32_t struct ArrowBuffer* buffer = ArrowArrayBuffer(array, 1); result = ArrowBufferReserve(buffer, len * sizeof(int32_t)); if (result != NANOARROW_OK) { Rf_error("ArrowBufferReserve() failed"); } int32_t* buffer_data = (int32_t*)buffer->data; // It's easy to accidentally overflow here, so make sure to warn int64_t n_overflow = 0; for (int64_t i = 0; i < len; i++) { // UBSAN warns for buffer_data[i] = nan if (R_IsNA(x_data[i]) || R_IsNaN(x_data[i])) { buffer_data[i] = 0; } else if (x_data[i] > INT_MAX || x_data[i] < INT_MIN) { n_overflow++; buffer_data[i] = 0; } else { buffer_data[i] = (int32_t)x_data[i]; } } if (n_overflow > 0) { warn_lossy_conversion(n_overflow, "overflowed in double -> na_int32() creation"); } buffer->size_bytes = len * sizeof(int32_t); } else { result = ArrowArrayStartAppending(array); if (result != NANOARROW_OK) { Rf_error("ArrowArrayStartAppending() failed"); } result = ArrowArrayReserve(array, len); if (result != NANOARROW_OK) { Rf_error("ArrowArrayReserve() failed"); } for (int64_t i = 0; i < len; i++) { result = ArrowArrayAppendDouble(array, x_data[i]); if (result != NANOARROW_OK) { Rf_error("ArrowArrayAppendDouble() failed"); } } } // Set the array fields array->length = len; array->offset = 0; int64_t null_count = 0; // Look for the first null (will be the last index if there are none) int64_t first_null = -1; for (int64_t i = 0; i < len; i++) { if (R_IsNA(x_data[i]) || R_IsNaN(x_data[i])) { first_null = i; break; } } // If there are nulls, pack the validity buffer if (first_null != -1) { struct ArrowBitmap bitmap; ArrowBitmapInit(&bitmap); result = ArrowBitmapReserve(&bitmap, len); if (result != NANOARROW_OK) { Rf_error("ArrowBitmapReserve() failed"); } ArrowBitmapAppendUnsafe(&bitmap, 1, first_null); for (int64_t i = first_null; i < len; i++) { uint8_t is_valid = !R_IsNA(x_data[i]) && !R_IsNaN(x_data[i]); null_count += !is_valid; ArrowBitmapAppendUnsafe(&bitmap, is_valid, 1); } ArrowArraySetValidityBitmap(array, &bitmap); } array->null_count = null_count; result = ArrowArrayFinishBuildingDefault(array, error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayFinishBuildingDefault(): %s", error->message); } } static void as_array_chr(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowSchemaView* schema_view, struct ArrowError* error) { switch (schema_view->type) { case NANOARROW_TYPE_BINARY: case NANOARROW_TYPE_STRING: case NANOARROW_TYPE_LARGE_STRING: case NANOARROW_TYPE_LARGE_BINARY: case NANOARROW_TYPE_STRING_VIEW: case NANOARROW_TYPE_BINARY_VIEW: break; default: call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } int64_t len = Rf_xlength(x_sexp); int result = ArrowArrayInitFromType(array, schema_view->type); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromType() failed"); } result = ArrowArrayStartAppending(array); if (result != NANOARROW_OK) { Rf_error("ArrowArrayStartAppending() failed"); } struct ArrowStringView item_view; for (int64_t i = 0; i < len; i++) { SEXP item = STRING_ELT(x_sexp, i); if (item == NA_STRING) { result = ArrowArrayAppendNull(array, 1); if (result != NANOARROW_OK) { Rf_error("ArrowArrayAppendString() failed"); } } else { const void* vmax = vmaxget(); item_view.data = Rf_translateCharUTF8(item); item_view.size_bytes = strlen(item_view.data); result = ArrowArrayAppendString(array, item_view); if (result != NANOARROW_OK) { Rf_error("ArrowArrayAppendString() failed"); } vmaxset(vmax); } } result = ArrowArrayFinishBuildingDefault(array, error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayFinishBuildingDefault() failed with code %d: %s", result, error->message); } } static void as_array_default(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowError* error); static void as_array_data_frame(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowSchemaView* schema_view, struct ArrowError* error) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); switch (schema_view->type) { case NANOARROW_TYPE_SPARSE_UNION: case NANOARROW_TYPE_DENSE_UNION: call_as_nanoarrow_array(x_sexp, array, schema_xptr, "union_array_from_data_frame"); return; case NANOARROW_TYPE_STRUCT: break; default: call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } if (Rf_xlength(x_sexp) != schema->n_children) { Rf_error("Expected %ld schema children but found %ld", (long)Rf_xlength(x_sexp), (long)schema->n_children); } int result = ArrowArrayInitFromType(array, NANOARROW_TYPE_STRUCT); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromType() failed"); } result = ArrowArrayAllocateChildren(array, schema->n_children); if (result != NANOARROW_OK) { Rf_error("ArrowArrayAllocateChildren() failed"); } for (int64_t i = 0; i < schema->n_children; i++) { SEXP child_xptr = PROTECT(borrow_schema_child_xptr(schema_xptr, i)); as_array_default(VECTOR_ELT(x_sexp, i), array->children[i], child_xptr, error); UNPROTECT(1); } array->length = nanoarrow_data_frame_size(x_sexp); array->null_count = 0; array->offset = 0; } static void as_array_list(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowSchemaView* schema_view, struct ArrowError* error) { switch (schema_view->type) { case NANOARROW_TYPE_BINARY: case NANOARROW_TYPE_LARGE_BINARY: case NANOARROW_TYPE_FIXED_SIZE_BINARY: case NANOARROW_TYPE_BINARY_VIEW: break; default: call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } int64_t len = Rf_xlength(x_sexp); // Use schema here to ensure we fixed-size binary byte width works struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); int result = ArrowArrayInitFromSchema(array, schema, error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayInitFromType() failed: %s", error->message); } result = ArrowArrayStartAppending(array); if (result != NANOARROW_OK) { Rf_error("ArrowArrayStartAppending() failed"); } struct ArrowBufferView item_view; for (int64_t i = 0; i < len; i++) { SEXP item = VECTOR_ELT(x_sexp, i); if (item == R_NilValue) { result = ArrowArrayAppendNull(array, 1); if (result != NANOARROW_OK) { Rf_error("ArrowArrayAppendNull() failed"); } } else if (TYPEOF(item) == RAWSXP) { item_view.data.data = RAW(item); item_view.size_bytes = Rf_xlength(item); result = ArrowArrayAppendBytes(array, item_view); if (result != NANOARROW_OK) { Rf_error("ArrowArrayAppendBytes() failed"); } } else { Rf_error("All list items must be raw() or NULL in conversion to %s", ArrowTypeString(schema_view->type)); } } result = ArrowArrayFinishBuildingDefault(array, error); if (result != NANOARROW_OK) { Rf_error("ArrowArrayFinishBuildingDefault() failed with code %d: %s", result, error->message); } } static void as_array_default(SEXP x_sexp, struct ArrowArray* array, SEXP schema_xptr, struct ArrowError* error) { struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); struct ArrowSchemaView schema_view; int result = ArrowSchemaViewInit(&schema_view, schema, error); if (result != NANOARROW_OK) { Rf_error("ArrowSchemaViewInit(): %s", error->message); } // Ensure that extension types dispatch from R regardless of source if (schema_view.extension_name.size_bytes > 0) { call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } if (Rf_isObject(x_sexp)) { if (Rf_inherits(x_sexp, "data.frame")) { as_array_data_frame(x_sexp, array, schema_xptr, &schema_view, error); return; } else { call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } } switch (TYPEOF(x_sexp)) { case LGLSXP: as_array_lgl(x_sexp, array, schema_xptr, &schema_view, error); return; case INTSXP: as_array_int(x_sexp, array, schema_xptr, &schema_view, error); return; case REALSXP: as_array_dbl(x_sexp, array, schema_xptr, &schema_view, error); return; case STRSXP: as_array_chr(x_sexp, array, schema_xptr, &schema_view, error); return; case VECSXP: as_array_list(x_sexp, array, schema_xptr, &schema_view, error); return; default: call_as_nanoarrow_array(x_sexp, array, schema_xptr, "as_nanoarrow_array_from_c"); return; } } SEXP nanoarrow_c_as_array_default(SEXP x_sexp, SEXP schema_xptr) { SEXP array_xptr = PROTECT(nanoarrow_array_owning_xptr()); struct ArrowArray* array = nanoarrow_output_array_from_xptr(array_xptr); struct ArrowError error; as_array_default(x_sexp, array, schema_xptr, &error); array_xptr_set_schema(array_xptr, schema_xptr); UNPROTECT(1); return array_xptr; } nanoarrow/src/array_view.c0000644000176200001440000000446014547575511015405 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" #include "array.h" #include "schema.h" #include "util.h" static void finalize_array_view_xptr(SEXP array_view_xptr) { struct ArrowArrayView* array_view = (struct ArrowArrayView*)R_ExternalPtrAddr(array_view_xptr); if (array_view != NULL) { ArrowArrayViewReset(array_view); ArrowFree(array_view); } } SEXP nanoarrow_c_array_view(SEXP array_xptr, SEXP schema_xptr) { struct ArrowArray* array = nanoarrow_array_from_xptr(array_xptr); struct ArrowSchema* schema = nanoarrow_schema_from_xptr(schema_xptr); struct ArrowError error; ArrowErrorInit(&error); struct ArrowArrayView* array_view = (struct ArrowArrayView*)ArrowMalloc(sizeof(struct ArrowArrayView)); ArrowArrayViewInitFromType(array_view, NANOARROW_TYPE_UNINITIALIZED); SEXP xptr = PROTECT(R_MakeExternalPtr(array_view, R_NilValue, array_xptr)); R_RegisterCFinalizer(xptr, &finalize_array_view_xptr); int result = ArrowArrayViewInitFromSchema(array_view, schema, &error); if (result != NANOARROW_OK) { Rf_error(" %s", error.message); } result = ArrowArrayViewSetArray(array_view, array, &error); if (result != NANOARROW_OK) { Rf_error(" %s", error.message); } Rf_setAttrib(xptr, R_ClassSymbol, nanoarrow_cls_array_view); UNPROTECT(1); return xptr; } SEXP array_view_xptr_from_array_xptr(SEXP array_xptr) { return nanoarrow_c_array_view(array_xptr, R_ExternalPtrTag(array_xptr)); } nanoarrow/src/materialize_int.h0000644000176200001440000001145514547575511016424 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_INT_H_INCLUDED #define R_MATERIALIZE_INT_H_INCLUDED #include #include #include "materialize_common.h" #include "nanoarrow.h" static inline int nanoarrow_materialize_int(struct ArrayViewSlice* src, struct VectorSlice* dst, struct MaterializeOptions* options) { if (src->array_view->array->dictionary != NULL) { return ENOTSUP; } int* result = INTEGER(dst->vec_sexp); int64_t n_bad_values = 0; // True for all the types supported here const uint8_t* is_valid = src->array_view->buffer_views[0].data.as_uint8; int64_t raw_src_offset = src->array_view->array->offset + src->offset; // Fill the buffer switch (src->array_view->storage_type) { case NANOARROW_TYPE_NA: for (R_xlen_t i = 0; i < dst->length; i++) { result[dst->offset + i] = NA_INTEGER; } break; case NANOARROW_TYPE_INT32: memcpy(result + dst->offset, src->array_view->buffer_views[1].data.as_int32 + raw_src_offset, dst->length * sizeof(int32_t)); // Set any nulls to NA_INTEGER if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_INTEGER; } } } break; case NANOARROW_TYPE_BOOL: ArrowBitsUnpackInt32( src->array_view->buffer_views[1].data.as_uint8 + raw_src_offset, raw_src_offset, dst->length, result + dst->offset); // Set any nulls to NA_LOGICAL if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_LOGICAL; } } } break; case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT16: // No need to bounds check for these types for (R_xlen_t i = 0; i < dst->length; i++) { result[dst->offset + i] = (int32_t)ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i); } // Set any nulls to NA_INTEGER if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_INTEGER; } } } break; case NANOARROW_TYPE_UINT32: case NANOARROW_TYPE_INT64: case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_FLOAT: case NANOARROW_TYPE_DOUBLE: // Loop + bounds check. Because we don't know what memory might be // in a null slot, we have to check nulls if there are any. if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (ArrowBitGet(is_valid, raw_src_offset + i)) { int64_t value = ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i); if (value > INT_MAX || value <= NA_INTEGER) { result[dst->offset + i] = NA_INTEGER; n_bad_values++; } else { result[dst->offset + i] = (int32_t)value; } } else { result[dst->offset + i] = NA_INTEGER; } } } else { for (R_xlen_t i = 0; i < dst->length; i++) { int64_t value = ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i); if (value > INT_MAX || value <= NA_INTEGER) { result[dst->offset + i] = NA_INTEGER; n_bad_values++; } else { result[dst->offset + i] = (int32_t)value; } } } break; default: return EINVAL; } if (n_bad_values > 0) { warn_lossy_conversion(n_bad_values, "outside integer range set to NA"); } return NANOARROW_OK; } #endif nanoarrow/src/vctr.c0000644000176200001440000000646514672341746014222 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "nanoarrow.h" #include "nanoarrow/r.h" SEXP nanoarrow_c_vctr_chunk_offsets(SEXP array_list) { int num_chunks = Rf_length(array_list); SEXP offsets_sexp = PROTECT(Rf_allocVector(INTSXP, num_chunks + 1)); int* offsets = INTEGER(offsets_sexp); offsets[0] = 0; int64_t cumulative_offset = 0; struct ArrowArray* array; for (int i = 0; i < num_chunks; i++) { array = nanoarrow_array_from_xptr(VECTOR_ELT(array_list, i)); cumulative_offset += array->length; if (cumulative_offset > INT_MAX) { Rf_error("Can't build nanoarrow_vctr with length > INT_MAX"); // # nocov } offsets[i + 1] = cumulative_offset; } UNPROTECT(1); return offsets_sexp; } SEXP nanoarrow_c_vctr_chunk_resolve(SEXP indices_sexp, SEXP offsets_sexp) { int* offsets = INTEGER(offsets_sexp); int n_offsets = Rf_length(offsets_sexp); int last_offset = offsets[n_offsets - 1]; int n = Rf_length(indices_sexp); SEXP chunk_indices_sexp = PROTECT(Rf_allocVector(INTSXP, n)); int* chunk_indices = INTEGER(chunk_indices_sexp); int buf[1024]; for (int i = 0; i < n; i++) { if (i % 1024 == 0) { INTEGER_GET_REGION(indices_sexp, i, 1024, buf); } int index0 = buf[i % 1024]; if (index0 < 0 || index0 > last_offset) { chunk_indices[i] = NA_INTEGER; } else { chunk_indices[i] = ArrowResolveChunk32(index0, offsets, 0, n_offsets); } } UNPROTECT(1); return chunk_indices_sexp; } SEXP nanoarrow_c_vctr_as_slice(SEXP indices_sexp) { if (TYPEOF(indices_sexp) != INTSXP) { return R_NilValue; } SEXP slice_sexp = PROTECT(Rf_allocVector(INTSXP, 2)); int* slice = INTEGER(slice_sexp); int n = Rf_length(indices_sexp); slice[1] = n; if (n == 1) { slice[0] = INTEGER_ELT(indices_sexp, 0); UNPROTECT(1); return slice_sexp; } else if (n == 0) { slice[0] = NA_INTEGER; UNPROTECT(1); return slice_sexp; } // It may be possible to check for the R ALTREP sequence type, // which would eliminate the need for the below check for // sequential values. int buf[1024]; INTEGER_GET_REGION(indices_sexp, 0, 1024, buf); slice[0] = buf[0]; int last_value = buf[0]; int this_value = 0; for (int i = 1; i < n; i++) { if (i % 1024 == 0) { INTEGER_GET_REGION(indices_sexp, i, 1024, buf); } this_value = buf[i % 1024]; if ((this_value - last_value) != 1) { UNPROTECT(1); return R_NilValue; } last_value = this_value; } UNPROTECT(1); return slice_sexp; } nanoarrow/src/materialize_difftime.h0000644000176200001440000000520014355121773017402 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_DIFFTIME_H_INCLUDED #define R_MATERIALIZE_DIFFTIME_H_INCLUDED #include #include #include "materialize_common.h" #include "materialize_dbl.h" #include "nanoarrow.h" static inline int nanoarrow_materialize_difftime(struct RConverter* converter) { if (converter->ptype_view.sexp_type == REALSXP) { switch (converter->schema_view.type) { case NANOARROW_TYPE_NA: NANOARROW_RETURN_NOT_OK(nanoarrow_materialize_dbl(converter)); return NANOARROW_OK; case NANOARROW_TYPE_TIME32: case NANOARROW_TYPE_TIME64: case NANOARROW_TYPE_DURATION: NANOARROW_RETURN_NOT_OK(nanoarrow_materialize_dbl(converter)); break; default: return EINVAL; } double scale; switch (converter->ptype_view.r_time_units) { case R_TIME_UNIT_MINUTES: scale = 1.0 / 60; break; case R_TIME_UNIT_HOURS: scale = 1.0 / (60 * 60); break; case R_TIME_UNIT_DAYS: scale = 1.0 / (60 * 60 * 24); break; case R_TIME_UNIT_WEEKS: scale = 1.0 / (60 * 60 * 24 * 7); break; default: scale = 1.0; break; } switch (converter->schema_view.time_unit) { case NANOARROW_TIME_UNIT_SECOND: scale *= 1; break; case NANOARROW_TIME_UNIT_MILLI: scale *= 1e-3; break; case NANOARROW_TIME_UNIT_MICRO: scale *= 1e-6; break; case NANOARROW_TIME_UNIT_NANO: scale *= 1e-9; break; default: return EINVAL; } if (scale != 1) { double* result = REAL(converter->dst.vec_sexp); for (int64_t i = 0; i < converter->dst.length; i++) { result[converter->dst.offset + i] = result[converter->dst.offset + i] * scale; } } return NANOARROW_OK; } return EINVAL; } #endif nanoarrow/src/materialize_int64.h0000644000176200001440000001057514502402562016562 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_INT64_H_INCLUDED #define R_MATERIALIZE_INT64_H_INCLUDED #include #include #include "materialize_common.h" #include "nanoarrow.h" #define NA_INTEGER64 INT64_MIN static inline int nanoarrow_materialize_int64(struct ArrayViewSlice* src, struct VectorSlice* dst, struct MaterializeOptions* options) { if (src->array_view->array->dictionary != NULL) { return ENOTSUP; } int64_t* result = (int64_t*)REAL(dst->vec_sexp); int64_t n_bad_values = 0; // True for all the types supported here const uint8_t* is_valid = src->array_view->buffer_views[0].data.as_uint8; int64_t raw_src_offset = src->array_view->array->offset + src->offset; // Fill the buffer switch (src->array_view->storage_type) { case NANOARROW_TYPE_NA: for (R_xlen_t i = 0; i < dst->length; i++) { result[dst->offset + i] = NA_INTEGER64; } break; case NANOARROW_TYPE_INT64: memcpy(result + dst->offset, src->array_view->buffer_views[1].data.as_int32 + raw_src_offset, dst->length * sizeof(int64_t)); // Set any nulls to NA_INTEGER64 if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_INTEGER64; } } } break; case NANOARROW_TYPE_BOOL: case NANOARROW_TYPE_INT8: case NANOARROW_TYPE_UINT8: case NANOARROW_TYPE_INT16: case NANOARROW_TYPE_UINT16: case NANOARROW_TYPE_INT32: case NANOARROW_TYPE_UINT32: // No need to bounds check for these types for (R_xlen_t i = 0; i < dst->length; i++) { result[dst->offset + i] = ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i); } // Set any nulls to NA_INTEGER if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (!ArrowBitGet(is_valid, raw_src_offset + i)) { result[dst->offset + i] = NA_INTEGER64; } } } break; case NANOARROW_TYPE_UINT64: case NANOARROW_TYPE_FLOAT: case NANOARROW_TYPE_DOUBLE: // Loop + bounds check. Because we don't know what memory might be // in a null slot, we have to check nulls if there are any. if (is_valid != NULL && src->array_view->array->null_count != 0) { for (R_xlen_t i = 0; i < dst->length; i++) { if (ArrowBitGet(is_valid, raw_src_offset + i)) { int64_t value = ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i); if (value > INT64_MAX || value <= NA_INTEGER64) { result[dst->offset + i] = NA_INTEGER64; n_bad_values++; } else { result[dst->offset + i] = value; } } else { result[dst->offset + i] = NA_INTEGER64; } } } else { for (R_xlen_t i = 0; i < dst->length; i++) { int64_t value = ArrowArrayViewGetIntUnsafe(src->array_view, src->offset + i); if (value > INT64_MAX || value <= NA_INTEGER64) { result[dst->offset + i] = NA_INTEGER64; n_bad_values++; } else { result[dst->offset + i] = value; } } } break; default: return EINVAL; } if (n_bad_values > 0) { warn_lossy_conversion(n_bad_values, "outside integer64 range set to NA"); } return NANOARROW_OK; } #endif nanoarrow/src/materialize_posixct.h0000644000176200001440000000462414355121773017315 0ustar liggesusers// 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. #ifndef R_MATERIALIZE_POSIXCT_H_INCLUDED #define R_MATERIALIZE_POSIXCT_H_INCLUDED #include #include #include "materialize_common.h" #include "materialize_dbl.h" #include "nanoarrow.h" static inline int nanoarrow_materialize_posixct(struct RConverter* converter) { if (converter->ptype_view.sexp_type == REALSXP) { enum ArrowTimeUnit time_unit; switch (converter->schema_view.type) { case NANOARROW_TYPE_NA: time_unit = NANOARROW_TIME_UNIT_SECOND; NANOARROW_RETURN_NOT_OK(nanoarrow_materialize_dbl(converter)); break; case NANOARROW_TYPE_DATE64: time_unit = NANOARROW_TIME_UNIT_MILLI; NANOARROW_RETURN_NOT_OK(nanoarrow_materialize_dbl(converter)); break; case NANOARROW_TYPE_TIMESTAMP: time_unit = converter->schema_view.time_unit; NANOARROW_RETURN_NOT_OK(nanoarrow_materialize_dbl(converter)); break; default: return EINVAL; } double scale; switch (time_unit) { case NANOARROW_TIME_UNIT_SECOND: scale = 1; break; case NANOARROW_TIME_UNIT_MILLI: scale = 1e-3; break; case NANOARROW_TIME_UNIT_MICRO: scale = 1e-6; break; case NANOARROW_TIME_UNIT_NANO: scale = 1e-9; break; default: return EINVAL; } if (scale != 1) { double* result = REAL(converter->dst.vec_sexp); for (int64_t i = 0; i < converter->dst.length; i++) { result[converter->dst.offset + i] = result[converter->dst.offset + i] * scale; } } return NANOARROW_OK; } return EINVAL; } #endif nanoarrow/src/array_stream.c0000644000176200001440000002075714635121021015712 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "array.h" #include "array_stream.h" #include "nanoarrow.h" #include "schema.h" #include "util.h" // Ideally user-supplied finalizers are written in such a way that they don't jump; // however if they do it is likely that memory will leak. Here, we use // R_tryCatchError to minimize the chances of that happening. static SEXP run_finalizer_wrapper(void* data) { SEXP finalizer_sym = PROTECT(Rf_install("array_stream_finalizer")); SEXP finalizer_call = PROTECT(Rf_lang1(finalizer_sym)); Rf_eval(finalizer_call, (SEXP)data); UNPROTECT(2); return R_NilValue; } static SEXP run_finalizer_error_handler(SEXP cond, void* hdata) { REprintf("Error evaluating user-supplied array stream finalizer"); return R_NilValue; } static void run_user_array_stream_finalizer(SEXP array_stream_xptr) { SEXP protected = PROTECT(R_ExternalPtrProtected(array_stream_xptr)); R_SetExternalPtrProtected(array_stream_xptr, R_NilValue); if (Rf_inherits(protected, "nanoarrow_array_stream_finalizer")) { R_tryCatchError(&run_finalizer_wrapper, protected, &run_finalizer_error_handler, NULL); } UNPROTECT(1); } SEXP nanoarrow_c_array_stream_get_schema(SEXP array_stream_xptr) { struct ArrowArrayStream* array_stream = nanoarrow_array_stream_from_xptr(array_stream_xptr); SEXP schema_xptr = PROTECT(nanoarrow_schema_owning_xptr()); struct ArrowSchema* schema = nanoarrow_output_schema_from_xptr(schema_xptr); int result = ArrowArrayStreamGetSchema(array_stream, schema, NULL); if (result != 0) { Rf_error("array_stream->get_schema(): [%d] %s", result, ArrowArrayStreamGetLastError(array_stream)); } UNPROTECT(1); return schema_xptr; } SEXP nanoarrow_c_array_stream_get_next(SEXP array_stream_xptr) { struct ArrowArrayStream* array_stream = nanoarrow_array_stream_from_xptr(array_stream_xptr); SEXP array_xptr = PROTECT(nanoarrow_array_owning_xptr()); struct ArrowArray* array = nanoarrow_output_array_from_xptr(array_xptr); int result = ArrowArrayStreamGetNext(array_stream, array, NULL); if (result != NANOARROW_OK) { Rf_error("array_stream->get_next(): [%d] %s", result, ArrowArrayStreamGetLastError(array_stream)); } UNPROTECT(1); return array_xptr; } SEXP nanoarrow_c_basic_array_stream(SEXP batches_sexp, SEXP schema_xptr, SEXP validate_sexp) { int validate = LOGICAL(validate_sexp)[0]; // Schema needs a copy here because ArrowBasicArrayStreamInit() takes ownership SEXP schema_copy_xptr = PROTECT(nanoarrow_schema_owning_xptr()); struct ArrowSchema* schema_copy = nanoarrow_output_schema_from_xptr(schema_copy_xptr); schema_export(schema_xptr, schema_copy); SEXP array_stream_xptr = PROTECT(nanoarrow_array_stream_owning_xptr()); struct ArrowArrayStream* array_stream = nanoarrow_output_array_stream_from_xptr(array_stream_xptr); int64_t n_arrays = Rf_xlength(batches_sexp); if (ArrowBasicArrayStreamInit(array_stream, schema_copy, n_arrays) != NANOARROW_OK) { Rf_error("Failed to initialize array stream"); } struct ArrowArray array; for (int64_t i = 0; i < n_arrays; i++) { array_export(VECTOR_ELT(batches_sexp, i), &array); ArrowBasicArrayStreamSetArray(array_stream, i, &array); } if (validate) { struct ArrowError error; if (ArrowBasicArrayStreamValidate(array_stream, &error) != NANOARROW_OK) { Rf_error("ArrowBasicArrayStreamValidate(): %s", ArrowErrorMessage(&error)); } } UNPROTECT(2); return array_stream_xptr; } SEXP nanoarrow_c_array_list_total_length(SEXP list_of_array_xptr) { int64_t total_length = 0; R_xlen_t num_chunks = Rf_xlength(list_of_array_xptr); for (R_xlen_t i = 0; i < num_chunks; i++) { struct ArrowArray* chunk = (struct ArrowArray*)R_ExternalPtrAddr(VECTOR_ELT(list_of_array_xptr, i)); total_length += chunk->length; } return length_sexp_from_int64(total_length); } // Implementation of an ArrowArrayStream that keeps a dependent object valid struct WrapperArrayStreamData { SEXP parent_array_stream_xptr; struct ArrowArrayStream* parent_array_stream; }; static void finalize_wrapper_array_stream(struct ArrowArrayStream* array_stream) { if (array_stream->private_data != NULL) { struct WrapperArrayStreamData* data = (struct WrapperArrayStreamData*)array_stream->private_data; // Run the parent array stream release callback data->parent_array_stream->release(data->parent_array_stream); // If safe to do so, attempt to do an eager evaluation of a release // callback that may have been registered. If it is not safe to do so, // garbage collection will run any finalizers that have been set // on the chain of environments leading up to the finalizer. if (nanoarrow_is_main_thread()) { run_user_array_stream_finalizer(data->parent_array_stream_xptr); } nanoarrow_release_sexp(data->parent_array_stream_xptr); ArrowFree(array_stream->private_data); } array_stream->release = NULL; } static const char* wrapper_array_stream_get_last_error( struct ArrowArrayStream* array_stream) { struct WrapperArrayStreamData* data = (struct WrapperArrayStreamData*)array_stream->private_data; return data->parent_array_stream->get_last_error(data->parent_array_stream); } static int wrapper_array_stream_get_schema(struct ArrowArrayStream* array_stream, struct ArrowSchema* out) { struct WrapperArrayStreamData* data = (struct WrapperArrayStreamData*)array_stream->private_data; return data->parent_array_stream->get_schema(data->parent_array_stream, out); } static int wrapper_array_stream_get_next(struct ArrowArrayStream* array_stream, struct ArrowArray* out) { struct WrapperArrayStreamData* data = (struct WrapperArrayStreamData*)array_stream->private_data; return data->parent_array_stream->get_next(data->parent_array_stream, out); } void array_stream_export(SEXP parent_array_stream_xptr, struct ArrowArrayStream* array_stream_copy) { struct ArrowArrayStream* parent_array_stream = nanoarrow_array_stream_from_xptr(parent_array_stream_xptr); // If there is no dependent object, don't bother with this wrapper SEXP dependent_sexp = R_ExternalPtrProtected(parent_array_stream_xptr); if (dependent_sexp == R_NilValue) { ArrowArrayStreamMove(parent_array_stream, array_stream_copy); return; } // Allocate a new external pointer for an array stream (for consistency: // we always move an array stream when exporting) SEXP parent_array_stream_xptr_new = PROTECT(nanoarrow_array_stream_owning_xptr()); struct ArrowArrayStream* parent_array_stream_new = (struct ArrowArrayStream*)R_ExternalPtrAddr(parent_array_stream_xptr_new); ArrowArrayStreamMove(parent_array_stream, parent_array_stream_new); R_SetExternalPtrProtected(parent_array_stream_xptr_new, dependent_sexp); array_stream_copy->private_data = NULL; array_stream_copy->get_last_error = &wrapper_array_stream_get_last_error; array_stream_copy->get_schema = &wrapper_array_stream_get_schema; array_stream_copy->get_next = &wrapper_array_stream_get_next; array_stream_copy->release = &finalize_wrapper_array_stream; struct WrapperArrayStreamData* data = (struct WrapperArrayStreamData*)ArrowMalloc(sizeof(struct WrapperArrayStreamData)); check_trivial_alloc(data, "struct WrapperArrayStreamData"); data->parent_array_stream_xptr = parent_array_stream_xptr_new; data->parent_array_stream = parent_array_stream_new; array_stream_copy->private_data = data; // Transfer responsibility for the stream_xptr to the C object nanoarrow_preserve_sexp(parent_array_stream_xptr_new); UNPROTECT(1); } nanoarrow/src/flatcc/0000755000176200001440000000000014702646313014311 5ustar liggesusersnanoarrow/src/flatcc/flatcc_endian.h0000644000176200001440000000763614702632113017241 0ustar liggesusers#ifndef FLATCC_ENDIAN_H #define FLATCC_ENDIAN_H #ifdef __cplusplus extern "C" { #endif /* * This file provides helper macros to define type-specific macros and * inline functions that convert between stored data and native data * indedpently of both native (host) endianness and protocol endianness * (i.e. the serialized endian format). * * To detect endianness correctly ensure one of the following is defined. * * __LITTLE_ENDIAN__ * __BIG_ENDIAN__ * FLATBUFFERS_LITTLEENDIAN=1 * FLATBUFFERS_LITTLEENDIAN=0 * * Note: the Clang compiler likely already does this, but other * compilers may have their own way, if at all. * * It is also necessary to include or a compatible * implementation in order to provide: * * le16toh, le32to, le64toh, be16toh, be32toh, be64toh, * htole16, htole32, htole64, htobe16, htobe32, htobe64. * * A simple way to ensure all of the above for most platforms is * to include the portable endian support file: * * #include "flatcc/portable/pendian.h" * * It is also necessary to include * * #include "flatcc/flatcc_types.h" * * or an equivalent file. This makes it possible to change the * endianness of the serialized data and the sizes of flatbuffer * specific types such as `uoffset_t`. * * Note: the mentioned include files are likely already included * by the file including this file, at least for the default * configuration. */ #ifndef UINT8_t #include #endif /* These are needed to simplify accessor macros and are not found in . */ #ifndef le8toh #define le8toh(n) (n) #endif #ifndef be8toh #define be8toh(n) (n) #endif #ifndef htole8 #define htole8(n) (n) #endif #ifndef htobe8 #define htobe8(n) (n) #endif #include "flatcc/flatcc_accessors.h" /* This is the binary encoding endianness, usually LE for flatbuffers. */ #if FLATBUFFERS_PROTOCOL_IS_LE #define flatbuffers_endian le #elif FLATBUFFERS_PROTOCOL_IS_BE #define flatbuffers_endian be #else #error "flatbuffers has no defined endiannesss" #endif __flatcc_define_basic_scalar_accessors(flatbuffers_, flatbuffers_endian) __flatcc_define_integer_accessors(flatbuffers_bool, flatbuffers_bool_t, FLATBUFFERS_BOOL_WIDTH, flatbuffers_endian) __flatcc_define_integer_accessors(flatbuffers_union_type, flatbuffers_union_type_t, FLATBUFFERS_UTYPE_WIDTH, flatbuffers_endian) __flatcc_define_integer_accessors(__flatbuffers_uoffset, flatbuffers_uoffset_t, FLATBUFFERS_UOFFSET_WIDTH, flatbuffers_endian) __flatcc_define_integer_accessors(__flatbuffers_soffset, flatbuffers_soffset_t, FLATBUFFERS_SOFFSET_WIDTH, flatbuffers_endian) __flatcc_define_integer_accessors(__flatbuffers_voffset, flatbuffers_voffset_t, FLATBUFFERS_VOFFSET_WIDTH, flatbuffers_endian) __flatcc_define_integer_accessors(__flatbuffers_utype, flatbuffers_utype_t, FLATBUFFERS_UTYPE_WIDTH, flatbuffers_endian) __flatcc_define_integer_accessors(__flatbuffers_thash, flatbuffers_thash_t, FLATBUFFERS_THASH_WIDTH, flatbuffers_endian) /* flatcc/portable/pendian.h sets LITTLE/BIG flags if possible, and always defines le16toh. */ #ifndef flatbuffers_is_native_pe #if defined(__LITTLE_ENDIAN__) || FLATBUFFERS_LITTLEENDIAN #undef FLATBUFFERS_LITTLEENDIAN #define FLATBUFFERS_LITTLEENDIAN 1 #define flatbuffers_is_native_pe() (FLATBUFFERS_PROTOCOL_IS_LE) #elif defined(__BIG_ENDIAN__) || (defined(FLATBUFFERS_LITTLEENDIAN) && !FLATBUFFERS_LITTLEENDIAN) #undef FLATBUFFERS_LITTLEENDIAN #define FLATBUFFERS_LITTLEENDIAN 0 #define flatbuffers_is_native_pe() (FLATBUFFERS_PROTOCOL_IS_BE) #else #define flatbuffers_is_native_pe() (__FLATBUFFERS_CONCAT(flatbuffers_endian, 16toh)(1) == 1) #endif #endif #ifndef flatbuffers_is_native_le #define flatbuffers_is_native_le() flatbuffers_is_native_pe() #endif #ifndef flatbuffers_is_native_be #define flatbuffers_is_native_be() (!flatbuffers_is_native_pe()) #endif #ifdef __cplusplus } #endif #endif /* FLATCC_ENDIAN_H */ nanoarrow/src/flatcc/flatcc_iov.h0000644000176200001440000000107714702632113016571 0ustar liggesusers#ifndef FLATCC_IOV_H #define FLATCC_IOV_H #ifdef __cplusplus extern "C" { #endif #include /* * The emitter receives one, or a few buffers at a time via * this type. compatible iovec structure used for * allocation and emitter interface. */ typedef struct flatcc_iovec flatcc_iovec_t; struct flatcc_iovec { void *iov_base; size_t iov_len; }; /* * The largest iovec vector the builder will issue. It will * always be a relatively small number. */ #define FLATCC_IOV_COUNT_MAX 8 #ifdef __cplusplus } #endif #endif /* FLATCC_IOV_H */ nanoarrow/src/flatcc/flatcc_emitter.h0000644000176200001440000001641514702632113017447 0ustar liggesusers#ifndef FLATCC_EMITTER_H #define FLATCC_EMITTER_H #ifdef __cplusplus extern "C" { #endif /* * Default implementation of a flatbuilder emitter. * * This may be used as a starting point for more advanced emitters, * for example writing completed pages to disk or network and * the recycling those pages. */ #include #include #include "flatcc/flatcc_types.h" #include "flatcc/flatcc_iov.h" #include "flatcc/flatcc_alloc.h" /* * The buffer steadily grows during emission but the design allows for * an extension where individual pages can recycled before the buffer * is complete, for example because they have been transmitted. * * When done, the buffer can be cleared to free all memory, or reset to * maintain an adaptive page pool for next buffer construction. * * Unlike an exponentially growing buffer, each buffer page remains * stable in memory until reset, clear or recycle is called. * * Design notes for possible extensions: * * The buffer is a ring buffer marked by a front and a back page. The * front and back may be the same page and may initially be absent. * Anything outside these pages are unallocated pages for recycling. * Any page between (but excluding) the front and back pages may be * recycled by unlinking and relinking outside the front and back pages * but then copy operations no longer makes sense. Each page stores the * logical offset within the buffer but isn't otherwise used by the * implemention - it might be used for network transmission. The buffer * is not explicitly designed for multithreaded access but any page * strictly between front and back is not touched unless recycled and in * this case aligned allocation is useful to prevent cache line sharing. */ /* * Memory is allocated in fixed length page units - the first page is * split between front and back so each get half the page size. If the * size is a multiple of 128 then each page offset will be a multiple of * 64, which may be useful for sequencing etc. */ #ifndef FLATCC_EMITTER_PAGE_SIZE #define FLATCC_EMITTER_MAX_PAGE_SIZE 3000 #define FLATCC_EMITTER_PAGE_MULTIPLE 64 #define FLATCC_EMITTER_PAGE_SIZE ((FLATCC_EMITTER_MAX_PAGE_SIZE) &\ ~(2 * (FLATCC_EMITTER_PAGE_MULTIPLE) - 1)) #endif #ifndef FLATCC_EMITTER_ALLOC #ifdef FLATCC_EMITTER_USE_ALIGNED_ALLOC /* * does not always provide aligned_alloc, so include whatever * is required when enabling this feature. */ #define FLATCC_EMITTER_ALLOC(n) aligned_alloc(FLATCC_EMITTER_PAGE_MULTIPLE,\ (((n) + FLATCC_EMITTER_PAGE_MULTIPLE - 1) & ~(FLATCC_EMITTER_PAGE_MULTIPLE - 1))) #ifndef FLATCC_EMITTER_FREE #define FLATCC_EMITTER_FREE(p) aligned_free(p) #endif #endif #endif #ifndef FLATCC_EMITTER_ALLOC #define FLATCC_EMITTER_ALLOC(n) FLATCC_ALLOC(n) #endif #ifndef FLATCC_EMITTER_FREE #define FLATCC_EMITTER_FREE(p) FLATCC_FREE(p) #endif typedef struct flatcc_emitter_page flatcc_emitter_page_t; typedef struct flatcc_emitter flatcc_emitter_t; struct flatcc_emitter_page { uint8_t page[FLATCC_EMITTER_PAGE_SIZE]; flatcc_emitter_page_t *next; flatcc_emitter_page_t *prev; /* * The offset is relative to page start, but not necessarily * to any present content if part of front or back page, * and undefined for unused pages. */ flatbuffers_soffset_t page_offset; }; /* * Must be allocated and zeroed externally, e.g. on the stack * then provided as emit_context to the flatbuilder along * with the `flatcc_emitter` function. */ struct flatcc_emitter { flatcc_emitter_page_t *front, *back; uint8_t *front_cursor; size_t front_left; uint8_t *back_cursor; size_t back_left; size_t used; size_t capacity; size_t used_average; }; /* Optional helper to ensure emitter is zeroed initially. */ static inline void flatcc_emitter_init(flatcc_emitter_t *E) { memset(E, 0, sizeof(*E)); } /* Deallocates all buffer memory making the emitter ready for next use. */ void flatcc_emitter_clear(flatcc_emitter_t *E); /* * Similar to `clear_flatcc_emitter` but heuristacally keeps some allocated * memory between uses while gradually reducing peak allocations. * For small buffers, a single page will remain available with no * additional allocations or deallocations after first use. */ void flatcc_emitter_reset(flatcc_emitter_t *E); /* * Helper function that allows a page between front and back to be * recycled while the buffer is still being constructed - most likely as part * of partial copy or transmission. Attempting to recycle front or back * pages will result in an error. Recycling pages outside the * front and back will be valid but pointless. After recycling and copy * operations are no longer well-defined and should be replaced with * whatever logic is recycling the pages. The reset operation * automatically recycles all (remaining) pages when emission is * complete. After recycling, the `flatcc_emitter_size` function will * return as if recycle was not called, but will only represent the * logical size, not the size of the active buffer. Because a recycled * page is fully utilized, it is fairly easy to compensate for this if * required. * * Returns 0 on success. */ int flatcc_emitter_recycle_page(flatcc_emitter_t *E, flatcc_emitter_page_t *p); /* * The amount of data copied with `flatcc_emitter_copy_buffer` and related * functions. Normally called at end of buffer construction but is * always valid, as is the copy functions. The size is a direct * function of the amount emitted data so the flatbuilder itself can * also provide this information. */ static inline size_t flatcc_emitter_get_buffer_size(flatcc_emitter_t *E) { return E->used; } /* * Returns buffer start iff the buffer fits on a single internal page. * Only useful for fairly small buffers - about half the page size since * one half of first page goes to vtables that likely use little space. * Returns null if request could not be served. * * If `size_out` is not null, it is set to the buffer size, or 0 if * operation failed. */ static inline void *flatcc_emitter_get_direct_buffer(flatcc_emitter_t *E, size_t *size_out) { if (E->front == E->back) { if (size_out) { *size_out = E->used; } return E->front_cursor; } if (size_out) { *size_out = 0; } return 0; } /* * Copies the internal flatcc_emitter representation to an externally * provided linear buffer that must have size `flatcc_emitter_get_size`. * * If pages have been recycled, only the remaining pages will be copied * and thus less data than what `flatcc_emitter_get_size` would suggest. It * makes more sense to provide a customized copy operation when * recycling pages. * * If the buffer is too small, nothing is copied, otherwise the * full buffer is copied and the input buffer is returned. */ void *flatcc_emitter_copy_buffer(flatcc_emitter_t *E, void *buf, size_t size); /* * The emitter interface function to the flatbuilder API. * `emit_context` should be of type `flatcc_emitter_t` for this * particular implementation. * * This function is compatible with the `flatbuilder_emit_fun` * type defined in "flatbuilder.h". */ int flatcc_emitter(void *emit_context, const flatcc_iovec_t *iov, int iov_count, flatbuffers_soffset_t offset, size_t len); #ifdef __cplusplus } #endif #endif /* FLATCC_EMITTER_H */ nanoarrow/src/flatcc/flatcc_alloc.h0000644000176200001440000000672314702632113017071 0ustar liggesusers#ifndef FLATCC_ALLOC_H #define FLATCC_ALLOC_H #ifdef __cplusplus extern "C" { #endif /* * These allocation abstractions are __only__ for runtime libraries. * * The flatcc compiler uses Posix allocation routines regardless * of how this file is configured. * * This header makes it possible to use systems where malloc is not * valid to use. In this case the portable library will not help * because it implements Posix / C11 abstractions. * * Systems like FreeRTOS do not work with Posix memory calls and here it * can be helpful to override runtime allocation primitives. * * In general, it is better to customize the allocator and emitter via * flatcc_builder_custom_init and to avoid using the default emitter * specific high level calls the copy out a buffer that must later be * deallocated. This provides full control of allocation withou the need * for this file. * * * IMPORTANT * * If you override malloc, free, etc., make sure your applications * use the same allocation methods. For example, samples/monster.c * and several test cases are no longer guaranteed to work out of the * box. * * The changes must only affect target runtime compilation including the * the runtime library libflatccrt. * * The host system flatcc compiler and the compiler library libflatcc * should NOT be compiled with non-Posix allocation since the compiler * has a dependency on the runtime library and the wrong free operation * might be callled. The safest way to avoid this problem this is to * compile flatcc with the CMake script and the runtime files with a * dedicated build system for the target system. */ #include #ifndef FLATCC_ALLOC #define FLATCC_ALLOC(n) malloc(n) #endif #ifndef FLATCC_FREE #define FLATCC_FREE(p) free(p) #endif #ifndef FLATCC_REALLOC #define FLATCC_REALLOC(p, n) realloc(p, n) #endif #ifndef FLATCC_CALLOC #define FLATCC_CALLOC(nm, n) calloc(nm, n) #endif /* * Implements `aligned_alloc` and `aligned_free`. * Even with C11, this implements non-standard aligned_free needed for portable * aligned_alloc implementations. */ #ifndef FLATCC_USE_GENERIC_ALIGNED_ALLOC #ifndef FLATCC_NO_PALIGNED_ALLOC #include "flatcc/portable/paligned_alloc.h" #else #if !defined(__aligned_free_is_defined) || !__aligned_free_is_defined #define aligned_free free #endif #endif #else /* FLATCC_USE_GENERIC_ALIGNED_ALLOC */ #ifndef FLATCC_ALIGNED_ALLOC static inline void *__flatcc_aligned_alloc(size_t alignment, size_t size) { char *raw; void *buf; size_t total_size = (size + alignment - 1 + sizeof(void *)); if (alignment < sizeof(void *)) { alignment = sizeof(void *); } raw = (char *)(size_t)FLATCC_ALLOC(total_size); if (!raw) return 0; buf = raw + alignment - 1 + sizeof(void *); buf = (void *)(((size_t)buf) & ~(alignment - 1)); ((void **)buf)[-1] = raw; return buf; } #define FLATCC_ALIGNED_ALLOC(alignment, size) __flatcc_aligned_alloc(alignment, size) #endif /* FLATCC_USE_GENERIC_ALIGNED_ALLOC */ #ifndef FLATCC_ALIGNED_FREE static inline void __flatcc_aligned_free(void *p) { char *raw; if (!p) return; raw = ((void **)p)[-1]; FLATCC_FREE(raw); } #define FLATCC_ALIGNED_FREE(p) __flatcc_aligned_free(p) #endif #endif /* FLATCC_USE_GENERIC_ALIGNED_ALLOC */ #ifndef FLATCC_ALIGNED_ALLOC #define FLATCC_ALIGNED_ALLOC(a, n) aligned_alloc(a, n) #endif #ifndef FLATCC_ALIGNED_FREE #define FLATCC_ALIGNED_FREE(p) aligned_free(p) #endif #ifdef __cplusplus } #endif #endif /* FLATCC_ALLOC_H */ nanoarrow/src/flatcc/flatcc_verifier.h0000644000176200001440000003011614702632113017603 0ustar liggesusers#ifndef FLATCC_VERIFIER_H #define FLATCC_VERIFIER_H #ifdef __cplusplus extern "C" { #endif /* * Runtime support for verifying flatbuffers. * * Link with the verifier implementation file. * * Note: * * 1) nested buffers will NOT have their identifier verified. * The user may do so subsequently. The reason is in part because * the information is not readily avaible without generated reader code, * in part because the buffer might use a different, but valid, * identifier and the user has no chance of specifiying this in the * verifier code. The root verifier also doesn't assume a specific id * but accepts a user supplied input which may be null. * * 2) All offsets in a buffer are verified for alignment relative to the * buffer start, but the buffer itself is only assumed to aligned to * uoffset_t. A reader should therefore ensure buffer alignment separately * before reading the buffer. Nested buffers are in fact checked for * alignment, but still only relative to the root buffer. * * 3) The max nesting level includes nested buffer nestings, so the * verifier might fail even if the individual buffers are otherwise ok. * This is to prevent abuse with lots of nested buffers. * * * IMPORTANT: * * Even if verifier passes, the buffer may be invalid to access due to * lack of alignemnt in memory, but the verifier is safe to call. * * NOTE: The buffer is not safe to modify after verification because an * attacker may craft overlapping data structures such that modification * of one field updates another in a way that violates the buffer * constraints. This may also be caused by a clever compression scheme. * * It is likely faster to rewrite the table although this is also * dangerous because an attacker (or even normal user) can draft a DAG * that explodes when expanded carelesslessly. A safer approach is to * hash all object references written and reuse those that match. This * will expand references into other objects while bounding expansion * and it will be safe to update assuming shared objects are ok to * update. * */ #include "flatcc/flatcc_types.h" #define FLATCC_VERIFY_ERROR_MAP(XX)\ XX(ok, "ok")\ XX(buffer_header_too_small, "buffer header too small")\ XX(identifier_mismatch, "identifier mismatch")\ XX(max_nesting_level_reached, "max nesting level reached")\ XX(required_field_missing, "required field missing")\ XX(runtime_buffer_header_not_aligned, "runtime: buffer header not aligned")\ XX(runtime_buffer_size_too_large, "runtime: buffer size too large")\ XX(string_not_zero_terminated, "string not zero terminated")\ XX(string_out_of_range, "string out of range")\ XX(struct_out_of_range, "struct out of range")\ XX(struct_size_overflow, "struct size overflow")\ XX(struct_unaligned, "struct unaligned")\ XX(table_field_not_aligned, "table field not aligned")\ XX(table_field_out_of_range, "table field out of range")\ XX(table_field_size_overflow, "table field size overflow")\ XX(table_header_out_of_range_or_unaligned, "table header out of range or unaligned")\ XX(vector_header_out_of_range_or_unaligned, "vector header out of range or unaligned")\ XX(string_header_out_of_range_or_unaligned, "string header out of range or unaligned")\ XX(offset_out_of_range, "offset out of range")\ XX(table_offset_out_of_range_or_unaligned, "table offset out of range or unaligned")\ XX(table_size_out_of_range, "table size out of range")\ XX(type_field_absent_from_required_union_field, "type field absent from required union field")\ XX(type_field_absent_from_required_union_vector_field, "type field absent from required union vector field")\ XX(union_cannot_have_a_table_without_a_type, "union cannot have a table without a type")\ XX(union_type_NONE_cannot_have_a_value, "union value field present with type NONE")\ XX(vector_count_exceeds_representable_vector_size, "vector count exceeds representable vector size")\ XX(vector_out_of_range, "vector out of range")\ XX(vtable_header_out_of_range, "vtable header out of range")\ XX(vtable_header_too_small, "vtable header too small")\ XX(vtable_offset_out_of_range_or_unaligned, "vtable offset out of range or unaligned")\ XX(vtable_size_out_of_range_or_unaligned, "vtable size out of range or unaligned")\ XX(vtable_size_overflow, "vtable size overflow")\ XX(union_element_absent_without_type_NONE, "union element absent without type NONE")\ XX(union_element_present_with_type_NONE, "union element present with type NONE")\ XX(union_vector_length_mismatch, "union type and table vectors have different lengths")\ XX(union_vector_verification_not_supported, "union vector verification not supported")\ XX(runtime_buffer_size_less_than_size_field, "runtime buffer size less than buffer headers size field")\ XX(not_supported, "not supported") enum flatcc_verify_error_no { #define XX(no, str) flatcc_verify_error_##no, FLATCC_VERIFY_ERROR_MAP(XX) #undef XX }; #define flatcc_verify_ok flatcc_verify_error_ok const char *flatcc_verify_error_string(int err); /* * Type specific table verifier function that checks each known field * for existence in the vtable and then calls the appropriate verifier * function in this library. * * The table descriptor values have been verified for bounds, overflow, * and alignment, but vtable entries after header must be verified * for all fields the table verifier function understands. * * Calls other typespecific verifier functions recursively whenever a * table field, union or table vector is encountered. */ typedef struct flatcc_table_verifier_descriptor flatcc_table_verifier_descriptor_t; struct flatcc_table_verifier_descriptor { /* Pointer to buffer. Not assumed to be aligned beyond uoffset_t. */ const void *buf; /* Buffer size. */ flatbuffers_uoffset_t end; /* Time to live: number nesting levels left before failure. */ int ttl; /* Vtable of current table. */ const void *vtable; /* Table offset relative to buffer start */ flatbuffers_uoffset_t table; /* Table end relative to buffer start as per vtable[1] field. */ flatbuffers_voffset_t tsize; /* Size of vtable in bytes. */ flatbuffers_voffset_t vsize; }; typedef int flatcc_table_verifier_f(flatcc_table_verifier_descriptor_t *td); typedef struct flatcc_union_verifier_descriptor flatcc_union_verifier_descriptor_t; struct flatcc_union_verifier_descriptor { /* Pointer to buffer. Not assumed to be aligned beyond uoffset_t. */ const void *buf; /* Buffer size. */ flatbuffers_uoffset_t end; /* Time to live: number nesting levels left before failure. */ int ttl; /* Type of union value to be verified */ flatbuffers_utype_t type; /* Offset relative to buffer start to where union value offset is stored. */ flatbuffers_uoffset_t base; /* Offset of union value relative to base. */ flatbuffers_uoffset_t offset; }; typedef int flatcc_union_verifier_f(flatcc_union_verifier_descriptor_t *ud); /* * The `as_root` functions are normally the only functions called * explicitly in this interface. * * If `fid` is null, the identifier is not checked and is allowed to be entirely absent. * * The buffer must at least be aligned to uoffset_t on systems that * require aligned memory addresses. The buffer pointers alignment is * not significant to internal verification of the buffer. * * The `_with_size` variant handles size prefixed buffers which aligns slighly differently * due to the size prefix, notably for buffers with alignment above the uoffset_t type. */ int flatcc_verify_struct_as_root(const void *buf, size_t bufsiz, const char *fid, size_t size, uint16_t align); int flatcc_verify_struct_as_root_with_size(const void *buf, size_t bufsiz, const char *fid, size_t size, uint16_t align); int flatcc_verify_struct_as_typed_root(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, size_t size, uint16_t align); int flatcc_verify_struct_as_typed_root_with_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, size_t size, uint16_t align); int flatcc_verify_table_as_root(const void *buf, size_t bufsiz, const char *fid, flatcc_table_verifier_f *root_tvf); int flatcc_verify_table_as_root_with_size(const void *buf, size_t bufsiz, const char *fid, flatcc_table_verifier_f *root_tvf); int flatcc_verify_table_as_typed_root(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, flatcc_table_verifier_f *root_tvf); int flatcc_verify_table_as_typed_root_with_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, flatcc_table_verifier_f *root_tvf); /* * The buffer header is verified by any of the `_as_root` verifiers, but * this function may be used as a quick sanity check. */ int flatcc_verify_buffer_header(const void *buf, size_t bufsiz, const char *fid); int flatcc_verify_typed_buffer_header(const void *buf, size_t bufsiz, flatbuffers_thash_t type_hash); /* * Verifies size prefixed buffer headers. The `bufsiz` argument is a pointer that will be updated * with the size stored in the buffer header iff it is no larger than the input argument, and * otherwise the verifer fails. The updated size field adds sizeof(flatbuffers_uoffset_t) to the size * to be compatible with bufsiz since the header size field does not include itself. */ int flatcc_verify_buffer_header_with_size(const void *buf, size_t *bufsiz, const char *fid); int flatcc_verify_typed_buffer_header_with_size(const void *buf, size_t *bufsiz, flatbuffers_thash_t type_hash); /* * The following functions are typically called by a generated table * verifier function. */ /* Scalar, enum or struct field. */ int flatcc_verify_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, size_t size, uint16_t align); /* Vector of scalars, enums or structs. */ int flatcc_verify_vector_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, size_t elem_size, uint16_t align, size_t max_count); int flatcc_verify_string_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required); int flatcc_verify_string_vector_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required); int flatcc_verify_table_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, flatcc_table_verifier_f tvf); int flatcc_verify_table_vector_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, flatcc_table_verifier_f tvf); /* Table verifiers pass 0 as fid. */ int flatcc_verify_struct_as_nested_root(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, const char *fid, size_t size, uint16_t align); int flatcc_verify_table_as_nested_root(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, const char *fid, uint16_t align, flatcc_table_verifier_f tvf); /* * A NONE type will not accept a table being present, and a required * union will not accept a type field being absent, and an absent type * field will not accept a table field being present. * * If the above checks out and the type is not NONE, the uvf callback * is executed. It must test each known table type and silently accept * any unknown table type for forward compatibility. A union table * value is verified without the required flag because an absent table * encodes a typed NULL value while an absent type field encodes a * missing union which fails if required. */ int flatcc_verify_union_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, flatcc_union_verifier_f uvf); int flatcc_verify_union_vector_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, flatcc_union_verifier_f uvf); int flatcc_verify_union_table(flatcc_union_verifier_descriptor_t *ud, flatcc_table_verifier_f *tvf); int flatcc_verify_union_struct(flatcc_union_verifier_descriptor_t *ud, size_t size, uint16_t align); int flatcc_verify_union_string(flatcc_union_verifier_descriptor_t *ud); #ifdef __cplusplus } #endif #endif /* FLATCC_VERIFIER_H */ nanoarrow/src/flatcc/flatcc_refmap.h0000644000176200001440000001133214702632113017241 0ustar liggesusers/* * The flatcc builder supports storing a pointer to a refmap * and wraps some operations to make them work as a dummy * even if no refmap has been set. This enables optional * DAG preservation possible during clone operations. * * A refmap maps a source address to a builder reference. * * This is just a map, but the semantics are important: * * The map thus preserves identity of the source. It is not a * cache because cache eviction would fail to properly track * identity. * * The map is used for memoization during object cloning are and * may also be used by user logic doing similar operations. * This ensures that identity is preserved so a source object is * not duplicated which could lead to either loss of semantic * information, or an explosion in size, or both. In some, or * even most, cases this concern may not be important, but when * it is important, it is important. * * The source address must not be reused for different content * for the lifetime of the map, although the content doest not * have to be valid or event exist at that location since source * address is just used as a key. * * The lifetime may be a single clone operation which then * tracks child object references as well, or it may be the * lifetime of the buffer builder. * * The map may be flushed explicitly when the source addresses * are no longer unique, such as when reusing a memory buffer, * and when identity preservation is no longer important. * Flushing a map is esentially the same as ending a lifetime. * * Multiple maps may exist concurrently for example if cloning * an object twice into two new objects that should have * separate identities. This is especially true and necessary * when creating a new nested buffer because the nested buffer * cannot share references with the parent. Cloning and object * that contains a nested buffer does not require multiple maps * because the nested buffer is then opaque. */ #ifndef FLATCC_REFMAP_H #define FLATCC_REFMAP_H #ifdef __cplusplus extern "C" { #endif #include "flatcc/flatcc_types.h" #ifndef FLATCC_REFMAP_MIN_BUCKETS /* 8 buckets gives us 5 useful initial entries with a load factor of 0.7 */ #define FLATCC_REFMAP_MIN_BUCKETS 8 #endif #define FLATCC_REFMAP_LOAD_FACTOR 0.7f typedef struct flatcc_refmap flatcc_refmap_t; typedef flatbuffers_soffset_t flatcc_refmap_ref_t; static const flatcc_refmap_ref_t flatcc_refmap_not_found = 0; struct flatcc_refmap_item { const void *src; flatcc_refmap_ref_t ref; }; struct flatcc_refmap { size_t count; size_t buckets; struct flatcc_refmap_item *table; /* Use stack allocation for small maps. */ struct flatcc_refmap_item min_table[FLATCC_REFMAP_MIN_BUCKETS]; }; /* * Fast zero initialization - does not allocate any memory. * May be replaced by memset 0, but `init` avoids clearing the * stack allocated initial hash table until it is needed. */ static inline int flatcc_refmap_init(flatcc_refmap_t *refmap) { refmap->count = 0; refmap->buckets = 0; refmap->table = 0; return 0; } /* * Removes all items and deallocates memory. * Not required unless `insert` or `resize` took place. The map can be * reused subsequently without calling `init`. */ void flatcc_refmap_clear(flatcc_refmap_t *refmap); /* * Keeps allocated memory as is, but removes all items. The map * must intialized first. */ void flatcc_refmap_reset(flatcc_refmap_t *refmap); /* * Returns the inserted reference if the `src` pointer was found, * without inspecting the content of the `src` pointer. * * Returns flatcc_refmap_not_found (default 0) if the `src` pointer was * not found. */ flatcc_refmap_ref_t flatcc_refmap_find(flatcc_refmap_t *refmap, const void *src); /* * Inserts a `src` source pointer and its associated `ref` reference * into the refmap without inspecting the `src` pointer content. The * `ref` value will be replaced if the the `src` pointer already exists. * * Inserting null will just return the ref without updating the map. * * There is no delete operation which simplifies an open * addressing hash table, and it isn't needed for this use case. * * Returns the input ref or not_found on allocation error. */ flatcc_refmap_ref_t flatcc_refmap_insert(flatcc_refmap_t *refmap, const void *src, flatcc_refmap_ref_t ref); /* * Set the hash table to accommodate at least `count` items while staying * within the predefined load factor. * * Resize is primarily an internal operation, but the user may resize * ahead of a large anticipated load, or after a large load to shrink * the table using 0 as the `count` argument. The table never shrinks * on its own account. */ int flatcc_refmap_resize(flatcc_refmap_t *refmap, size_t count); #ifdef __cplusplus } #endif #endif /* FLATCC_REFMAP_H */ nanoarrow/src/flatcc/flatcc_flatbuffers.h0000644000176200001440000000272014702632113020273 0ustar liggesusers/* * Even C11 compilers depend on clib support for `static_assert` which * isn't always present, so we deal with this here for all compilers. * * Outside include guard to handle scope counter. */ #include "flatcc/portable/pstatic_assert.h" #ifndef FLATCC_FLATBUFFERS_H #define FLATCC_FLATBUFFERS_H #ifdef __cplusplus extern "C" { #endif #ifndef flatcc_flatbuffers_defined #define flatcc_flatbuffers_defined #ifdef FLATCC_PORTABLE #include "flatcc/flatcc_portable.h" #endif #include "flatcc/portable/pwarnings.h" /* Needed by C99 compilers without FLATCC_PORTABLE. */ #include "flatcc/portable/pstdalign.h" /* Handle fallthrough attribute in switch statements. */ #include "flatcc/portable/pattributes.h" #include "flatcc/flatcc_alloc.h" #include "flatcc/flatcc_assert.h" #define __FLATBUFFERS_PASTE2(a, b) a ## b #define __FLATBUFFERS_PASTE3(a, b, c) a ## b ## c #define __FLATBUFFERS_CONCAT(a, b) __FLATBUFFERS_PASTE2(a, b) /* * "flatcc_endian.h" requires the preceeding include files, * or compatible definitions. */ #include "flatcc/portable/pendian.h" /* Needed by flatcc_accessors.h to handle strict aliasing rules. */ #include "flatcc/portable/pmemaccess.h" #include "flatcc/flatcc_types.h" #include "flatcc/flatcc_endian.h" #include "flatcc/flatcc_identifier.h" #ifndef FLATBUFFERS_WRAP_NAMESPACE #define FLATBUFFERS_WRAP_NAMESPACE(ns, x) ns ## _ ## x #endif #endif /* flatcc_flatbuffers_defined */ #ifdef __cplusplus } #endif #endif /* FLATCC_FLATBUFFERS_H */ nanoarrow/src/flatcc/flatcc_assert.h0000644000176200001440000000223214702632113017267 0ustar liggesusers#ifndef FLATCC_ASSERT_H #define FLATCC_ASSERT_H #ifdef __cplusplus extern "C" { #endif /* * This assert abstraction is only used for the flatcc runtime library. * The flatcc compiler uses Posix assert routines regardless of how this * file is configured. * * This header makes it possible to use systems where assert is not * valid to use. Note that `` may remain a dependency for static * assertions. * * `FLATCC_ASSERT` is designed to handle errors which cannot be ignored * and could lead to crash. The portable library may use assertions that * are not affected by this macro. * * `FLATCC_ASSERT` defaults to POSIX assert but can be overrided by a * preprocessor definition. * * Runtime assertions can be entirely disabled by defining * `FLATCC_NO_ASSERT`. */ #ifdef FLATCC_NO_ASSERT /* NOTE: This will not affect inclusion of for static assertions. */ #undef FLATCC_ASSERT #define FLATCC_ASSERT(x) ((void)0) /* Grisu3 is used for floating point conversion in JSON processing. */ #define GRISU3_NO_ASSERT #endif #ifndef FLATCC_ASSERT #include #define FLATCC_ASSERT assert #endif #ifdef __cplusplus } #endif #endif /* FLATCC_ASSERT_H */ nanoarrow/src/flatcc/flatcc_accessors.h0000644000176200001440000001426014702632113017757 0ustar liggesusers#ifndef FLATCC_ACCESSORS #define FLATCC_ACCESSORS #ifdef __cplusplus extern "C" { #endif #ifndef UINT8_MAX #include #endif #define __flatcc_basic_scalar_accessors_impl(N, T, W, E) \ static inline size_t N ## __size(void) \ { return sizeof(T); } \ static inline T *N ## __ptr_add(T *p, size_t i) \ { return p + i; } \ static inline const T *N ## __const_ptr_add(const T *p, size_t i) \ { return p + i; } \ static inline T N ## _read_from_pe(const void *p) \ { return N ## _cast_from_pe(N ## _read(p)); } \ static inline T N ## _read_to_pe(const void *p) \ { return N ## _cast_to_pe(N ## _read(p)); } \ static inline void N ## _write_from_pe(void *p, T v) \ { N ## _write(p, N ## _cast_from_pe(v)); } \ static inline void N ## _write_to_pe(void *p, T v) \ { N ## _write(p, N ## _cast_to_pe(v)); } \ static inline T N ## _read_from_le(const void *p) \ { return N ## _cast_from_le(N ## _read(p)); } \ typedef struct { int is_null; T value; } N ## _option_t; #define __flatcc_define_integer_accessors_impl(N, T, W, E) \ static inline T N ## _read(const void *p) \ { return (T) mem_read_ ## W(p); } \ static inline void N ## _write(void *p, T v) \ { mem_write_ ## W(p, v); } \ static inline T N ## _cast_from_pe(T v) \ { return (T) E ## W ## toh((uint ## W ## _t)v); } \ static inline T N ## _cast_to_pe(T v) \ { return (T) hto ## E ## W((uint ## W ## _t)v); } \ static inline T N ## _cast_from_le(T v) \ { return (T) le ## W ## toh((uint ## W ## _t)v); } \ static inline T N ## _cast_to_le(T v) \ { return (T) htole ## W((uint ## W ## _t)v); } \ static inline T N ## _cast_from_be(T v) \ { return (T) be ## W ## toh((uint ## W ## _t)v); } \ static inline T N ## _cast_to_be(T v) \ { return (T) htobe ## W((uint ## W ## _t)v); } \ __flatcc_basic_scalar_accessors_impl(N, T, W, E) #define __flatcc_define_real_accessors_impl(N, T, W, E) \ static inline T N ## _read(const void *p) \ { return (T) mem_read_float_ ## W(p); } \ static inline void N ## _write(void *p, T v) \ { mem_write_float_ ## W(p, v); } \ union __ ## N ## _cast { T v; uint ## W ## _t u; }; \ static inline T N ## _cast_from_pe(T v) \ { union __ ## N ## _cast x; \ x.v = v; x.u = E ## W ## toh(x.u); return x.v; } \ static inline T N ## _cast_to_pe(T v) \ { union __ ## N ## _cast x; \ x.v = v; x.u = hto ## E ## W(x.u); return x.v; } \ static inline T N ## _cast_from_le(T v) \ { union __ ## N ## _cast x; \ x.v = v; x.u = le ## W ## toh(x.u); return x.v; } \ static inline T N ## _cast_to_le(T v) \ { union __ ## N ## _cast x; \ x.v = v; x.u = htole ## W(x.u); return x.v; } \ static inline T N ## _cast_from_be(T v) \ { union __ ## N ## _cast x; \ x.v = v; x.u = be ## W ## toh(x.u); return x.v; } \ static inline T N ## _cast_to_be(T v) \ { union __ ## N ## _cast x; \ x.v = v; x.u = htobe ## W(x.u); return x.v; } \ __flatcc_basic_scalar_accessors_impl(N, T, W, E) #define __flatcc_define_integer_accessors(N, T, W, E) \ __flatcc_define_integer_accessors_impl(N, T, W, E) #define __flatcc_define_real_accessors(N, T, W, E) \ __flatcc_define_real_accessors_impl(N, T, W, E) #define __flatcc_define_basic_integer_accessors(NS, TN, T, W, E) \ __flatcc_define_integer_accessors(NS ## TN, T, W, E) #define __flatcc_define_basic_real_accessors(NS, TN, T, W, E) \ __flatcc_define_real_accessors(NS ## TN, T, W, E) #define __flatcc_define_basic_scalar_accessors(NS, E) \ __flatcc_define_basic_integer_accessors(NS, char, char, 8, E) \ __flatcc_define_basic_integer_accessors(NS, uint8, uint8_t, 8, E) \ __flatcc_define_basic_integer_accessors(NS, uint16, uint16_t, 16, E) \ __flatcc_define_basic_integer_accessors(NS, uint32, uint32_t, 32, E) \ __flatcc_define_basic_integer_accessors(NS, uint64, uint64_t, 64, E) \ __flatcc_define_basic_integer_accessors(NS, int8, int8_t, 8, E) \ __flatcc_define_basic_integer_accessors(NS, int16, int16_t, 16, E) \ __flatcc_define_basic_integer_accessors(NS, int32, int32_t, 32, E) \ __flatcc_define_basic_integer_accessors(NS, int64, int64_t, 64, E) \ __flatcc_define_basic_real_accessors(NS, float, float, 32, E) \ __flatcc_define_basic_real_accessors(NS, double, double, 64, E) #ifdef __cplusplus } #endif #endif /* FLATCC_ACCESSORS */ nanoarrow/src/flatcc/flatcc_epilogue.h0000644000176200001440000000016714702632113017604 0ustar liggesusers/* Include guard intentionally left out. */ #ifdef __cplusplus } #endif #include "flatcc/portable/pdiagnostic_pop.h" nanoarrow/src/flatcc/portable/0000755000176200001440000000000014671442101016113 5ustar liggesusersnanoarrow/src/flatcc/portable/pdiagnostic_push.h0000644000176200001440000000223314702632113021626 0ustar liggesusers/* * See also comment in "pdiagnostic.h" * * e.g. * #define PDIAGNOSTIC_IGNORE_USED_FUNCTION * #define PDIAGNOSTIC_IGNORE_USED_VARIABLE * #include "pdiagnostic_push" * ... * #include "pdiagnostic_pop.h" * * * or if push pop isn't desired: * #define PDIAGNOSTIC_IGNORE_USED_FUNCTION * #define PDIAGNOSTIC_IGNORE_USED_VARIABLE * #include "pdiagnostic.h" * ... * * * * Some if these warnings cannot be ignored * at the #pragma level, but might in the future. * Use compiler switches like -Wno-unused-function * to work around this. */ #if defined(_MSC_VER) #pragma warning( push ) #define PDIAGNOSTIC_PUSHED_MSVC 1 #else #define PDIAGNOSTIC_PUSHED_MSVC 0 #endif #if defined(__clang__) #pragma clang diagnostic push #define PDIAGNOSTIC_PUSHED_CLANG 1 #else #define PDIAGNOSTIC_PUSHED_CLANG 0 #endif #if defined(__GNUC__) && !defined(__clang__) #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic push #define PDIAGNOSTIC_PUSHED_GCC 1 #else #define PDIAGNOSTIC_PUSHED_GCC 0 #endif // GNUC >= 4.6 #else #define PDIAGNOSTIC_PUSHED_GCC 0 #endif // defined(__GNUC__) && !defined(__clang__) #include "pdiagnostic.h" nanoarrow/src/flatcc/portable/pinline.h0000644000176200001440000000065014702632113017722 0ustar liggesusers#ifndef PINLINE_H #define PINLINE_H #ifndef __cplusplus #if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) /* C99 or newer */ #elif _MSC_VER >= 1500 /* MSVC 9 or newer */ #undef inline #define inline __inline #elif __GNUC__ >= 3 /* GCC 3 or newer */ #define inline __inline #else /* Unknown or ancient */ #define inline #endif #endif /* __cplusplus */ #endif /* PINLINE_H */ nanoarrow/src/flatcc/portable/pendian_detect.h0000644000176200001440000000720714702632113021237 0ustar liggesusers/* * Uses various known flags to decide endianness and defines: * * __LITTLE_ENDIAN__ or __BIG_ENDIAN__ if not already defined * * and also defines * * __BYTE_ORDER__ to either __ORDER_LITTLE_ENDIAN__ or * __ORDER_BIG_ENDIAN__ if not already defined * * If none of these could be set, __UNKNOWN_ENDIAN__ is defined, * which is not a known flag. If __BYTE_ORDER__ is defined but * not big or little endian, __UNKNOWN_ENDIAN__ is also defined. * * Note: Some systems define __BYTE_ORDER without __ at the end * - this will be mapped to to __BYTE_ORDER__. */ #ifndef PENDIAN_DETECT #define PENDIAN_DETECT #ifdef __cplusplus extern "C" { #endif #ifndef __ORDER_LITTLE_ENDIAN__ #define __ORDER_LITTLE_ENDIAN__ 1234 #endif #ifndef __ORDER_BIG_ENDIAN__ #define __ORDER_BIG_ENDIAN__ 4321 #endif #ifdef __BYTE_ORDER__ #if defined(__LITTLE_ENDIAN__) && __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ #error __LITTLE_ENDIAN__ inconsistent with __BYTE_ORDER__ #endif #if defined(__BIG_ENDIAN__) && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ #error __BIG_ENDIAN__ inconsistent with __BYTE_ORDER__ #endif #else /* __BYTE_ORDER__ */ #if \ defined(__LITTLE_ENDIAN__) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \ defined(__ARMEL__) || defined(__THUMBEL__) || \ defined(__AARCH64EL__) || \ (defined(_MSC_VER) && defined(_M_ARM)) || \ defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || \ defined(_M_X64) || defined(_M_IX86) || defined(_M_I86) || \ defined(__i386__) || defined(__alpha__) || \ defined(__ia64) || defined(__ia64__) || \ defined(_M_IA64) || defined(_M_ALPHA) || \ defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || \ defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ defined(__bfin__) #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #endif #if \ defined (__BIG_ENDIAN__) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __ORDER_BIG_ENDIAN) || \ defined(__ARMEB__) || defined(THUMBEB__) || defined (__AARCH64EB__) || \ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || \ defined(__sparc) || defined(__sparc__) || \ defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || \ defined(__hpux) || defined(__hppa) || defined(__s390__) #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ #endif #endif /* __BYTE_ORDER__ */ #ifdef __BYTE_ORDER__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifndef __LITTLE_ENDIAN__ #define __LITTLE_ENDIAN__ 1 #endif #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #ifndef __BIG_ENDIAN__ #define __BIG_ENDIAN__ 1 #endif #else /* * Custom extension - we only define __BYTE_ORDER__ if known big or little. * User code that understands __BYTE_ORDER__ may also assume unkown if * it is not defined by now - this will allow other endian formats than * big or little when supported by compiler. */ #ifndef __UNKNOWN_ENDIAN__ #define __UNKNOWN_ENDIAN__ 1 #endif #endif #endif /* __BYTE_ORDER__ */ #if defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__) #error conflicting definitions of __LITTLE_ENDIAN__ and __BIG_ENDIAN__ #endif #ifdef __cplusplus } #endif #endif /* PENDIAN_DETECT */ nanoarrow/src/flatcc/portable/portable_basic.h0000644000176200001440000000127614702632113021242 0ustar liggesusers#ifndef PORTABLE_BASIC_H #define PORTABLE_BASIC_H /* * Basic features need to make compilers support the most common moden C * features, and endian / unligned read support as well. * * It is not assumed that this file is always included. * Other include files are independent or include what they need. */ #include "pversion.h" #include "pwarnings.h" /* Featutures that ought to be supported by C11, but some aren't. */ #include "pinttypes.h" #include "pstdalign.h" #include "pinline.h" #include "pstatic_assert.h" /* These are not supported by C11 and are general platform abstractions. */ #include "pendian.h" #include "punaligned.h" #include "pmemaccess.h" #endif /* PORTABLE_BASIC_H */ nanoarrow/src/flatcc/portable/pwarnings.h0000644000176200001440000000315514702632113020277 0ustar liggesusers#ifndef PWARNINGS_H #define PWARNINGS_H #ifdef __cplusplus extern "C" { #endif /* * See also pdiagnostics.h headers for per file control of common * warnings. * * This file is intended for global disabling of warnings that shouldn't * be present in C11 or perhaps C99, or a generally just noise where * recent clang / gcc compile cleanly with high warning levels. */ #if defined(_MSC_VER) /* Needed when flagging code in or out and more. */ #pragma warning(disable: 4127) /* conditional expression is constant */ /* happens also in MS's own headers. */ #pragma warning(disable: 4668) /* preprocessor name not defined */ /* MSVC does not respect double parenthesis for intent */ #pragma warning(disable: 4706) /* assignment within conditional expression */ /* `inline` only advisory anyway. */ #pragma warning(disable: 4710) /* function not inlined */ /* Well, we don't intend to add the padding manually. */ #pragma warning(disable: 4820) /* x bytes padding added in struct */ /* * Don't warn that fopen etc. are unsafe * * Define a compiler flag like `-D_CRT_SECURE_NO_WARNINGS` in the build. * For some reason it doesn't work when defined here. * * #define _CRT_SECURE_NO_WARNINGS */ /* * Anonymous union in struct is valid in C11 and has been supported in * GCC and Clang for a while, but it is not C99. MSVC also handles it, * but warns. Truly portable code should perhaps not use this feature, * but this is not the place to complain about it. */ #pragma warning(disable: 4201) /* nonstandard extension used: nameless struct/union */ #endif /* _MSV_VER */ #ifdef __cplusplus } #endif #endif /* PWARNINGS_H */ nanoarrow/src/flatcc/portable/portable.h0000644000176200001440000000015014702632113020067 0ustar liggesusers/* portable.h is widely used, so we redirect to a less conflicting name. */ #include "portable_basic.h" nanoarrow/src/flatcc/portable/pinttypes.h0000644000176200001440000000205014702632113020317 0ustar liggesusers#ifndef PINTTYPES_H #define PINTTYPES_H #ifndef PRId16 #if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) /* C99 or newer */ #include #else /* * This is not a complete implementation of , just the most * useful printf modifiers. */ #include "pstdint.h" #ifndef PRINTF_INT64_MODIFIER #error "please define PRINTF_INT64_MODIFIER" #endif #ifndef PRId64 #define PRId64 PRINTF_INT64_MODIFIER "d" #define PRIu64 PRINTF_INT64_MODIFIER "u" #define PRIx64 PRINTF_INT64_MODIFIER "x" #endif #ifndef PRINTF_INT32_MODIFIER #define PRINTF_INT32_MODIFIER "l" #endif #ifndef PRId32 #define PRId32 PRINTF_INT32_MODIFIER "d" #define PRIu32 PRINTF_INT32_MODIFIER "u" #define PRIx32 PRINTF_INT32_MODIFIER "x" #endif #ifndef PRINTF_INT16_MODIFIER #define PRINTF_INT16_MODIFIER "h" #endif #ifndef PRId16 #define PRId16 PRINTF_INT16_MODIFIER "d" #define PRIu16 PRINTF_INT16_MODIFIER "u" #define PRIx16 PRINTF_INT16_MODIFIER "x" #endif # endif /* __STDC__ */ #endif /* PRId16 */ #endif /* PINTTYPES */ nanoarrow/src/flatcc/portable/pstatic_assert.h0000644000176200001440000000346414702632113021322 0ustar liggesusers#ifndef PSTATIC_ASSERT_H #define PSTATIC_ASSERT_H #include /* Handle clang */ #ifndef __has_feature #define __has_feature(x) 0 #endif #if defined(static_assert) #ifndef __static_assert_is_defined #define __static_assert_is_defined 1 #endif #endif /* Handle static_assert as a keyword in C++ and compiler specifics. */ #if !defined(__static_assert_is_defined) #if defined(__cplusplus) #if __cplusplus >= 201103L #define __static_assert_is_defined 1 #elif __has_feature(cxx_static_assert) #define __static_assert_is_defined 1 #elif defined(_MSC_VER) && (_MSC_VER >= 1600) #define __static_assert_is_defined 1 #endif #else #if defined(_MSC_VER) && (_MSC_VER >= 1600) #define __static_assert_is_defined 1 #elif __has_feature(c_static_assert) #define static_assert(pred, msg) _Static_assert(pred, msg) #define __static_assert_is_defined 1 #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* In case the clib headers are not compliant. */ #define static_assert(pred, msg) _Static_assert(pred, msg) #define __static_assert_is_defined 1 #endif #endif /* __cplusplus */ #endif /* __static_assert_is_defined */ #if !defined(__static_assert_is_defined) #define __PSTATIC_ASSERT_CONCAT_(a, b) static_assert_scope_##a##_line_##b #define __PSTATIC_ASSERT_CONCAT(a, b) __PSTATIC_ASSERT_CONCAT_(a, b) #ifdef __COUNTER__ #define static_assert(e, msg) enum { __PSTATIC_ASSERT_CONCAT(__COUNTER__, __LINE__) = 1/(!!(e)) } #else #include "pstatic_assert_scope.h" #define static_assert(e, msg) enum { __PSTATIC_ASSERT_CONCAT(__PSTATIC_ASSERT_COUNTER, __LINE__) = 1/(int)(!!(e)) } #endif #define __static_assert_is_defined 1 #endif /* __static_assert_is_defined */ #endif /* PSTATIC_ASSERT_H */ /* Update scope counter outside of include guard. */ #ifdef __PSTATIC_ASSERT_COUNTER #include "pstatic_assert_scope.h" #endif nanoarrow/src/flatcc/portable/pendian.h0000644000176200001440000001224414702632113017704 0ustar liggesusers#ifndef PENDIAN_H #define PENDIAN_H #ifdef __cplusplus extern "C" { #endif /* * Defines platform optimized (as per linux * * le16toh, le32to, le64toh, be16toh, be32toh, be64toh * htole16, htole32, htole64, htobe16, htobe32, htobe64 * * Falls back to auto-detect endian conversion which is also fast * if fast byteswap operation was detected. * * Also defines platform optimized: * * bswap16, bswap32, bswap64, * * with fall-back to shift-or implementation. * * For convenience also defines: * * le8to, be8toh, htole8, htobe8 * bswap8 * * The convience functions makes is simpler to define conversion macros * based on type size. * * NOTE: this implementation expects arguments with no side-effects and * with appropriately sized unsigned arguments. These are expected to be * used with typesafe wrappers. */ #ifndef UINT8_MAX #include "pstdint.h" #endif #if defined(__linux__) #include #elif defined(__OpenBSD__) || defined(__FreeBSD__) #include #endif #include "pendian_detect.h" #if defined(_MSC_VER) #if _MSC_VER >= 1300 #include #define bswap16 _byteswap_ushort #define bswap32 _byteswap_ulong #define bswap64 _byteswap_uint64 #endif #elif defined(__clang__) #if __has_builtin(__builtin_bswap16) #ifndef bswap16 #define bswap16 __builtin_bswap16 #endif #endif #if __has_builtin(__builtin_bswap32) #ifndef bswap32 #define bswap32 __builtin_bswap32 #endif #endif #if __has_builtin(__builtin_bswap64) #ifndef bswap64 #define bswap64 __builtin_bswap64 #endif #endif #elif defined(__OpenBSD__) || defined(__FreeBSD__) #ifndef bswap16 #define bswap16 swap16 #endif #ifndef bswap32 #define bswap32 swap32 #endif #ifndef bswap64 #define bswap64 swap64 #endif #elif defined(__GNUC__) /* Supported since at least GCC 4.4 */ #ifndef bswap32 #define bswap32 __builtin_bswap32 #endif #ifndef bswap64 #define bswap64 __builtin_bswap64 #endif #endif #ifndef bswap16 #define bswap16(v) \ (((uint16_t)(v) << 8) | ((uint16_t)(v) >> 8)) #endif #ifndef bswap32 #define bswap32(v) \ ((((uint32_t)(v) << 24)) \ | (((uint32_t)(v) << 8) & UINT32_C(0x00FF0000)) \ | (((uint32_t)(v) >> 8) & UINT32_C(0x0000FF00)) \ | (((uint32_t)(v) >> 24))) #endif #ifndef bswap64 #define bswap64(v) \ ((((uint64_t)(v) << 56)) \ | (((uint64_t)(v) << 40) & UINT64_C(0x00FF000000000000)) \ | (((uint64_t)(v) << 24) & UINT64_C(0x0000FF0000000000)) \ | (((uint64_t)(v) << 8) & UINT64_C(0x000000FF00000000)) \ | (((uint64_t)(v) >> 8) & UINT64_C(0x00000000FF000000)) \ | (((uint64_t)(v) >> 24) & UINT64_C(0x0000000000FF0000)) \ | (((uint64_t)(v) >> 40) & UINT64_C(0x000000000000FF00)) \ | (((uint64_t)(v) >> 56))) #endif #ifndef bswap8 #define bswap8(v) ((uint8_t)(v)) #endif #if !defined(le16toh) && defined(letoh16) #define le16toh letoh16 #define le32toh letoh32 #define le64toh letoh64 #endif #if !defined(be16toh) && defined(betoh16) #define be16toh betoh16 #define be32toh betoh32 #define be64toh betoh64 #endif /* Assume it goes for all. */ #if !defined(le16toh) #if defined(__LITTLE_ENDIAN__) #define le16toh(v) (v) #define le32toh(v) (v) #define le64toh(v) (v) #define htole16(v) (v) #define htole32(v) (v) #define htole64(v) (v) #define be16toh(v) bswap16(v) #define be32toh(v) bswap32(v) #define be64toh(v) bswap64(v) #define htobe16(v) bswap16(v) #define htobe32(v) bswap32(v) #define htobe64(v) bswap64(v) #elif defined(__BIG_ENDIAN__) #define le16toh(v) bswap16(v) #define le32toh(v) bswap32(v) #define le64toh(v) bswap64(v) #define htole16(v) bswap16(v) #define htole32(v) bswap32(v) #define htole64(v) bswap64(v) #define be16toh(v) (v) #define be32toh(v) (v) #define be64toh(v) (v) #define htobe16(v) (v) #define htobe32(v) (v) #define htobe64(v) (v) #else static const int __pendian_test = 1; #define le16toh(v) (*(char *)&__pendian_test ? (v) : bswap16(v)) #define le32toh(v) (*(char *)&__pendian_test ? (v) : bswap32(v)) #define le64toh(v) (*(char *)&__pendian_test ? (v) : bswap64(v)) #define htole16(v) (*(char *)&__pendian_test ? (v) : bswap16(v)) #define htole32(v) (*(char *)&__pendian_test ? (v) : bswap32(v)) #define htole64(v) (*(char *)&__pendian_test ? (v) : bswap64(v)) #define be16toh(v) (*(char *)&__pendian_test ? bswap16(v) : (v)) #define be32toh(v) (*(char *)&__pendian_test ? bswap32(v) : (v)) #define be64toh(v) (*(char *)&__pendian_test ? bswap64(v) : (v)) #define htobe16(v) (*(char *)&__pendian_test ? bswap16(v) : (v)) #define htobe32(v) (*(char *)&__pendian_test ? bswap32(v) : (v)) #define htobe64(v) (*(char *)&__pendian_test ? bswap64(v) : (v)) #endif #endif /* le16toh */ /* Helpers not part of Linux */ #if !defined(le8toh) #define le8toh(n) (n) #define htole8(n) (n) #define be8toh(n) (n) #define htobe8(n) (n) #endif #ifdef __cplusplus } #endif #endif /* PENDIAN_H */ nanoarrow/src/flatcc/portable/pstdalign.h0000644000176200001440000001030714702632113020251 0ustar liggesusers#ifndef PSTDALIGN_H #define PSTDALIGN_H /* * NOTE: aligned_alloc is defined via paligned_alloc.h * and requires aligned_free to be fully portable although * free also works on C11 and platforms with posix_memalign. * * NOTE: C++11 defines alignas as a keyword but then also defines * __alignas_is_defined. * * C++14 does not define __alignas_is_defined, at least sometimes. * * GCC 8.3 reverts on this and makes C++11 behave the same as C++14 * preventing a simple __cplusplus version check from working. * * Clang C++ without std=c++11 or std=c++14 does define alignas * but does so incorrectly wrt. C11 and C++11 semantics because * `alignas(4) float x;` is not recognized. * To fix such issues, either move to a std version, or * include a working stdalign.h for the given compiler before * this file. * * newlib defines _Alignas and _Alignof in sys/cdefs but rely on * gcc version for which can lead to conflicts if * stdalign is not included. * * newlibs need for conflicts with broken C++ stdalign * but this can be fixed be using std=C++11 or newer. * * MSVC does not support at least up to MSVC 2015, * but does appear to support alignas and alignof keywords in * recent standard C++. * * TCC only supports alignas with a numeric argument like * `alignas(4)`, but not `alignas(float)`. * * If stdalign.h is supported but heuristics in this file are * insufficient to detect this, try including manually * or define HAVE_STDALIGN_H. */ /* https://github.com/dvidelabs/flatcc/issues/130 */ #ifndef __alignas_is_defined #if defined(__cplusplus) #if __cplusplus == 201103 && !defined(__clang__) && ((__GNUC__ > 8) || (__GNUC__ == 8 && __GNUC_MINOR__ >= 3)) #define __alignas_is_defined 1 #define __alignof_is_defined 1 #include #endif #endif #endif /* Allow for alternative solution to be included first. */ #ifndef __alignas_is_defined #ifdef __cplusplus #if defined(PORTABLE_PATCH_CPLUSPLUS_STDALIGN) #include #undef alignas #define alignas(t) __attribute__((__aligned__(t))) #endif #endif #if !defined(PORTABLE_HAS_INCLUDE_STDALIGN) #if defined(__has_include) #if __has_include() #define PORTABLE_HAS_INCLUDE_STDALIGN 1 #else #define PORTABLE_HAS_INCLUDE_STDALIGN 0 #endif #endif #endif /* https://lists.gnu.org/archive/html/bug-gnulib/2015-08/msg00003.html */ #if defined(__cplusplus) #if !defined(_MSC_VER) #include #endif #if __cplusplus > 201103 #define __alignas_is_defined 1 #define __alignof_is_defined 1 #endif #elif PORTABLE_HAS_INCLUDE_STDALIGN #include #elif !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) #include #elif defined(HAVE_STDALIGN_H) #include #endif #endif /* __alignas_is_defined */ #ifndef __alignas_is_defined #ifdef __cplusplus extern "C" { #endif #if (!defined(__clang__) && defined(__GNUC__) && \ ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 7))) #undef PORTABLE_C11_STDALIGN_MISSING #define PORTABLE_C11_STDALIGN_MISSING #endif #if defined(__IBMC__) #undef PORTABLE_C11_STDALIGN_MISSING #define PORTABLE_C11_STDALIGN_MISSING #endif #if ((defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && \ !defined(PORTABLE_C11_STDALIGN_MISSING)) /* C11 or newer */ #include #else #if defined(__GNUC__) || defined(__IBM_ALIGNOF__) || defined(__clang__) #ifndef _Alignas #define _Alignas(t) __attribute__((__aligned__(t))) #endif #ifndef _Alignof #define _Alignof(t) __alignof__(t) #endif #elif defined(_MSC_VER) #define _Alignas(t) __declspec (align(t)) #define _Alignof(t) __alignof(t) #elif defined(__TINYC__) /* Supports `_Alignas(integer-expression)`, but not `_Alignas(type)`. */ #define _Alignas(t) __attribute__(aligned(t)) #define _Alignof(t) __alignof__(t) #else #error please update pstdalign.h with support for current compiler and library #endif #endif /* __STDC__ */ #ifndef alignas #define alignas _Alignas #endif #ifndef alignof #define alignof _Alignof #endif #define __alignas_is_defined 1 #define __alignof_is_defined 1 #ifdef __cplusplus } #endif #endif /* __alignas__is_defined */ #include "paligned_alloc.h" #endif /* PSTDALIGN_H */ nanoarrow/src/flatcc/portable/pdiagnostic.h0000644000176200001440000000514114702632113020570 0ustar liggesusers /* There is intentionally no include guard in this file. */ /* * Usage: optionally disable any of these before including. * * #define PDIAGNOSTIC_IGNORE_UNUSED_FUNCTION * #define PDIAGNOSTIC_IGNORE_UNUSED_VARIABLE * #define PDIAGNOSTIC_IGNORE_UNUSED_PARAMETER * #define PDIAGNOSTIC_IGNORE_UNUSED // all of the above * * #include "pdiagnostic.h" * * Alternatively use #include "pdiagnostic_push/pop.h" */ #ifdef _MSC_VER /**/#pragma warning(disable: 4668) /* preprocessor name not defined */ #endif #if !defined(PDIAGNOSTIC_AWARE_MSVC) && defined(_MSC_VER) #define PDIAGNOSTIC_AWARE_MSVC 1 #elif !defined(PDIAGNOSTIC_AWARE_MSVC) #define PDIAGNOSTIC_AWARE_MSVC 0 #endif #if !defined(PDIAGNOSTIC_AWARE_CLANG) && defined(__clang__) #define PDIAGNOSTIC_AWARE_CLANG 1 #elif !defined(PDIAGNOSTIC_AWARE_CLANG) #define PDIAGNOSTIC_AWARE_CLANG 0 #endif #if !defined(PDIAGNOSTIC_AWARE_GCC) && defined(__GNUC__) && !defined(__clang__) /* Can disable some warnings even if push is not available (gcc-4.2 vs gcc-4.7) */ #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) #define PDIAGNOSTIC_AWARE_GCC 1 #endif #endif #if !defined(PDIAGNOSTIC_AWARE_GCC) #define PDIAGNOSTIC_AWARE_GCC 0 #endif #if defined(PDIAGNOSTIC_IGNORE_UNUSED_FUNCTION) || defined(PDIAGNOSTIC_IGNORE_UNUSED) #if PDIAGNOSTIC_AWARE_CLANG /**/#pragma clang diagnostic ignored "-Wunused-function" #elif PDIAGNOSTIC_AWARE_GCC /**/#pragma GCC diagnostic ignored "-Wunused-function" #endif #endif #undef PDIAGNOSTIC_IGNORE_UNUSED_FUNCTION #if defined(PDIAGNOSTIC_IGNORE_UNUSED_VARIABLE) || defined(PDIAGNOSTIC_IGNORE_UNUSED) #if PDIAGNOSTIC_AWARE_MSVC /**/#pragma warning(disable: 4101) /* unused local variable */ #elif PDIAGNOSTIC_AWARE_CLANG /**/#pragma clang diagnostic ignored "-Wunused-variable" #elif PDIAGNOSTIC_AWARE_GCC /**/#pragma GCC diagnostic ignored "-Wunused-variable" #endif #endif #undef PDIAGNOSTIC_IGNORE_UNUSED_VARIABLE #if defined(PDIAGNOSTIC_IGNORE_UNUSED_PARAMETER) || defined(PDIAGNOSTIC_IGNORE_UNUSED) #if PDIAGNOSTIC_AWARE_CLANG /**/#pragma clang diagnostic ignored "-Wunused-parameter" #elif PDIAGNOSTIC_AWARE_GCC /**/#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #endif #undef PDIAGNOSTIC_IGNORE_UNUSED_PARAMETER #undef PDIAGNOSTIC_IGNORE_UNUSED #if defined (__cplusplus) && __cplusplus < 201103L #if PDIAGNOSTIC_AWARE_CLANG /* Needed for < C++11 clang C++ static_assert */ /**/#pragma clang diagnostic ignored "-Wc11-extensions" /* Needed for empty macro arguments. */ /**/#pragma clang diagnostic ignored "-Wc99-extensions" /* Needed for trailing commas. */ /**/#pragma clang diagnostic ignored "-Wc++11-extensions" #endif #endif nanoarrow/src/flatcc/portable/pattributes.h0000644000176200001440000000463414702632113020640 0ustar liggesusers /* * C23 introduces an attribute syntax `[[]]`. Prior to that * other non-standard syntaxes such as `__attribute__(())` * and `__declspec()` have been supported by some compiler * versions. * * See also: * https://en.cppreference.com/w/c/language/attributes * * There is no portable way to use C23 attributes in older C standards * so in order to use these portably, some macro name needs to be * defined for each attribute that either maps to the older supported * syntax, or ignores the attribute as appropriate. * * The Linux kernel defines certain attributes as macros, such as * `fallthrough`. When adding attributes it seems reasonable to follow * the Linux conventions in lack of any official standard. However, it * is not the intention that this file should mirror the Linux * attributes 1 to 1. * * See also: * https://github.com/torvalds/linux/blob/master/include/linux/compiler_attributes.h * * There is a risk that exposed attribute names may lead to name * conflicts. A conflicting name can be undefined and if necessary used * using `pattribute()`. All attributes can be hidden by * defining `PORTABLE_EXPOSE_ATTRIBUTES=0` in which case * `pattribute()` can still be used and then if a specific * attribute name still needs to be exposed, it can be defined manually * like `#define fallthrough pattribute(fallthrough)`. */ #ifndef PATTRIBUTES_H #define PATTRIBUTES_H #ifdef __cplusplus extern "C" { #endif #ifndef PORTABLE_EXPOSE_ATTRIBUTES #define PORTABLE_EXPOSE_ATTRIBUTES 0 #endif #ifdef __has_c_attribute # define PORTABLE_HAS_C_ATTRIBUTE(x) __has_c_attribute(x) #else # define PORTABLE_HAS_C_ATTRIBUTE(x) 0 #endif #ifdef __has_attribute # define PORTABLE_HAS_ATTRIBUTE(x) __has_attribute(x) #else # define PORTABLE_HAS_ATTRIBUTE(x) 0 #endif /* https://en.cppreference.com/w/c/language/attributes/fallthrough */ #if PORTABLE_HAS_C_ATTRIBUTE(__fallthrough__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L # define pattribute_fallthrough [[__fallthrough__]] #elif PORTABLE_HAS_ATTRIBUTE(__fallthrough__) # define pattribute_fallthrough __attribute__((__fallthrough__)) #else # define pattribute_fallthrough ((void)0) #endif #define pattribute(x) pattribute_##x #if PORTABLE_EXPOSE_ATTRIBUTES #ifndef fallthrough # define fallthrough pattribute(fallthrough) #endif #endif #ifdef __cplusplus } #endif #endif /* PATTRIBUTES_H */ nanoarrow/src/flatcc/portable/paligned_alloc.h0000644000176200001440000001346314702632113021227 0ustar liggesusers#ifndef PALIGNED_ALLOC_H #ifdef __cplusplus extern "C" { #endif /* * NOTE: MSVC in general has no aligned alloc function that is * compatible with free and it is not trivial to implement a version * which is. Therefore, to remain portable, end user code needs to * use `aligned_free` which is not part of C11 but defined in this header. * * glibc only provides aligned_alloc when _ISOC11_SOURCE is defined, but * MingW does not support aligned_alloc despite of this, it uses the * the _aligned_malloc as MSVC. * * The same issue is present on some Unix systems not providing * posix_memalign. * * Note that clang and gcc with -std=c11 or -std=c99 will not define * _POSIX_C_SOURCE and thus posix_memalign cannot be detected but * aligned_alloc is not necessarily available either. We assume * that clang always has posix_memalign although it is not strictly * correct. For gcc, use -std=gnu99 or -std=gnu11 or don't use -std in * order to enable posix_memalign, or live with the fallback until using * a system where glibc has a version that supports aligned_alloc. * * For C11 compliant compilers and compilers with posix_memalign, * it is valid to use free instead of aligned_free with the above * caveats. */ #include /* * Define this to see which version is used so the fallback is not * enganged unnecessarily: * * #define PORTABLE_DEBUG_ALIGNED_ALLOC */ #if 0 #define PORTABLE_DEBUG_ALIGNED_ALLOC #endif #if !defined(PORTABLE_C11_ALIGNED_ALLOC) /* * PORTABLE_C11_ALIGNED_ALLOC = 1 * indicates that the system has builtin aligned_alloc * If it doesn't, the section after detection provides an implemention. */ #if defined (__MINGW32__) /* MingW does not provide aligned_alloc despite defining _ISOC11_SOURCE */ #define PORTABLE_C11_ALIGNED_ALLOC 0 #elif defined (_ISOC11_SOURCE) /* glibc aligned_alloc detection, but MingW is not truthful */ #define PORTABLE_C11_ALIGNED_ALLOC 1 #elif defined (__GLIBC__) /* aligned_alloc is not available in glibc just because __STDC_VERSION__ >= 201112L. */ #define PORTABLE_C11_ALIGNED_ALLOC 0 #elif defined (__clang__) #define PORTABLE_C11_ALIGNED_ALLOC 0 #elif defined (__APPLE__) #define PORTABLE_C11_ALIGNED_ALLOC 0 #elif defined(__IBMC__) #define PORTABLE_C11_ALIGNED_ALLOC 0 #elif (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) #define PORTABLE_C11_ALIGNED_ALLOC 1 #else #define PORTABLE_C11_ALIGNED_ALLOC 0 #endif #endif /* PORTABLE_C11_ALIGNED_ALLOC */ /* https://linux.die.net/man/3/posix_memalign */ #if !defined(PORTABLE_POSIX_MEMALIGN) && defined(_GNU_SOURCE) #define PORTABLE_POSIX_MEMALIGN 1 #endif /* https://forum.kde.org/viewtopic.php?p=66274 */ #if !defined(PORTABLE_POSIX_MEMALIGN) && defined(_XOPEN_SOURCE) #if _XOPEN_SOURCE >= 600 #define PORTABLE_POSIX_MEMALIGN 1 #endif #endif #if !defined(PORTABLE_POSIX_MEMALIGN) && defined(_POSIX_C_SOURCE) #if _POSIX_C_SOURCE >= 200112L #define PORTABLE_POSIX_MEMALIGN 1 #endif #endif #if !defined(PORTABLE_POSIX_MEMALIGN) && defined(__clang__) #define PORTABLE_POSIX_MEMALIGN 1 #endif #if !defined(PORTABLE_POSIX_MEMALIGN) #define PORTABLE_POSIX_MEMALIGN 0 #endif /* https://forum.kde.org/viewtopic.php?p=66274 */ #if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) /* C11 or newer */ #include #endif /* C11 or newer */ #if !defined(aligned_alloc) && !defined(__aligned_alloc_is_defined) #if PORTABLE_C11_ALIGNED_ALLOC #ifdef PORTABLE_DEBUG_ALIGNED_ALLOC #error "DEBUG: C11_ALIGNED_ALLOC configured" #endif #elif defined(_MSC_VER) || defined(__MINGW32__) #ifdef PORTABLE_DEBUG_ALIGNED_ALLOC #error "DEBUG: Windows _aligned_malloc configured" #endif /* Aligned _aligned_malloc is not compatible with free. */ #define aligned_alloc(alignment, size) _aligned_malloc(size, alignment) #define aligned_free(p) _aligned_free(p) #define __aligned_alloc_is_defined 1 #define __aligned_free_is_defined 1 #elif PORTABLE_POSIX_MEMALIGN #if defined(__GNUC__) #if !defined(__GNUCC__) extern int posix_memalign (void **, size_t, size_t); #elif __GNUCC__ < 5 extern int posix_memalign (void **, size_t, size_t); #endif #endif static inline void *__portable_aligned_alloc(size_t alignment, size_t size) { int err; void *p = 0; if (alignment < sizeof(void *)) { alignment = sizeof(void *); } err = posix_memalign(&p, alignment, size); if (err && p) { free(p); p = 0; } return p; } #ifdef PORTABLE_DEBUG_ALIGNED_ALLOC #error "DEBUG: POSIX_MEMALIGN configured" #endif #define aligned_alloc(alignment, size) __portable_aligned_alloc(alignment, size) #define aligned_free(p) free(p) #define __aligned_alloc_is_defined 1 #define __aligned_free_is_defined 1 #else static inline void *__portable_aligned_alloc(size_t alignment, size_t size) { char *raw; void *buf; size_t total_size = (size + alignment - 1 + sizeof(void *)); if (alignment < sizeof(void *)) { alignment = sizeof(void *); } raw = (char *)(size_t)malloc(total_size); if (!raw) return 0; buf = raw + alignment - 1 + sizeof(void *); buf = (void *)(((size_t)buf) & ~(alignment - 1)); ((void **)buf)[-1] = raw; return buf; } static inline void __portable_aligned_free(void *p) { char *raw; if (p) { raw = (char*)((void **)p)[-1]; free(raw); } } #define aligned_alloc(alignment, size) __portable_aligned_alloc(alignment, size) #define aligned_free(p) __portable_aligned_free(p) #define __aligned_alloc_is_defined 1 #define __aligned_free_is_defined 1 #ifdef PORTABLE_DEBUG_ALIGNED_ALLOC #error "DEBUG: aligned_alloc malloc fallback configured" #endif #endif #endif /* aligned_alloc */ #if !defined(aligned_free) && !defined(__aligned_free_is_defined) #define aligned_free(p) free(p) #define __aligned_free_is_defined 1 #endif #ifdef __cplusplus } #endif #endif /* PALIGNED_ALLOC_H */ nanoarrow/src/flatcc/portable/flatcc_portable.h0000644000176200001440000000030614671440121021407 0ustar liggesusers#ifndef FLATCC_PORTABLE_H #define FLATCC_PORTABLE_H #ifdef __cplusplus extern "C" { #endif #include "flatcc/portable/portable_basic.h" #ifdef __cplusplus } #endif #endif /* FLATCC_PORTABLE_H */ nanoarrow/src/flatcc/portable/punaligned.h0000644000176200001440000002126214702632113020414 0ustar liggesusers/* * Copyright (c) 2016 Mikkel Fahnøe Jørgensen, dvide.com * * (MIT License) * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * - The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * - The Software is provided "as is", without warranty of any kind, express or * implied, including but not limited to the warranties of merchantability, * fitness for a particular purpose and noninfringement. In no event shall the * authors or copyright holders be liable for any claim, damages or other * liability, whether in an action of contract, tort or otherwise, arising from, * out of or in connection with the Software or the use or other dealings in the * Software. */ #ifndef PUNLIGNED_H #define PUNLIGNED_H #ifdef __cplusplus extern "C" { #endif #ifndef PORTABLE_UNALIGNED_ACCESS #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) #define PORTABLE_UNALIGNED_ACCESS 1 #else #define PORTABLE_UNALIGNED_ACCESS 0 #endif #endif /* `unaligned_read_16` might not be defined if endianness was not determined. */ #if !defined(unaligned_read_le16toh) #include "pendian.h" #ifndef UINT8_MAX #include #endif #if PORTABLE_UNALIGNED_ACCESS #define unaligned_read_16(p) (*(uint16_t*)(p)) #define unaligned_read_32(p) (*(uint32_t*)(p)) #define unaligned_read_64(p) (*(uint64_t*)(p)) #define unaligned_read_le16toh(p) le16toh(*(uint16_t*)(p)) #define unaligned_read_le32toh(p) le32toh(*(uint32_t*)(p)) #define unaligned_read_le64toh(p) le64toh(*(uint64_t*)(p)) #define unaligned_read_be16toh(p) be16toh(*(uint16_t*)(p)) #define unaligned_read_be32toh(p) be32toh(*(uint32_t*)(p)) #define unaligned_read_be64toh(p) be64toh(*(uint64_t*)(p)) #define unaligned_write_16(p, v) (*(uint16_t*)(p) = (uint16_t)(v)) #define unaligned_write_32(p, v) (*(uint32_t*)(p) = (uint32_t)(v)) #define unaligned_write_64(p, v) (*(uint64_t*)(p) = (uint64_t)(v)) #define unaligned_write_htole16(p, v) (*(uint16_t*)(p) = htole16(v)) #define unaligned_write_htole32(p, v) (*(uint32_t*)(p) = htole32(v)) #define unaligned_write_htole64(p, v) (*(uint64_t*)(p) = htole64(v)) #define unaligned_write_htobe16(p, v) (*(uint16_t*)(p) = htobe16(v)) #define unaligned_write_htobe32(p, v) (*(uint32_t*)(p) = htobe32(v)) #define unaligned_write_htobe64(p, v) (*(uint64_t*)(p) = htobe64(v)) #else #define unaligned_read_le16toh(p) ( \ (((uint16_t)(((uint8_t *)(p))[0])) << 0) | \ (((uint16_t)(((uint8_t *)(p))[1])) << 8)) #define unaligned_read_le32toh(p) ( \ (((uint32_t)(((uint8_t *)(p))[0])) << 0) | \ (((uint32_t)(((uint8_t *)(p))[1])) << 8) | \ (((uint32_t)(((uint8_t *)(p))[2])) << 16) | \ (((uint32_t)(((uint8_t *)(p))[3])) << 24)) #define unaligned_read_le64toh(p) ( \ (((uint64_t)(((uint8_t *)(p))[0])) << 0) | \ (((uint64_t)(((uint8_t *)(p))[1])) << 8) | \ (((uint64_t)(((uint8_t *)(p))[2])) << 16) | \ (((uint64_t)(((uint8_t *)(p))[3])) << 24) | \ (((uint64_t)(((uint8_t *)(p))[4])) << 32) | \ (((uint64_t)(((uint8_t *)(p))[5])) << 40) | \ (((uint64_t)(((uint8_t *)(p))[6])) << 48) | \ (((uint64_t)(((uint8_t *)(p))[7])) << 56)) #define unaligned_read_be16toh(p) ( \ (((uint16_t)(((uint8_t *)(p))[0])) << 8) | \ (((uint16_t)(((uint8_t *)(p))[1])) << 0)) #define unaligned_read_be32toh(p) ( \ (((uint32_t)(((uint8_t *)(p))[0])) << 24) | \ (((uint32_t)(((uint8_t *)(p))[1])) << 16) | \ (((uint32_t)(((uint8_t *)(p))[2])) << 8) | \ (((uint32_t)(((uint8_t *)(p))[3])) << 0)) #define unaligned_read_be64toh(p) ( \ (((uint64_t)(((uint8_t *)(p))[0])) << 56) | \ (((uint64_t)(((uint8_t *)(p))[1])) << 48) | \ (((uint64_t)(((uint8_t *)(p))[2])) << 40) | \ (((uint64_t)(((uint8_t *)(p))[3])) << 32) | \ (((uint64_t)(((uint8_t *)(p))[4])) << 24) | \ (((uint64_t)(((uint8_t *)(p))[5])) << 16) | \ (((uint64_t)(((uint8_t *)(p))[6])) << 8) | \ (((uint64_t)(((uint8_t *)(p))[7])) << 0)) #define unaligned_write_htole16(p, v) do { \ ((uint8_t *)(p))[0] = (uint8_t)(((uint16_t)(v)) >> 0); \ ((uint8_t *)(p))[1] = (uint8_t)(((uint16_t)(v)) >> 8); \ } while (0) #define unaligned_write_htole32(p, v) do { \ ((uint8_t *)(p))[0] = (uint8_t)(((uint32_t)(v)) >> 0); \ ((uint8_t *)(p))[1] = (uint8_t)(((uint32_t)(v)) >> 8); \ ((uint8_t *)(p))[2] = (uint8_t)(((uint32_t)(v)) >> 16); \ ((uint8_t *)(p))[3] = (uint8_t)(((uint32_t)(v)) >> 24); \ } while (0) #define unaligned_write_htole64(p, v) do { \ ((uint8_t *)(p))[0] = (uint8_t)(((uint64_t)(v)) >> 0); \ ((uint8_t *)(p))[1] = (uint8_t)(((uint64_t)(v)) >> 8); \ ((uint8_t *)(p))[2] = (uint8_t)(((uint64_t)(v)) >> 16); \ ((uint8_t *)(p))[3] = (uint8_t)(((uint64_t)(v)) >> 24); \ ((uint8_t *)(p))[4] = (uint8_t)(((uint64_t)(v)) >> 32); \ ((uint8_t *)(p))[5] = (uint8_t)(((uint64_t)(v)) >> 40); \ ((uint8_t *)(p))[6] = (uint8_t)(((uint64_t)(v)) >> 48); \ ((uint8_t *)(p))[7] = (uint8_t)(((uint64_t)(v)) >> 56); \ } while (0) #define unaligned_write_htobe16(p, v) do { \ ((uint8_t *)(p))[0] = (uint8_t)(((uint16_t)(v)) >> 8); \ ((uint8_t *)(p))[1] = (uint8_t)(((uint16_t)(v)) >> 0); \ } while (0) #define unaligned_write_htobe32(p, v) do { \ ((uint8_t *)(p))[0] = (uint8_t)(((uint32_t)(v)) >> 24); \ ((uint8_t *)(p))[1] = (uint8_t)(((uint32_t)(v)) >> 16); \ ((uint8_t *)(p))[2] = (uint8_t)(((uint32_t)(v)) >> 8); \ ((uint8_t *)(p))[3] = (uint8_t)(((uint32_t)(v)) >> 0); \ } while (0) #define unaligned_write_htobe64(p) do { \ ((uint8_t *)(p))[0] = (uint8_t)(((uint64_t)(v)) >> 56); \ ((uint8_t *)(p))[1] = (uint8_t)(((uint64_t)(v)) >> 48); \ ((uint8_t *)(p))[2] = (uint8_t)(((uint64_t)(v)) >> 40); \ ((uint8_t *)(p))[3] = (uint8_t)(((uint64_t)(v)) >> 32); \ ((uint8_t *)(p))[4] = (uint8_t)(((uint64_t)(v)) >> 24); \ ((uint8_t *)(p))[5] = (uint8_t)(((uint64_t)(v)) >> 16); \ ((uint8_t *)(p))[6] = (uint8_t)(((uint64_t)(v)) >> 8); \ ((uint8_t *)(p))[7] = (uint8_t)(((uint64_t)(v)) >> 0); \ } while (0) #if __LITTLE_ENDIAN__ #define unaligned_read_16(p) unaligned_read_le16toh(p) #define unaligned_read_32(p) unaligned_read_le32toh(p) #define unaligned_read_64(p) unaligned_read_le64toh(p) #define unaligned_write_16(p) unaligned_write_htole16(p) #define unaligned_write_32(p) unaligned_write_htole32(p) #define unaligned_write_64(p) unaligned_write_htole64(p) #endif #if __BIG_ENDIAN__ #define unaligned_read_16(p) unaligned_read_be16toh(p) #define unaligned_read_32(p) unaligned_read_be32toh(p) #define unaligned_read_64(p) unaligned_read_be64toh(p) #define unaligned_write_16(p) unaligned_write_htobe16(p) #define unaligned_write_32(p) unaligned_write_htobe32(p) #define unaligned_write_64(p) unaligned_write_htobe64(p) #endif #endif #endif #ifdef __cplusplus } #endif #endif /* PUNALIGNED_H */ nanoarrow/src/flatcc/portable/pversion.h0000644000176200001440000000027614702632113020135 0ustar liggesusers#define PORTABLE_VERSION_TEXT "0.2.6-pre" #define PORTABLE_VERSION_MAJOR 0 #define PORTABLE_VERSION_MINOR 2 #define PORTABLE_VERSION_PATCH 6 /* 1 or 0 */ #define PORTABLE_VERSION_RELEASED 0 nanoarrow/src/flatcc/portable/pdiagnostic_pop.h0000644000176200001440000000113014702632113021440 0ustar liggesusers#if defined(PDIAGNOSTIC_PUSHED_MSVC) #if PDIAGNOSTIC_PUSHED_MSVC #pragma warning( pop ) #endif // PDIAGNOSTIC_PUSHED_MSVC #undef PDIAGNOSTIC_PUSHED_MSVC #endif // defined(PDIAGNOSTIC_PUSHED_MSVC) #if defined(PDIAGNOSTIC_PUSHED_CLANG) #if PDIAGNOSTIC_PUSHED_CLANG #pragma clang diagnostic pop #endif // PDIAGNOSTIC_PUSHED_CLANG #undef PDIAGNOSTIC_PUSHED_CLANG #endif // defined(PDIAGNOSTIC_PUSHED_CLANG) #if defined(PDIAGNOSTIC_PUSHED_GCC) #if PDIAGNOSTIC_PUSHED_GCC #pragma GCC diagnostic pop #endif // PDIAGNOSTIC_PUSHED_GCC #undef PDIAGNOSTIC_PUSHED_GCC #endif // defined(PDIAGNOSTIC_PUSHED_GCC) nanoarrow/src/flatcc/portable/pmemaccess.h0000644000176200001440000002227714702632113020415 0ustar liggesusers/* * Copyright (c) 2024 Mikkel Fahnøe Jørgensen, dvide.com * * (MIT License) * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * - The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * - The Software is provided "as is", without warranty of any kind, express or * implied, including but not limited to the warranties of merchantability, * fitness for a particular purpose and noninfringement. In no event shall the * authors or copyright holders be liable for any claim, damages or other * liability, whether in an action of contract, tort or otherwise, arising from, * out of or in connection with the Software or the use or other dealings in the * Software. */ /* Provide strict aliasing safe portable access to reading and writing integer and floating point values from memory buffers of size 1, 2, 4, and 8 bytes, and optionally 16 bytes when C23 uint128_t is available. Also supports casting between integers and floats at the binary level, e.g. mem_read_float32(&myuint32), which can be necessary for endian conversions. It is often suggested to use memcpy for this purpose, that is not an ideal solution. See comments below. While this is intended to be aligned access, the strict C aliasing rules forces this to be the same as unaligned access. On x86/64 we can be more relaxed both with aliasing and alignment, but if at some point a compiler starts to modify this behaviour, the header can be updated or PORTABLE_MEM_PTR_ACCESS can be defined to 0 in the build configuration, or this file can be updated. The balance is betweem knowing memcpy or __builtin_memcpy is fast, and knowing that pointer casts do not break. Known targets that require PORTABLE_MEM_PTR_ACCESS=0 for at least some version: - ARM cross compiler: arm-none-eabi, -O2, -mcpu=cortext-m7, breaks on PORTABLE_MEM_PTR_ACCESS=0 slow memcpy, has fast __builtin_memcpy - Intel ICC -O3 on x86/64 (that compiler is deprecated by Intel). breaks on PORTABLE_MEM_PTR_ACCESS=0 has __builtin_memcpy, performance unknown, memcpy perforamnce unknown. */ /* NOTE: for best performance, `__builtin_memcpy` should be detectable, but the current detection logic is not ideal for older compilers. See below. */ #ifndef PMEMACCESS_H #define PMEMACCESS_H #ifdef __cplusplus extern "C" { #endif /* Set to 1 to see which implementation is chosen on current platform. */ #ifndef PORTABLE_MEM_ACCESS_DEBUG #define PORTABLE_MEM_ACCESS_DEBUG 0 #endif /* MEM_PTR_ACCESS (aka pointer casts) (*(T *)p) is not formally valid for strict aliasing. It works in most cases, but not always. It may be the best option for older compilers that do not optimize well and which don't care about strict aliazing. x86/64 platforms appears to work well with this, while it only sometimes work on other platforms. NOTE: this might change as compiler updates their optimization strategies. */ #ifndef PORTABLE_MEM_PTR_ACCESS #if defined(__INTEL_COMPILER) # /* Prevents Intel ICC compiler from breaking on -O3 on x86/64 target, likely due to strict aliasing rules. */ # define PORTABLE_MEM_PTR_ACCESS 0 #elif (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) # define PORTABLE_MEM_PTR_ACCESS 1 #else # define PORTABLE_MEM_PTR_ACCESS 0 #endif #endif /* PORTABLE_MEM_PTR_ACCESS */ #ifndef UINT8_MAX # include #endif /* `mem_copy_word` implements optimized non-overlapping memory copies of 1, 2, 4, 8, or 16 bytes, noting that C23 introduces uin128_t. Other sizes are not defined even if some implementation might support them. `mem_copy_word` of 16 bytes are supported even if uint128_t is not available. Ideally call `mem_copy_word` with known constant lengths for best optimization. The objective is both to support type punning where a binary representation is reinterpreted, and to read and write integers and floats safely from memory without risking undefined behaviour from strict aliasing rules. `memcpy` is supposed to handle this efficiently given small constant powers of 2, but this evidently fails on some platforms since even small constants lengths with -O2 level optimization can issue a function call. On such platforms, `__builtin_memcpy` tends to work better, if it can be detected. A pointer cast can and will, albeit uncommon, lead to undefined behaviour such as reading from uninitialized stack memory when strict aliasing is the default optimization strategy. Note: __has_builtin is not necessarily defined on platforms with __builtin_memcpy support, so detection can be improved. Feel free to contribute. Note: `mem_copy_word_` is a macro that may call `mem_copy_word` but it is guaranteed to be called with a literal length argument, so it could be redefined to forward calls to e.g. my_mem_copy_word_2 via token pasting. It is used with the `mem_read/write_nn` functions below. */ #ifndef mem_copy_word # if defined(__has_builtin) # if __has_builtin(__builtin_memcpy) # define mem_copy_word(d, s, n) __builtin_memcpy((d), (s), (n)) # if PORTABLE_MEM_ACCESS_DEBUG # error mem_copy_word using: __builtin_memcpy # endif # endif # endif #endif #ifndef mem_copy_word #include "pinline.h" #include "prestrict.h" /* Sometimes `memcpy` is a call even when optimized and given small constant length arguments, so this is more likely to be optimized. `int len` is used to avoid dependency. Also, by not using `memcpy`, we avoid depending on . As an alternative consider PORTABLE_MEM_PTR_ACCESS=1 with `mem_read/write_nn` for some older platforms that might not care about strict aliasing, and which also might not optimize well. */ static inline void mem_copy_word(void * restrict dest, const void * restrict src, int len) { char *d = (char *)dest; const char *s = (const char *)src; while(len--) *d++ = *s++; } #if PORTABLE_MEM_ACCESS_DEBUG # error mem_copy_word using: inline memcpy #endif #endif #if PORTABLE_MEM_PTR_ACCESS #define mem_read_8(p) (*(uint8_t*)(p)) #define mem_read_16(p) (*(uint16_t*)(p)) #define mem_read_32(p) (*(uint32_t*)(p)) #define mem_read_64(p) (*(uint64_t*)(p)) #define mem_write_8(p, v) ((void)(*(uint8_t*)(p) = (uint8_t)(v))) #define mem_write_16(p, v) ((void)(*(uint16_t*)(p) = (uint16_t)(v))) #define mem_write_32(p, v) ((void)(*(uint32_t*)(p) = (uint32_t)(v))) #define mem_write_64(p, v) ((void)(*(uint64_t*)(p) = (uint64_t)(v))) #define mem_read_float_32(p) (*(float*)(p)) #define mem_read_float_64(p) (*(double*)(p)) #define mem_write_float_32(p, v) ((void)(*(float*)(p) = (float)(v))) #define mem_write_float_64(p, v) ((void)(*(double*)(p) = (double)(v))) #ifdef UINT128_MAX #define mem_read_128(p) (*(uint128_t*)(p)) #define mem_write_128(p, v) ((void)(*(uint128_t*)(p) = (uint128_t)(v))) #endif #if PORTABLE_MEM_ACCESS_DEBUG # error mem_read/write_nn using: pointer cast #endif #else /* PORTABLE_MEM_PTR_ACCESS */ /* mem_copy_word_ is guaranteed to receive literal `n` arguments so operations can be optimized via token pasting if necessary. */ #ifndef mem_copy_word_ #define mem_copy_word_(d, s, n) mem_copy_word(d, s, n) #endif #define mem_read_8(p) (*(uint8_t*)(p)) #define mem_write_8(p, v) ((void)(*(uint8_t*)(p) = (uint8_t)(v))) static inline uint16_t mem_read_16(const void *p) { uint16_t v; mem_copy_word_(&v, p, 2); return v; } static inline uint32_t mem_read_32(const void *p) { uint32_t v; mem_copy_word_(&v, p, 4); return v; } static inline uint64_t mem_read_64(const void *p) { uint64_t v; mem_copy_word_(&v, p, 8); return v; } #define mem_write_16(p, v) do { const uint16_t x = (uint16_t)(v); mem_copy_word_((p), &x, 2); } while(0) #define mem_write_32(p, v) do { const uint32_t x = (uint32_t)(v); mem_copy_word_((p), &x, 4); } while(0) #define mem_write_64(p, v) do { const uint64_t x = (uint64_t)(v); mem_copy_word_((p), &x, 8); } while(0) static inline float mem_read_float_32(const void *p) { float v; mem_copy_word_(&v, p, 4); return v; } static inline double mem_read_float_64(const void *p) { double v; mem_copy_word_(&v, p, 8); return v; } #define mem_write_float_32(p, v) do { const float x = (float)(v); mem_copy_word_((p), &x, 4); } while(0) #define mem_write_float_64(p, v) do { const double x = (double)(v); mem_copy_word_((p), &x, 8); } while(0) #ifdef UINT128_MAX static inline uint128_t mem_read_128(const void *p) { uint128_t v; mem_copy_word_(&v, p, 16); return v; } #define mem_write_128(p, v) do { const uint128_t x = (uint128_t)(v); mem_copy_word_((p), &x, 128); } while(0) #endif #if PORTABLE_MEM_ACCESS_DEBUG # error mem_read/write_nn using: mem_copy_word #endif #endif /* PORTABLE_MEM_PTR_ACCESS */ #ifdef __cplusplus } #endif #endif /* PMEMACCESS_H */ nanoarrow/src/flatcc/portable/prestrict.h0000644000176200001440000000306714702632113020310 0ustar liggesusers /* * Copyright (c) 2024 Mikkel Fahnøe Jørgensen, dvide.com * * (MIT License) * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * - The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * - The Software is provided "as is", without warranty of any kind, express or * implied, including but not limited to the warranties of merchantability, * fitness for a particular purpose and noninfringement. In no event shall the * authors or copyright holders be liable for any claim, damages or other * liability, whether in an action of contract, tort or otherwise, arising from, * out of or in connection with the Software or the use or other dealings in the * Software. */ #ifndef PRESTRICT_H #define PRESTRICT_H #if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) /* C99 or newer */ #elif defined(__restrict) /* Some C/C++ compilers use alternative syntax. If these are defines, we can detect them. */ #define restrict __restrict #elif defined(__restrict__) #define restrict __restrict__ #else #define restrict #endif #endif /* PRESTRICT_H */ nanoarrow/src/flatcc/portable/pstdint.h0000644000176200001440000007313714702632113017763 0ustar liggesusers/* A portable stdint.h **************************************************************************** * BSD License: **************************************************************************** * * Copyright (c) 2005-2016 Paul Hsieh * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * **************************************************************************** * * Version 0.1.15.2 * * The ANSI C standard committee, for the C99 standard, specified the * inclusion of a new standard include file called stdint.h. This is * a very useful and long desired include file which contains several * very precise definitions for integer scalar types that is * critically important for making portable several classes of * applications including cryptography, hashing, variable length * integer libraries and so on. But for most developers its likely * useful just for programming sanity. * * The problem is that some compiler vendors chose to ignore the C99 * standard and some older compilers have no opportunity to be updated. * Because of this situation, simply including stdint.h in your code * makes it unportable. * * So that's what this file is all about. Its an attempt to build a * single universal include file that works on as many platforms as * possible to deliver what stdint.h is supposed to. Even compilers * that already come with stdint.h can use this file instead without * any loss of functionality. A few things that should be noted about * this file: * * 1) It is not guaranteed to be portable and/or present an identical * interface on all platforms. The extreme variability of the * ANSI C standard makes this an impossibility right from the * very get go. Its really only meant to be useful for the vast * majority of platforms that possess the capability of * implementing usefully and precisely defined, standard sized * integer scalars. Systems which are not intrinsically 2s * complement may produce invalid constants. * * 2) There is an unavoidable use of non-reserved symbols. * * 3) Other standard include files are invoked. * * 4) This file may come in conflict with future platforms that do * include stdint.h. The hope is that one or the other can be * used with no real difference. * * 5) In the current verison, if your platform can't represent * int32_t, int16_t and int8_t, it just dumps out with a compiler * error. * * 6) 64 bit integers may or may not be defined. Test for their * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. * Note that this is different from the C99 specification which * requires the existence of 64 bit support in the compiler. If * this is not defined for your platform, yet it is capable of * dealing with 64 bits then it is because this file has not yet * been extended to cover all of your system's capabilities. * * 7) (u)intptr_t may or may not be defined. Test for its presence * with the test: #ifdef PTRDIFF_MAX. If this is not defined * for your platform, then it is because this file has not yet * been extended to cover all of your system's capabilities, not * because its optional. * * 8) The following might not been defined even if your platform is * capable of defining it: * * WCHAR_MIN * WCHAR_MAX * (u)int64_t * PTRDIFF_MIN * PTRDIFF_MAX * (u)intptr_t * * 9) The following have not been defined: * * WINT_MIN * WINT_MAX * * 10) The criteria for defining (u)int_least(*)_t isn't clear, * except for systems which don't have a type that precisely * defined 8, 16, or 32 bit types (which this include file does * not support anyways). Default definitions have been given. * * 11) The criteria for defining (u)int_fast(*)_t isn't something I * would trust to any particular compiler vendor or the ANSI C * committee. It is well known that "compatible systems" are * commonly created that have very different performance * characteristics from the systems they are compatible with, * especially those whose vendors make both the compiler and the * system. Default definitions have been given, but its strongly * recommended that users never use these definitions for any * reason (they do *NOT* deliver any serious guarantee of * improved performance -- not in this file, nor any vendor's * stdint.h). * * 12) The following macros: * * PRINTF_INTMAX_MODIFIER * PRINTF_INT64_MODIFIER * PRINTF_INT32_MODIFIER * PRINTF_INT16_MODIFIER * PRINTF_LEAST64_MODIFIER * PRINTF_LEAST32_MODIFIER * PRINTF_LEAST16_MODIFIER * PRINTF_INTPTR_MODIFIER * * are strings which have been defined as the modifiers required * for the "d", "u" and "x" printf formats to correctly output * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, * (u)least32_t, (u)least16_t and (u)intptr_t types respectively. * PRINTF_INTPTR_MODIFIER is not defined for some systems which * provide their own stdint.h. PRINTF_INT64_MODIFIER is not * defined if INT64_MAX is not defined. These are an extension * beyond what C99 specifies must be in stdint.h. * * In addition, the following macros are defined: * * PRINTF_INTMAX_HEX_WIDTH * PRINTF_INT64_HEX_WIDTH * PRINTF_INT32_HEX_WIDTH * PRINTF_INT16_HEX_WIDTH * PRINTF_INT8_HEX_WIDTH * PRINTF_INTMAX_DEC_WIDTH * PRINTF_INT64_DEC_WIDTH * PRINTF_INT32_DEC_WIDTH * PRINTF_INT16_DEC_WIDTH * PRINTF_UINT8_DEC_WIDTH * PRINTF_UINTMAX_DEC_WIDTH * PRINTF_UINT64_DEC_WIDTH * PRINTF_UINT32_DEC_WIDTH * PRINTF_UINT16_DEC_WIDTH * PRINTF_UINT8_DEC_WIDTH * * Which specifies the maximum number of characters required to * print the number of that type in either hexadecimal or decimal. * These are an extension beyond what C99 specifies must be in * stdint.h. * * Compilers tested (all with 0 warnings at their highest respective * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 * * This file should be considered a work in progress. Suggestions for * improvements, especially those which increase coverage are strongly * encouraged. * * Acknowledgements * * The following people have made significant contributions to the * development and testing of this file: * * Chris Howie * John Steele Scott * Dave Thorup * John Dill * Florian Wobbe * Christopher Sean Morrison * Mikkel Fahnoe Jorgensen * */ #include #include #include /* * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. */ #if ((defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED) #include #define _PSTDINT_H_INCLUDED # if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__)) # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "l" # endif # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif # else # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # ifndef PRINTF_INT32_MODIFIER # if (UINT_MAX == UINT32_MAX) # define PRINTF_INT32_MODIFIER "" # else # define PRINTF_INT32_MODIFIER "l" # endif # endif # endif # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "h" # endif # ifndef PRINTF_INTMAX_MODIFIER # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER # endif # ifndef PRINTF_INT64_HEX_WIDTH # define PRINTF_INT64_HEX_WIDTH "16" # endif # ifndef PRINTF_UINT64_HEX_WIDTH # define PRINTF_UINT64_HEX_WIDTH "16" # endif # ifndef PRINTF_INT32_HEX_WIDTH # define PRINTF_INT32_HEX_WIDTH "8" # endif # ifndef PRINTF_UINT32_HEX_WIDTH # define PRINTF_UINT32_HEX_WIDTH "8" # endif # ifndef PRINTF_INT16_HEX_WIDTH # define PRINTF_INT16_HEX_WIDTH "4" # endif # ifndef PRINTF_UINT16_HEX_WIDTH # define PRINTF_UINT16_HEX_WIDTH "4" # endif # ifndef PRINTF_INT8_HEX_WIDTH # define PRINTF_INT8_HEX_WIDTH "2" # endif # ifndef PRINTF_UINT8_HEX_WIDTH # define PRINTF_UINT8_HEX_WIDTH "2" # endif # ifndef PRINTF_INT64_DEC_WIDTH # define PRINTF_INT64_DEC_WIDTH "19" # endif # ifndef PRINTF_UINT64_DEC_WIDTH # define PRINTF_UINT64_DEC_WIDTH "20" # endif # ifndef PRINTF_INT32_DEC_WIDTH # define PRINTF_INT32_DEC_WIDTH "10" # endif # ifndef PRINTF_UINT32_DEC_WIDTH # define PRINTF_UINT32_DEC_WIDTH "10" # endif # ifndef PRINTF_INT16_DEC_WIDTH # define PRINTF_INT16_DEC_WIDTH "5" # endif # ifndef PRINTF_UINT16_DEC_WIDTH # define PRINTF_UINT16_DEC_WIDTH "5" # endif # ifndef PRINTF_INT8_DEC_WIDTH # define PRINTF_INT8_DEC_WIDTH "3" # endif # ifndef PRINTF_UINT8_DEC_WIDTH # define PRINTF_UINT8_DEC_WIDTH "3" # endif # ifndef PRINTF_INTMAX_HEX_WIDTH # define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH # endif # ifndef PRINTF_UINTMAX_HEX_WIDTH # define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH # endif # ifndef PRINTF_INTMAX_DEC_WIDTH # define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH # endif # ifndef PRINTF_UINTMAX_DEC_WIDTH # define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH # endif /* * Something really weird is going on with Open Watcom. Just pull some of * these duplicated definitions from Open Watcom's stdint.h file for now. */ # if defined (__WATCOMC__) && __WATCOMC__ >= 1250 # if !defined (INT64_C) # define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) # endif # if !defined (UINT64_C) # define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) # endif # if !defined (INT32_C) # define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) # endif # if !defined (UINT32_C) # define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) # endif # if !defined (INT16_C) # define INT16_C(x) (x) # endif # if !defined (UINT16_C) # define UINT16_C(x) (x) # endif # if !defined (INT8_C) # define INT8_C(x) (x) # endif # if !defined (UINT8_C) # define UINT8_C(x) (x) # endif # if !defined (UINT64_MAX) # define UINT64_MAX 18446744073709551615ULL # endif # if !defined (INT64_MAX) # define INT64_MAX 9223372036854775807LL # endif # if !defined (UINT32_MAX) # define UINT32_MAX 4294967295UL # endif # if !defined (INT32_MAX) # define INT32_MAX 2147483647L # endif # if !defined (INTMAX_MAX) # define INTMAX_MAX INT64_MAX # endif # if !defined (INTMAX_MIN) # define INTMAX_MIN INT64_MIN # endif # endif #endif #ifndef _PSTDINT_H_INCLUDED #define _PSTDINT_H_INCLUDED #ifndef SIZE_MAX # define SIZE_MAX (~(size_t)0) #endif /* * Deduce the type assignments from limits.h under the assumption that * integer sizes in bits are powers of 2, and follow the ANSI * definitions. */ #ifndef UINT8_MAX # define UINT8_MAX 0xff #endif #if !defined(uint8_t) && !defined(_UINT8_T) # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) typedef unsigned char uint8_t; # define UINT8_C(v) ((uint8_t) v) # else # error "Platform not supported" # endif #endif #ifndef INT8_MAX # define INT8_MAX 0x7f #endif #ifndef INT8_MIN # define INT8_MIN INT8_C(0x80) #endif #if !defined(int8_t) && !defined(_INT8_T) # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) typedef signed char int8_t; # define INT8_C(v) ((int8_t) v) # else # error "Platform not supported" # endif #endif #ifndef UINT16_MAX # define UINT16_MAX 0xffff #endif #if !defined(uint16_t) && !defined(_UINT16_T) #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) typedef unsigned int uint16_t; # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "" # endif # define UINT16_C(v) ((uint16_t) (v)) #elif (USHRT_MAX == UINT16_MAX) typedef unsigned short uint16_t; # define UINT16_C(v) ((uint16_t) (v)) # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "h" # endif #else #error "Platform not supported" #endif #endif #ifndef INT16_MAX # define INT16_MAX 0x7fff #endif #ifndef INT16_MIN # define INT16_MIN INT16_C(0x8000) #endif #if !defined(int16_t) && !defined(_INT16_T) #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) typedef signed int int16_t; # define INT16_C(v) ((int16_t) (v)) # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "" # endif #elif (SHRT_MAX == INT16_MAX) typedef signed short int16_t; # define INT16_C(v) ((int16_t) (v)) # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "h" # endif #else #error "Platform not supported" #endif #endif #ifndef UINT32_MAX # define UINT32_MAX (0xffffffffUL) #endif #if !defined(uint32_t) && !defined(_UINT32_T) #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) typedef unsigned long uint32_t; # define UINT32_C(v) v ## UL # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "l" # endif #elif (UINT_MAX == UINT32_MAX) typedef unsigned int uint32_t; # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif # define UINT32_C(v) v ## U #elif (USHRT_MAX == UINT32_MAX) typedef unsigned short uint32_t; # define UINT32_C(v) ((unsigned short) (v)) # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif #else #error "Platform not supported" #endif #endif #ifndef INT32_MAX # define INT32_MAX (0x7fffffffL) #endif #ifndef INT32_MIN # define INT32_MIN INT32_C(0x80000000) #endif #if !defined(int32_t) && !defined(_INT32_T) #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) typedef signed long int32_t; # define INT32_C(v) v ## L # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "l" # endif #elif (INT_MAX == INT32_MAX) typedef signed int int32_t; # define INT32_C(v) v # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif #elif (SHRT_MAX == INT32_MAX) typedef signed short int32_t; # define INT32_C(v) ((short) (v)) # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif #else #error "Platform not supported" #endif #endif /* * The macro stdint_int64_defined is temporarily used to record * whether or not 64 integer support is available. It must be * defined for any 64 integer extensions for new platforms that are * added. */ #undef stdint_int64_defined #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) # if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S) # define stdint_int64_defined typedef long long int64_t; typedef unsigned long long uint64_t; # define UINT64_C(v) v ## ULL # define INT64_C(v) v ## LL # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # endif #endif #if !defined (stdint_int64_defined) # if defined(__GNUC__) # define stdint_int64_defined __extension__ typedef long long int64_t; __extension__ typedef unsigned long long uint64_t; # define UINT64_C(v) v ## ULL # define INT64_C(v) v ## LL # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) # define stdint_int64_defined typedef long long int64_t; typedef unsigned long long uint64_t; # define UINT64_C(v) v ## ULL # define INT64_C(v) v ## LL # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) # define stdint_int64_defined typedef __int64 int64_t; typedef unsigned __int64 uint64_t; # define UINT64_C(v) v ## UI64 # define INT64_C(v) v ## I64 # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "I64" # endif # endif #endif #if !defined (LONG_LONG_MAX) && defined (INT64_C) # define LONG_LONG_MAX INT64_C (9223372036854775807) #endif #ifndef ULONG_LONG_MAX # define ULONG_LONG_MAX UINT64_C (18446744073709551615) #endif #if !defined (INT64_MAX) && defined (INT64_C) # define INT64_MAX INT64_C (9223372036854775807) #endif #if !defined (INT64_MIN) && defined (INT64_C) # define INT64_MIN INT64_C (-9223372036854775808) #endif #if !defined (UINT64_MAX) && defined (INT64_C) # define UINT64_MAX UINT64_C (18446744073709551615) #endif /* * Width of hexadecimal for number field. */ #ifndef PRINTF_INT64_HEX_WIDTH # define PRINTF_INT64_HEX_WIDTH "16" #endif #ifndef PRINTF_INT32_HEX_WIDTH # define PRINTF_INT32_HEX_WIDTH "8" #endif #ifndef PRINTF_INT16_HEX_WIDTH # define PRINTF_INT16_HEX_WIDTH "4" #endif #ifndef PRINTF_INT8_HEX_WIDTH # define PRINTF_INT8_HEX_WIDTH "2" #endif #ifndef PRINTF_INT64_DEC_WIDTH # define PRINTF_INT64_DEC_WIDTH "19" #endif #ifndef PRINTF_INT32_DEC_WIDTH # define PRINTF_INT32_DEC_WIDTH "10" #endif #ifndef PRINTF_INT16_DEC_WIDTH # define PRINTF_INT16_DEC_WIDTH "5" #endif #ifndef PRINTF_INT8_DEC_WIDTH # define PRINTF_INT8_DEC_WIDTH "3" #endif #ifndef PRINTF_UINT64_DEC_WIDTH # define PRINTF_UINT64_DEC_WIDTH "20" #endif #ifndef PRINTF_UINT32_DEC_WIDTH # define PRINTF_UINT32_DEC_WIDTH "10" #endif #ifndef PRINTF_UINT16_DEC_WIDTH # define PRINTF_UINT16_DEC_WIDTH "5" #endif #ifndef PRINTF_UINT8_DEC_WIDTH # define PRINTF_UINT8_DEC_WIDTH "3" #endif /* * Ok, lets not worry about 128 bit integers for now. Moore's law says * we don't need to worry about that until about 2040 at which point * we'll have bigger things to worry about. */ #ifdef stdint_int64_defined typedef int64_t intmax_t; typedef uint64_t uintmax_t; # define INTMAX_MAX INT64_MAX # define INTMAX_MIN INT64_MIN # define UINTMAX_MAX UINT64_MAX # define UINTMAX_C(v) UINT64_C(v) # define INTMAX_C(v) INT64_C(v) # ifndef PRINTF_INTMAX_MODIFIER # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER # endif # ifndef PRINTF_INTMAX_HEX_WIDTH # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH # endif # ifndef PRINTF_INTMAX_DEC_WIDTH # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH # endif #else typedef int32_t intmax_t; typedef uint32_t uintmax_t; # define INTMAX_MAX INT32_MAX # define UINTMAX_MAX UINT32_MAX # define UINTMAX_C(v) UINT32_C(v) # define INTMAX_C(v) INT32_C(v) # ifndef PRINTF_INTMAX_MODIFIER # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER # endif # ifndef PRINTF_INTMAX_HEX_WIDTH # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH # endif # ifndef PRINTF_INTMAX_DEC_WIDTH # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH # endif #endif /* * Because this file currently only supports platforms which have * precise powers of 2 as bit sizes for the default integers, the * least definitions are all trivial. Its possible that a future * version of this file could have different definitions. */ #ifndef stdint_least_defined typedef int8_t int_least8_t; typedef uint8_t uint_least8_t; typedef int16_t int_least16_t; typedef uint16_t uint_least16_t; typedef int32_t int_least32_t; typedef uint32_t uint_least32_t; # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER # define UINT_LEAST8_MAX UINT8_MAX # define INT_LEAST8_MAX INT8_MAX # define UINT_LEAST16_MAX UINT16_MAX # define INT_LEAST16_MAX INT16_MAX # define UINT_LEAST32_MAX UINT32_MAX # define INT_LEAST32_MAX INT32_MAX # define INT_LEAST8_MIN INT8_MIN # define INT_LEAST16_MIN INT16_MIN # define INT_LEAST32_MIN INT32_MIN # ifdef stdint_int64_defined typedef int64_t int_least64_t; typedef uint64_t uint_least64_t; # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER # define UINT_LEAST64_MAX UINT64_MAX # define INT_LEAST64_MAX INT64_MAX # define INT_LEAST64_MIN INT64_MIN # endif #endif #undef stdint_least_defined /* * The ANSI C committee pretending to know or specify anything about * performance is the epitome of misguided arrogance. The mandate of * this file is to *ONLY* ever support that absolute minimum * definition of the fast integer types, for compatibility purposes. * No extensions, and no attempt to suggest what may or may not be a * faster integer type will ever be made in this file. Developers are * warned to stay away from these types when using this or any other * stdint.h. */ typedef int_least8_t int_fast8_t; typedef uint_least8_t uint_fast8_t; typedef int_least16_t int_fast16_t; typedef uint_least16_t uint_fast16_t; typedef int_least32_t int_fast32_t; typedef uint_least32_t uint_fast32_t; #define UINT_FAST8_MAX UINT_LEAST8_MAX #define INT_FAST8_MAX INT_LEAST8_MAX #define UINT_FAST16_MAX UINT_LEAST16_MAX #define INT_FAST16_MAX INT_LEAST16_MAX #define UINT_FAST32_MAX UINT_LEAST32_MAX #define INT_FAST32_MAX INT_LEAST32_MAX #define INT_FAST8_MIN INT_LEAST8_MIN #define INT_FAST16_MIN INT_LEAST16_MIN #define INT_FAST32_MIN INT_LEAST32_MIN #ifdef stdint_int64_defined typedef int_least64_t int_fast64_t; typedef uint_least64_t uint_fast64_t; # define UINT_FAST64_MAX UINT_LEAST64_MAX # define INT_FAST64_MAX INT_LEAST64_MAX # define INT_FAST64_MIN INT_LEAST64_MIN #endif #undef stdint_int64_defined /* * Whatever piecemeal, per compiler thing we can do about the wchar_t * type limits. */ #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) # include # ifndef WCHAR_MIN # define WCHAR_MIN 0 # endif # ifndef WCHAR_MAX # define WCHAR_MAX ((wchar_t)-1) # endif #endif /* * Whatever piecemeal, per compiler/platform thing we can do about the * (u)intptr_t types and limits. */ #if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T) # define STDINT_H_UINTPTR_T_DEFINED #endif #ifndef STDINT_H_UINTPTR_T_DEFINED # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__) # define stdint_intptr_bits 64 # elif defined (__WATCOMC__) || defined (__TURBOC__) # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) # define stdint_intptr_bits 16 # else # define stdint_intptr_bits 32 # endif # elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__) # define stdint_intptr_bits 32 # elif defined (__INTEL_COMPILER) /* TODO -- what did Intel do about x86-64? */ # else /* #error "This platform might not be supported yet" */ # endif # ifdef stdint_intptr_bits # define stdint_intptr_glue3_i(a,b,c) a##b##c # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) # ifndef PRINTF_INTPTR_MODIFIER # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) # endif # ifndef PTRDIFF_MAX # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) # endif # ifndef PTRDIFF_MIN # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) # endif # ifndef UINTPTR_MAX # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) # endif # ifndef INTPTR_MAX # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) # endif # ifndef INTPTR_MIN # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) # endif # ifndef INTPTR_C # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) # endif # ifndef UINTPTR_C # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) # endif typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; # else /* TODO -- This following is likely wrong for some platforms, and does nothing for the definition of uintptr_t. */ typedef ptrdiff_t intptr_t; # endif # define STDINT_H_UINTPTR_T_DEFINED #endif /* * Assumes sig_atomic_t is signed and we have a 2s complement machine. */ #ifndef SIG_ATOMIC_MAX # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) #endif #endif #if defined (__TEST_PSTDINT_FOR_CORRECTNESS) /* * Please compile with the maximum warning settings to make sure macros are * not defined more than once. */ #include #include #include #define glue3_aux(x,y,z) x ## y ## z #define glue3(x,y,z) glue3_aux(x,y,z) #define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0); #define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0); #define DECL(us,bits) glue3(DECL,us,) (bits) #define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits) #define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; } int main () { int err_n = 0; int err_first = 0; DECL(I,8) DECL(U,8) DECL(I,16) DECL(U,16) DECL(I,32) DECL(U,32) #ifdef INT64_MAX DECL(I,64) DECL(U,64) #endif intmax_t imax = INTMAX_C(0); uintmax_t umax = UINTMAX_C(0); char str0[256], str1[256]; sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647)); if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH)); sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295)); if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH)); #ifdef INT64_MAX sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807)); if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1))); sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591)); if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1))); #endif sprintf (str0, "%d %x\n", 0, ~0); sprintf (str1, "%d %x\n", i8, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1)); sprintf (str1, "%u %x\n", u8, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1)); sprintf (str1, "%d %x\n", i16, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1)); sprintf (str1, "%u %x\n", u16, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1)); sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1)); sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1)); #ifdef INT64_MAX sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1)); #endif sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1)); sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1)); TESTUMAX(8); TESTUMAX(16); TESTUMAX(32); #ifdef INT64_MAX TESTUMAX(64); #endif #define STR(v) #v #define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v)); if (err_n) { printf ("pstdint.h is not correct. Please use sizes below to correct it:\n"); } Q(int) Q(unsigned) Q(long int) Q(short int) Q(int8_t) Q(int16_t) Q(int32_t) #ifdef INT64_MAX Q(int64_t) #endif return EXIT_SUCCESS; } #endif nanoarrow/src/flatcc/flatcc_rtconfig.h0000644000176200001440000001227414702632113017610 0ustar liggesusers#ifndef FLATCC_RTCONFIG_H #define FLATCC_RTCONFIG_H #ifdef __cplusplus extern "C" { #endif /* Include portability layer here since all other files depend on it. */ #ifdef FLATCC_PORTABLE #include "flatcc/portable/portable.h" #endif /* * Fast printing and parsing of double. * * This requires the grisu3/grisu3_* files to be in the include path, * otherwise strod and sprintf will be used (these needed anyway * as fallback for cases not supported by grisu3). */ #ifndef FLATCC_USE_GRISU3 #define FLATCC_USE_GRISU3 1 #endif /* * This requires compiler that has enabled marc=native or similar so * __SSE4_2__ flag is defined. Otherwise it will have no effect. * * While SSE may be used for different purposes, it has (as of this * writing) only be used to test the effect on JSON whitespace handling * which improved, but not by a lot, assuming 64-bit unligned access is * otherwise available: * * With 8 space indentation, the JSON benchmark handles 308K parse ops/sec * while SSE ups that to 333 parse ops/sec or 336 if \r\n is also * consumed by SSE. Disabling indentation leaves SSE spacing handling * ineffective, and performance reaches 450K parse ops/sec and can * improve further to 500+K parse ops/sec if inexact GRISU3 numbers are * allowed (they are pretty accurate anyway, just not exact). This * feature requires hacking a flag direct in the grisu3 double parsing * lib directly and only mentioned for comparison. * * In conclusion SSE doesn't add a lot to JSON space handling at least. * * Disabled by default, but can be overriden by build system. */ #ifndef FLATCC_USE_SSE4_2 #define FLATCC_USE_SSE4_2 0 #endif /* * The verifier only reports yes and no. The following setting * enables assertions in debug builds. It must be compiled into * the runtime library and is not normally the desired behavior. * * NOTE: enabling this can break test cases so use with build, not test. */ #if !defined(FLATCC_DEBUG_VERIFY) && !defined(NDEBUG) #define FLATCC_DEBUG_VERIFY 0 #endif #if !defined(FLATCC_TRACE_VERIFY) #define FLATCC_TRACE_VERIFY 0 #endif /* * Some producers allow empty vectors to be misaligned. * The following setting will cause the verifier to require the index 0 * position to be element aligned even if the vector is empty (otherwise that * position is only required to be aligned to the preceding size field). */ #if !defined(FLATCC_ENFORCE_ALIGNED_EMPTY_VECTORS) #define FLATCC_ENFORCE_ALIGNED_EMPTY_VECTORS 0 #endif /* * Limit recursion level for tables. Actual level may be deeper * when structs are deeply nested - but these are limited by the * schema compiler. */ #ifndef FLATCC_JSON_PRINT_MAX_LEVELS #define FLATCC_JSON_PRINT_MAX_LEVELS 100 #endif /* Maximum length of names printed exluding _type suffix. */ #ifndef FLATCC_JSON_PRINT_NAME_LEN_MAX #define FLATCC_JSON_PRINT_NAME_LEN_MAX 100 #endif /* * Print float and double values with C99 hexadecimal floating point * notation. This option is not valid JSON but it avoids precision * loss, correctly handles NaN, +/-Infinity and is significantly faster * to parse and print. Some JSON parsers rely on strtod which does * support hexadecimal floating points when C99 compliant. */ #ifndef FLATCC_JSON_PRINT_HEX_FLOAT #define FLATCC_JSON_PRINT_HEX_FLOAT 0 #endif /* * Always print multipe enum flags like `color: "Red Green"` * even when unquote is selected as an option for single * value like `color: Green`. Otherwise multiple values * are printed as `color: Red Green`, but this could break * some flatbuffer json parser. */ #ifndef FLATCC_JSON_PRINT_ALWAYS_QUOTE_MULTIPLE_FLAGS #define FLATCC_JSON_PRINT_ALWAYS_QUOTE_MULTIPLE_FLAGS 1 #endif /* * The general nesting limit may be lower, but for skipping * JSON we do not need to - we can set this high as it only * costs a single char per level in a stack array. */ #ifndef FLATCC_JSON_PARSE_GENERIC_MAX_NEST #define FLATCC_JSON_PARSE_GENERIC_MAX_NEST 512 #endif /* Store value even if it is default. */ #ifndef FLATCC_JSON_PARSE_FORCE_DEFAULTS #define FLATCC_JSON_PARSE_FORCE_DEFAULTS 0 #endif #ifndef FLATCC_JSON_PARSE_ALLOW_UNQUOTED #define FLATCC_JSON_PARSE_ALLOW_UNQUOTED 1 #endif /* * Multiple enum values are by default not permitted unless * quoted like `color: "Red Green" as per Googles flatc JSON * parser while a single value like `color: Red` can be * unquoted. Enabling this setting will allow `color: Red * Green`, but only if FLATCC_JSON_PARSE_ALLOW_UNQUOTED is * also enabled. */ #ifndef FLATCC_JSON_PARSE_ALLOW_UNQUOTED_LIST #define FLATCC_JSON_PARSE_ALLOW_UNQUOTED_LIST 0 #endif #ifndef FLATCC_JSON_PARSE_ALLOW_UNKNOWN_FIELD #define FLATCC_JSON_PARSE_ALLOW_UNKNOWN_FIELD 1 #endif #ifndef FLATCC_JSON_PARSE_ALLOW_TRAILING_COMMA #define FLATCC_JSON_PARSE_ALLOW_TRAILING_COMMA 1 #endif /* * Just parse to the closing bracket '}' if set. * Otherwise parse to end by consuming space and * fail if anything but space follows. */ #ifndef FLATCC_PARSE_IGNORE_TRAILING_DATA #define FLATCC_PARSE_IGNORE_TRAILING_DATA 0 #endif /* * Optimize to parse a lot of white space, but * in most cases it probably slows parsing down. */ #ifndef FLATCC_JSON_PARSE_WIDE_SPACE #define FLATCC_JSON_PARSE_WIDE_SPACE 0 #endif #ifdef __cplusplus } #endif #endif /* FLATCC_RTCONFIG_H */ nanoarrow/src/flatcc/flatcc_types.h0000644000176200001440000000602314702632113017134 0ustar liggesusers#ifndef FLATCC_TYPES_H #define FLATCC_TYPES_H #ifdef __cplusplus extern "C" { #endif #include #ifndef UINT8_MAX #include #endif /* * This should match generated type declaratios in * `flatbuffers_common_reader.h` (might have different name prefix). * Read only generated code does not depend on library code, * hence the duplication. */ #ifndef flatbuffers_types_defined #define flatbuffers_types_defined /* * uoffset_t and soffset_t must be same integer type, except for sign. * They can be (u)int16_t, (u)int32_t, or (u)int64_t. * The default is (u)int32_t. * * voffset_t is expected to be uint16_t, but can experimentally be * compiled from uint8_t up to uint32_t. * * ID_MAX is the largest value that can index a vtable. The table size * is given as voffset value. Each id represents a voffset value index * from 0 to max inclusive. Space is required for two header voffset * fields and the unaddressible highest index (due to the table size * representation). For 16-bit voffsets this yields a max of 2^15 - 4, * or (2^16 - 1) / 2 - 3. */ #define flatbuffers_uoffset_t_defined #define flatbuffers_soffset_t_defined #define flatbuffers_voffset_t_defined #define flatbuffers_utype_t_defined #define flatbuffers_bool_t_defined #define flatbuffers_thash_t_defined #define flatbuffers_fid_t_defined /* uoffset_t is also used for vector and string headers. */ #define FLATBUFFERS_UOFFSET_MAX UINT32_MAX #define FLATBUFFERS_SOFFSET_MAX INT32_MAX #define FLATBUFFERS_SOFFSET_MIN INT32_MIN #define FLATBUFFERS_VOFFSET_MAX UINT16_MAX #define FLATBUFFERS_UTYPE_MAX UINT8_MAX /* Well - the max of the underlying type. */ #define FLATBUFFERS_BOOL_MAX UINT8_MAX #define FLATBUFFERS_THASH_MAX UINT32_MAX #define FLATBUFFERS_ID_MAX (FLATBUFFERS_VOFFSET_MAX / sizeof(flatbuffers_voffset_t) - 3) /* Vectors of empty structs can yield div by zero, so we must guard against this. */ #define FLATBUFFERS_COUNT_MAX(elem_size) (FLATBUFFERS_UOFFSET_MAX/((elem_size) == 0 ? 1 : (elem_size))) #define FLATBUFFERS_UOFFSET_WIDTH 32 #define FLATBUFFERS_COUNT_WIDTH 32 #define FLATBUFFERS_SOFFSET_WIDTH 32 #define FLATBUFFERS_VOFFSET_WIDTH 16 #define FLATBUFFERS_UTYPE_WIDTH 8 #define FLATBUFFERS_BOOL_WIDTH 8 #define FLATBUFFERS_THASH_WIDTH 32 #define FLATBUFFERS_TRUE 1 #define FLATBUFFERS_FALSE 0 #define FLATBUFFERS_PROTOCOL_IS_LE 1 #define FLATBUFFERS_PROTOCOL_IS_BE 0 typedef uint32_t flatbuffers_uoffset_t; typedef int32_t flatbuffers_soffset_t; typedef uint16_t flatbuffers_voffset_t; typedef uint8_t flatbuffers_utype_t; typedef uint8_t flatbuffers_bool_t; typedef uint32_t flatbuffers_thash_t; /* Public facing type operations. */ typedef flatbuffers_utype_t flatbuffers_union_type_t; static const flatbuffers_bool_t flatbuffers_true = FLATBUFFERS_TRUE; static const flatbuffers_bool_t flatbuffers_false = FLATBUFFERS_FALSE; #define FLATBUFFERS_IDENTIFIER_SIZE (FLATBUFFERS_THASH_WIDTH / 8) typedef char flatbuffers_fid_t[FLATBUFFERS_IDENTIFIER_SIZE]; #endif /* flatbuffers_types_defined */ #ifdef __cplusplus } #endif #endif /* FLATCC_TYPES_H */ nanoarrow/src/flatcc/flatcc_prologue.h0000644000176200001440000000024514702632113017624 0ustar liggesusers/* Include guard intentionally left out. */ #define PDIAGNOSTIC_IGNORE_UNUSED #include "flatcc/portable/pdiagnostic_push.h" #ifdef __cplusplus extern "C" { #endif nanoarrow/src/flatcc/flatcc_identifier.h0000644000176200001440000001125214702632113020112 0ustar liggesusers#ifndef FLATCC_IDENTIFIER_H #define FLATCC_IDENTIFIER_H #ifdef __cplusplus extern "C" { #endif #ifndef FLATCC_FLATBUFFERS_H #error "include via flatcc/flatcc_flatbuffers.h" #endif #ifndef UINT8_MAX #include #endif /* * FlatBuffers identifiers are normally specified by "file_identifer" in * the schema, but a standard hash of the fully qualified type name can * also be used. This file implements such a mapping, but the generated * headers also contain the necessary information for known types. */ /* * Returns the type hash of a given name in native endian format. * Generated code already provides these, but if a name was changed * in the schema it may be relevant to recompute the hash manually. * * The wire-format of this value should always be little endian. * * Note: this must be the fully qualified name, e.g. in the namespace * "MyGame.Example": * * flatbuffers_type_hash_from_name("MyGame.Example.Monster"); * * or, in the global namespace just: * * flatbuffers_type_hash_from_name("MyTable"); * * This assumes 32 bit hash type. For other sizes, other FNV-1a * constants would be required. * * Note that we reserve hash value 0 for missing or ignored value. */ static inline flatbuffers_thash_t flatbuffers_type_hash_from_name(const char *name) { uint32_t hash = UINT32_C(2166136261); while (*name) { hash ^= (unsigned char)*name; hash = hash * UINT32_C(16777619); ++name; } if (hash == 0) { hash = UINT32_C(2166136261); } return hash; } /* * Type hash encoded as little endian file identifier string. * Note: if type hash is 0, the identifier should be null which * we cannot return in this interface. */ static inline void flatbuffers_identifier_from_type_hash(flatbuffers_thash_t type_hash, flatbuffers_fid_t out_identifier) { out_identifier[0] = (char)(type_hash & 0xff); type_hash >>= 8; out_identifier[1] = (char)(type_hash & 0xff); type_hash >>= 8; out_identifier[2] = (char)(type_hash & 0xff); type_hash >>= 8; out_identifier[3] = (char)(type_hash & 0xff); } /* Native integer encoding of file identifier. */ static inline flatbuffers_thash_t flatbuffers_type_hash_from_identifier(const flatbuffers_fid_t identifier) { uint8_t *p = (uint8_t *)identifier; return identifier ? (uint32_t)p[0] + (((uint32_t)p[1]) << 8) + (((uint32_t)p[2]) << 16) + (((uint32_t)p[3]) << 24) : 0; } /* * Convert a null terminated string identifier like "MONS" or "X" into a * native type hash identifier, usually for comparison. This will not * work with type hash strings because they can contain null bytes. */ static inline flatbuffers_thash_t flatbuffers_type_hash_from_string(const char *identifier) { flatbuffers_thash_t h = 0; const uint8_t *p = (const uint8_t *)identifier; if (!p[0]) return h; h += ((flatbuffers_thash_t)p[0]); if (!p[1]) return h; h += ((flatbuffers_thash_t)p[1]) << 8; if (!p[2]) return h; h += ((flatbuffers_thash_t)p[2]) << 16; /* No need to test for termination here. */ h += ((flatbuffers_thash_t)p[3]) << 24; return h; } /* * Computes the little endian wire format of the type hash. It can be * used as a file identifer argument to various flatcc buffer calls. * * `flatbuffers_fid_t` is just `char [4]` for the default flatbuffers * type system defined in `flatcc/flatcc_types.h`. */ static inline void flatbuffers_identifier_from_name(const char *name, flatbuffers_fid_t out_identifier) { flatbuffers_identifier_from_type_hash(flatbuffers_type_hash_from_name(name), out_identifier); } /* * This is a collision free hash (a permutation) of the type hash to * provide better distribution for use in hash tables. It is likely not * necessary in praxis, and for uniqueness of identifiers it provides no * advantage over just using the FNV-1a type hash, except when truncating * the identifier to less than 32-bits. * * Note: the output should not be used in transmission. It provides no * additional information and just complicates matters. Furthermore, the * unmodified type hash has the benefit that it can seed a child namespace. */ static inline uint32_t flatbuffers_disperse_type_hash(flatbuffers_thash_t type_hash) { /* http://stackoverflow.com/a/12996028 */ uint32_t x = type_hash; x = ((x >> 16) ^ x) * UINT32_C(0x45d9f3b); x = ((x >> 16) ^ x) * UINT32_C(0x45d9f3b); x = ((x >> 16) ^ x); return x; } /* We have hardcoded assumptions about identifier size. */ static_assert(sizeof(flatbuffers_fid_t) == 4, "unexpected file identifier size"); static_assert(sizeof(flatbuffers_thash_t) == 4, "unexpected type hash size"); #ifdef __cplusplus } #endif #endif /* FLATCC_IDENTIFIER_H */ nanoarrow/src/flatcc/flatcc_portable.h0000644000176200001440000000030614702632113017576 0ustar liggesusers#ifndef FLATCC_PORTABLE_H #define FLATCC_PORTABLE_H #ifdef __cplusplus extern "C" { #endif #include "flatcc/portable/portable_basic.h" #ifdef __cplusplus } #endif #endif /* FLATCC_PORTABLE_H */ nanoarrow/src/flatcc/flatcc_builder.h0000644000176200001440000023425614702632113017431 0ustar liggesusers#ifndef FLATCC_BUILDER_H #define FLATCC_BUILDER_H #ifdef __cplusplus extern "C" { #endif /** * Library for building untyped FlatBuffers. Intended as a support * library for generated C code to produce typed builders, but might * also be useful in runtime environments and as support for scripting * languages. * * The builder has two API layers: a stack based `start/end` approach, * and a direct `create`, and they may be mixed freely. The direct * approach may be used as part of more specialized optimizations such * as rewriting buffers while the stack approach is convenient for state * machine driven parsers without a stack, or with a very simple stack * without extra allocations. * * The builder emits partial buffer sequences to a user provided emitter * function and does not require a full buffer reprensenation in memory. * For this reason it also does not support sorting or other operations * that requires representing the buffer, but post-processors can easily * do this, and the generated schema specific code and provide functions * to handle this. * * A custom allocator with a default realloc implementation can place * restraints on resource consumption and provide initial allocation * sizes for various buffers and stacks in use. * * A buffer under construction uses a virtual address space for the * completed part of the buffer, starting at 0 and growing in both * directions, or just down depending on whether vtables should be * clustered at the end or not. Clustering may help caching and * preshipping that part of the buffer. * * Because an offset cannot be known before its reference location is * defined, every completed table, vector, etc. returns a reference into * the virtual address range. If the final buffer keeps the 0 offset, * these references remain stable an may be used for external references * into the buffer. * * The maximum buffer that can be constructed is in praxis limited to * half the UOFFSET_MAX size, typically 2^31 bytes, not counting * clustered vtables that may consume and additional 2^31 bytes * (positive address range), but in praxis cannot because vtable * references are signed and thus limited to 2^31 bytes (or equivalent * depending on the flatbuffer types chosen). * * CORRECTION: in various places rules are mentioned about nesting and using * a reference at most once. In fact, DAG's are also valid flatbuffers. * This means a reference may be reused as long as each individual use * obeys the rules and, for example, circular references are not * constructed (circular types are ok, but objects graphs with cycles * are not permitted). Be especially aware of the offset vector create * call which translates the references into offsets - this can be * reverted by noting the reference in vector and calculate the base * used for the offset to restore the original references after the * vector has been emitted. */ #include #ifndef UINT8_MAX #include #endif #include "flatcc_flatbuffers.h" #include "flatcc_emitter.h" #include "flatcc_refmap.h" /* It is possible to enable logging here. */ #ifndef FLATCC_BUILDER_ASSERT #define FLATCC_BUILDER_ASSERT(cond, reason) FLATCC_ASSERT(cond) #endif /* * Eror handling is not convenient and correct use should not cause * errors beyond possibly memory allocation, but assertions are a * good way to trace problems. * * Note: some internal assertion will remain if disabled. */ #ifndef FLATCC_BUILDER_ASSERT_ON_ERROR #define FLATCC_BUILDER_ASSERT_ON_ERROR 1 #endif /* * If set, checks user input agains state and returns error, * otherwise errors are ignored (assuming they won't happen). * Errors will be asserted if enabled and checks are not skipped. */ #ifndef FLATCC_BUILDER_SKIP_CHECKS #define FLATCC_BUILDER_SKIP_CHECKS 0 #endif /* * When adding the same field to a table twice this is either an error * or the existing field is returned, potentially introducing garbage * if the type is a vector, table, or string. When implementing parsers * it may be convenient to not treat this as an error. */ #ifndef FLATCC_BUILDER_ALLOW_REPEAT_TABLE_ADD #define FLATCC_BUILDER_ALLOW_REPEAT_TABLE_ADD 0 #endif /** * This type must have same size as `flatbuffers_uoffset_t` * and must be a signed type. */ typedef flatbuffers_soffset_t flatcc_builder_ref_t; typedef flatbuffers_utype_t flatcc_builder_utype_t; /** * This type must be compatible with code generation that * creates union specific ref types. */ typedef struct flatcc_builder_union_ref { flatcc_builder_utype_t type; flatcc_builder_ref_t value; } flatcc_builder_union_ref_t; typedef struct flatcc_builder_union_vec_ref { flatcc_builder_ref_t type; flatcc_builder_ref_t value; } flatcc_builder_union_vec_ref_t; /** * Virtual tables are off by one to avoid being mistaken for error at * position 0, and it makes them detectable as such because no other * reference is uneven. Vtables are emitted at their actual location * which is one less than the reference value. */ typedef flatbuffers_soffset_t flatcc_builder_vt_ref_t; typedef flatbuffers_uoffset_t flatcc_builder_identifier_t; /** * Hints to custom allocators so they can provide initial alloc sizes * etc. There will be at most one buffer for each allocation type per * flatcc_builder instance. Buffers containing only structs may avoid * allocation altogether using a `create` call. The vs stack must hold * vtable entries for all open tables up to their requested max id, but * unused max id overlap on the stack. The final vtables only store the * largest id actually added. The fs stack must hold stack frames for * the nesting levels expected in the buffer, each about 50-100 bytes. * The ds stack holds open vectors, table data, and nested buffer state. * `create` calls bypass the `ds` and `fs` stack and are thus faster. * The vb buffer holds a copy of all vtables seen and emitted since last * vtable flush. The patch log holds a uoffset for every table field * added to currently open tables. The hash table holds a uoffset entry * for each hash slot where the allocator decides how many to provide * above a certain minimum. The vd buffer allocates vtable descriptors * which is a reference to an emitted vtable, an offset to a cached * vtable, and a link to next descriptor with same hash. Calling `reset` * after build can either keep the allocation levels for the next * buffer, or reduce the buffers already allocated by requesting 1 byte * allocations (meaning provide a default). * * The user stack is not automatically allocated, but when entered * explicitly, the boundary is rembered in the current live * frame. */ enum flatcc_builder_alloc_type { /* The stack where vtables are build. */ flatcc_builder_alloc_vs, /* The stack where data structures are build. */ flatcc_builder_alloc_ds, /* The virtual table buffer cache, holds a copy of each vt seen. */ flatcc_builder_alloc_vb, /* The patch log, remembers table fields with outstanding offset refs. */ flatcc_builder_alloc_pl, /* The stack of frames for nested types. */ flatcc_builder_alloc_fs, /* The hash table part of the virtual table cache. */ flatcc_builder_alloc_ht, /* The vtable descriptor buffer, i.e. list elements for emitted vtables. */ flatcc_builder_alloc_vd, /* User stack frame for custom data. */ flatcc_builder_alloc_us, /* Number of allocation buffers. */ flatcc_builder_alloc_buffer_count }; /** Must reflect the `flatcc_builder_alloc_type` enum. */ #define FLATCC_BUILDER_ALLOC_BUFFER_COUNT flatcc_builder_alloc_buffer_count #ifndef FLATCC_BUILDER_ALLOC #define FLATCC_BUILDER_ALLOC(n) FLATCC_ALLOC(n) #endif #ifndef FLATCC_BUILDER_FREE #define FLATCC_BUILDER_FREE(p) FLATCC_FREE(p) #endif #ifndef FLATCC_BUILDER_REALLOC #define FLATCC_BUILDER_REALLOC(p, n) FLATCC_REALLOC(p, n) #endif #ifndef FLATCC_BUILDER_ALIGNED_ALLOC #define FLATCC_BUILDER_ALIGNED_ALLOC(a, n) FLATCC_ALIGNED_ALLOC(a, n) #endif #ifndef FLATCC_BUILDER_ALIGNED_FREE #define FLATCC_BUILDER_ALIGNED_FREE(p) FLATCC_ALIGNED_FREE(p) #endif /** * Emits data to a conceptual deque by appending to either front or * back, starting from offset 0. * * Each emit call appends a strictly later or earlier sequence than the * last emit with same offset sign. Thus a buffer is gradually grown at * both ends. `len` is the combined length of all iov entries such that * `offset + len` yields the former offset for negative offsets and * `offset + len` yields the next offset for non-negative offsets. * The bulk of the data will be in the negative range, possibly all of * it. The first emitted emitted range will either start or end at * offset 0. If offset 0 is emitted, it indicates the start of clustered * vtables. The last positive (non-zero) offset may be zero padding to * place the buffer in a full multiple of `block_align`, if set. * * No iov entry is empty, 0 < iov_count <= FLATCC_IOV_COUNT_MAX. * * The source data are in general ephemeral and should be consumed * immediately, as opposed to caching iov. * * For high performance applications: * * The `create` calls may reference longer living data, but header * fields etc. will still be short lived. If an emitter wants to * reference data in another buffer rather than copying, it should * inspect the memory range. The length of an iov entry may also be used * since headers are never very long (anything starting at 16 bytes can * safely be assumed to be user provided, or static zero padding). It is * guaranteed that data pointers in `create` calls receive a unique slot * separate from temporary headers, in the iov table which may be used * for range checking or hashing (`create_table` is the only call that * mutates the data buffer). It is also guaranteed (with the exception * of `create_table` and `create_cached_vtable`) that data provided to * create calls are not referenced at all by the builder, and these data * may therefore de-facto be handles rather than direct pointers when * the emitter and data provider can agree on such a protocol. This does * NOT apply to any start/end/add/etc. calls which do copy to stack. * `flatcc_builder_padding_base` may be used to test if an iov entry is * zero padding which always begins at that address. * * Future: the emit interface could be extended with a type code * and return an existing object insted of the emitted if, for * example, they are identical. Outside this api level, generated * code could provide a table comparison function to help such * deduplication. It would be optional because two equal objects * are not necessarily identical. The emitter already receives * one object at time. * * Returns 0 on success and otherwise causes the flatcc_builder * to fail. */ typedef int flatcc_builder_emit_fun(void *emit_context, const flatcc_iovec_t *iov, int iov_count, flatbuffers_soffset_t offset, size_t len); /* * Returns a pointer to static padding used in emitter calls. May * sometimes also be used for empty defaults such as identifier. */ extern const uint8_t flatcc_builder_padding_base[]; /** * `request` is a minimum size to be returned, but allocation is * expected to grow exponentially or in reasonable chunks. Notably, * `alloc_type = flatcc_builder_alloc_ht` will only use highest available * power of 2. The allocator may shrink if `request` is well below * current size but should avoid repeated resizing on small changes in * request sizes. If `zero_fill` is non-zero, allocated data beyond * the current size must be zeroed. The buffer `b` may be null with 0 * length initially. `alloc_context` is completely implementation * dependendent, and not needed when just relying on realloc. The * resulting buffer may be the same or different with moved data, like * realloc. Returns -1 with unmodified buffer on failure or 0 on * success. The `alloc_type` identifies the buffer type. This may be * used to cache buffers between instances of builders, or to decide a * default allocation size larger than requested. If `need` is zero the * buffer should be deallocate if non-zero, and return success (0) * regardless. */ typedef int flatcc_builder_alloc_fun(void *alloc_context, flatcc_iovec_t *b, size_t request, int zero_fill, int alloc_type); /* * The number of hash slots there will be allocated space for. The * allocator may provide more. The size returned should be * `sizeof(flatbuffers_uoffset_t) * count`, where the size is a power of * 2 (or the rest is wasted). The hash table can store many more entries * than slots using linear search. The table does not resize. */ #ifndef FLATCC_BUILDER_MIN_HASH_COUNT #define FLATCC_BUILDER_MIN_HASH_COUNT 64 #endif typedef struct __flatcc_builder_buffer_frame __flatcc_builder_buffer_frame_t; struct __flatcc_builder_buffer_frame { flatcc_builder_identifier_t identifier; flatcc_builder_ref_t mark; flatbuffers_uoffset_t vs_end; flatbuffers_uoffset_t nest_id; uint16_t flags; uint16_t block_align; }; typedef struct __flatcc_builder_vector_frame __flatcc_builder_vector_frame_t; struct __flatcc_builder_vector_frame { flatbuffers_uoffset_t elem_size; flatbuffers_uoffset_t count; flatbuffers_uoffset_t max_count; }; typedef struct __flatcc_builder_table_frame __flatcc_builder_table_frame_t; struct __flatcc_builder_table_frame { flatbuffers_uoffset_t vs_end; flatbuffers_uoffset_t pl_end; uint32_t vt_hash; flatbuffers_voffset_t id_end; }; /* * Store state for nested structures such as buffers, tables and vectors. * * For less busy data and data where access to a previous state is * irrelevant, the frame may store the current state directly. Otherwise * the current state is maintained in the flatcc_builder_t structure in a * possibly derived form (e.g. ds pointer instead of ds_end offset) and * the frame is used to store the previous state when the frame is * entered. * * Most operations have a start/update/end cycle the decides the * liftetime of a frame, but these generally also have a direct form * (create) that does not use a frame at all. These still do some * state updates notably passing min_align to parent which may also be * an operation without a frame following the child level operation * (e.g. create struct, create buffer). Ending a frame results in the * same kind of updates. */ typedef struct __flatcc_builder_frame __flatcc_builder_frame_t; struct __flatcc_builder_frame { flatbuffers_uoffset_t ds_first; flatbuffers_uoffset_t type_limit; flatbuffers_uoffset_t ds_offset; uint16_t align; uint16_t type; union { __flatcc_builder_table_frame_t table; __flatcc_builder_vector_frame_t vector; __flatcc_builder_buffer_frame_t buffer; } container; }; /** * The main flatcc_builder structure. Can be stack allocated and must * be initialized with `flatcc_builder_init` and cleared with * `flatcc_builder_clear` to reclaim memory. Between buffer builds, * `flatcc_builder_reset` may be used. */ typedef struct flatcc_builder flatcc_builder_t; struct flatcc_builder { /* Next entry on reserved stack in `alloc_pl` buffer. */ flatbuffers_voffset_t *pl; /* Next entry on reserved stack in `alloc_vs` buffer. */ flatbuffers_voffset_t *vs; /* One above the highest entry in vs, used to track vt_size. */ flatbuffers_voffset_t id_end; /* The evolving vtable hash updated with every new field. */ uint32_t vt_hash; /* Pointer to ds_first. */ uint8_t *ds; /* Offset from `ds` on current frame. */ flatbuffers_uoffset_t ds_offset; /* ds buffer size relative to ds_first, clamped to max size of current type. */ flatbuffers_uoffset_t ds_limit; /* ds_first, ds_first + ds_offset is current ds stack range. */ flatbuffers_uoffset_t ds_first; /* Points to currently open frame in `alloc_fs` buffer. */ __flatcc_builder_frame_t *frame; /* Only significant to emitter function, if at all. */ void *emit_context; /* Only significant to allocator function, if at all. */ void *alloc_context; /* Customizable write function that both appends and prepends data. */ flatcc_builder_emit_fun *emit; /* Customizable allocator that also deallocates. */ flatcc_builder_alloc_fun *alloc; /* Buffers indexed by `alloc_type` */ flatcc_iovec_t buffers[FLATCC_BUILDER_ALLOC_BUFFER_COUNT]; /* Number of slots in ht given as 1 << ht_width. */ size_t ht_width; /* The location in vb to add next cached vtable. */ flatbuffers_uoffset_t vb_end; /* Where to allocate next vtable descriptor for hash table. */ flatbuffers_uoffset_t vd_end; /* Ensure final buffer is aligned to at least this. Nested buffers get their own `min_align`. */ uint16_t min_align; /* The current active objects alignment isolated from nested activity. */ uint16_t align; /* The current buffers block alignment used when emitting buffer. */ uint16_t block_align; /* Signed virtual address range used for `flatcc_builder_ref_t` and emitter. */ flatcc_builder_ref_t emit_start; flatcc_builder_ref_t emit_end; /* 0 for top level, and end of buffer ref for nested buffers (can also be 0). */ flatcc_builder_ref_t buffer_mark; /* Next nest_id. */ flatbuffers_uoffset_t nest_count; /* Unique id to prevent sharing of vtables across buffers. */ flatbuffers_uoffset_t nest_id; /* Current nesting level. Helpful to state-machines with explicit stack and to check `max_level`. */ int level; /* Aggregate check for allocated frame and max_level. */ int limit_level; /* Track size prefixed buffer. */ uint16_t buffer_flags; /* Settings that may happen with no frame allocated. */ flatcc_builder_identifier_t identifier; /* Settings that survive reset (emitter, alloc, and contexts also survive): */ /* If non-zero, vtable cache gets flushed periodically. */ size_t vb_flush_limit; /* If non-zero, fails on deep nesting to help drivers with a stack, such as recursive parsers etc. */ int max_level; /* If non-zero, do not cluster vtables at end, only emit negative offsets (0 by default). */ int disable_vt_clustering; /* Set if the default emitter is being used. */ int is_default_emitter; /* Only used with default emitter. */ flatcc_emitter_t default_emit_context; /* Offset to the last entered user frame on the user frame stack, after frame header, or 0. */ size_t user_frame_offset; /* The offset to the end of the most recent user frame. */ size_t user_frame_end; /* The optional user supplied refmap for cloning DAG's - not shared with nested buffers. */ flatcc_refmap_t *refmap; }; /** * Call this before any other API call. * * The emitter handles the completed chunks of the buffer that will no * longer be required by the builder. It is largely a `write` function * that can append to both positive and negative offsets. * * No memory is allocated during init. Buffers will be allocated as * needed. The `emit_context` is only used by the emitter, if at all. * * `flatcc_builder_reset/clear` calls are automtically forwarded to the * default emitter. * * Returns -1 on failure, 0 on success. */ int flatcc_builder_init(flatcc_builder_t *B); /** * Use instead of `flatcc_builder_init` when providing a custom allocator * or emitter. Leave emitter or allocator null to use default. * Cleanup of emit and alloc context must be handled manually after * the builder is cleared or reset, except if emitter is null the * default will be automatically cleared and reset. * * Returns -1 on failure, 0 on success. */ int flatcc_builder_custom_init(flatcc_builder_t *B, flatcc_builder_emit_fun *emit, void *emit_context, flatcc_builder_alloc_fun *alloc, void *alloc_context); /* * Returns (flatcc_emitter_t *) if the default context is used. * Other emitter might have null contexts. */ void *flatcc_builder_get_emit_context(flatcc_builder_t *B); /** * Prepares builder for a new build. The emitter is not told when a * buffer is finished or when a new begins, and must be told so * separately. Allocated buffers will be zeroed, but may optionally be * reduced to their defaults (signalled by reallocating each non-empty * buffer to a single byte). General settings are cleared optionally, * such as cache flushing. Buffer specific settings such as buffer * identifier are always cleared. * * Returns -1 if allocator complains during buffer reduction, 0 on * success. */ int flatcc_builder_custom_reset(flatcc_builder_t *B, int reduce_buffers, int set_defaults); /* * Same as `flatcc_builder_custom_reset` with default arguments * where buffers are not reduced and default settings are not reset. */ int flatcc_builder_reset(flatcc_builder_t *B); /** * Deallocates all memory by calling allocate with a zero size request * on each buffer, then zeroing the builder structure itself. */ void flatcc_builder_clear(flatcc_builder_t *B); /** * Allocates to next higher power of 2 using system realloc and ignores * `alloc_context`. Only reduces size if a small subsequent increase in * size would not trigger a reallocation. `alloc_type` is used to * set minimum sizes. Hash tables are allocated to the exact requested * size. See also `alloc_fun`. */ int flatcc_builder_default_alloc(void *alloc_context, flatcc_iovec_t *b, size_t request, int zero_fill, int alloc_type); /** * If non-zero, the vtable cache will get flushed whenever it reaches * the given limit at a point in time where more space is needed. The * limit is not exact as it is only tested when reallocation is * required. */ void flatcc_builder_set_vtable_cache_limit(flatcc_builder_t *B, size_t size); /** * Manual flushing of vtable for long running tasks. Mostly used * internally to deal with nested buffers. */ void flatcc_builder_flush_vtable_cache(flatcc_builder_t *B); /** * Low-level support function to aid in constructing nested buffers without * allocation. Not for regular use. * * Call where `start_buffer` would have been placed when using * `create_buffer` in a nested context. Save the return value on a stack * as argument to `pop_buffer_alignment`. * * The call resets the current derived buffer alignment so the nested * buffer will not be aligned to more than required. * * Often it will not be necessary to be so careful with alignment since * the alignment cannot be invalid by failing to use push and pop, but * for code generation it will ensure the correct result every time. */ uint16_t flatcc_builder_push_buffer_alignment(flatcc_builder_t *B); /** * Low-level call. * * Call with the return value from push_buffer_alignment after a nested * `create_buffer_call`. The alignments merge back up in the buffer * hierarchy so the top level buffer gets the largest of all aligments. */ void flatcc_builder_pop_buffer_alignment(flatcc_builder_t *B, uint16_t buffer_align); /** * This value may be of interest when the buffer has been ended, for * example when subsequently allocating memory for the buffer to ensure * that memory is properly aligned. */ uint16_t flatcc_builder_get_buffer_alignment(flatcc_builder_t *B); /** * Level 0 means no buffer is started, otherwise it increments with * start calls and decrements with end calls (approximately for * optimized operations such as table vectors). * * If `max_level` has been set, `get_level` always returns a value <= * `max_level` provided no start call has failed. * * Level continues to increment inside nested buffers. */ int flatcc_builder_get_level(flatcc_builder_t *B); /** * Setting the max level triggers a failure on start of new nestings * when the level is reached. May be used to protect recursive descend * parsers etc. or later buffer readers. * * The builder itself is not sensitive to depth, and the allocator is a * better way to protect resource abuse. * * `max_level` is not reset inside nested buffers. */ void flatcc_builder_set_max_level(flatcc_builder_t *B, int level); /** * By default ordinary data such as tables are placed in front of * earlier produced content and vtables are placed at the very end thus * clustering vtables together. This can be disabled so all content is * placed in front. Nested buffers ignores this setting because they can * only place content in front because they cannot blend with the * containing buffers content. Clustering could be more cache friendly * and also enables pre-shipping of the vtables during transmission. */ void flatcc_builder_set_vtable_clustering(flatcc_builder_t *B, int enable); /** * Sets a new user supplied refmap which maps source pointers to * references and returns the old refmap, or null. It is also * possible to disable an existing refmap by setting a null * refmap. * * A clone or pick operation may use this map when present, * depending on the data type. If a hit is found, the stored * reference will be used instead of performing a new clone or * pick operation. It is also possible to manually populate the * refmap. Note that the builder does not have a concept of * clone or pick - these are higher level recursive operations * to add data from one buffer to another - but such code may * rely on the builder to provide the current refmap during * recursive operations. For this reason, the builder makes no * calls to the refmap interface on its own - it just stores the * current refmap such that recursive operations can find it. * * Refmaps MUST be reset, replaced or disabled if a source * pointer may be reused for different purposes - for example if * repeatedly reading FlatBuffers into the same memory buffer * and performing a clone into a buffer under construction. * Refmaps may also be replaced if the same object is to be * cloned several times keeping the internal DAG structure * intact with every new clone being an independent object. * * Refmaps must also be replaced or disabled prior to starting a * nested buffer and after stopping it, or when cloning a object * as a nested root. THIS IS VERY EASY TO GET WRONG! The * builder does a lot of bookkeeping for nested buffers but not * in this case. Shared references may happen and they WILL fail * verification and they WILL break when copying out a nested * buffer to somewhere else. The user_frame stack may be used * for pushing refmaps, but often user codes recursive stack * will work just as well. * * It is entirely optional to use refmaps when cloning - they * preserve DAG structure and may speed up operations or slow * them down, depending on the source material. * * Refmaps may consume a lot of space when large offset vectors * are cloned when these do not have significant shared * references. They may also be very cheap to use without any * dynamic allocation when objects are small and have at most a * few references. * * Refmaps only support init, insert, find, reset, clear but not * delete. There is a standard implementation in the runtime * source tree but it can easily be replaced compile time and it * may also be left out if unused. The builder wraps reset, insert, * and find so the user does not have to check if a refmap is * present but other operations must be done direcly on the * refmap. * * The builder wrapped refmap operations are valid on a null * refmap which will find nothing and insert nothing. * * The builder will reset the refmap during a builder reset and * clear the refmap during a builder clear operation. If the * refmap goes out of scope before that happens it is important * to call set_refmap with null and manually clear the refmap. */ static inline flatcc_refmap_t *flatcc_builder_set_refmap(flatcc_builder_t *B, flatcc_refmap_t *refmap) { flatcc_refmap_t *refmap_old; refmap_old = B->refmap; B->refmap = refmap; return refmap_old; } /* Retrieves the current refmap, or null. */ static inline flatcc_refmap_t *flatcc_builder_get_refmap(flatcc_builder_t *B) { return B->refmap; } /* Finds a reference, or a null reference if no refmap is active. * */ static inline flatcc_builder_ref_t flatcc_builder_refmap_find(flatcc_builder_t *B, const void *src) { return B->refmap ? flatcc_refmap_find(B->refmap, src) : flatcc_refmap_not_found; } /* * Inserts into the current refmap with the inseted ref upon * upon success, or not_found on failure (default 0), or just * returns ref if refmap is absent. * * Note that if an existing item exists, the ref is replaced * and the new, not the old, ref is returned. */ static inline flatcc_builder_ref_t flatcc_builder_refmap_insert(flatcc_builder_t *B, const void *src, flatcc_builder_ref_t ref) { return B->refmap ? flatcc_refmap_insert(B->refmap, src, ref) : ref; } static inline void flatcc_builder_refmap_reset(flatcc_builder_t *B) { if (B->refmap) flatcc_refmap_reset(B->refmap); } typedef uint16_t flatcc_builder_buffer_flags_t; static const flatcc_builder_buffer_flags_t flatcc_builder_is_nested = 1; static const flatcc_builder_buffer_flags_t flatcc_builder_with_size = 2; /* The flag size in the API needs to match the internal size. */ static_assert(sizeof(flatcc_builder_buffer_flags_t) == sizeof(((flatcc_builder_t *)0)->buffer_flags), "flag size mismatch"); /** * An alternative to start buffer, start struct/table ... end buffer. * * This call is mostly of interest as a means to quicly create a zero * allocation top-level buffer header following a call to create_struct, * or to create_vtable/create_table. For that, it is quite simple to * use. For general buffer construction without allocation, more care is * needed, as discussed below. * * If the content is created with `start/end_table` calls, or similar, * it is better to use `start/end_buffer` since stack allocation is used * anyway. * * The buffer alignment must be provided manually as it is not derived * from constructed content, unlike `start/end_buffer`. Typically * `align` would be same argument as provided to `create_struct`. * `get_buffer_alignment` may also used (note: `get_buffer_alignment` * may return different after the call because it will be updated with * the `block_align` argument to `create_buffer` but that is ok). * * The buffer may be constructed as a nested buffer with the `is_nested * = 1` flag. As a nested buffer a ubyte vector header is placed before * the aligned buffer header. A top-level buffer will normally have * flags set to 0. * * A top-level buffer may also be constructed with the `with_size = 2` * flag for top level buffers. It adds a size prefix similar to * `is_nested` but the size is part of the aligned buffer. A size * prefixed top level buffer must be accessed with a size prefix aware * reader, or the buffer given to a standard reader must point to after * the size field while keeping the buffer aligned to the size field * (this will depend on the readers API which may be an arbitrary other * language). * * If the `with_size` is used with the `is_nested` flag, the size is * added as usual and all fields remain aligned as before, but padding * is adjusted to ensure the buffer is aligned to the size field so * that, for example, the nested buffer with size can safely be copied * to a new memory buffer for consumption. * * Generally, references may only be used within the same buffer * context. With `create_buffer` this becomes less precise. The rule * here is that anything that would be valid with start/end_buffer * nestings is also valid when removing the `start_buffer` call and * replacing `end_buffer` with `create_buffer`. * * Note the additional burden of tracking buffer alignment manually - * To help with this use `push_buffer_alignment` where `start_buffer` * would have been placed, and `pop_buffer_alignment after the * `create_buffer` call, and use `get_buffer_alignemnt` as described * above. * * `create_buffer` is not suitable as a container for buffers created * with `start/end_buffer` as these make assumptions about context that * create buffer does not provide. Also, there is no point in doing so, * since the idea of `create_buffer` is to avoid allocation in the first * place. */ flatcc_builder_ref_t flatcc_builder_create_buffer(flatcc_builder_t *B, const char identifier[FLATBUFFERS_IDENTIFIER_SIZE], uint16_t block_align, flatcc_builder_ref_t ref, uint16_t align, flatcc_builder_buffer_flags_t flags); /** * Creates a struct within the current buffer without using any * allocation. * * The struct should be used as a root in the `end_buffer` call or as a * union value as there are no other ways to use struct while conforming * to the FlatBuffer format - noting that tables embed structs in their * own data area except in union fields. * * The struct should be in little endian format and follow the usual * FlatBuffers alignment rules, although this API won't care about what * is being stored. * * May also be used to simply emit a struct through the emitter * interface without being in a buffer and without being a valid * FlatBuffer. */ flatcc_builder_ref_t flatcc_builder_create_struct(flatcc_builder_t *B, const void *data, size_t size, uint16_t align); /** * Starts a struct and returns a pointer that should be used immediately * to fill in the struct in protocol endian format, and when done, * `end_struct` should be called. The returned reference should be used * as argument to `end_buffer` or as a union value. See also * `create_struct`. */ void *flatcc_builder_start_struct(flatcc_builder_t *B, size_t size, uint16_t align); /** * Return a pointer also returned at start struct, e.g. for endian * conversion. */ void *flatcc_builder_struct_edit(flatcc_builder_t *B); /** * Emits the struct started by `start_struct` and returns a reference to * be used as root in an enclosing `end_buffer` call or as a union * value. As mentioned in `create_struct`, these can also be used more * freely, but not while being conformant FlatBuffers. */ flatcc_builder_ref_t flatcc_builder_end_struct(flatcc_builder_t *B); /** * The buffer always aligns to at least the offset size (typically 4) * and the internal alignment requirements of the buffer content which * is derived as content is added. * * In addition, block_align can be specified. This ensures the resulting * buffer is at least aligned to the block size and that the total size * is zero padded to fill a block multiple if necessary. Because the * emitter operates on a virtual address range before the full buffer is * aligned, it may have to make assumptions based on that: For example, * it may be processing encryption blocks in the fly, and the resulting * buffer should be aligned to the encryption block size, even if the * content is just a byte aligned struct. Block align helps ensure this. * If the block align as 1 there will be no attempt to zero pad at the * end, but the content may still warrant padding after the header. End * padding is only needed with clustered vtables (which is the default). * * `block_align` is allowed to be 0 meaning it will inherit from parent if * present, and otherwise it defaults to 1. * * The identifier may be null, and it may optionally be set later with * `set_identifier` before the `end_buffer` call. * * General note: * * Only references returned with this buffer as current (i.e. last * unended buffer) can be stored in other objects (tables, offset * vectors) also belonging to this buffer, or used as the root argument * to `end_buffer`. A reference may be stored at most once, and unused * references will result in buffer garbage. All calls must be balanced * around the respective start / end operations, but may otherwise nest * freely, including nested buffers. Nested buffers are supposed to be * stored in a table offset field to comply with FlatBuffers, but the * API does not place any restrictions on where references are stored, * as long as they are indicated as offset fields. * * All alignment in all API calls must be between 1 and 256 and must be a * power of 2. This is not checked. Only if explicitly documented can it * also be 0 for a default value. * * `flags` can be `with_size` but `is_nested` is derived from context * see also `create_buffer`. */ int flatcc_builder_start_buffer(flatcc_builder_t *B, const char identifier[FLATBUFFERS_IDENTIFIER_SIZE], uint16_t block_align, flatcc_builder_buffer_flags_t flags); /** * The root object should be a struct or a table to conform to the * FlatBuffers format, but technically it can also be a vector or a * string, or even a child buffer (which is also vector as seen by the * buffer). The object must be created within the current buffer * context, that is, while the current buffer is the deepest nested * buffer on the stack. */ flatcc_builder_ref_t flatcc_builder_end_buffer(flatcc_builder_t *B, flatcc_builder_ref_t root); /** * The embed buffer is mostly intended to add an existing buffer as a * nested buffer. The buffer will be wrapped in a ubyte vector such that * the buffer is aligned at vector start, after the size field. * * If `align` is 0 it will default to 8 so that all FlatBuffer numeric * types will be readable. NOTE: generally do not count on align 0 being * valid or even checked by the API, but in this case it may be * difficult to know the internal buffer alignment, and 1 would be the wrong * choice. * * If `block_align` is set (non-zero), the buffer is placed in an isolated * block multiple. This may cost up to almost 2 block sizes in padding. * If the `block_align` argument is 0, it inherits from the parent * buffer block_size, or defaults to 1. * * The `align` argument must be set to respect the buffers internal * alignment requirements, but if the buffer is smaller it will not be * padded to isolate the buffer. For example a buffer of with * `align = 64` and `size = 65` may share its last 64 byte block with * other content, but not if `block_align = 64`. * * Because the ubyte size field is not, by default, part of the aligned * buffer, significant space can be wasted if multiple blocks are added * in sequence with a large block size. * * In most cases the distinction between the two alignments is not * important, but it allows separate configuration of block internal * alignment and block size, which can be important for auto-generated * code that may know the alignment of the buffer, but not the users * operational requirements. * * If the buffer is embedded without a parent buffer, it will simply * emit the buffer through the emit interface, but may also add padding * up to block alignment. At top-level there will be no size field * header. * * If `with_size` flag is set, the buffer is aligned to size field and * the above note about padding space no longer applies. The size field * is added regardless. The `is_nested` flag has no effect since it is * impplied. */ flatcc_builder_ref_t flatcc_builder_embed_buffer(flatcc_builder_t *B, uint16_t block_align, const void *data, size_t size, uint16_t align, flatcc_builder_buffer_flags_t flags); /** * Applies to the innermost open buffer. The identifier may be null or * contain all zero. Overrides any identifier given to the start buffer * call. */ void flatcc_builder_set_identifier(flatcc_builder_t *B, const char identifier[FLATBUFFERS_IDENTIFIER_SIZE]); enum flatcc_builder_type { flatcc_builder_empty = 0, flatcc_builder_buffer, flatcc_builder_struct, flatcc_builder_table, flatcc_builder_vector, flatcc_builder_offset_vector, flatcc_builder_string, flatcc_builder_union_vector }; /** * Returns the object type currently on the stack, for example if * needing to decide how to close a buffer. Because a table is * automatically added when starting a table buffer, * `flatcc_builder_table_buffer` should not normally be seen and the level * should be 2 before when closing a top-level table buffer, and 0 * after. A `flatcc_builder_struct_buffer` will be visible at level 1. * */ enum flatcc_builder_type flatcc_builder_get_type(flatcc_builder_t *B); /** * Similar to `get_type` but for a specific level. `get_type_at(B, 1)` * will return `flatcc_builder_table_buffer` if this is the root buffer * type. get_type_at(B, 0) is always `flatcc_builder_empty` and so are any * level above `get_level`. */ enum flatcc_builder_type flatcc_builder_get_type_at(flatcc_builder_t *B, int level); /** * The user stack is available for custom data. It may be used as * a simple stack by extending or reducing the inner-most frame. * * A frame has a size and a location on the user stack. Entering * a frame ensures the start is aligned to sizeof(size_t) and * ensures the requested space is available without reallocation. * When exiting a frame, the previous frame is restored. * * A user frame works completely independently of the builders * frame stack for tracking tables vectors etc. and does not have * to be completely at exit, but obviously it is not valid to * exit more often the entered. * * The frame is zeroed when entered. * * Returns a non-zero handle to the user frame upon success or * 0 on allocation failure. */ size_t flatcc_builder_enter_user_frame(flatcc_builder_t *B, size_t size); /** * Makes the parent user frame current, if any. It is not valid to call * if there isn't any current frame. Returns handle to parent frame if * any, or 0. */ size_t flatcc_builder_exit_user_frame(flatcc_builder_t *B); /** * Exits the frame represented by the given handle. All more * recently entered frames will also be exited. Returns the parent * frame handle if any, or 0. */ size_t flatcc_builder_exit_user_frame_at(flatcc_builder_t *B, size_t handle); /** * Returns a non-zero handle to the current inner-most user frame if * any, or 0. */ size_t flatcc_builder_get_current_user_frame(flatcc_builder_t *B); /* * Returns a pointer to the user frame at the given handle. Any active * frame can be accessed in this manner but the pointer is invalidated * by user frame enter and exit operations. */ void *flatcc_builder_get_user_frame_ptr(flatcc_builder_t *B, size_t handle); /** * Returns the size of the buffer and the logical start and end address * of with respect to the emitters address range. `end` - `start` also * yields the size. During construction `size` is the emitted number of * bytes and after buffer close it is the actual buffer size - by then * the start is also the return value of close buffer. End marks the end * of the virtual table cluster block. * * NOTE: there is no guarantee that all vtables end up in the cluster * block if there is placed a limit on the vtable size, or if nested * buffers are being used. On the other hand, if these conditions are * met, it is guaranteed that all vtables are present if the vtable * block is available (this depends on external transmission - the * vtables are always emitted before tables using them). In all cases * the vtables will behave as valid vtables in a flatbuffer. */ size_t flatcc_builder_get_buffer_size(flatcc_builder_t *B); /** * Returns the reference to the start of the emitter buffer so far, or * in total after buffer end, in the virtual address range used * by the emitter. Start is also returned by buffer end. */ flatcc_builder_ref_t flatcc_builder_get_buffer_start(flatcc_builder_t *B); /** * Returns the reference to the end of buffer emitted so far. When * clustering vtables, this is the end of tables, or after buffer end, * also zero padding if block aligned. If clustering is disabled, this * method will return 0 as the buffer only grows down then. */ flatcc_builder_ref_t flatcc_builder_get_buffer_mark(flatcc_builder_t *B); /** * Creates the vtable in the current buffer context, somewhat similar to * how create_vector operates. Each call results in a new table even if * an identical has already been emitted. * * Also consider `create_cached_vtable` which will reuse existing * vtables. * * This is low-low-level function intended to support * `create_cached_vtable` or equivalent, and `create_table`, both of * which are normally used indirectly via `start_table`, `table_add`, * `table_add_offset`..., `table_end`. * * Creates a vtable as a verbatim copy. This means the vtable must * include the header fields containing the vtable size and the table * size in little endian voffset_t encoding followed by the vtable * entries in same encoding. * * The function may be used to copy vtables from other other buffers * since they are directly transferable. * * The returned reference is actually the emitted location + 1. This * ensures the vtable is not mistaken for error because 0 is a valid * vtable reference. `create_table` is aware of this and substracts one * before computing the final offset relative to the table. This also * means vtable references are uniquely identifiable by having the * lowest bit set. * * vtable references may be reused within the same buffer, not any * parent or other related buffer (technically this is possible though, * as long as it is within same builder context, but it will not construct * valid FlatBuffers because the buffer cannot be extracted in isolation). */ flatcc_builder_vt_ref_t flatcc_builder_create_vtable(flatcc_builder_t *B, const flatbuffers_voffset_t *vt, flatbuffers_voffset_t vt_size); /** * Support function to `create_vtable`. See also the uncached version * `create_vtable`. * * Looks up the constructed vtable on the vs stack too see if it matches * a cached entry. If not, it emits a new vtable either at the end if * top-level and clustering is enabled, or at the front (always for * nested buffers). * * If the same vtable was already emitted in a different buffer, but not * in the current buffer, the cache entry will be reused, but a new * table will be emitted the first it happens in the same table. * * The returned reference is + 1 relative to the emitted address range * to identify it as a vtable and to avoid mistaking the valid 0 * reference for an error (clustered vtables tend to start at the end at * the virtual address 0, and up). * * The hash function can be chosen arbitrarily but may result in * duplicate emitted vtables if different hash functions are being used * concurrently, such as mixing the default used by `start/end table` * with a custom function (this is not incorrect, it only increases the * buffer size and cache pressure). * * If a vtable has a unique ID by other means than hashing the content, * such as an integer id, and offset into another buffer, or a pointer, * a good hash may be multiplication by a 32-bit prime number. The hash * table is not very sensitive to collissions as it uses externally * chained hashing with move to front semantics. */ flatcc_builder_vt_ref_t flatcc_builder_create_cached_vtable(flatcc_builder_t *B, const flatbuffers_voffset_t *vt, flatbuffers_voffset_t vt_size, uint32_t vt_hash); /* * Based on Knuth's prime multiplier. * * This is an incremental hash that is called with id and size of each * non-empty field, and finally with the two vtable header fields * when vtables are constructed via `table_add/table_add_offset`. * */ #ifndef FLATCC_SLOW_MUL #ifndef FLATCC_BUILDER_INIT_VT_HASH #define FLATCC_BUILDER_INIT_VT_HASH(hash) { (hash) = (uint32_t)0x2f693b52UL; } #endif #ifndef FLATCC_BUILDER_UPDATE_VT_HASH #define FLATCC_BUILDER_UPDATE_VT_HASH(hash, id, offset) \ { (hash) = (((((uint32_t)id ^ (hash)) * (uint32_t)2654435761UL)\ ^ (uint32_t)(offset)) * (uint32_t)2654435761UL); } #endif #ifndef FLATCC_BUILDER_BUCKET_VT_HASH #define FLATCC_BUILDER_BUCKET_VT_HASH(hash, width) (((uint32_t)(hash)) >> (32 - (width))) #endif #endif /* * By default we use Bernsteins hash as fallback if multiplication is slow. * * This just have to be simple, fast, and work on devices without fast * multiplication. We are not too sensitive to collisions. Feel free to * experiment and replace. */ #ifndef FLATCC_BUILDER_INIT_VT_HASH #define FLATCC_BUILDER_INIT_VT_HASH(hash) { (hash) = 5381; } #endif #ifndef FLATCC_BUILDER_UPDATE_VT_HASH #define FLATCC_BUILDER_UPDATE_VT_HASH(hash, id, offset) \ { (hash) = ((((hash) << 5) ^ (id)) << 5) ^ (offset); } #endif #ifndef FLATCC_BUILDER_BUCKET_VT_HASH #define FLATCC_BUILDER_BUCKET_VT_HASH(hash, width) (((1 << (width)) - 1) & (hash)) #endif /** * Normally use `start_table` instead of this call. * * This is a low-level call only intended for high-performance * applications that repeatedly churn about similar tables of known * layout, or as a support layer for other builders that maintain their * own allocation rather than using the stack of this builder. * * Creates a table from an already emitted vtable, actual data that is * properly aligned relative to data start and in little endian * encoding. Unlike structs, tables can have offset fields. These must * be stored as flatcc_builder_ref_t types (which have uoffset_t size) as * returned by the api in native encoding. The `offsets` table contain * voffsets relative to `data` start (this is different from how vtables * store offsets because they are relative to a table header). The * `offsets` table is only used temporarily to translate the stored * references and is not part of final buffer content. `offsets` may be * null if `offset_count` is 0. `align` should be the highest aligned * field in the table, but `size` need not be a multiple of `align`. * Aside from endian encoding, the vtable must record a table size equal * to `size + sizeof(flatbuffers_uoffset_t)` because it includes the * table header field size. The vtable is not accessed by this call (nor * is it available). Unlike other references, the vtable reference may * be shared between tables in the same buffer (not with any related * buffer such as a parent buffer). * * The operation will not use any allocation, but will update the * alignment of the containing buffer if any. * * Note: unlike other create calls, except `create_offset_vector`, * the source data is modified in order to translate references intok * offsets before emitting the table. */ flatcc_builder_ref_t flatcc_builder_create_table(flatcc_builder_t *B, const void *data, size_t size, uint16_t align, flatbuffers_voffset_t *offsets, int offset_count, flatcc_builder_vt_ref_t vt_ref); /** * Starts a table, typically following a start_buffer call as an * alternative to starting a struct, or to create table fields to be * stored in a parent table, or in an offset vector. * A number of `table_add` and table_add_offset` call may be placed * before the `end_table` call. Struct fields should NOT use `struct` * related call (because table structs are in-place), rather they should * use the `table_add` call with the appropriate size and alignment. * * A table, like other reference returning calls, may also be started * outside a buffer if the buffer header and alignment is of no * interest to the application, for example as part of an externally * built buffer. * * `count` must be larger than the largest id used for this table * instance. Normally it is set to the number of fields defined in the * schema, but it may be less if memory is constrained and only few * fields with low valued id's are in use. The count can extended later * with `reserve_table` if necessary. `count` may be also be set to a * large enough value such as FLATBUFFERS_ID_MAX + 1 if memory is not a * concern (reserves about twice the maximum vtable size to track the * current vtable and voffsets where references must be translated to * offsets at table end). `count` may be zero if for example * `reserve_table` is being used. * * Returns -1 on error, 0 on success. */ int flatcc_builder_start_table(flatcc_builder_t *B, int count); /** * Call before adding a field with an id that is not below the count set * at table start. Not needed in most cases. For performance reasons * the builder does not check all bounds all the the time, but the user * can do so if memory constraints prevent start_table from using a * conservative value. See also `table_start`. * * Note: this call has absolutely no effect on the table layout, it just * prevents internal buffer overruns. * * Returns -1 on error, 0 on success. */ int flatcc_builder_reserve_table(flatcc_builder_t *B, int count); /** * Completes the table constructed on the internal stack including * emitting a vtable, or finding a matching vtable that has already been * emitted to the same buffer. (Vtables cannot be shared between * buffers, but they can between tables of the same buffer). * * Note: there is a considerable, but necessary, amount of bookkeeping * involved in constructing tables. The `create_table` call is much * faster, but it also expects a lot of work to be done already. * * Tables can be created with no fields added. This will result in an * empty vtable and a table with just a vtable reference. If a table is * used as a sub-table, such a table might also not be stored at all, * but we do not return a special reference for that, nor do we provide * and option to not create the table in this case. This may be * interpreted as the difference between a null table (not stored in * parent), and an empty table with a unique offset (and thus identity) * different from other empty tables. */ flatcc_builder_ref_t flatcc_builder_end_table(flatcc_builder_t *B); /** * Optionally this method can be called just before `flatcc_builder_end_table` * to verify that all required fields have been set. * Each entry is a table field id. * * Union fields should use the type field when checking for presence and * may also want to check the soundness of the union field overall using * `check_union_field` with the id one higher than the type field id. * * This funcion is typically called by an assertion in generated builder * interfaces while release builds may want to avoid this performance * overhead. * * Returns 1 if all fields are matched, 0 otherwise. */ int flatcc_builder_check_required(flatcc_builder_t *B, const flatbuffers_voffset_t *required, int count); /** * Same as `check_required` when called with a single element. * * Typically used when direct calls are more convenient than building an * array first. Useful when dealing with untrusted intput such as parsed * text from an external source. */ int flatcc_builder_check_required_field(flatcc_builder_t *B, flatbuffers_voffset_t id); /** * Checks that a union field is valid. * * The criteria is: * * If the type field is not present (at id - 1), or it holds a zero value, * then the table field (at id) must be present. * * Generated builder code may be able to enforce valid unions without * this check by setting both type and table together, but e.g. parsers * may receive the type and the table independently and then it makes * sense to validate the union fields before table completion. * * Note that an absent union field is perfectly valid. If a union is * required, the type field (id - 1), should be checked separately * while the table field should only be checked here because it can * (and must) be absent when the type is NONE (= 0). */ int flatcc_builder_check_union_field(flatcc_builder_t *B, flatbuffers_voffset_t id); /** * A struct, enum or scalar added should be stored in little endian in * the return pointer location. The pointer is short lived and will * not necessarily survive other builder calls. * * A union type field can also be set using this call. In fact, this is * the only way to deal with unions via this API. Consequently, it is * the users repsonsibility to ensure the appropriate type is added * at the next higher id. * * Null and default values: * * FlatBuffers does not officially provide an option for null values * because it does not distinguish between default values and values * that are not present. At this api level, we do not deal with defaults * at all. Callee should test the stored value against the default value * and only add the field if it does not match the default. This only * applies to scalar and enum values. Structs cannot have defaults so * their absence means null, and strings, vectors and subtables do have * natural null values different from the empty object and empty objects * with different identity is also possible. * * To handle Null for scalars, the following approach is recommended: * * Provide a schema-specific `add` operation that only calls this * low-level add method if the default does not match, and also provide * another `set` operation that always stores the value, regardless of * default. For most readers this will be transparent, except for extra * space used, but for Null aware readers, these can support operations * to test for Null/default/other value while still supporting the * normal read operation that returns default when a value is absent * (i.e. Null). * * It is valid to call with a size of 0 - the effect being adding the * vtable entry. The call may also be dropped in this case to reduce * the vtable size - the difference will be in null detection. */ void *flatcc_builder_table_add(flatcc_builder_t *B, int id, size_t size, uint16_t align); /** * Returns a pointer to the buffer holding the last field added. The * size argument must match the field size added. May, for example, be * used to perform endian conversion after initially updating field * as a native struct. Must be called before the table is ended. */ void *flatcc_builder_table_edit(flatcc_builder_t *B, size_t size); /** * Similar to `table_add` but copies source data into the buffer before * it is returned. Useful when adding a larger struct already encoded in * little endian. */ void *flatcc_builder_table_add_copy(flatcc_builder_t *B, int id, const void *data, size_t size, uint16_t align); /** * Add a string, vector, or sub-table depending on the type if the * field identifier. The offset ref obtained when the field object was * closed should be stored as is in the given pointer. The pointer * is only valid short term, so create the object before calling * add to table, but the owner table can be started earlier. Never mix * refs from nested buffers with parent buffers. * * Also uses this method to add nested buffers. A nested buffer is * simple a buffer created while another buffer is open. The buffer * close operation provides the necessary reference. * * When the table closes, all references get converted into offsets. * Before that point, it is not required that the offset is written * to. */ flatcc_builder_ref_t *flatcc_builder_table_add_offset(flatcc_builder_t *B, int id); /* * Adds a union type and reference in a single operation and returns 0 * on success. Stores the type field at `id - 1` and the value at * `id`. The `value` is a reference to a table, to a string, or to a * standalone `struct` outside the table. * * If the type is 0, the value field must also be 0. * * Unions can also be added as separate calls to the type and the offset * separately which can lead to better packing when the type is placed * together will other small fields. */ int flatcc_builder_table_add_union(flatcc_builder_t *B, int id, flatcc_builder_union_ref_t uref); /* * Adds a union type vector and value vector in a single operations * and returns 0 on success. * * If both the type and value vector is null, nothing is added. * Otherwise both must be present and have the same length. * * Any 0 entry in the type vector must also have a 0 entry in * the value vector. */ int flatcc_builder_table_add_union_vector(flatcc_builder_t *B, int id, flatcc_builder_union_vec_ref_t uvref); /** * Creates a vector in a single operation using an externally supplied * buffer. This completely bypasses the stack, but the size must be * known and the content must be little endian. Do not use for strings * and offset vectors. Other flatbuffer vectors could be used as a * source, but the length prefix is not required. * * Set `max_count` to `FLATBUFFERS_COUNT_MAX(elem_size)` before a call * to any string or vector operation to the get maximum safe vector * size, or use (size_t)-1 if overflow is not a concern. * * The max count property is a global property that remains until * explicitly changed. * * `max_count` is to prevent malicous or accidental overflow which is * difficult to detect by multiplication alone, depending on the type * sizes being used and having `max_count` thus avoids a division for * every vector created. `max_count` does not guarantee a vector will * fit in an empty buffer, it just ensures the internal size checks do * not overflow. A safe, sane limit woud be max_count / 4 because that * is half the maximum buffer size that can realistically be * constructed, corresponding to a vector size of `UOFFSET_MAX / 4` * which can always hold the vector in 1GB excluding the size field when * sizeof(uoffset_t) = 4. */ flatcc_builder_ref_t flatcc_builder_create_vector(flatcc_builder_t *B, const void *data, size_t count, size_t elem_size, uint16_t align, size_t max_count); /** * Starts a vector on the stack. * * Do not use these calls for string or offset vectors, but do store * scalars, enums and structs, always in little endian encoding. * * Use `extend_vector` subsequently to add zero, one or more elements * at time. * * See `create_vector` for `max_count` argument (strings and offset * vectors have a fixed element size and does not need this argument). * * Returns 0 on success. */ int flatcc_builder_start_vector(flatcc_builder_t *B, size_t elem_size, uint16_t align, size_t max_count); /** * Emits the vector constructed on the stack by start_vector. * * The vector may be accessed in the emitted stream using the returned * reference, even if the containing buffer is still under construction. * This may be useful for sorting. This api does not support sorting * because offset vectors cannot read their references after emission, * and while plain vectors could be sorted, it has been chosen that this * task is better left as a separate processing step. Generated code can * provide sorting functions that work on final in-memory buffers. */ flatcc_builder_ref_t flatcc_builder_end_vector(flatcc_builder_t *B); /** Returns the number of elements currently on the stack. */ size_t flatcc_builder_vector_count(flatcc_builder_t *B); /** * Returns a pointer ot the first vector element on stack, * accessible up to the number of elements currently on stack. */ void *flatcc_builder_vector_edit(flatcc_builder_t *B); /** * Returns a zero initialized buffer to a new region of the vector which * is extended at the end. The buffer must be consumed before other api * calls that may affect the stack, including `extend_vector`. * * Do not use for strings, offset or union vectors. May be used for nested * buffers, but these have dedicated calls to provide better alignment. */ void *flatcc_builder_extend_vector(flatcc_builder_t *B, size_t count); /** * A specialized `vector_extend` that pushes a single element. * * Returns the buffer holding a modifiable copy of the added content, * or null on error. Note: for structs, care must be taken to ensure * the source has been zero padded. For this reason it may be better to * use extend(B, 1) and assign specific fields instead. */ void *flatcc_builder_vector_push(flatcc_builder_t *B, const void *data); /** * Pushes multiple elements at a time. * * Returns the buffer holding a modifiable copy of the added content, * or null on error. */ void *flatcc_builder_append_vector(flatcc_builder_t *B, const void *data, size_t count); /** * Removes elements already added to vector that has not been ended. * For example, a vector of parsed list may remove the trailing comma, * or the vector may simply overallocate to get some temporary working * space. The total vector size must never become negative. * * Returns -1 if the count as larger than current count, or 0 on success. */ int flatcc_builder_truncate_vector(flatcc_builder_t *B, size_t count); /* * Similar to `create_vector` but with references that get translated * into offsets. The references must, as usual, belong to the current * buffer. Strings, scalar and struct vectors can emit directly without * stack allocation, but offset vectors must translate the offsets * and therefore need the temporary space. Thus, this function is * roughly equivalent to to start, append, end offset vector. * * See also `flatcc_builder_create_offset_vector_direct`. */ flatcc_builder_ref_t flatcc_builder_create_offset_vector(flatcc_builder_t *B, const flatcc_builder_ref_t *data, size_t count); /* * NOTE: this call takes non-const source array of references * and destroys the content. * * This is a faster version of `create_offset_vector` where the * source references are destroyed. In return the vector can be * emitted directly without passing over the stack. */ flatcc_builder_ref_t flatcc_builder_create_offset_vector_direct(flatcc_builder_t *B, flatcc_builder_ref_t *data, size_t count); /** * Starts a vector holding offsets to tables or strings. Before * completion it will hold `flatcc_builder_ref_t` references because the * offset is not known until the vector start location is known, which * depends to the final size, which for parsers is generally unknown. */ int flatcc_builder_start_offset_vector(flatcc_builder_t *B); /** * Similar to `end_vector` but updates all stored references so they * become offsets to the vector start. */ flatcc_builder_ref_t flatcc_builder_end_offset_vector(flatcc_builder_t *B); /** * Same as `flatcc_builder_end_offset_vector` except null references are * permitted when the corresponding `type` entry is 0 (the 'NONE' type). * This makes it possible to build union vectors with less overhead when * the `type` vector is already known. Use standand offset vector calls * prior to this call. */ flatcc_builder_ref_t flatcc_builder_end_offset_vector_for_unions(flatcc_builder_t *B, const flatcc_builder_utype_t *type); /** Returns the number of elements currently on the stack. */ size_t flatcc_builder_offset_vector_count(flatcc_builder_t *B); /** * Returns a pointer ot the first vector element on stack, * accessible up to the number of elements currently on stack. */ void *flatcc_builder_offset_vector_edit(flatcc_builder_t *B); /** * Similar to `extend_vector` but returns a buffer indexable as * `flatcc_builder_ref_t` array. All elements must be set to a valid * unique non-null reference, but truncate and extend may be used to * perform edits. Unused references will leave garbage in the buffer. * References should not originate from any other buffer than the * current, including parents and nested buffers. It is valid to reuse * references in DAG form when contained in the sammer, excluding any * nested, sibling or parent buffers. */ flatcc_builder_ref_t *flatcc_builder_extend_offset_vector(flatcc_builder_t *B, size_t count); /** Similar to truncate_vector. */ int flatcc_builder_truncate_offset_vector(flatcc_builder_t *B, size_t count); /** * A specialized extend that pushes a single element. * * Returns the buffer holding a modifiable copy of the added content, * or null on error. */ flatcc_builder_ref_t *flatcc_builder_offset_vector_push(flatcc_builder_t *B, flatcc_builder_ref_t ref); /** * Takes an array of refs as argument to do a multi push operation. * * Returns the buffer holding a modifiable copy of the added content, * or null on error. */ flatcc_builder_ref_t *flatcc_builder_append_offset_vector(flatcc_builder_t *B, const flatcc_builder_ref_t *refs, size_t count); /** * All union vector operations are like offset vector operations, * except they take a struct with a type and a reference rather than * just a reference. The finished union vector is returned as a struct * of two references, one for the type vector and one for the table offset * vector. Each reference goes to a separate table field where the type * offset vector id must be one larger than the type vector. */ /** * Creates a union vector which is in reality two vectors, a type vector * and an offset vector. Both vectors references are returned. */ flatcc_builder_union_vec_ref_t flatcc_builder_create_union_vector(flatcc_builder_t *B, const flatcc_builder_union_ref_t *urefs, size_t count); /* * NOTE: this call takes non-const source array of references * and destroys the content. The type array remains intact. * * This is a faster version of `create_union_vector` where the source * references are destroyed and where the types are given in a separate * array. In return the vector can be emitted directly without passing * over the stack. * * Unlike `create_offset_vector` we do allow null references but only if * the union type is NONE (0). */ flatcc_builder_union_vec_ref_t flatcc_builder_create_union_vector_direct(flatcc_builder_t *B, const flatcc_builder_utype_t *types, flatcc_builder_ref_t *data, size_t count); /* * Creates just the type vector part of a union vector. This is * similar to a normal `create_vector` call except that the size * and alignment are given implicitly. Can be used during * cloning or similar operations where the types are all given * but the values must be handled one by one as prescribed by * the type. The values can be added separately as an offset vector. */ flatcc_builder_ref_t flatcc_builder_create_type_vector(flatcc_builder_t *B, const flatcc_builder_utype_t *types, size_t count); /** * Starts a vector holding types and offsets to tables or strings. Before * completion it will hold `flatcc_builder_union_ref_t` references because the * offset is not known until the vector start location is known, which * depends to the final size, which for parsers is generally unknown, * and also because the union type must be separated out into a separate * vector. It would not be practicaly to push on two different vectors * during construction. */ int flatcc_builder_start_union_vector(flatcc_builder_t *B); /** * Similar to `end_vector` but updates all stored references so they * become offsets to the vector start and splits the union references * into a type vector and an offset vector. */ flatcc_builder_union_vec_ref_t flatcc_builder_end_union_vector(flatcc_builder_t *B); /** Returns the number of elements currently on the stack. */ size_t flatcc_builder_union_vector_count(flatcc_builder_t *B); /** * Returns a pointer ot the first vector element on stack, * accessible up to the number of elements currently on stack. */ void *flatcc_builder_union_vector_edit(flatcc_builder_t *B); /** * Similar to `extend_offset_vector` but returns a buffer indexable as a * `flatcc_builder_union_ref_t` array. All elements must be set to a valid * unique non-null reference with a valid union type to match, or it * must be null with a zero union type. */ flatcc_builder_union_ref_t *flatcc_builder_extend_union_vector(flatcc_builder_t *B, size_t count); /** Similar to truncate_vector. */ int flatcc_builder_truncate_union_vector(flatcc_builder_t *B, size_t count); /** * A specialized extend that pushes a single element. * * Returns the buffer holding a modifiable copy of the added content, * or null on error. */ flatcc_builder_union_ref_t *flatcc_builder_union_vector_push(flatcc_builder_t *B, flatcc_builder_union_ref_t uref); /** * Takes an array of union_refs as argument to do a multi push operation. * * Returns the buffer holding a modifiable copy of the added content, * or null on error. */ flatcc_builder_union_ref_t *flatcc_builder_append_union_vector(flatcc_builder_t *B, const flatcc_builder_union_ref_t *urefs, size_t count); /** * Faster string operation that avoids temporary stack storage. The * string is not required to be zero-terminated, but is expected * (unchecked) to be utf-8. Embedded zeroes would be allowed but * ubyte vectors should be used for that. The resulting string will * have a zero termination added, not included in length. */ flatcc_builder_ref_t flatcc_builder_create_string(flatcc_builder_t *B, const char *s, size_t len); /** `create_string` up to zero termination of source. */ flatcc_builder_ref_t flatcc_builder_create_string_str(flatcc_builder_t *B, const char *s); /** * `create_string` up to zero termination or at most max_len of source. * * Note that like `strncpy` it will include `max_len` characters if * the source is longer than `max_len`, but unlike `strncpy` it will * always add zero termination. */ flatcc_builder_ref_t flatcc_builder_create_string_strn(flatcc_builder_t *B, const char *s, size_t max_len); /** * Starts an empty string that can be extended subsequently. * * While the string is being created, it is guaranteed that there is * always a null character after the end of the current string length. * This also holds after `extend` and `append` operations. It is not * allowed to modify the null character. * * Returns 0 on success. */ int flatcc_builder_start_string(flatcc_builder_t *B); /** * Similar to `extend_vector` except for the buffer return type and a * slight speed advantage. Strings are expected to contain utf-8 content * but this isn't verified, and null characters would be accepted. The * length is given in bytes. * * Appending too much, then truncating can be used to trim string * escapes during parsing, or convert between unicode formats etc. */ char *flatcc_builder_extend_string(flatcc_builder_t *B, size_t len); /** * Concatenes a length of string. If the string contains zeroes (which * it formally shouldn't), they will be copied in. * * Returns the buffer holding a modifiable copy of the added content, * or null on error. */ char *flatcc_builder_append_string(flatcc_builder_t *B, const char *s, size_t len); /** `append_string` up to zero termination of source. */ char *flatcc_builder_append_string_str(flatcc_builder_t *B, const char *s); /** `append_string` up zero termination or at most max_len of source. */ char *flatcc_builder_append_string_strn(flatcc_builder_t *B, const char *s, size_t max_len); /** * Similar to `truncate_vector` available for consistency and a slight * speed advantage. Reduces string by `len` bytes - it does not set * the length. The resulting length must not become negative. Zero * termination is not counted. * * Returns -1 of the length becomes negative, 0 on success. */ int flatcc_builder_truncate_string(flatcc_builder_t *B, size_t len); /** * Similar to `end_vector` but adds a trailing zero not included * in the length. The trailing zero is added regardless of whatever * zero content may exist in the provided string (although it * formally should not contain any). */ flatcc_builder_ref_t flatcc_builder_end_string(flatcc_builder_t *B); /** Returns the length of string currently on the stack. */ size_t flatcc_builder_string_len(flatcc_builder_t *B); /** * Returns a ponter to the start of the string * accessible up the length of string currently on the stack. */ char *flatcc_builder_string_edit(flatcc_builder_t *B); /* * Only for use with the default emitter. * * Fast acces to small buffers from default emitter. * * Only valid for default emitters before `flatcc_builder_clear`. The * return buffer is not valid after a call to `flatcc_builder_reset` or * `flatcc_builder_clear`. * * Returns null if the buffer size is too large to a have a linear * memory representation or if the emitter is not the default. A valid * size is between half and a full emitter page size depending on vtable * content. * * Non-default emitters must be accessed by means specific to the * particular emitter. * * If `size_out` is not null, it is set to the buffer size, or 0 if * operation failed. * * The returned buffer should NOT be deallocated explicitly. * * The buffer size is the size reported by `flatcc_builder_get_buffer_size`. */ void *flatcc_builder_get_direct_buffer(flatcc_builder_t *B, size_t *size_out); /* * Only for use with the default emitter. * * Default finalizer that allocates a buffer from the default emitter. * * Returns null if memory could not be allocated or if the emitter is * not the default. This is just a convenience method - there are many * other possible ways to extract the result of the emitter depending on * use case. * * If `size_out` is not null, it is set to the buffer size, or 0 if * operation failed. * * The allocated buffer is aligned according to malloc which may not be * sufficient in advanced cases - for that purpose * `flatcc_builder_finalize_aligned_buffer` may be used. * * It may be worth calling `flatcc_builder_get_direct_buffer` first to see * if the buffer is small enough to avoid copying. * * The returned buffer must be deallocated using `free`. */ void *flatcc_builder_finalize_buffer(flatcc_builder_t *B, size_t *size_out); /* * Only for use with the default emitter. * * Similar to `flatcc_builder_finalize_buffer` but ensures the returned * memory is aligned to the overall alignment required for the buffer. * Often it is not necessary unless special operations rely on larger * alignments than the stored scalars. * * If `size_out` is not null, it is set to the buffer size, or 0 if * operation failed. * * The returned buffer must be deallocated using `aligned_free` which is * implemented via `flatcc_flatbuffers.h`. `free` will usually work but * is not portable to platforms without posix_memalign or C11 * aligned_alloc support. * * NOTE: if a library might be compiled with a version of aligned_free * that differs from the application using it, use * `flatcc_builder_aligned_free` to make sure the correct deallocation * function is used. */ void *flatcc_builder_finalize_aligned_buffer(flatcc_builder_t *B, size_t *size_out); /* * A stable implementation of `aligned_alloc` that is not sensitive * to the applications compile time flags. */ void *flatcc_builder_aligned_alloc(size_t alignment, size_t size); /* * A stable implementation of `aligned_free` that is not sensitive * to the applications compile time flags. */ void flatcc_builder_aligned_free(void *p); /* * Same allocation as `flatcc_builder_finalize_buffer` returnes. Usually * same as `malloc` but can redefined via macros. */ void *flatcc_builder_alloc(size_t size); /* * A stable implementation of `free` when the default allocation * methods have been redefined. * * Deallocates memory returned from `flatcc_builder_finalize_buffer`. */ void flatcc_builder_free(void *p); /* * Only for use with the default emitter. * * Convenience method to copy buffer from default emitter. Forwards * call to default emitter and returns input pointer, or null if * the emitter is not default or of the given size is smaller than * the buffer size. * * Note: the `size` argument is the target buffers capacity, not the * flatcc_builders buffer size. * * Other emitters have custom interfaces for reaching their content. */ void *flatcc_builder_copy_buffer(flatcc_builder_t *B, void *buffer, size_t size); #ifdef __cplusplus } #endif #endif /* FLATCC_BUILDER_H */ nanoarrow/src/materialize.c0000644000176200001440000005565614672341746015560 0ustar liggesusers// 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. #define R_NO_REMAP #include #include #include "array.h" #include "nanoarrow.h" #include "nanoarrow/r.h" #include "util.h" // Needed for the list_of materializer #include "convert.h" #include "materialize.h" #include "materialize_blob.h" #include "materialize_chr.h" #include "materialize_date.h" #include "materialize_dbl.h" #include "materialize_difftime.h" #include "materialize_int.h" #include "materialize_int64.h" #include "materialize_lgl.h" #include "materialize_posixct.h" #include "materialize_unspecified.h" SEXP nanoarrow_alloc_type(enum VectorType vector_type, R_xlen_t len) { switch (vector_type) { case VECTOR_TYPE_LGL: return Rf_allocVector(LGLSXP, len); case VECTOR_TYPE_INT: return Rf_allocVector(INTSXP, len); case VECTOR_TYPE_DBL: return Rf_allocVector(REALSXP, len); case VECTOR_TYPE_CHR: return Rf_allocVector(STRSXP, len); default: return R_NilValue; } } // A version of Rf_getAttrib(x, sym) != R_NilValue that never // expands the row.names attribute static int has_attrib_safe(SEXP x, SEXP sym) { for (SEXP atts = ATTRIB(x); atts != R_NilValue; atts = CDR(atts)) { if (TAG(atts) == sym) return TRUE; } return FALSE; } R_xlen_t nanoarrow_data_frame_size(SEXP x) { if (Rf_length(x) > 0) { // This both avoids materializing the row.names attribute and // makes this work with struct-style vctrs that don't have a // row.names attribute but that always have one or more element return Rf_xlength(VECTOR_ELT(x, 0)); } else { // Since ALTREP was introduced, materializing the row.names attribute is // usually deferred such that values in the form c(NA, -nrow), 1:nrow, or // as.character(1:nrow) are never actually computed when the length is // taken. return Rf_xlength(Rf_getAttrib(x, R_RowNamesSymbol)); } } void nanoarrow_set_rownames(SEXP x, R_xlen_t len) { // If len fits in the integer range, we can use the c(NA, -nrow) // shortcut for the row.names attribute. R expands this when // the actual value is accessed (even from Rf_getAttrib()). // If len does not fit in the integer range, we need // as.character(seq_len(nrow)) (which returns a deferred ALTREP // string conversion of an ALTREP sequence in recent R). Manipulating // data frames with more than INT_MAX rows is not supported in most // places but column access still works. if (len <= INT_MAX) { SEXP rownames = PROTECT(Rf_allocVector(INTSXP, 2)); INTEGER(rownames)[0] = NA_INTEGER; INTEGER(rownames)[1] = (int)(-len); Rf_setAttrib(x, R_RowNamesSymbol, rownames); UNPROTECT(1); } else { SEXP length_dbl = PROTECT(Rf_ScalarReal((double)len)); SEXP seq_len_symbol = PROTECT(Rf_install("seq_len")); SEXP seq_len_call = PROTECT(Rf_lang2(seq_len_symbol, length_dbl)); SEXP rownames_call = PROTECT(Rf_lang2(R_AsCharacterSymbol, seq_len_call)); Rf_setAttrib(x, R_RowNamesSymbol, Rf_eval(rownames_call, R_BaseNamespace)); UNPROTECT(4); } } int nanoarrow_ptype_is_data_frame(SEXP ptype) { return Rf_isObject(ptype) && TYPEOF(ptype) == VECSXP && (Rf_inherits(ptype, "data.frame") || (Rf_xlength(ptype) > 0 && has_attrib_safe(ptype, R_NamesSymbol))); } int nanoarrow_ptype_is_nanoarrow_vctr(SEXP ptype) { return Rf_inherits(ptype, "nanoarrow_vctr"); } SEXP nanoarrow_materialize_realloc(SEXP ptype, R_xlen_t len) { SEXP result; if (Rf_isObject(ptype)) { // There may be a more accurate test that more precisely captures the case // where a user has specified a valid ptype that doesn't work in a preallocate // + fill conversion. if (Rf_inherits(ptype, "factor")) { SEXP levels = Rf_getAttrib(ptype, R_LevelsSymbol); if (Rf_length(levels) == 0) { Rf_error("Can't allocate ptype of class 'factor' with empty levels"); } } if (nanoarrow_ptype_is_nanoarrow_vctr(ptype)) { // The object we return here is one that will accumulate chunks and // be finalized with a value (rather than being strictly copied into // after every new chunk is seen). result = PROTECT(Rf_allocVector(INTSXP, len)); Rf_copyMostAttrib(ptype, result); // For the purposes of building the list of chunks, chunks is a pairlist // (it will be converted to a regular list when this converter is finalized) // Technically the first value here won't be used (this simplifies the // appending). SEXP chunks_list = PROTECT(Rf_list1(R_NilValue)); // To start, the chunks list and the end of the chunks list are the same node SEXP chunks_tail_sym = PROTECT(Rf_install("chunks_tail")); SEXP chunks_sym = PROTECT(Rf_install("chunks")); Rf_setAttrib(result, chunks_sym, chunks_list); Rf_setAttrib(result, chunks_tail_sym, chunks_list); UNPROTECT(3); } else if (nanoarrow_ptype_is_data_frame(ptype)) { R_xlen_t num_cols = Rf_xlength(ptype); result = PROTECT(Rf_allocVector(VECSXP, num_cols)); for (R_xlen_t i = 0; i < num_cols; i++) { SET_VECTOR_ELT(result, i, nanoarrow_materialize_realloc(VECTOR_ELT(ptype, i), len)); } // Set attributes from ptype Rf_setAttrib(result, R_NamesSymbol, Rf_getAttrib(ptype, R_NamesSymbol)); Rf_copyMostAttrib(ptype, result); // ...except rownames if (Rf_inherits(ptype, "data.frame")) { nanoarrow_set_rownames(result, len); } } else { result = PROTECT(Rf_allocVector(TYPEOF(ptype), len)); Rf_copyMostAttrib(ptype, result); } } else { result = PROTECT(Rf_allocVector(TYPEOF(ptype), len)); } UNPROTECT(1); return result; } // Used in union building to pre-set all values to null static void fill_vec_with_nulls(SEXP x, R_xlen_t offset, R_xlen_t len) { if (nanoarrow_ptype_is_data_frame(x)) { for (R_xlen_t i = 0; i < Rf_xlength(x); i++) { fill_vec_with_nulls(VECTOR_ELT(x, i), offset, len); } return; } switch (TYPEOF(x)) { case RAWSXP: // Not perfect: raw() doesn't really support NA in R memset(RAW(x), 0, len * sizeof(char)); break; case LGLSXP: case INTSXP: { int* values = INTEGER(x); for (R_xlen_t i = 0; i < len; i++) { values[offset + i] = NA_INTEGER; } return; } case REALSXP: { double* values = REAL(x); for (R_xlen_t i = 0; i < len; i++) { values[offset + i] = NA_REAL; } return; } case CPLXSXP: { Rcomplex* values = COMPLEX(x); Rcomplex na_value; na_value.r = NA_REAL; na_value.i = NA_REAL; for (R_xlen_t i = 0; i < len; i++) { values[offset + i] = na_value; } return; } case STRSXP: for (R_xlen_t i = 0; i < len; i++) { SET_STRING_ELT(x, offset + i, NA_STRING); } return; case VECSXP: for (R_xlen_t i = 0; i < len; i++) { SET_VECTOR_ELT(x, offset + i, R_NilValue); } return; default: Rf_error("Attempt to fill vector with nulls with unsupported type"); } } static void copy_vec_into(SEXP x, SEXP dst, R_xlen_t offset, R_xlen_t len) { if (nanoarrow_ptype_is_nanoarrow_vctr(dst)) { Rf_error("Can't copy_vec_into() to nanoarrow_vctr"); } if (nanoarrow_ptype_is_data_frame(dst)) { if (!nanoarrow_ptype_is_data_frame(x)) { Rf_error("Expected record-style vctr result but got non-record-style result"); } R_xlen_t x_len = nanoarrow_data_frame_size(x); if (len != x_len) { Rf_error("Unexpected data.frame row count in copy_vec_into()"); } // This does not currently consider column names (i.e., it blindly copies // by index). if (Rf_xlength(x) != Rf_xlength(dst)) { Rf_error("Unexpected data.frame column count in copy_vec_into()"); } for (R_xlen_t i = 0; i < Rf_xlength(x); i++) { copy_vec_into(VECTOR_ELT(x, i), VECTOR_ELT(dst, i), offset, len); } return; } else if (nanoarrow_ptype_is_data_frame(x)) { Rf_error("Expected non-record-style vctr result but got record-style result"); } if (TYPEOF(dst) != TYPEOF(x)) { Rf_error("Unexpected SEXP type in result copy_vec_into()"); } if (Rf_length(x) != len) { Rf_error("Unexpected length of result in copy_vec_into()"); } switch (TYPEOF(dst)) { case RAWSXP: memcpy(RAW(dst) + offset, RAW(x), len * sizeof(uint8_t)); break; case REALSXP: memcpy(REAL(dst) + offset, REAL(x), len * sizeof(double)); break; case INTSXP: case LGLSXP: memcpy(INTEGER(dst) + offset, INTEGER(x), len * sizeof(int)); break; case CPLXSXP: memcpy(COMPLEX(dst) + offset, COMPLEX(x), len * sizeof(Rcomplex)); break; case STRSXP: for (R_xlen_t i = 0; i < len; i++) { SET_STRING_ELT(dst, offset + i, STRING_ELT(x, i)); } break; case VECSXP: for (R_xlen_t i = 0; i < len; i++) { SET_VECTOR_ELT(dst, offset + i, VECTOR_ELT(x, i)); } break; default: Rf_error("Unhandled SEXP type in copy_vec_into()"); break; } } int nanoarrow_materialize_finalize_result(SEXP converter_xptr) { SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SEXP result = VECTOR_ELT(converter_shelter, 4); // Materialize never called (e.g., empty stream) if (result == R_NilValue) { NANOARROW_RETURN_NOT_OK(nanoarrow_converter_reserve(converter_xptr, 0)); result = VECTOR_ELT(converter_shelter, 4); } if (nanoarrow_ptype_is_nanoarrow_vctr(result)) { // Get the schema for this converter. Technically this will overwrite // a schema that was provided explicitly; however, we currently do not // handle that case. SEXP schema_xptr = VECTOR_ELT(converter_shelter, 1); // We no longer need to keep track of chunks_tail SEXP chunks_tail_sym = PROTECT(Rf_install("chunks_tail")); Rf_setAttrib(result, chunks_tail_sym, R_NilValue); // We also want to pass on the class of the ptype we received SEXP subclass_sexp = Rf_getAttrib(result, R_ClassSymbol); // We no longer need the first element of the pairlist, which was // intentionally set to R_NilValue. SEXP chunks_sym = PROTECT(Rf_install("chunks")); SEXP chunks_pairlist0 = Rf_getAttrib(result, chunks_sym); // If there were zero chunks, there will be no "first" node SEXP chunks_list; if (CDR(chunks_pairlist0) == R_NilValue) { chunks_list = PROTECT(Rf_allocVector(VECSXP, 0)); } else { chunks_list = PROTECT(Rf_PairToVectorList(CDR(chunks_pairlist0))); } // Set up the call to new_nanoarrow_vctr SEXP new_nanoarrow_vctr_sym = PROTECT(Rf_install("new_nanoarrow_vctr")); SEXP new_nanoarrow_vctr_call = PROTECT( Rf_lang4(new_nanoarrow_vctr_sym, chunks_list, schema_xptr, subclass_sexp)); SEXP final_result = PROTECT(Rf_eval(new_nanoarrow_vctr_call, nanoarrow_ns_pkg)); SET_VECTOR_ELT(converter_shelter, 4, final_result); UNPROTECT(6); } else if (nanoarrow_ptype_is_data_frame(result)) { // For each child, finalize the result and then reassign it SEXP child_converter_xptrs = VECTOR_ELT(converter_shelter, 3); for (R_xlen_t i = 0; i < Rf_xlength(child_converter_xptrs); i++) { SEXP child_converter_xptr = VECTOR_ELT(child_converter_xptrs, i); NANOARROW_RETURN_NOT_OK( nanoarrow_materialize_finalize_result(child_converter_xptr)); SEXP child_result = PROTECT(nanoarrow_converter_release_result(child_converter_xptr)); SET_VECTOR_ELT(result, i, child_result); UNPROTECT(1); } } return NANOARROW_OK; } static int nanoarrow_materialize_nanoarrow_vctr(struct RConverter* converter, SEXP converter_xptr) { // This is a case where the callee needs ownership, which we can do via a // shallow copy. SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SEXP schema_xptr = VECTOR_ELT(converter_shelter, 1); SEXP array_xptr = VECTOR_ELT(converter_shelter, 2); SEXP array_out_xptr = PROTECT(nanoarrow_array_owning_xptr()); struct ArrowArray* out_array = nanoarrow_output_array_from_xptr(array_out_xptr); array_export(array_xptr, out_array); R_SetExternalPtrTag(array_out_xptr, schema_xptr); // Update the offset/length in case a slice is being requested from the // converter. out_array->offset += converter->src.offset; out_array->length = converter->src.length; // Get the cached copy of the pairlist node at the end of the current // chunks list. SEXP chunks_tail_sym = PROTECT(Rf_install("chunks_tail")); SEXP chunks_tail = PROTECT(Rf_getAttrib(converter->dst.vec_sexp, chunks_tail_sym)); // Create a length-1 pairlist node containing the chunk SEXP next_sexp = PROTECT(Rf_cons(array_out_xptr, R_NilValue)); // Append it to the end of the current pairlist SETCDR(chunks_tail, next_sexp); UNPROTECT(1); // Update the cached copy of the pairlist node at the end of the current // chunks list. Rf_setAttrib(converter->dst.vec_sexp, chunks_tail_sym, next_sexp); UNPROTECT(3); return NANOARROW_OK; } static int nanoarrow_materialize_other(struct RConverter* converter, SEXP converter_xptr) { // Ensure that we have a ptype SEXP to send in the call back to R if (converter->ptype_view.ptype == R_NilValue) { SEXP ptype = PROTECT(nanoarrow_alloc_type(converter->ptype_view.vector_type, 0)); converter->ptype_view.ptype = ptype; SET_VECTOR_ELT(R_ExternalPtrProtected(converter_xptr), 0, ptype); UNPROTECT(1); } // Special-case the nanoarrow_vctr conversion if (Rf_inherits(converter->dst.vec_sexp, "nanoarrow_vctr")) { return nanoarrow_materialize_nanoarrow_vctr(converter, converter_xptr); } // We've ensured proper ownership of array_xptr and ensured that its // schema is set, so we can pass these safely to the R-level // convert_fallback_other. SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SEXP array_xptr = VECTOR_ELT(converter_shelter, 2); // The R code in convert_fallback_other() takes care of ensuring an independent copy // with the correct offset/length if it is necessary to update them. SEXP offset_sexp = PROTECT( Rf_ScalarReal((double)(converter->src.array_view->offset + converter->src.offset))); SEXP length_sexp = PROTECT(Rf_ScalarReal((double)converter->src.length)); SEXP fun = PROTECT(Rf_install("convert_fallback_other")); SEXP call = PROTECT( Rf_lang5(fun, array_xptr, offset_sexp, length_sexp, converter->ptype_view.ptype)); SEXP result_src = PROTECT(Rf_eval(call, nanoarrow_ns_pkg)); // Copy the result into a slice of dst copy_vec_into(result_src, converter->dst.vec_sexp, converter->dst.offset, converter->dst.length); UNPROTECT(5); return NANOARROW_OK; } static int nanoarrow_materialize_data_frame(struct RConverter* converter, SEXP converter_xptr) { if (converter->ptype_view.vector_type != VECTOR_TYPE_DATA_FRAME) { return EINVAL; } // Make sure we error for dictionary types if (converter->src.array_view->array->dictionary != NULL) { return EINVAL; } SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SEXP child_converter_xptrs = VECTOR_ELT(converter_shelter, 3); switch (converter->array_view.storage_type) { case NANOARROW_TYPE_STRUCT: for (R_xlen_t i = 0; i < converter->n_children; i++) { converter->children[i]->src.offset = converter->src.offset; converter->children[i]->src.length = converter->src.length; converter->children[i]->dst.offset = converter->dst.offset; converter->children[i]->dst.length = converter->dst.length; SEXP child_converter_xptr = VECTOR_ELT(child_converter_xptrs, i); NANOARROW_RETURN_NOT_OK( nanoarrow_materialize(converter->children[i], child_converter_xptr)); } return NANOARROW_OK; case NANOARROW_TYPE_DENSE_UNION: case NANOARROW_TYPE_SPARSE_UNION: // Pre-fill everything with nulls fill_vec_with_nulls(converter->dst.vec_sexp, converter->dst.offset, converter->dst.length); // Fill in the possibly non-null values one at a time for (R_xlen_t i = 0; i < converter->dst.length; i++) { int64_t child_index = ArrowArrayViewUnionChildIndex(&converter->array_view, converter->src.offset + i); int64_t child_offset = ArrowArrayViewUnionChildOffset(&converter->array_view, converter->src.offset + i); converter->children[child_index]->src.offset = child_offset; converter->children[child_index]->src.length = 1; converter->children[child_index]->dst.offset = converter->dst.offset + i; converter->children[child_index]->dst.length = 1; SEXP child_converter_xptr = VECTOR_ELT(child_converter_xptrs, child_index); NANOARROW_RETURN_NOT_OK(nanoarrow_materialize(converter->children[child_index], child_converter_xptr)); } return NANOARROW_OK; default: return ENOTSUP; } } static int materialize_list_element(struct RConverter* converter, SEXP converter_xptr, int64_t offset, int64_t length) { if (nanoarrow_converter_reserve(converter_xptr, length) != NANOARROW_OK) { nanoarrow_converter_stop(converter_xptr); } converter->src.offset = offset; converter->src.length = length; converter->dst.offset = 0; converter->dst.length = length; if (nanoarrow_converter_materialize_n(converter_xptr, length) != length) { return EINVAL; } NANOARROW_RETURN_NOT_OK(nanoarrow_converter_finalize(converter_xptr)); return NANOARROW_OK; } static int nanoarrow_materialize_list_of(struct RConverter* converter, SEXP converter_xptr) { SEXP converter_shelter = R_ExternalPtrProtected(converter_xptr); SEXP child_converter_xptrs = VECTOR_ELT(converter_shelter, 3); struct RConverter* child_converter = converter->children[0]; SEXP child_converter_xptr = VECTOR_ELT(child_converter_xptrs, 0); struct ArrayViewSlice* src = &converter->src; struct VectorSlice* dst = &converter->dst; // Make sure we error for dictionary types if (src->array_view->array->dictionary != NULL) { return EINVAL; } const int32_t* offsets = src->array_view->buffer_views[1].data.as_int32; const int64_t* large_offsets = src->array_view->buffer_views[1].data.as_int64; int64_t raw_src_offset = src->array_view->array->offset + src->offset; int64_t offset; int64_t length; switch (src->array_view->storage_type) { case NANOARROW_TYPE_NA: return NANOARROW_OK; case NANOARROW_TYPE_LIST: for (int64_t i = 0; i < dst->length; i++) { if (!ArrowArrayViewIsNull(src->array_view, src->offset + i)) { offset = offsets[raw_src_offset + i]; length = offsets[raw_src_offset + i + 1] - offset; NANOARROW_RETURN_NOT_OK(materialize_list_element( child_converter, child_converter_xptr, offset, length)); SET_VECTOR_ELT(dst->vec_sexp, dst->offset + i, nanoarrow_converter_release_result(child_converter_xptr)); } } break; case NANOARROW_TYPE_LARGE_LIST: for (int64_t i = 0; i < dst->length; i++) { if (!ArrowArrayViewIsNull(src->array_view, src->offset + i)) { offset = large_offsets[raw_src_offset + i]; length = large_offsets[raw_src_offset + i + 1] - offset; NANOARROW_RETURN_NOT_OK(materialize_list_element( child_converter, child_converter_xptr, offset, length)); SET_VECTOR_ELT(dst->vec_sexp, dst->offset + i, nanoarrow_converter_release_result(child_converter_xptr)); } } break; case NANOARROW_TYPE_FIXED_SIZE_LIST: length = src->array_view->layout.child_size_elements; for (int64_t i = 0; i < dst->length; i++) { if (!ArrowArrayViewIsNull(src->array_view, src->offset + i)) { offset = (raw_src_offset + i) * length; NANOARROW_RETURN_NOT_OK(materialize_list_element( child_converter, child_converter_xptr, offset, length)); SET_VECTOR_ELT(dst->vec_sexp, dst->offset + i, nanoarrow_converter_release_result(child_converter_xptr)); } } break; default: return EINVAL; } return NANOARROW_OK; } static int nanoarrow_materialize_base(struct RConverter* converter, SEXP converter_xptr) { struct ArrayViewSlice* src = &converter->src; struct VectorSlice* dst = &converter->dst; struct MaterializeOptions* options = converter->options; // Make sure extension conversion calls into R if (converter->schema_view.extension_name.size_bytes > 0) { return nanoarrow_materialize_other(converter, converter_xptr); } switch (converter->ptype_view.vector_type) { case VECTOR_TYPE_UNSPECIFIED: return nanoarrow_materialize_unspecified(src, dst, options); case VECTOR_TYPE_LGL: return nanoarrow_materialize_lgl(src, dst, options); case VECTOR_TYPE_INT: return nanoarrow_materialize_int(src, dst, options); case VECTOR_TYPE_DBL: return nanoarrow_materialize_dbl(converter); case VECTOR_TYPE_CHR: return nanoarrow_materialize_chr(converter); case VECTOR_TYPE_POSIXCT: return nanoarrow_materialize_posixct(converter); case VECTOR_TYPE_DATE: return nanoarrow_materialize_date(converter); case VECTOR_TYPE_DIFFTIME: return nanoarrow_materialize_difftime(converter); case VECTOR_TYPE_INTEGER64: return nanoarrow_materialize_int64(src, dst, options); case VECTOR_TYPE_BLOB: return nanoarrow_materialize_blob(src, dst, options); case VECTOR_TYPE_LIST_OF: return nanoarrow_materialize_list_of(converter, converter_xptr); case VECTOR_TYPE_DATA_FRAME: return nanoarrow_materialize_data_frame(converter, converter_xptr); default: return nanoarrow_materialize_other(converter, converter_xptr); } } int nanoarrow_materialize(struct RConverter* converter, SEXP converter_xptr) { int result = nanoarrow_materialize_base(converter, converter_xptr); if (result != NANOARROW_OK) { return nanoarrow_materialize_other(converter, converter_xptr); } else { return NANOARROW_OK; } } nanoarrow/src/flatcc.c0000644000176200001440000031635414702632113014462 0ustar liggesusers/* * Codegenerator for C, building FlatBuffers. * * There are several approaches, some light, some requiring a library, * some with vectored I/O etc. * * Here we focus on a reasonable balance of light code and efficiency. * * Builder code is generated to a separate file that includes the * generated read-only code. * * Mutable buffers are not supported in this version. * */ #include #include #include "flatcc/flatcc_builder.h" #include "flatcc/flatcc_emitter.h" /* * `check` is designed to handle incorrect use errors that can be * ignored in production of a tested product. * * `check_error` fails if condition is false and is designed to return an * error code in production. */ #if FLATCC_BUILDER_ASSERT_ON_ERROR #define check(cond, reason) FLATCC_BUILDER_ASSERT(cond, reason) #else #define check(cond, reason) ((void)0) #endif #if FLATCC_BUILDER_SKIP_CHECKS #define check_error(cond, err, reason) ((void)0) #else #define check_error(cond, err, reason) if (!(cond)) { check(cond, reason); return err; } #endif /* `strnlen` not widely supported. */ static inline size_t pstrnlen(const char *s, size_t max_len) { const char *end = memchr(s, 0, max_len); return end ? (size_t)(end - s) : max_len; } #undef strnlen #define strnlen pstrnlen /* Padding can be up to 255 zeroes, and 1 zero string termination byte. * When two paddings are combined at nested buffers, we need twice that. * Visible to emitter so it can test for zero padding in iov. */ const uint8_t flatcc_builder_padding_base[512] = { 0 }; #define _pad flatcc_builder_padding_base #define uoffset_t flatbuffers_uoffset_t #define soffset_t flatbuffers_soffset_t #define voffset_t flatbuffers_voffset_t #define utype_t flatbuffers_utype_t #define write_uoffset __flatbuffers_uoffset_write_to_pe #define write_voffset __flatbuffers_voffset_write_to_pe #define write_identifier __flatbuffers_uoffset_write_to_pe #define write_utype __flatbuffers_utype_write_to_pe #define field_size sizeof(uoffset_t) #define max_offset_count FLATBUFFERS_COUNT_MAX(field_size) #define union_size sizeof(flatcc_builder_union_ref_t) #define max_union_count FLATBUFFERS_COUNT_MAX(union_size) #define utype_size sizeof(utype_t) #define max_utype_count FLATBUFFERS_COUNT_MAX(utype_size) #define max_string_len FLATBUFFERS_COUNT_MAX(1) #define identifier_size FLATBUFFERS_IDENTIFIER_SIZE #define iovec_t flatcc_iovec_t #define frame_size sizeof(__flatcc_builder_frame_t) #define frame(x) (B->frame[0].x) /* `align` must be a power of 2. */ static inline uoffset_t alignup_uoffset(uoffset_t x, size_t align) { return (x + (uoffset_t)align - 1u) & ~((uoffset_t)align - 1u); } static inline size_t alignup_size(size_t x, size_t align) { return (x + align - 1u) & ~(align - 1u); } typedef struct vtable_descriptor vtable_descriptor_t; struct vtable_descriptor { /* Where the vtable is emitted. */ flatcc_builder_ref_t vt_ref; /* Which buffer it was emitted to. */ uoffset_t nest_id; /* Where the vtable is cached. */ uoffset_t vb_start; /* Hash table collision chain. */ uoffset_t next; }; typedef struct flatcc_iov_state flatcc_iov_state_t; struct flatcc_iov_state { size_t len; int count; flatcc_iovec_t iov[FLATCC_IOV_COUNT_MAX]; }; #define iov_state_t flatcc_iov_state_t /* This assumes `iov_state_t iov;` has been declared in scope */ #define push_iov_cond(base, size, cond) if ((size) > 0 && (cond)) { iov.len += size;\ iov.iov[iov.count].iov_base = (void *)(base); iov.iov[iov.count].iov_len = (size); ++iov.count; } #define push_iov(base, size) push_iov_cond(base, size, 1) #define init_iov() { iov.len = 0; iov.count = 0; } int flatcc_builder_default_alloc(void *alloc_context, iovec_t *b, size_t request, int zero_fill, int hint) { void *p; size_t n; (void)alloc_context; if (request == 0) { if (b->iov_base) { FLATCC_BUILDER_FREE(b->iov_base); b->iov_base = 0; b->iov_len = 0; } return 0; } switch (hint) { case flatcc_builder_alloc_ds: n = 256; break; case flatcc_builder_alloc_ht: /* Should be exact size, or space size is just wasted. */ n = request; break; case flatcc_builder_alloc_fs: n = sizeof(__flatcc_builder_frame_t) * 8; break; case flatcc_builder_alloc_us: n = 64; break; default: /* * We have many small structures - vs stack for tables with few * elements, and few offset fields in patch log. No need to * overallocate in case of busy small messages. */ n = 32; break; } while (n < request) { n *= 2; } if (request <= b->iov_len && b->iov_len / 2 >= n) { /* Add hysteresis to shrink. */ return 0; } if (!(p = FLATCC_BUILDER_REALLOC(b->iov_base, n))) { return -1; } /* Realloc might also shrink. */ if (zero_fill && b->iov_len < n) { memset((uint8_t *)p + b->iov_len, 0, n - b->iov_len); } b->iov_base = p; b->iov_len = n; return 0; } #define T_ptr(base, pos) ((void *)((size_t)(base) + (size_t)(pos))) #define ds_ptr(pos) (T_ptr(B->buffers[flatcc_builder_alloc_ds].iov_base, (pos))) #define vs_ptr(pos) (T_ptr(B->buffers[flatcc_builder_alloc_vs].iov_base, (pos))) #define pl_ptr(pos) (T_ptr(B->buffers[flatcc_builder_alloc_pl].iov_base, (pos))) #define us_ptr(pos) (T_ptr(B->buffers[flatcc_builder_alloc_us].iov_base, (pos))) #define vd_ptr(pos) (T_ptr(B->buffers[flatcc_builder_alloc_vd].iov_base, (pos))) #define vb_ptr(pos) (T_ptr(B->buffers[flatcc_builder_alloc_vb].iov_base, (pos))) #define vs_offset(ptr) ((uoffset_t)((size_t)(ptr) - (size_t)B->buffers[flatcc_builder_alloc_vs].iov_base)) #define pl_offset(ptr) ((uoffset_t)((size_t)(ptr) - (size_t)B->buffers[flatcc_builder_alloc_pl].iov_base)) #define us_offset(ptr) ((uoffset_t)((size_t)(ptr) - (size_t)B->buffers[flatcc_builder_alloc_us].iov_base)) #define table_limit (FLATBUFFERS_VOFFSET_MAX - field_size + 1) #define data_limit (FLATBUFFERS_UOFFSET_MAX - field_size + 1) #define set_identifier(id) memcpy(&B->identifier, (id) ? (void *)(id) : (void *)_pad, identifier_size) /* Must also return true when no buffer has been started. */ #define is_top_buffer(B) (B->nest_id == 0) /* * Tables use a stack represention better suited for quickly adding * fields to tables, but it must occasionally be refreshed following * reallocation or reentry from child frame. */ static inline void refresh_ds(flatcc_builder_t *B, uoffset_t type_limit) { iovec_t *buf = B->buffers + flatcc_builder_alloc_ds; B->ds = ds_ptr(B->ds_first); B->ds_limit = (uoffset_t)buf->iov_len - B->ds_first; /* * So we don't allocate outside tables representation size, nor our * current buffer size. */ if (B->ds_limit > type_limit) { B->ds_limit = type_limit; } /* So exit frame can refresh fast. */ frame(type_limit) = type_limit; } static int reserve_ds(flatcc_builder_t *B, size_t need, uoffset_t limit) { iovec_t *buf = B->buffers + flatcc_builder_alloc_ds; if (B->alloc(B->alloc_context, buf, B->ds_first + need, 1, flatcc_builder_alloc_ds)) { return -1; } refresh_ds(B, limit); return 0; } /* * Make sure there is always an extra zero termination on stack * even if it isn't emitted such that string updates may count * on zero termination being present always. */ static inline void *push_ds(flatcc_builder_t *B, uoffset_t size) { size_t offset; offset = B->ds_offset; if ((B->ds_offset += size) >= B->ds_limit) { if (reserve_ds(B, B->ds_offset + 1, data_limit)) { return 0; } } return B->ds + offset; } static inline void unpush_ds(flatcc_builder_t *B, uoffset_t size) { B->ds_offset -= size; memset(B->ds + B->ds_offset, 0, size); } static inline void *push_ds_copy(flatcc_builder_t *B, const void *data, uoffset_t size) { void *p; if (!(p = push_ds(B, size))) { return 0; } memcpy(p, data, size); return p; } static inline void *push_ds_field(flatcc_builder_t *B, uoffset_t size, uint16_t align, voffset_t id) { uoffset_t offset; /* * We calculate table field alignment relative to first entry, not * header field with vtable offset. * * Note: >= comparison handles special case where B->ds is not * allocated yet and size is 0 so the return value would be mistaken * for an error. */ offset = alignup_uoffset(B->ds_offset, align); if ((B->ds_offset = offset + size) >= B->ds_limit) { if (reserve_ds(B, B->ds_offset + 1, table_limit)) { return 0; } } B->vs[id] = (voffset_t)(offset + field_size); if (id >= B->id_end) { B->id_end = id + 1u; } return B->ds + offset; } static inline void *push_ds_offset_field(flatcc_builder_t *B, voffset_t id) { uoffset_t offset; offset = alignup_uoffset(B->ds_offset, field_size); if ((B->ds_offset = offset + field_size) > B->ds_limit) { if (reserve_ds(B, B->ds_offset, table_limit)) { return 0; } } B->vs[id] = (voffset_t)(offset + field_size); if (id >= B->id_end) { B->id_end = id + 1u; } *B->pl++ = (flatbuffers_voffset_t)offset; return B->ds + offset; } static inline void *reserve_buffer(flatcc_builder_t *B, int alloc_type, size_t used, size_t need, int zero_init) { iovec_t *buf = B->buffers + alloc_type; if (used + need > buf->iov_len) { if (B->alloc(B->alloc_context, buf, used + need, zero_init, alloc_type)) { check(0, "memory allocation failed"); return 0; } } return (void *)((size_t)buf->iov_base + used); } static inline int reserve_fields(flatcc_builder_t *B, int count) { size_t used, need; /* Provide faster stack operations for common table operations. */ used = frame(container.table.vs_end) + frame(container.table.id_end) * sizeof(voffset_t); need = (size_t)(count + 2) * sizeof(voffset_t); if (!(B->vs = reserve_buffer(B, flatcc_builder_alloc_vs, used, need, 1))) { return -1; } /* Move past header for convenience. */ B->vs += 2; used = frame(container.table.pl_end); /* Add one to handle special case of first table being empty. */ need = (size_t)count * sizeof(*(B->pl)) + 1; if (!(B->pl = reserve_buffer(B, flatcc_builder_alloc_pl, used, need, 0))) { return -1; } return 0; } static int alloc_ht(flatcc_builder_t *B) { iovec_t *buf = B->buffers + flatcc_builder_alloc_ht; size_t size, k; /* Allocate null entry so we can check for return errors. */ FLATCC_ASSERT(B->vd_end == 0); if (!reserve_buffer(B, flatcc_builder_alloc_vd, B->vd_end, sizeof(vtable_descriptor_t), 0)) { return -1; } B->vd_end = sizeof(vtable_descriptor_t); size = field_size * FLATCC_BUILDER_MIN_HASH_COUNT; if (B->alloc(B->alloc_context, buf, size, 1, flatcc_builder_alloc_ht)) { return -1; } while (size * 2 <= buf->iov_len) { size *= 2; } size /= field_size; for (k = 0; (((size_t)1) << k) < size; ++k) { } B->ht_width = k; return 0; } static inline uoffset_t *lookup_ht(flatcc_builder_t *B, uint32_t hash) { uoffset_t *T; if (B->ht_width == 0) { if (alloc_ht(B)) { return 0; } } T = B->buffers[flatcc_builder_alloc_ht].iov_base; return &T[FLATCC_BUILDER_BUCKET_VT_HASH(hash, B->ht_width)]; } void flatcc_builder_flush_vtable_cache(flatcc_builder_t *B) { iovec_t *buf = B->buffers + flatcc_builder_alloc_ht; if (B->ht_width == 0) { return; } memset(buf->iov_base, 0, buf->iov_len); /* Reserve the null entry. */ B->vd_end = sizeof(vtable_descriptor_t); B->vb_end = 0; } int flatcc_builder_custom_init(flatcc_builder_t *B, flatcc_builder_emit_fun *emit, void *emit_context, flatcc_builder_alloc_fun *alloc, void *alloc_context) { /* * Do not allocate anything here. Only the required buffers will be * allocated. For simple struct buffers, no allocation is required * at all. */ memset(B, 0, sizeof(*B)); if (emit == 0) { B->is_default_emitter = 1; emit = flatcc_emitter; emit_context = &B->default_emit_context; } if (alloc == 0) { alloc = flatcc_builder_default_alloc; } B->alloc_context = alloc_context; B->alloc = alloc; B->emit_context = emit_context; B->emit = emit; return 0; } int flatcc_builder_init(flatcc_builder_t *B) { return flatcc_builder_custom_init(B, 0, 0, 0, 0); } int flatcc_builder_custom_reset(flatcc_builder_t *B, int set_defaults, int reduce_buffers) { iovec_t *buf; int i; for (i = 0; i < FLATCC_BUILDER_ALLOC_BUFFER_COUNT; ++i) { buf = B->buffers + i; if (buf->iov_base) { /* Don't try to reduce the hash table. */ if (i != flatcc_builder_alloc_ht && reduce_buffers && B->alloc(B->alloc_context, buf, 1, 1, i)) { return -1; } memset(buf->iov_base, 0, buf->iov_len); } else { FLATCC_ASSERT(buf->iov_len == 0); } } B->vb_end = 0; if (B->vd_end > 0) { /* Reset past null entry. */ B->vd_end = sizeof(vtable_descriptor_t); } B->min_align = 0; B->emit_start = 0; B->emit_end = 0; B->level = 0; B->limit_level = 0; B->ds_offset = 0; B->ds_limit = 0; B->nest_count = 0; B->nest_id = 0; /* Needed for correct offset calculation. */ B->ds = B->buffers[flatcc_builder_alloc_ds].iov_base; B->pl = B->buffers[flatcc_builder_alloc_pl].iov_base; B->vs = B->buffers[flatcc_builder_alloc_vs].iov_base; B->frame = 0; if (set_defaults) { B->vb_flush_limit = 0; B->max_level = 0; B->disable_vt_clustering = 0; } if (B->is_default_emitter) { flatcc_emitter_reset(&B->default_emit_context); } if (B->refmap) { flatcc_refmap_reset(B->refmap); } return 0; } int flatcc_builder_reset(flatcc_builder_t *B) { return flatcc_builder_custom_reset(B, 0, 0); } void flatcc_builder_clear(flatcc_builder_t *B) { iovec_t *buf; int i; for (i = 0; i < FLATCC_BUILDER_ALLOC_BUFFER_COUNT; ++i) { buf = B->buffers + i; B->alloc(B->alloc_context, buf, 0, 0, i); } if (B->is_default_emitter) { flatcc_emitter_clear(&B->default_emit_context); } if (B->refmap) { flatcc_refmap_clear(B->refmap); } memset(B, 0, sizeof(*B)); } static inline void set_min_align(flatcc_builder_t *B, uint16_t align) { if (B->min_align < align) { B->min_align = align; } } /* * It's a max, but the minimum viable alignment is the largest observed * alignment requirement, but no larger. */ static inline void get_min_align(uint16_t *align, uint16_t b) { if (*align < b) { *align = b; } } void *flatcc_builder_enter_user_frame_ptr(flatcc_builder_t *B, size_t size) { size_t *frame; size = alignup_size(size, sizeof(size_t)) + sizeof(size_t); if (!(frame = reserve_buffer(B, flatcc_builder_alloc_us, B->user_frame_end, size, 0))) { return 0; } memset(frame, 0, size); *frame++ = B->user_frame_offset; B->user_frame_offset = B->user_frame_end + sizeof(size_t); B->user_frame_end += size; return frame; } size_t flatcc_builder_enter_user_frame(flatcc_builder_t *B, size_t size) { size_t *frame; size = alignup_size(size, sizeof(size_t)) + sizeof(size_t); if (!(frame = reserve_buffer(B, flatcc_builder_alloc_us, B->user_frame_end, size, 0))) { return 0; } memset(frame, 0, size); *frame++ = B->user_frame_offset; B->user_frame_offset = B->user_frame_end + sizeof(size_t); B->user_frame_end += size; return B->user_frame_offset; } size_t flatcc_builder_exit_user_frame(flatcc_builder_t *B) { size_t *hdr; FLATCC_ASSERT(B->user_frame_offset > 0); hdr = us_ptr(B->user_frame_offset); B->user_frame_end = B->user_frame_offset - sizeof(size_t); return B->user_frame_offset = hdr[-1]; } size_t flatcc_builder_exit_user_frame_at(flatcc_builder_t *B, size_t handle) { FLATCC_ASSERT(B->user_frame_offset >= handle); B->user_frame_offset = handle; return flatcc_builder_exit_user_frame(B); } size_t flatcc_builder_get_current_user_frame(flatcc_builder_t *B) { return B->user_frame_offset; } void *flatcc_builder_get_user_frame_ptr(flatcc_builder_t *B, size_t handle) { return us_ptr(handle); } static int enter_frame(flatcc_builder_t *B, uint16_t align) { if (++B->level > B->limit_level) { if (B->max_level > 0 && B->level > B->max_level) { return -1; } if (!(B->frame = reserve_buffer(B, flatcc_builder_alloc_fs, (size_t)(B->level - 1) * frame_size, frame_size, 0))) { return -1; } B->limit_level = (int)(B->buffers[flatcc_builder_alloc_fs].iov_len / frame_size); if (B->max_level > 0 && B->max_level < B->limit_level) { B->limit_level = B->max_level; } } else { ++B->frame; } frame(ds_offset) = B->ds_offset; frame(align) = B->align; B->align = align; /* Note: do not assume padding before first has been allocated! */ frame(ds_first) = B->ds_first; frame(type_limit) = data_limit; B->ds_first = alignup_uoffset(B->ds_first + B->ds_offset, 8); B->ds_offset = 0; return 0; } static inline void exit_frame(flatcc_builder_t *B) { memset(B->ds, 0, B->ds_offset); B->ds_offset = frame(ds_offset); B->ds_first = frame(ds_first); refresh_ds(B, frame(type_limit)); /* * Restore local alignment: e.g. a table should not change alignment * because a child table was just created elsewhere in the buffer, * but the overall alignment (min align), should be aware of it. * Each buffer has its own min align that then migrates up without * being affected by sibling or child buffers. */ set_min_align(B, B->align); B->align = frame(align); --B->frame; --B->level; } static inline uoffset_t front_pad(flatcc_builder_t *B, uoffset_t size, uint16_t align) { return (uoffset_t)(B->emit_start - (flatcc_builder_ref_t)size) & (align - 1u); } static inline uoffset_t back_pad(flatcc_builder_t *B, uint16_t align) { return (uoffset_t)(B->emit_end) & (align - 1u); } static inline flatcc_builder_ref_t emit_front(flatcc_builder_t *B, iov_state_t *iov) { flatcc_builder_ref_t ref; /* * We might have overflow when including headers, but without * headers we should have checks to prevent overflow in the * uoffset_t range, hence we subtract 16 to be safe. With that * guarantee we can also make a safe check on the soffset_t range. * * We only allow buffers half the theoritical size of * FLATBUFFERS_UOFFSET_MAX so we can safely use signed references. * * NOTE: vtables vt_offset field is signed, and the check in create * table only ensures the signed limit. The check would fail if the * total buffer size could grow beyond UOFFSET_MAX, and we prevent * that by limiting the lower end to SOFFSET_MIN, and the upper end * at emit_back to SOFFSET_MAX. */ ref = B->emit_start - (flatcc_builder_ref_t)iov->len; if ((iov->len > 16 && iov->len - 16 > FLATBUFFERS_UOFFSET_MAX) || ref >= B->emit_start) { check(0, "buffer too large to represent"); return 0; } if (B->emit(B->emit_context, iov->iov, iov->count, ref, iov->len)) { check(0, "emitter rejected buffer content"); return 0; } return B->emit_start = ref; } static inline flatcc_builder_ref_t emit_back(flatcc_builder_t *B, iov_state_t *iov) { flatcc_builder_ref_t ref; ref = B->emit_end; B->emit_end = ref + (flatcc_builder_ref_t)iov->len; /* * Similar to emit_front check, but since we only emit vtables and * padding at the back, we are not concerned with iov->len overflow, * only total buffer overflow. * * With this check, vtable soffset references at table header can * still overflow in extreme cases, so this must be checked * separately. */ if (B->emit_end < ref) { check(0, "buffer too large to represent"); return 0; } if (B->emit(B->emit_context, iov->iov, iov->count, ref, iov->len)) { check(0, "emitter rejected buffer content"); return 0; } /* * Back references always return ref + 1 because ref == 0 is valid and * should not be mistaken for error. vtables understand this. */ return ref + 1; } /* If nested we cannot pad the end of the buffer without moving the entire buffer, so we don't. */ static int align_buffer_end(flatcc_builder_t *B, uint16_t *align, uint16_t block_align, int is_nested) { size_t end_pad; iov_state_t iov; block_align = block_align ? block_align : B->block_align ? B->block_align : 1; get_min_align(align, field_size); get_min_align(align, block_align); /* Pad end of buffer to multiple. */ if (!is_nested) { end_pad = back_pad(B, *align); if (end_pad) { init_iov(); push_iov(_pad, end_pad); if (0 == emit_back(B, &iov)) { check(0, "emitter rejected buffer content"); return -1; } } } return 0; } flatcc_builder_ref_t flatcc_builder_embed_buffer(flatcc_builder_t *B, uint16_t block_align, const void *data, size_t size, uint16_t align, flatcc_builder_buffer_flags_t flags) { uoffset_t size_field, pad; iov_state_t iov; int with_size = (flags & flatcc_builder_with_size) != 0; if (align_buffer_end(B, &align, block_align, !is_top_buffer(B))) { return 0; } pad = front_pad(B, (uoffset_t)(size + (with_size ? field_size : 0)), align); write_uoffset(&size_field, (uoffset_t)size + pad); init_iov(); /* Add ubyte vector size header if nested buffer. */ push_iov_cond(&size_field, field_size, !is_top_buffer(B)); push_iov(data, size); push_iov(_pad, pad); return emit_front(B, &iov); } flatcc_builder_ref_t flatcc_builder_create_buffer(flatcc_builder_t *B, const char identifier[identifier_size], uint16_t block_align, flatcc_builder_ref_t object_ref, uint16_t align, flatcc_builder_buffer_flags_t flags) { flatcc_builder_ref_t buffer_ref; uoffset_t header_pad, id_size = 0; uoffset_t object_offset, buffer_size, buffer_base; iov_state_t iov; flatcc_builder_identifier_t id_out = 0; int is_nested = (flags & flatcc_builder_is_nested) != 0; int with_size = (flags & flatcc_builder_with_size) != 0; if (align_buffer_end(B, &align, block_align, is_nested)) { return 0; } set_min_align(B, align); if (identifier) { FLATCC_ASSERT(sizeof(flatcc_builder_identifier_t) == identifier_size); FLATCC_ASSERT(sizeof(flatcc_builder_identifier_t) == field_size); memcpy(&id_out, identifier, identifier_size); id_out = __flatbuffers_thash_read_from_le(&id_out); write_identifier(&id_out, id_out); } id_size = id_out ? identifier_size : 0; header_pad = front_pad(B, field_size + id_size + (uoffset_t)(with_size ? field_size : 0), align); init_iov(); /* ubyte vectors size field wrapping nested buffer. */ push_iov_cond(&buffer_size, field_size, is_nested || with_size); push_iov(&object_offset, field_size); /* Identifiers are not always present in buffer. */ push_iov(&id_out, id_size); push_iov(_pad, header_pad); buffer_base = (uoffset_t)B->emit_start - (uoffset_t)iov.len + (uoffset_t)((is_nested || with_size) ? field_size : 0); if (is_nested) { write_uoffset(&buffer_size, (uoffset_t)B->buffer_mark - buffer_base); } else { /* Also include clustered vtables. */ write_uoffset(&buffer_size, (uoffset_t)B->emit_end - buffer_base); } write_uoffset(&object_offset, (uoffset_t)object_ref - buffer_base); if (0 == (buffer_ref = emit_front(B, &iov))) { check(0, "emitter rejected buffer content"); return 0; } return buffer_ref; } flatcc_builder_ref_t flatcc_builder_create_struct(flatcc_builder_t *B, const void *data, size_t size, uint16_t align) { size_t pad; iov_state_t iov; check(align >= 1, "align cannot be 0"); set_min_align(B, align); pad = front_pad(B, (uoffset_t)size, align); init_iov(); push_iov(data, size); /* * Normally structs will already be a multiple of their alignment, * so this padding will not likely be emitted. */ push_iov(_pad, pad); return emit_front(B, &iov); } int flatcc_builder_start_buffer(flatcc_builder_t *B, const char identifier[identifier_size], uint16_t block_align, flatcc_builder_buffer_flags_t flags) { /* * This saves the parent `min_align` in the align field since we * shouldn't use that for the current buffer. `exit_frame` * automatically aggregates align up, so it is updated when the * buffer frame exits. */ if (enter_frame(B, B->min_align)) { return -1; } /* B->align now has parent min_align, and child frames will save it. */ /* Since we allow objects to be created before the buffer at top level, we need to respect min_align in that case. */ if (!is_top_buffer(B) || B->min_align == 0) { B->min_align = 1; } /* Save the parent block align, and set proper defaults for this buffer. */ frame(container.buffer.block_align) = B->block_align; B->block_align = block_align; frame(container.buffer.flags = B->buffer_flags); B->buffer_flags = (uint16_t)flags; frame(container.buffer.mark) = B->buffer_mark; frame(container.buffer.nest_id) = B->nest_id; /* * End of buffer when nested. Not defined for top-level because we * here (on only here) permit strings etc. to be created before buffer start and * because top-level buffer vtables can be clustered. */ B->buffer_mark = B->emit_start; /* Must be 0 before and after entering top-level buffer, and unique otherwise. */ B->nest_id = B->nest_count++; frame(container.buffer.identifier) = B->identifier; set_identifier(identifier); frame(type) = flatcc_builder_buffer; return 0; } flatcc_builder_ref_t flatcc_builder_end_buffer(flatcc_builder_t *B, flatcc_builder_ref_t root) { flatcc_builder_ref_t buffer_ref; flatcc_builder_buffer_flags_t flags; flags = (flatcc_builder_buffer_flags_t)B->buffer_flags & flatcc_builder_with_size; flags |= is_top_buffer(B) ? 0 : flatcc_builder_is_nested; check(frame(type) == flatcc_builder_buffer, "expected buffer frame"); set_min_align(B, B->block_align); if (0 == (buffer_ref = flatcc_builder_create_buffer(B, (void *)&B->identifier, B->block_align, root, B->min_align, flags))) { return 0; } B->buffer_mark = frame(container.buffer.mark); B->nest_id = frame(container.buffer.nest_id); B->identifier = frame(container.buffer.identifier); B->buffer_flags = frame(container.buffer.flags); B->block_align = frame(container.buffer.block_align); exit_frame(B); return buffer_ref; } void *flatcc_builder_start_struct(flatcc_builder_t *B, size_t size, uint16_t align) { /* Allocate space for the struct on the ds stack. */ if (enter_frame(B, align)) { return 0; } frame(type) = flatcc_builder_struct; refresh_ds(B, data_limit); return push_ds(B, (uoffset_t)size); } void *flatcc_builder_struct_edit(flatcc_builder_t *B) { return B->ds; } flatcc_builder_ref_t flatcc_builder_end_struct(flatcc_builder_t *B) { flatcc_builder_ref_t object_ref; check(frame(type) == flatcc_builder_struct, "expected struct frame"); if (0 == (object_ref = flatcc_builder_create_struct(B, B->ds, B->ds_offset, B->align))) { return 0; } exit_frame(B); return object_ref; } static inline int vector_count_add(flatcc_builder_t *B, uoffset_t count, uoffset_t max_count) { uoffset_t n, n1; n = frame(container.vector.count); n1 = n + count; /* * This prevents elem_size * count from overflowing iff max_vector * has been set sensible. Without this check we might allocate to * little on the ds stack and return a buffer the user thinks is * much larger which of course is bad even though the buffer eventually * would fail anyway. */ check_error(n <= n1 && n1 <= max_count, -1, "vector too large to represent"); frame(container.vector.count) = n1; return 0; } void *flatcc_builder_extend_vector(flatcc_builder_t *B, size_t count) { if (vector_count_add(B, (uoffset_t)count, frame(container.vector.max_count))) { return 0; } return push_ds(B, frame(container.vector.elem_size) * (uoffset_t)count); } void *flatcc_builder_vector_push(flatcc_builder_t *B, const void *data) { check(frame(type) == flatcc_builder_vector, "expected vector frame"); check_error(frame(container.vector.count) <= frame(container.vector.max_count), 0, "vector max count exceeded"); frame(container.vector.count) += 1; return push_ds_copy(B, data, frame(container.vector.elem_size)); } void *flatcc_builder_append_vector(flatcc_builder_t *B, const void *data, size_t count) { check(frame(type) == flatcc_builder_vector, "expected vector frame"); if (vector_count_add(B, (uoffset_t)count, frame(container.vector.max_count))) { return 0; } return push_ds_copy(B, data, frame(container.vector.elem_size) * (uoffset_t)count); } flatcc_builder_ref_t *flatcc_builder_extend_offset_vector(flatcc_builder_t *B, size_t count) { if (vector_count_add(B, (uoffset_t)count, max_offset_count)) { return 0; } return push_ds(B, (uoffset_t)(field_size * count)); } flatcc_builder_ref_t *flatcc_builder_offset_vector_push(flatcc_builder_t *B, flatcc_builder_ref_t ref) { flatcc_builder_ref_t *p; check(frame(type) == flatcc_builder_offset_vector, "expected offset vector frame"); if (frame(container.vector.count) == max_offset_count) { return 0; } frame(container.vector.count) += 1; if (0 == (p = push_ds(B, field_size))) { return 0; } *p = ref; return p; } flatcc_builder_ref_t *flatcc_builder_append_offset_vector(flatcc_builder_t *B, const flatcc_builder_ref_t *refs, size_t count) { check(frame(type) == flatcc_builder_offset_vector, "expected offset vector frame"); if (vector_count_add(B, (uoffset_t)count, max_offset_count)) { return 0; } return push_ds_copy(B, refs, (uoffset_t)(field_size * count)); } char *flatcc_builder_extend_string(flatcc_builder_t *B, size_t len) { check(frame(type) == flatcc_builder_string, "expected string frame"); if (vector_count_add(B, (uoffset_t)len, max_string_len)) { return 0; } return push_ds(B, (uoffset_t)len); } char *flatcc_builder_append_string(flatcc_builder_t *B, const char *s, size_t len) { check(frame(type) == flatcc_builder_string, "expected string frame"); if (vector_count_add(B, (uoffset_t)len, max_string_len)) { return 0; } return push_ds_copy(B, s, (uoffset_t)len); } char *flatcc_builder_append_string_str(flatcc_builder_t *B, const char *s) { return flatcc_builder_append_string(B, s, strlen(s)); } char *flatcc_builder_append_string_strn(flatcc_builder_t *B, const char *s, size_t max_len) { return flatcc_builder_append_string(B, s, strnlen(s, max_len)); } int flatcc_builder_truncate_vector(flatcc_builder_t *B, size_t count) { check(frame(type) == flatcc_builder_vector, "expected vector frame"); check_error(frame(container.vector.count) >= count, -1, "cannot truncate vector past empty"); frame(container.vector.count) -= (uoffset_t)count; unpush_ds(B, frame(container.vector.elem_size) * (uoffset_t)count); return 0; } int flatcc_builder_truncate_offset_vector(flatcc_builder_t *B, size_t count) { check(frame(type) == flatcc_builder_offset_vector, "expected offset vector frame"); check_error(frame(container.vector.count) >= (uoffset_t)count, -1, "cannot truncate vector past empty"); frame(container.vector.count) -= (uoffset_t)count; unpush_ds(B, frame(container.vector.elem_size) * (uoffset_t)count); return 0; } int flatcc_builder_truncate_string(flatcc_builder_t *B, size_t len) { check(frame(type) == flatcc_builder_string, "expected string frame"); check_error(frame(container.vector.count) >= len, -1, "cannot truncate string past empty"); frame(container.vector.count) -= (uoffset_t)len; unpush_ds(B, (uoffset_t)len); return 0; } int flatcc_builder_start_vector(flatcc_builder_t *B, size_t elem_size, uint16_t align, size_t max_count) { get_min_align(&align, field_size); if (enter_frame(B, align)) { return -1; } frame(container.vector.elem_size) = (uoffset_t)elem_size; frame(container.vector.count) = 0; frame(container.vector.max_count) = (uoffset_t)max_count; frame(type) = flatcc_builder_vector; refresh_ds(B, data_limit); return 0; } int flatcc_builder_start_offset_vector(flatcc_builder_t *B) { if (enter_frame(B, field_size)) { return -1; } frame(container.vector.elem_size) = field_size; frame(container.vector.count) = 0; frame(type) = flatcc_builder_offset_vector; refresh_ds(B, data_limit); return 0; } flatcc_builder_ref_t flatcc_builder_create_offset_vector(flatcc_builder_t *B, const flatcc_builder_ref_t *vec, size_t count) { flatcc_builder_ref_t *_vec; if (flatcc_builder_start_offset_vector(B)) { return 0; } if (!(_vec = flatcc_builder_extend_offset_vector(B, count))) { return 0; } memcpy(_vec, vec, count * field_size); return flatcc_builder_end_offset_vector(B); } int flatcc_builder_start_string(flatcc_builder_t *B) { if (enter_frame(B, 1)) { return -1; } frame(container.vector.elem_size) = 1; frame(container.vector.count) = 0; frame(type) = flatcc_builder_string; refresh_ds(B, data_limit); return 0; } int flatcc_builder_reserve_table(flatcc_builder_t *B, int count) { check(count >= 0, "cannot reserve negative count"); return reserve_fields(B, count); } int flatcc_builder_start_table(flatcc_builder_t *B, int count) { if (enter_frame(B, field_size)) { return -1; } frame(container.table.vs_end) = vs_offset(B->vs); frame(container.table.pl_end) = pl_offset(B->pl); frame(container.table.vt_hash) = B->vt_hash; frame(container.table.id_end) = B->id_end; B->vt_hash = 0; FLATCC_BUILDER_INIT_VT_HASH(B->vt_hash); B->id_end = 0; frame(type) = flatcc_builder_table; if (reserve_fields(B, count)) { return -1; } refresh_ds(B, table_limit); return 0; } flatcc_builder_vt_ref_t flatcc_builder_create_vtable(flatcc_builder_t *B, const voffset_t *vt, voffset_t vt_size) { flatcc_builder_vt_ref_t vt_ref; iov_state_t iov; voffset_t *vt_; size_t i; /* * Only top-level buffer can cluster vtables because only it can * extend beyond the end. * * We write the vtable after the referencing table to maintain * the construction invariant that any offset reference has * valid emitted data at a higher address, and also that any * issued negative emit address represents an offset reference * to some flatbuffer object or vector (or possibly a root * struct). * * The vt_ref is stored as the reference + 1 to avoid having 0 as a * valid reference (which usally means error). It also idententifies * vtable references as the only uneven references, and the only * references that can be used multiple times in the same buffer. * * We do the vtable conversion here so cached vtables can be built * hashed and compared more efficiently, and so end users with * direct vtable construction don't have to worry about endianness. * This also ensures the hash function works the same wrt. * collision frequency. */ if (!flatbuffers_is_native_pe()) { /* Make space in vtable cache for temporary endian conversion. */ if (!(vt_ = reserve_buffer(B, flatcc_builder_alloc_vb, B->vb_end, vt_size, 0))) { return 0; } for (i = 0; i < vt_size / sizeof(voffset_t); ++i) { write_voffset(&vt_[i], vt[i]); } vt = vt_; /* We don't need to free the reservation since we don't advance any base pointer. */ } init_iov(); push_iov(vt, vt_size); if (is_top_buffer(B) && !B->disable_vt_clustering) { /* Note that `emit_back` already returns ref + 1 as we require for vtables. */ if (0 == (vt_ref = emit_back(B, &iov))) { return 0; } } else { if (0 == (vt_ref = emit_front(B, &iov))) { return 0; } /* * We don't have a valid 0 ref here, but to be consistent with * clustered vtables we offset by one. This cannot be zero * either. */ vt_ref += 1; } return vt_ref; } flatcc_builder_vt_ref_t flatcc_builder_create_cached_vtable(flatcc_builder_t *B, const voffset_t *vt, voffset_t vt_size, uint32_t vt_hash) { vtable_descriptor_t *vd, *vd2; uoffset_t *pvd, *pvd_head; uoffset_t next; voffset_t *vt_; /* This just gets the hash table slot, we still have to inspect it. */ if (!(pvd_head = lookup_ht(B, vt_hash))) { return 0; } pvd = pvd_head; next = *pvd; /* Tracks if there already is a cached copy. */ vd2 = 0; while (next) { vd = vd_ptr(next); vt_ = vb_ptr(vd->vb_start); if (vt_[0] != vt_size || 0 != memcmp(vt, vt_, vt_size)) { pvd = &vd->next; next = vd->next; continue; } /* Can't share emitted vtables between buffers, */ if (vd->nest_id != B->nest_id) { /* but we don't have to resubmit to cache. */ vd2 = vd; /* See if there is a better match. */ pvd = &vd->next; next = vd->next; continue; } /* Move to front hash strategy. */ if (pvd != pvd_head) { *pvd = vd->next; vd->next = *pvd_head; *pvd_head = next; } /* vtable exists and has been emitted within current buffer. */ return vd->vt_ref; } /* Allocate new descriptor. */ if (!(vd = reserve_buffer(B, flatcc_builder_alloc_vd, B->vd_end, sizeof(vtable_descriptor_t), 0))) { return 0; } next = B->vd_end; B->vd_end += (uoffset_t)sizeof(vtable_descriptor_t); /* Identify the buffer this vtable descriptor belongs to. */ vd->nest_id = B->nest_id; /* Move to front hash strategy. */ vd->next = *pvd_head; *pvd_head = next; if (0 == (vd->vt_ref = flatcc_builder_create_vtable(B, vt, vt_size))) { return 0; } if (vd2) { /* Reuse cached copy. */ vd->vb_start = vd2->vb_start; } else { if (B->vb_flush_limit && B->vb_flush_limit < B->vb_end + vt_size) { flatcc_builder_flush_vtable_cache(B); } else { /* Make space in vtable cache. */ if (!(vt_ = reserve_buffer(B, flatcc_builder_alloc_vb, B->vb_end, vt_size, 0))) { return -1; } vd->vb_start = B->vb_end; B->vb_end += vt_size; memcpy(vt_, vt, vt_size); } } return vd->vt_ref; } flatcc_builder_ref_t flatcc_builder_create_table(flatcc_builder_t *B, const void *data, size_t size, uint16_t align, flatbuffers_voffset_t *offsets, int offset_count, flatcc_builder_vt_ref_t vt_ref) { int i; uoffset_t pad, vt_offset, vt_offset_field, vt_base, base, offset, *offset_field; iov_state_t iov; check(offset_count >= 0, "expected non-negative offset_count"); /* * vtable references are offset by 1 to avoid confusion with * 0 as an error reference. It also uniquely identifies them * as vtables being the only uneven reference type. */ check(vt_ref & 1, "invalid vtable referenc"); get_min_align(&align, field_size); set_min_align(B, align); /* Alignment is calculated for the first element, not the header. */ pad = front_pad(B, (uoffset_t)size, align); base = (uoffset_t)B->emit_start - (uoffset_t)(pad + size + field_size); /* Adjust by 1 to get unencoded vtable reference. */ vt_base = (uoffset_t)(vt_ref - 1); vt_offset = base - vt_base; /* Avoid overflow. */ if (base - vt_offset != vt_base) { return -1; } /* Protocol endian encoding. */ write_uoffset(&vt_offset_field, vt_offset); for (i = 0; i < offset_count; ++i) { offset_field = (uoffset_t *)((size_t)data + offsets[i]); offset = *offset_field - base - offsets[i] - (uoffset_t)field_size; write_uoffset(offset_field, offset); } init_iov(); push_iov(&vt_offset_field, field_size); push_iov(data, size); push_iov(_pad, pad); return emit_front(B, &iov); } int flatcc_builder_check_required_field(flatcc_builder_t *B, flatbuffers_voffset_t id) { check(frame(type) == flatcc_builder_table, "expected table frame"); return id < B->id_end && B->vs[id] != 0; } int flatcc_builder_check_union_field(flatcc_builder_t *B, flatbuffers_voffset_t id) { check(frame(type) == flatcc_builder_table, "expected table frame"); if (id == 0 || id >= B->id_end) { return 0; } if (B->vs[id - 1] == 0) { return B->vs[id] == 0; } if (*(uint8_t *)(B->ds + B->vs[id - 1])) { return B->vs[id] != 0; } return B->vs[id] == 0; } int flatcc_builder_check_required(flatcc_builder_t *B, const flatbuffers_voffset_t *required, int count) { int i; check(frame(type) == flatcc_builder_table, "expected table frame"); if (B->id_end < count) { return 0; } for (i = 0; i < count; ++i) { if (B->vs[required[i]] == 0) { return 0; } } return 1; } flatcc_builder_ref_t flatcc_builder_end_table(flatcc_builder_t *B) { voffset_t *vt, vt_size; flatcc_builder_ref_t table_ref, vt_ref; int pl_count; voffset_t *pl; size_t tsize; check(frame(type) == flatcc_builder_table, "expected table frame"); /* We have `ds_limit`, so we should not have to check for overflow here. */ vt = B->vs - 2; vt_size = (voffset_t)(sizeof(voffset_t) * (B->id_end + 2u)); /* Update vtable header fields, first vtable size, then object table size. */ vt[0] = vt_size; /* * The `ds` buffer is always at least `field_size` aligned but excludes the * initial vtable offset field. Therefore `field_size` is added here * to the total table size in the vtable. */ tsize = (size_t)(B->ds_offset + field_size); /* * Tables are limited to 64K in standard FlatBuffers format due to the voffset * 16 bit size, but we must also be able to store the table size, so the * table payload has to be slightly less than that. */ check(tsize <= FLATBUFFERS_VOFFSET_MAX, "table too large"); vt[1] = (voffset_t)tsize; FLATCC_BUILDER_UPDATE_VT_HASH(B->vt_hash, (uint32_t)vt[0], (uint32_t)vt[1]); /* Find already emitted vtable, or emit a new one. */ if (!(vt_ref = flatcc_builder_create_cached_vtable(B, vt, vt_size, B->vt_hash))) { return 0; } /* Clear vs stack so it is ready for the next vtable (ds stack is cleared by exit frame). */ memset(vt, 0, vt_size); pl = pl_ptr(frame(container.table.pl_end)); pl_count = (int)(B->pl - pl); if (0 == (table_ref = flatcc_builder_create_table(B, B->ds, B->ds_offset, B->align, pl, pl_count, vt_ref))) { return 0; } B->vt_hash = frame(container.table.vt_hash); B->id_end = frame(container.table.id_end); B->vs = vs_ptr(frame(container.table.vs_end)); B->pl = pl_ptr(frame(container.table.pl_end)); exit_frame(B); return table_ref; } flatcc_builder_ref_t flatcc_builder_create_vector(flatcc_builder_t *B, const void *data, size_t count, size_t elem_size, uint16_t align, size_t max_count) { /* * Note: it is important that vec_size is uoffset not size_t * in case sizeof(uoffset_t) > sizeof(size_t) because max_count is * defined in terms of uoffset_t representation size, and also * because we risk accepting too large a vector even if max_count is * not violated. */ uoffset_t vec_size, vec_pad, length_prefix; iov_state_t iov; check_error(count <= max_count, 0, "vector max_count violated"); get_min_align(&align, field_size); set_min_align(B, align); vec_size = (uoffset_t)count * (uoffset_t)elem_size; /* * That can happen on 32 bit systems when uoffset_t is defined as 64-bit. * `emit_front/back` captures overflow, but not if our size type wraps first. */ #if FLATBUFFERS_UOFFSET_MAX > SIZE_MAX check_error(vec_size < SIZE_MAX, 0, "vector larger than address space"); #endif write_uoffset(&length_prefix, (uoffset_t)count); /* Alignment is calculated for the first element, not the header. */ vec_pad = front_pad(B, vec_size, align); init_iov(); push_iov(&length_prefix, field_size); push_iov(data, vec_size); push_iov(_pad, vec_pad); return emit_front(B, &iov); } /* * Note: FlatBuffers official documentation states that the size field of a * vector is a 32-bit element count. It is not quite clear if the * intention is to have the size field be of type uoffset_t since tables * also have a uoffset_t sized header, or if the vector size should * remain unchanged if uoffset is changed to 16- or 64-bits * respectively. Since it makes most sense to have a vector compatible * with the addressable space, we choose to use uoffset_t as size field, * which remains compatible with the default 32-bit version of uoffset_t. */ flatcc_builder_ref_t flatcc_builder_end_vector(flatcc_builder_t *B) { flatcc_builder_ref_t vector_ref; check(frame(type) == flatcc_builder_vector, "expected vector frame"); if (0 == (vector_ref = flatcc_builder_create_vector(B, B->ds, frame(container.vector.count), frame(container.vector.elem_size), B->align, frame(container.vector.max_count)))) { return 0; } exit_frame(B); return vector_ref; } size_t flatcc_builder_vector_count(flatcc_builder_t *B) { return frame(container.vector.count); } void *flatcc_builder_vector_edit(flatcc_builder_t *B) { return B->ds; } /* This function destroys the source content but avoids stack allocation. */ static flatcc_builder_ref_t _create_offset_vector_direct(flatcc_builder_t *B, flatcc_builder_ref_t *vec, size_t count, const utype_t *types) { uoffset_t vec_size, vec_pad; uoffset_t length_prefix, offset; uoffset_t i; soffset_t base; iov_state_t iov; if ((uoffset_t)count > max_offset_count) { return 0; } set_min_align(B, field_size); vec_size = (uoffset_t)(count * field_size); write_uoffset(&length_prefix, (uoffset_t)count); /* Alignment is calculated for the first element, not the header. */ vec_pad = front_pad(B, vec_size, field_size); init_iov(); push_iov(&length_prefix, field_size); push_iov(vec, vec_size); push_iov(_pad, vec_pad); base = B->emit_start - (soffset_t)iov.len; for (i = 0; i < (uoffset_t)count; ++i) { /* * 0 is either end of buffer, start of vtables, or start of * buffer depending on the direction in which the buffer is * built. None of these can create a valid 0 reference but it * is easy to create by mistake when manually building offset * vectors. * * Unions do permit nulls, but only when the type is NONE. */ if (vec[i] != 0) { offset = (uoffset_t) (vec[i] - base - (soffset_t)(i * field_size) - (soffset_t)field_size); write_uoffset(&vec[i], offset); if (types) { check(types[i] != 0, "union vector cannot have non-null element with type NONE"); } } else { if (types) { check(types[i] == 0, "union vector cannot have null element without type NONE"); } else { check(0, "offset vector cannot have null element"); } } } return emit_front(B, &iov); } flatcc_builder_ref_t flatcc_builder_create_offset_vector_direct(flatcc_builder_t *B, flatcc_builder_ref_t *vec, size_t count) { return _create_offset_vector_direct(B, vec, count, 0); } flatcc_builder_ref_t flatcc_builder_end_offset_vector(flatcc_builder_t *B) { flatcc_builder_ref_t vector_ref; check(frame(type) == flatcc_builder_offset_vector, "expected offset vector frame"); if (0 == (vector_ref = flatcc_builder_create_offset_vector_direct(B, (flatcc_builder_ref_t *)B->ds, frame(container.vector.count)))) { return 0; } exit_frame(B); return vector_ref; } flatcc_builder_ref_t flatcc_builder_end_offset_vector_for_unions(flatcc_builder_t *B, const utype_t *types) { flatcc_builder_ref_t vector_ref; check(frame(type) == flatcc_builder_offset_vector, "expected offset vector frame"); if (0 == (vector_ref = _create_offset_vector_direct(B, (flatcc_builder_ref_t *)B->ds, frame(container.vector.count), types))) { return 0; } exit_frame(B); return vector_ref; } void *flatcc_builder_offset_vector_edit(flatcc_builder_t *B) { return B->ds; } size_t flatcc_builder_offset_vector_count(flatcc_builder_t *B) { return frame(container.vector.count); } int flatcc_builder_table_add_union(flatcc_builder_t *B, int id, flatcc_builder_union_ref_t uref) { flatcc_builder_ref_t *pref; flatcc_builder_utype_t *putype; check(frame(type) == flatcc_builder_table, "expected table frame"); check_error(uref.type != 0 || uref.value == 0, -1, "expected null value for type NONE"); if (uref.value != 0) { pref = flatcc_builder_table_add_offset(B, id); check_error(pref != 0, -1, "unable to add union value"); *pref = uref.value; } putype = flatcc_builder_table_add(B, id - 1, utype_size, utype_size); check_error(putype != 0, -1, "unable to add union type"); write_utype(putype, uref.type); return 0; } int flatcc_builder_table_add_union_vector(flatcc_builder_t *B, int id, flatcc_builder_union_vec_ref_t uvref) { flatcc_builder_ref_t *pref; check(frame(type) == flatcc_builder_table, "expected table frame"); check_error((uvref.type == 0) == (uvref.value == 0), -1, "expected both type and value vector, or neither"); if (uvref.type != 0) { pref = flatcc_builder_table_add_offset(B, id - 1); check_error(pref != 0, -1, "unable to add union member"); *pref = uvref.type; pref = flatcc_builder_table_add_offset(B, id); check_error(pref != 0, -1, "unable to add union member"); *pref = uvref.value; } return 0; } flatcc_builder_union_vec_ref_t flatcc_builder_create_union_vector(flatcc_builder_t *B, const flatcc_builder_union_ref_t *urefs, size_t count) { flatcc_builder_union_vec_ref_t uvref = { 0, 0 }; flatcc_builder_utype_t *types; flatcc_builder_ref_t *refs; size_t i; if (flatcc_builder_start_offset_vector(B)) { return uvref; } if (0 == flatcc_builder_extend_offset_vector(B, count)) { return uvref; } if (0 == (types = push_ds(B, (uoffset_t)(utype_size * count)))) { return uvref; } /* Safe even if push_ds caused stack reallocation. */ refs = flatcc_builder_offset_vector_edit(B); for (i = 0; i < count; ++i) { types[i] = urefs[i].type; refs[i] = urefs[i].value; } uvref = flatcc_builder_create_union_vector_direct(B, types, refs, count); /* No need to clean up after out temporary types vector. */ exit_frame(B); return uvref; } flatcc_builder_union_vec_ref_t flatcc_builder_create_union_vector_direct(flatcc_builder_t *B, const flatcc_builder_utype_t *types, flatcc_builder_ref_t *data, size_t count) { flatcc_builder_union_vec_ref_t uvref = { 0, 0 }; if (0 == (uvref.value = _create_offset_vector_direct(B, data, count, types))) { return uvref; } if (0 == (uvref.type = flatcc_builder_create_type_vector(B, types, count))) { return uvref; } return uvref; } flatcc_builder_ref_t flatcc_builder_create_type_vector(flatcc_builder_t *B, const flatcc_builder_utype_t *types, size_t count) { return flatcc_builder_create_vector(B, types, count, utype_size, utype_size, max_utype_count); } int flatcc_builder_start_union_vector(flatcc_builder_t *B) { if (enter_frame(B, field_size)) { return -1; } frame(container.vector.elem_size) = union_size; frame(container.vector.count) = 0; frame(type) = flatcc_builder_union_vector; refresh_ds(B, data_limit); return 0; } flatcc_builder_union_vec_ref_t flatcc_builder_end_union_vector(flatcc_builder_t *B) { flatcc_builder_union_vec_ref_t uvref = { 0, 0 }; flatcc_builder_utype_t *types; flatcc_builder_union_ref_t *urefs; flatcc_builder_ref_t *refs; size_t i, count; check(frame(type) == flatcc_builder_union_vector, "expected union vector frame"); /* * We could split the union vector in-place, but then we would have * to deal with strict pointer aliasing rules which is not worthwhile * so we create a new offset and type vector on the stack. * * We assume the stack is sufficiently aligned as is. */ count = flatcc_builder_union_vector_count(B); if (0 == (refs = push_ds(B, (uoffset_t)(count * (utype_size + field_size))))) { return uvref; } types = (flatcc_builder_utype_t *)(refs + count); /* Safe even if push_ds caused stack reallocation. */ urefs = flatcc_builder_union_vector_edit(B); for (i = 0; i < count; ++i) { types[i] = urefs[i].type; refs[i] = urefs[i].value; } uvref = flatcc_builder_create_union_vector_direct(B, types, refs, count); /* No need to clean up after out temporary types vector. */ exit_frame(B); return uvref; } void *flatcc_builder_union_vector_edit(flatcc_builder_t *B) { return B->ds; } size_t flatcc_builder_union_vector_count(flatcc_builder_t *B) { return frame(container.vector.count); } flatcc_builder_union_ref_t *flatcc_builder_extend_union_vector(flatcc_builder_t *B, size_t count) { if (vector_count_add(B, (uoffset_t)count, max_union_count)) { return 0; } return push_ds(B, (uoffset_t)(union_size * count)); } int flatcc_builder_truncate_union_vector(flatcc_builder_t *B, size_t count) { check(frame(type) == flatcc_builder_union_vector, "expected union vector frame"); check_error(frame(container.vector.count) >= (uoffset_t)count, -1, "cannot truncate vector past empty"); frame(container.vector.count) -= (uoffset_t)count; unpush_ds(B, frame(container.vector.elem_size) * (uoffset_t)count); return 0; } flatcc_builder_union_ref_t *flatcc_builder_union_vector_push(flatcc_builder_t *B, flatcc_builder_union_ref_t uref) { flatcc_builder_union_ref_t *p; check(frame(type) == flatcc_builder_union_vector, "expected union vector frame"); if (frame(container.vector.count) == max_union_count) { return 0; } frame(container.vector.count) += 1; if (0 == (p = push_ds(B, union_size))) { return 0; } *p = uref; return p; } flatcc_builder_union_ref_t *flatcc_builder_append_union_vector(flatcc_builder_t *B, const flatcc_builder_union_ref_t *urefs, size_t count) { check(frame(type) == flatcc_builder_union_vector, "expected union vector frame"); if (vector_count_add(B, (uoffset_t)count, max_union_count)) { return 0; } return push_ds_copy(B, urefs, (uoffset_t)(union_size * count)); } flatcc_builder_ref_t flatcc_builder_create_string(flatcc_builder_t *B, const char *s, size_t len) { uoffset_t s_pad; uoffset_t length_prefix; iov_state_t iov; if (len > max_string_len) { return 0; } write_uoffset(&length_prefix, (uoffset_t)len); /* Add 1 for zero termination. */ s_pad = front_pad(B, (uoffset_t)len + 1, field_size) + 1; init_iov(); push_iov(&length_prefix, field_size); push_iov(s, len); push_iov(_pad, s_pad); return emit_front(B, &iov); } flatcc_builder_ref_t flatcc_builder_create_string_str(flatcc_builder_t *B, const char *s) { return flatcc_builder_create_string(B, s, strlen(s)); } flatcc_builder_ref_t flatcc_builder_create_string_strn(flatcc_builder_t *B, const char *s, size_t max_len) { return flatcc_builder_create_string(B, s, strnlen(s, max_len)); } flatcc_builder_ref_t flatcc_builder_end_string(flatcc_builder_t *B) { flatcc_builder_ref_t string_ref; check(frame(type) == flatcc_builder_string, "expected string frame"); FLATCC_ASSERT(frame(container.vector.count) == B->ds_offset); if (0 == (string_ref = flatcc_builder_create_string(B, (const char *)B->ds, B->ds_offset))) { return 0; } exit_frame(B); return string_ref; } char *flatcc_builder_string_edit(flatcc_builder_t *B) { return (char *)B->ds; } size_t flatcc_builder_string_len(flatcc_builder_t *B) { return frame(container.vector.count); } void *flatcc_builder_table_add(flatcc_builder_t *B, int id, size_t size, uint16_t align) { /* * We align the offset relative to the first table field, excluding * the header holding the vtable reference. On the stack, `ds_first` * is aligned to 8 bytes thanks to the `enter_frame` logic, and this * provides a safe way to update the fields on the stack, but here * we are concerned with the target buffer alignment. * * We could also have aligned relative to the end of the table which * would allow us to emit each field immediately, but it would be a * confusing user experience wrt. field ordering, and it would add * more variability to vtable layouts, thus reducing reuse, and * frequent emissions to external emitter interface would be * sub-optimal. Also, with that appoach, the vtable offsets would * have to be adjusted at table end. * * As we have it, each emit occur at table end, vector end, string * end, or buffer end, which might be helpful to various backend * processors. */ check(frame(type) == flatcc_builder_table, "expected table frame"); check(id >= 0 && id <= (int)FLATBUFFERS_ID_MAX, "table id out of range"); if (align > B->align) { B->align = align; } #if FLATCC_BUILDER_ALLOW_REPEAT_TABLE_ADD if (B->vs[id] != 0) { return B->ds + B->vs[id] - field_size; } #else if (B->vs[id] != 0) { check(0, "table field already set"); return 0; } #endif FLATCC_BUILDER_UPDATE_VT_HASH(B->vt_hash, (uint32_t)id, (uint32_t)size); return push_ds_field(B, (uoffset_t)size, align, (voffset_t)id); } void *flatcc_builder_table_edit(flatcc_builder_t *B, size_t size) { check(frame(type) == flatcc_builder_table, "expected table frame"); return B->ds + B->ds_offset - size; } void *flatcc_builder_table_add_copy(flatcc_builder_t *B, int id, const void *data, size_t size, uint16_t align) { void *p; if ((p = flatcc_builder_table_add(B, id, size, align))) { memcpy(p, data, size); } return p; } flatcc_builder_ref_t *flatcc_builder_table_add_offset(flatcc_builder_t *B, int id) { check(frame(type) == flatcc_builder_table, "expected table frame"); check(id >= 0 && id <= (int)FLATBUFFERS_ID_MAX, "table id out of range"); #if FLATCC_BUILDER_ALLOW_REPEAT_TABLE_ADD if (B->vs[id] != 0) { return B->ds + B->vs[id] - field_size; } #else if (B->vs[id] != 0) { check(0, "table field already set"); return 0; } #endif FLATCC_BUILDER_UPDATE_VT_HASH(B->vt_hash, (uint32_t)id, (uint32_t)field_size); return push_ds_offset_field(B, (voffset_t)id); } uint16_t flatcc_builder_push_buffer_alignment(flatcc_builder_t *B) { uint16_t old_min_align = B->min_align; B->min_align = field_size; return old_min_align; } void flatcc_builder_pop_buffer_alignment(flatcc_builder_t *B, uint16_t pushed_align) { set_min_align(B, pushed_align); } uint16_t flatcc_builder_get_buffer_alignment(flatcc_builder_t *B) { return B->min_align; } void flatcc_builder_set_vtable_clustering(flatcc_builder_t *B, int enable) { /* Inverted because we zero all memory in B on init. */ B->disable_vt_clustering = !enable; } void flatcc_builder_set_block_align(flatcc_builder_t *B, uint16_t align) { B->block_align = align; } int flatcc_builder_get_level(flatcc_builder_t *B) { return B->level; } void flatcc_builder_set_max_level(flatcc_builder_t *B, int max_level) { B->max_level = max_level; if (B->limit_level < B->max_level) { B->limit_level = B->max_level; } } size_t flatcc_builder_get_buffer_size(flatcc_builder_t *B) { return (size_t)(B->emit_end - B->emit_start); } flatcc_builder_ref_t flatcc_builder_get_buffer_start(flatcc_builder_t *B) { return B->emit_start; } flatcc_builder_ref_t flatcc_builder_get_buffer_end(flatcc_builder_t *B) { return B->emit_end; } void flatcc_builder_set_vtable_cache_limit(flatcc_builder_t *B, size_t size) { B->vb_flush_limit = size; } void flatcc_builder_set_identifier(flatcc_builder_t *B, const char identifier[identifier_size]) { set_identifier(identifier); } enum flatcc_builder_type flatcc_builder_get_type(flatcc_builder_t *B) { return B->frame ? frame(type) : flatcc_builder_empty; } enum flatcc_builder_type flatcc_builder_get_type_at(flatcc_builder_t *B, int level) { if (level < 1 || level > B->level) { return flatcc_builder_empty; } return B->frame[level - B->level].type; } void *flatcc_builder_get_direct_buffer(flatcc_builder_t *B, size_t *size_out) { if (B->is_default_emitter) { return flatcc_emitter_get_direct_buffer(&B->default_emit_context, size_out); } else { if (size_out) { *size_out = 0; } } return 0; } void *flatcc_builder_copy_buffer(flatcc_builder_t *B, void *buffer, size_t size) { /* User is allowed to call tentatively to see if there is support. */ if (!B->is_default_emitter) { return 0; } buffer = flatcc_emitter_copy_buffer(&B->default_emit_context, buffer, size); check(buffer, "default emitter declined to copy buffer"); return buffer; } void *flatcc_builder_finalize_buffer(flatcc_builder_t *B, size_t *size_out) { void * buffer; size_t size; size = flatcc_builder_get_buffer_size(B); if (size_out) { *size_out = size; } buffer = FLATCC_BUILDER_ALLOC(size); if (!buffer) { check(0, "failed to allocated memory for finalized buffer"); goto done; } if (!flatcc_builder_copy_buffer(B, buffer, size)) { check(0, "default emitter declined to copy buffer"); FLATCC_BUILDER_FREE(buffer); buffer = 0; } done: if (!buffer && size_out) { *size_out = 0; } return buffer; } void *flatcc_builder_finalize_aligned_buffer(flatcc_builder_t *B, size_t *size_out) { void * buffer; size_t align; size_t size; size = flatcc_builder_get_buffer_size(B); if (size_out) { *size_out = size; } align = flatcc_builder_get_buffer_alignment(B); size = (size + align - 1) & ~(align - 1); buffer = FLATCC_BUILDER_ALIGNED_ALLOC(align, size); if (!buffer) { goto done; } if (!flatcc_builder_copy_buffer(B, buffer, size)) { FLATCC_BUILDER_ALIGNED_FREE(buffer); buffer = 0; goto done; } done: if (!buffer && size_out) { *size_out = 0; } return buffer; } void *flatcc_builder_aligned_alloc(size_t alignment, size_t size) { return FLATCC_BUILDER_ALIGNED_ALLOC(alignment, size); } void flatcc_builder_aligned_free(void *p) { FLATCC_BUILDER_ALIGNED_FREE(p); } void *flatcc_builder_alloc(size_t size) { return FLATCC_BUILDER_ALLOC(size); } void flatcc_builder_free(void *p) { FLATCC_BUILDER_FREE(p); } void *flatcc_builder_get_emit_context(flatcc_builder_t *B) { return B->emit_context; } #include #include "flatcc/flatcc_rtconfig.h" #include "flatcc/flatcc_emitter.h" static int advance_front(flatcc_emitter_t *E) { flatcc_emitter_page_t *p = 0; if (E->front && E->front->prev != E->back) { E->front->prev->page_offset = E->front->page_offset - FLATCC_EMITTER_PAGE_SIZE; E->front = E->front->prev; goto done; } if (!(p = FLATCC_EMITTER_ALLOC(sizeof(flatcc_emitter_page_t)))) { return -1; } E->capacity += FLATCC_EMITTER_PAGE_SIZE; if (E->front) { p->prev = E->back; p->next = E->front; E->front->prev = p; E->back->next = p; E->front = p; goto done; } /* * The first page is shared between front and back to avoid * double unecessary extra allocation. */ E->front = p; E->back = p; p->next = p; p->prev = p; E->front_cursor = E->front->page + FLATCC_EMITTER_PAGE_SIZE / 2; E->back_cursor = E->front_cursor; E->front_left = FLATCC_EMITTER_PAGE_SIZE / 2; E->back_left = FLATCC_EMITTER_PAGE_SIZE - E->front_left; p->page_offset = -(flatbuffers_soffset_t)E->front_left; return 0; done: E->front_cursor = E->front->page + FLATCC_EMITTER_PAGE_SIZE; E->front_left = FLATCC_EMITTER_PAGE_SIZE; E->front->page_offset = E->front->next->page_offset - FLATCC_EMITTER_PAGE_SIZE; return 0; } static int advance_back(flatcc_emitter_t *E) { flatcc_emitter_page_t *p = 0; if (E->back && E->back->next != E->front) { E->back = E->back->next; goto done; } if (!(p = FLATCC_EMITTER_ALLOC(sizeof(flatcc_emitter_page_t)))) { return -1; } E->capacity += FLATCC_EMITTER_PAGE_SIZE; if (E->back) { p->prev = E->back; p->next = E->front; E->front->prev = p; E->back->next = p; E->back = p; goto done; } /* * The first page is shared between front and back to avoid * double unecessary extra allocation. */ E->front = p; E->back = p; p->next = p; p->prev = p; E->front_cursor = E->front->page + FLATCC_EMITTER_PAGE_SIZE / 2; E->back_cursor = E->front_cursor; E->front_left = FLATCC_EMITTER_PAGE_SIZE / 2; E->back_left = FLATCC_EMITTER_PAGE_SIZE - E->front_left; p->page_offset = -(flatbuffers_soffset_t)E->front_left; return 0; done: E->back_cursor = E->back->page; E->back_left = FLATCC_EMITTER_PAGE_SIZE; E->back->page_offset = E->back->prev->page_offset + FLATCC_EMITTER_PAGE_SIZE; return 0; } static int copy_front(flatcc_emitter_t *E, uint8_t *data, size_t size) { size_t k; data += size; while (size) { k = size; if (k > E->front_left) { k = E->front_left; if (k == 0) { if (advance_front(E)) { return -1; } continue; } } E->front_cursor -= k; E->front_left -= k; data -= k; size -= k; memcpy(E->front_cursor, data, k); }; return 0; } static int copy_back(flatcc_emitter_t *E, uint8_t *data, size_t size) { size_t k; while (size) { k = size; if (k > E->back_left) { k = E->back_left; if (k == 0) { if (advance_back(E)) { return -1; } continue; } } memcpy(E->back_cursor, data, k); size -= k; data += k; E->back_cursor += k; E->back_left -= k; } return 0; } int flatcc_emitter_recycle_page(flatcc_emitter_t *E, flatcc_emitter_page_t *p) { if (p == E->front || p == E->back) { return -1; } p->next->prev = p->prev; p->prev->next = p->next; p->prev = E->front->prev; p->next = E->front; p->prev->next = p; p->next->prev = p; return 0; } void flatcc_emitter_reset(flatcc_emitter_t *E) { flatcc_emitter_page_t *p = E->front; // NOLINT(clang-analyzer-deadcode.DeadStores) if (!E->front) { return; } E->back = E->front; E->front_cursor = E->front->page + FLATCC_EMITTER_PAGE_SIZE / 2; E->back_cursor = E->front_cursor; E->front_left = FLATCC_EMITTER_PAGE_SIZE / 2; E->back_left = FLATCC_EMITTER_PAGE_SIZE - FLATCC_EMITTER_PAGE_SIZE / 2; E->front->page_offset = -(flatbuffers_soffset_t)E->front_left; /* Heuristic to reduce peak allocation over time. */ if (E->used_average == 0) { E->used_average = E->used; } E->used_average = E->used_average * 3 / 4 + E->used / 4; E->used = 0; while (E->used_average * 2 < E->capacity && E->back->next != E->front) { /* We deallocate the page after back since it is less likely to be hot in cache. */ p = E->back->next; E->back->next = p->next; p->next->prev = E->back; FLATCC_EMITTER_FREE(p); E->capacity -= FLATCC_EMITTER_PAGE_SIZE; } } void flatcc_emitter_clear(flatcc_emitter_t *E) { flatcc_emitter_page_t *p = E->front; if (!p) { return; } p->prev->next = 0; while (p->next) { p = p->next; FLATCC_EMITTER_FREE(p->prev); } FLATCC_EMITTER_FREE(p); memset(E, 0, sizeof(*E)); } int flatcc_emitter(void *emit_context, const flatcc_iovec_t *iov, int iov_count, flatbuffers_soffset_t offset, size_t len) { flatcc_emitter_t *E = emit_context; uint8_t *p; E->used += len; if (offset < 0) { if (len <= E->front_left) { E->front_cursor -= len; E->front_left -= len; p = E->front_cursor; goto copy; } iov += iov_count; while (iov_count--) { --iov; if (copy_front(E, iov->iov_base, iov->iov_len)) { return -1; } } } else { if (len <= E->back_left) { p = E->back_cursor; E->back_cursor += len; E->back_left -= len; goto copy; } while (iov_count--) { if (copy_back(E, iov->iov_base, iov->iov_len)) { return -1; } ++iov; } } return 0; copy: while (iov_count--) { memcpy(p, iov->iov_base, iov->iov_len); p += iov->iov_len; ++iov; } return 0; } void *flatcc_emitter_copy_buffer(flatcc_emitter_t *E, void *buf, size_t size) { flatcc_emitter_page_t *p; size_t len; if (size < E->used) { return 0; } if (!E->front) { return 0; } if (E->front == E->back) { memcpy(buf, E->front_cursor, E->used); return buf; } len = FLATCC_EMITTER_PAGE_SIZE - E->front_left; memcpy(buf, E->front_cursor, len); buf = (uint8_t *)buf + len; p = E->front->next; while (p != E->back) { memcpy(buf, p->page, FLATCC_EMITTER_PAGE_SIZE); buf = (uint8_t *)buf + FLATCC_EMITTER_PAGE_SIZE; p = p->next; } memcpy(buf, p->page, FLATCC_EMITTER_PAGE_SIZE - E->back_left); return buf; } /* * Runtime support for verifying flatbuffers. * * Depends mutually on generated verifier functions for table types that * call into this library. */ #include #include "flatcc/flatcc_rtconfig.h" #include "flatcc/flatcc_flatbuffers.h" #include "flatcc/flatcc_verifier.h" #include "flatcc/flatcc_identifier.h" /* Customization for testing. */ #if FLATCC_DEBUG_VERIFY #define FLATCC_VERIFIER_ASSERT_ON_ERROR 1 #include #define FLATCC_VERIFIER_ASSERT(cond, reason) \ if (!(cond)) { fprintf(stderr, "verifier assert: %s\n", \ flatcc_verify_error_string(reason)); FLATCC_ASSERT(0); return reason; } #endif #if FLATCC_TRACE_VERIFY #include #define trace_verify(s, p) \ fprintf(stderr, "trace verify: %s: 0x%02x\n", (s), (unsigned)(size_t)(p)); #else #define trace_verify(s, p) ((void)0) #endif /* The runtime library does not use the global config file. */ /* This is a guideline, not an exact measure. */ #ifndef FLATCC_VERIFIER_MAX_LEVELS #define FLATCC_VERIFIER_MAX_LEVELS 100 #endif #ifndef FLATCC_VERIFIER_ASSERT_ON_ERROR #define FLATCC_VERIFIER_ASSERT_ON_ERROR 0 #endif /* * Generally a check should tell if a buffer is valid or not such * that runtime can take appropriate actions rather than crash, * also in debug, but assertions are helpful in debugging a problem. * * This must be compiled into the debug runtime library to take effect. */ #ifndef FLATCC_VERIFIER_ASSERT_ON_ERROR #define FLATCC_VERIFIER_ASSERT_ON_ERROR 1 #endif /* May be redefined for logging purposes. */ #ifndef FLATCC_VERIFIER_ASSERT #define FLATCC_VERIFIER_ASSERT(cond, reason) FLATCC_ASSERT(cond) #endif #if FLATCC_VERIFIER_ASSERT_ON_ERROR #define flatcc_verify(cond, reason) if (!(cond)) { FLATCC_VERIFIER_ASSERT(cond, reason); return reason; } #else #define flatcc_verify(cond, reason) if (!(cond)) { return reason; } #endif #define uoffset_t flatbuffers_uoffset_t #define soffset_t flatbuffers_soffset_t #define voffset_t flatbuffers_voffset_t #define utype_t flatbuffers_utype_t #define thash_t flatbuffers_thash_t #define uoffset_size sizeof(uoffset_t) #define soffset_size sizeof(soffset_t) #define voffset_size sizeof(voffset_t) #define utype_size sizeof(utype_t) #define thash_size sizeof(thash_t) #define offset_size uoffset_size const char *flatcc_verify_error_string(int err) { switch (err) { #define XX(no, str) \ case flatcc_verify_error_##no: \ return str; FLATCC_VERIFY_ERROR_MAP(XX) #undef XX default: return "unknown"; } } /* `cond` may have side effects. */ #define verify(cond, reason) do { int c = (cond); flatcc_verify(c, reason); } while(0) /* * Identify checks related to runtime conditions (buffer size and * alignment) as seperate from those related to buffer content. */ #define verify_runtime(cond, reason) verify(cond, reason) #define check_result(x) if (x) { return (x); } #define check_field(td, id, required, base) do { \ int ret = get_offset_field(td, id, required, &base); \ if (ret || !base) { return ret; }} while (0) static inline uoffset_t read_uoffset(const void *p, uoffset_t base) { return __flatbuffers_uoffset_read_from_pe((uint8_t *)p + base); } static inline thash_t read_thash_identifier(const char *identifier) { return flatbuffers_type_hash_from_string(identifier); } static inline thash_t read_thash(const void *p, uoffset_t base) { return __flatbuffers_thash_read_from_pe((uint8_t *)p + base); } static inline voffset_t read_voffset(const void *p, uoffset_t base) { return __flatbuffers_voffset_read_from_pe((uint8_t *)p + base); } static inline int check_header(uoffset_t end, uoffset_t base, uoffset_t offset) { uoffset_t k = base + offset; if (uoffset_size <= voffset_size && k + offset_size < k) { return 0; } /* The `k > base` rather than `k >= base` is to avoid null offsets. */ return k > base && k + offset_size <= end && !(k & (offset_size - 1)); } static inline int verify_struct(uoffset_t end, uoffset_t base, uoffset_t offset, uoffset_t size, uint16_t align) { /* Structs can have zero size so `end` is a valid value. */ if (offset == 0 || base + offset > end) { return flatcc_verify_error_offset_out_of_range; } base += offset; verify(base + size >= base, flatcc_verify_error_struct_size_overflow); verify(base + size <= end, flatcc_verify_error_struct_out_of_range); verify (!(base & (align - 1u)), flatcc_verify_error_struct_unaligned); return flatcc_verify_ok; } static inline voffset_t read_vt_entry(flatcc_table_verifier_descriptor_t *td, voffset_t id) { voffset_t vo = (id + 2u) * sizeof(voffset_t); /* Assumes tsize has been verified for alignment. */ if (vo >= td->vsize) { return 0; } return read_voffset(td->vtable, vo); } static inline const void *get_field_ptr(flatcc_table_verifier_descriptor_t *td, voffset_t id) { voffset_t vte = read_vt_entry(td, id); return vte ? (const uint8_t *)td->buf + td->table + vte : 0; } static int verify_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, uoffset_t size, uint16_t align) { uoffset_t k, k2; voffset_t vte; uoffset_t base = (uoffset_t)(size_t)td->buf; /* * Otherwise range check assumptions break, and normal access code likely also. * We don't require voffset_size < uoffset_size, but some checks are faster if true. */ FLATCC_ASSERT(uoffset_size >= voffset_size); FLATCC_ASSERT(soffset_size == uoffset_size); vte = read_vt_entry(td, id); if (!vte) { verify(!required, flatcc_verify_error_required_field_missing); return flatcc_verify_ok; } trace_verify("table buffer", td->buf); trace_verify("table", td->table); trace_verify("id", id); trace_verify("vte", vte); /* * Note that we don't add td.table to k and we test against table * size not table end or buffer end. Otherwise it would not be safe * to optimized out the k <= k2 check for normal uoffset and voffset * configurations. */ k = vte; k2 = k + size; verify(k2 <= td->tsize, flatcc_verify_error_table_field_out_of_range); /* This normally optimizes to nop. */ verify(uoffset_size > voffset_size || k <= k2, flatcc_verify_error_table_field_size_overflow); trace_verify("table + vte", vte + td->table); k += td->table + base; trace_verify("entry: buf + table + vte", k); trace_verify("align", align); trace_verify("align masked entry", k & (align - 1u)); verify(!(k & (align - 1u)), flatcc_verify_error_table_field_not_aligned); /* We assume the table size has already been verified. */ return flatcc_verify_ok; } static int get_offset_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, uoffset_t *out) { uoffset_t k, k2; voffset_t vte; vte = read_vt_entry(td, id); if (!vte) { *out = 0; if (required) { return flatcc_verify_error_required_field_missing; } /* Missing, but not invalid. */ return flatcc_verify_ok; } /* * Note that we don't add td.table to k and we test against table * size not table end or buffer end. Otherwise it would not be safe * to optimized out the k <= k2 check for normal uoffset and voffset * configurations. */ k = vte; k2 = k + offset_size; verify(k2 <= td->tsize, flatcc_verify_error_table_field_out_of_range); /* This normally optimizes to nop. */ verify(uoffset_size > voffset_size || k <= k2, flatcc_verify_error_table_field_size_overflow); k += td->table; verify(!(k & (offset_size - 1u)), flatcc_verify_error_table_field_not_aligned); /* We assume the table size has already been verified. */ *out = k; return flatcc_verify_ok; } static inline int verify_string(const void *buf, uoffset_t end, uoffset_t base, uoffset_t offset) { uoffset_t n; verify(check_header(end, base, offset), flatcc_verify_error_string_header_out_of_range_or_unaligned); base += offset; n = read_uoffset(buf, base); base += offset_size; verify(end - base > n, flatcc_verify_error_string_out_of_range); verify(((uint8_t *)buf + base)[n] == 0, flatcc_verify_error_string_not_zero_terminated); return flatcc_verify_ok; } /* * Keep interface somwewhat similar ot flatcc_builder_start_vector. * `max_count` is a precomputed division to manage overflow check on vector length. */ static inline int verify_vector(const void *buf, uoffset_t end, uoffset_t base, uoffset_t offset, uoffset_t elem_size, uint16_t align, uoffset_t max_count) { uoffset_t n; verify(check_header(end, base, offset), flatcc_verify_error_vector_header_out_of_range_or_unaligned); base += offset; n = read_uoffset(buf, base); base += offset_size; #if !FLATCC_ENFORCE_ALIGNED_EMPTY_VECTORS /* This is due to incorrect buffers from other builders than cannot easily be ignored. */ align = n == 0 ? uoffset_size : align; #endif verify(!(base & ((align - 1u) | (uoffset_size - 1u))), flatcc_verify_error_vector_header_out_of_range_or_unaligned); /* `n * elem_size` can overflow uncontrollably otherwise. */ verify(n <= max_count, flatcc_verify_error_vector_count_exceeds_representable_vector_size); verify(end - base >= n * elem_size, flatcc_verify_error_vector_out_of_range); return flatcc_verify_ok; } static inline int verify_string_vector(const void *buf, uoffset_t end, uoffset_t base, uoffset_t offset) { uoffset_t i, n; check_result(verify_vector(buf, end, base, offset, offset_size, offset_size, FLATBUFFERS_COUNT_MAX(offset_size))); base += offset; n = read_uoffset(buf, base); base += offset_size; for (i = 0; i < n; ++i, base += offset_size) { check_result(verify_string(buf, end, base, read_uoffset(buf, base))); } return flatcc_verify_ok; } static inline int verify_table(const void *buf, uoffset_t end, uoffset_t base, uoffset_t offset, int ttl, flatcc_table_verifier_f tvf) { uoffset_t vbase, vend; flatcc_table_verifier_descriptor_t td; verify((td.ttl = ttl - 1), flatcc_verify_error_max_nesting_level_reached); verify(check_header(end, base, offset), flatcc_verify_error_table_header_out_of_range_or_unaligned); td.table = base + offset; /* Read vtable offset - it is signed, but we want it unsigned, assuming 2's complement works. */ vbase = td.table - read_uoffset(buf, td.table); verify((soffset_t)vbase >= 0 && !(vbase & (voffset_size - 1)), flatcc_verify_error_vtable_offset_out_of_range_or_unaligned); verify(vbase + voffset_size <= end, flatcc_verify_error_vtable_header_out_of_range); /* Read vtable size. */ td.vsize = read_voffset(buf, vbase); vend = vbase + td.vsize; verify(vend <= end && !(td.vsize & (voffset_size - 1)), flatcc_verify_error_vtable_size_out_of_range_or_unaligned); /* Optimizes away overflow check if uoffset_t is large enough. */ verify(uoffset_size > voffset_size || vend >= vbase, flatcc_verify_error_vtable_size_overflow); verify(td.vsize >= 2 * voffset_size, flatcc_verify_error_vtable_header_too_small); /* Read table size. */ td.tsize = read_voffset(buf, vbase + voffset_size); verify(end - td.table >= td.tsize, flatcc_verify_error_table_size_out_of_range); td.vtable = (uint8_t *)buf + vbase; td.buf = buf; td.end = end; return tvf(&td); } static inline int verify_table_vector(const void *buf, uoffset_t end, uoffset_t base, uoffset_t offset, int ttl, flatcc_table_verifier_f tvf) { uoffset_t i, n; verify(ttl-- > 0, flatcc_verify_error_max_nesting_level_reached); check_result(verify_vector(buf, end, base, offset, offset_size, offset_size, FLATBUFFERS_COUNT_MAX(offset_size))); base += offset; n = read_uoffset(buf, base); base += offset_size; for (i = 0; i < n; ++i, base += offset_size) { check_result(verify_table(buf, end, base, read_uoffset(buf, base), ttl, tvf)); } return flatcc_verify_ok; } static inline int verify_union_vector(const void *buf, uoffset_t end, uoffset_t base, uoffset_t offset, uoffset_t count, const utype_t *types, int ttl, flatcc_union_verifier_f uvf) { uoffset_t i, n, elem; flatcc_union_verifier_descriptor_t ud; verify(ttl-- > 0, flatcc_verify_error_max_nesting_level_reached); check_result(verify_vector(buf, end, base, offset, offset_size, offset_size, FLATBUFFERS_COUNT_MAX(offset_size))); base += offset; n = read_uoffset(buf, base); verify(n == count, flatcc_verify_error_union_vector_length_mismatch); base += offset_size; ud.buf = buf; ud.end = end; ud.ttl = ttl; for (i = 0; i < n; ++i, base += offset_size) { /* Table vectors can never be null, but unions can when the type is NONE. */ elem = read_uoffset(buf, base); if (elem == 0) { verify(types[i] == 0, flatcc_verify_error_union_element_absent_without_type_NONE); } else { verify(types[i] != 0, flatcc_verify_error_union_element_present_with_type_NONE); ud.type = types[i]; ud.base = base; ud.offset = elem; check_result(uvf(&ud)); } } return flatcc_verify_ok; } int flatcc_verify_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, size_t size, uint16_t align) { check_result(verify_field(td, id, 0, (uoffset_t)size, align)); return flatcc_verify_ok; } int flatcc_verify_string_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required) { uoffset_t base; check_field(td, id, required, base); return verify_string(td->buf, td->end, base, read_uoffset(td->buf, base)); } int flatcc_verify_vector_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, size_t elem_size, uint16_t align, size_t max_count) { uoffset_t base; check_field(td, id, required, base); return verify_vector(td->buf, td->end, base, read_uoffset(td->buf, base), (uoffset_t)elem_size, align, (uoffset_t)max_count); } int flatcc_verify_string_vector_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required) { uoffset_t base; check_field(td, id, required, base); return verify_string_vector(td->buf, td->end, base, read_uoffset(td->buf, base)); } int flatcc_verify_table_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, flatcc_table_verifier_f tvf) { uoffset_t base; check_field(td, id, required, base); return verify_table(td->buf, td->end, base, read_uoffset(td->buf, base), td->ttl, tvf); } int flatcc_verify_table_vector_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, flatcc_table_verifier_f tvf) { uoffset_t base; check_field(td, id, required, base); return verify_table_vector(td->buf, td->end, base, read_uoffset(td->buf, base), td->ttl, tvf); } int flatcc_verify_union_table(flatcc_union_verifier_descriptor_t *ud, flatcc_table_verifier_f *tvf) { return verify_table(ud->buf, ud->end, ud->base, ud->offset, ud->ttl, tvf); } int flatcc_verify_union_struct(flatcc_union_verifier_descriptor_t *ud, size_t size, uint16_t align) { return verify_struct(ud->end, ud->base, ud->offset, (uoffset_t)size, align); } int flatcc_verify_union_string(flatcc_union_verifier_descriptor_t *ud) { return verify_string(ud->buf, ud->end, ud->base, ud->offset); } int flatcc_verify_buffer_header(const void *buf, size_t bufsiz, const char *fid) { thash_t id, id2; verify_runtime(!(((size_t)buf) & (offset_size - 1)), flatcc_verify_error_runtime_buffer_header_not_aligned); /* -8 ensures no scalar or offset field size can overflow. */ verify_runtime(bufsiz <= FLATBUFFERS_UOFFSET_MAX - 8, flatcc_verify_error_runtime_buffer_size_too_large); /* * Even if we specify no fid, the user might later. Therefore * require space for it. Not all buffer generators will take this * into account, so it is possible to fail an otherwise valid buffer * - but such buffers aren't safe. */ verify(bufsiz >= offset_size + FLATBUFFERS_IDENTIFIER_SIZE, flatcc_verify_error_buffer_header_too_small); if (fid != 0) { id2 = read_thash_identifier(fid); id = read_thash(buf, offset_size); verify(id2 == 0 || id == id2, flatcc_verify_error_identifier_mismatch); } return flatcc_verify_ok; } int flatcc_verify_buffer_header_with_size(const void *buf, size_t *bufsiz, const char *fid) { thash_t id, id2; size_t size_field; verify_runtime(!(((size_t)buf) & (offset_size - 1)), flatcc_verify_error_runtime_buffer_header_not_aligned); /* -8 ensures no scalar or offset field size can overflow. */ verify_runtime(*bufsiz <= FLATBUFFERS_UOFFSET_MAX - 8, flatcc_verify_error_runtime_buffer_size_too_large); /* Size field, offset field, optional identifier field that must be read even if not present. */ verify(*bufsiz >= 2 * offset_size + FLATBUFFERS_IDENTIFIER_SIZE, flatcc_verify_error_buffer_header_too_small); size_field = (size_t)read_uoffset(buf, 0); verify_runtime(size_field <= *bufsiz - offset_size, flatcc_verify_error_runtime_buffer_size_less_than_size_field); if (fid != 0) { id2 = read_thash_identifier(fid); id = read_thash(buf, offset_size); verify(id2 == 0 || id == id2, flatcc_verify_error_identifier_mismatch); } *bufsiz = size_field + offset_size; return flatcc_verify_ok; } int flatcc_verify_typed_buffer_header(const void *buf, size_t bufsiz, flatbuffers_thash_t thash) { thash_t id, id2; verify_runtime(!(((size_t)buf) & (offset_size - 1)), flatcc_verify_error_runtime_buffer_header_not_aligned); /* -8 ensures no scalar or offset field size can overflow. */ verify_runtime(bufsiz <= FLATBUFFERS_UOFFSET_MAX - 8, flatcc_verify_error_runtime_buffer_size_too_large); /* * Even if we specify no fid, the user might later. Therefore * require space for it. Not all buffer generators will take this * into account, so it is possible to fail an otherwise valid buffer * - but such buffers aren't safe. */ verify(bufsiz >= offset_size + FLATBUFFERS_IDENTIFIER_SIZE, flatcc_verify_error_buffer_header_too_small); if (thash != 0) { id2 = thash; id = read_thash(buf, offset_size); verify(id2 == 0 || id == id2, flatcc_verify_error_identifier_mismatch); } return flatcc_verify_ok; } int flatcc_verify_typed_buffer_header_with_size(const void *buf, size_t *bufsiz, flatbuffers_thash_t thash) { thash_t id, id2; size_t size_field; verify_runtime(!(((size_t)buf) & (offset_size - 1)), flatcc_verify_error_runtime_buffer_header_not_aligned); /* -8 ensures no scalar or offset field size can overflow. */ verify_runtime(*bufsiz <= FLATBUFFERS_UOFFSET_MAX - 8, flatcc_verify_error_runtime_buffer_size_too_large); /* Size field, offset field, optional identifier field that must be read even if not present. */ verify(*bufsiz >= 2 * offset_size + FLATBUFFERS_IDENTIFIER_SIZE, flatcc_verify_error_buffer_header_too_small); size_field = (size_t)read_uoffset(buf, 0); verify_runtime(size_field <= *bufsiz - offset_size, flatcc_verify_error_runtime_buffer_size_less_than_size_field); if (thash != 0) { id2 = thash; id = read_thash(buf, offset_size); verify(id2 == 0 || id == id2, flatcc_verify_error_identifier_mismatch); } *bufsiz = size_field + offset_size; return flatcc_verify_ok; } int flatcc_verify_struct_as_root(const void *buf, size_t bufsiz, const char *fid, size_t size, uint16_t align) { check_result(flatcc_verify_buffer_header(buf, bufsiz, fid)); return verify_struct((uoffset_t)bufsiz, 0, read_uoffset(buf, 0), (uoffset_t)size, align); } int flatcc_verify_struct_as_root_with_size(const void *buf, size_t bufsiz, const char *fid, size_t size, uint16_t align) { check_result(flatcc_verify_buffer_header_with_size(buf, &bufsiz, fid)); return verify_struct((uoffset_t)bufsiz, 0, read_uoffset(buf, 0), (uoffset_t)size, align); } int flatcc_verify_struct_as_typed_root(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, size_t size, uint16_t align) { check_result(flatcc_verify_typed_buffer_header(buf, bufsiz, thash)); return verify_struct((uoffset_t)bufsiz, 0, read_uoffset(buf, 0), (uoffset_t)size, align); } int flatcc_verify_struct_as_typed_root_with_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, size_t size, uint16_t align) { check_result(flatcc_verify_typed_buffer_header_with_size(buf, &bufsiz, thash)); return verify_struct((uoffset_t)bufsiz, uoffset_size, read_uoffset(buf, uoffset_size), (uoffset_t)size, align); } int flatcc_verify_table_as_root(const void *buf, size_t bufsiz, const char *fid, flatcc_table_verifier_f *tvf) { check_result(flatcc_verify_buffer_header(buf, bufsiz, fid)); return verify_table(buf, (uoffset_t)bufsiz, 0, read_uoffset(buf, 0), FLATCC_VERIFIER_MAX_LEVELS, tvf); } int flatcc_verify_table_as_root_with_size(const void *buf, size_t bufsiz, const char *fid, flatcc_table_verifier_f *tvf) { check_result(flatcc_verify_buffer_header_with_size(buf, &bufsiz, fid)); return verify_table(buf, (uoffset_t)bufsiz, uoffset_size, read_uoffset(buf, uoffset_size), FLATCC_VERIFIER_MAX_LEVELS, tvf); } int flatcc_verify_table_as_typed_root(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, flatcc_table_verifier_f *tvf) { check_result(flatcc_verify_typed_buffer_header(buf, bufsiz, thash)); return verify_table(buf, (uoffset_t)bufsiz, 0, read_uoffset(buf, 0), FLATCC_VERIFIER_MAX_LEVELS, tvf); } int flatcc_verify_table_as_typed_root_with_size(const void *buf, size_t bufsiz, flatbuffers_thash_t thash, flatcc_table_verifier_f *tvf) { check_result(flatcc_verify_typed_buffer_header_with_size(buf, &bufsiz, thash)); return verify_table(buf, (uoffset_t)bufsiz, uoffset_size, read_uoffset(buf, uoffset_size), FLATCC_VERIFIER_MAX_LEVELS, tvf); } int flatcc_verify_struct_as_nested_root(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, const char *fid, size_t size, uint16_t align) { const uoffset_t *buf; uoffset_t bufsiz; check_result(flatcc_verify_vector_field(td, id, required, align, 1, FLATBUFFERS_COUNT_MAX(1))); if (0 == (buf = get_field_ptr(td, id))) { return flatcc_verify_ok; } buf = (const uoffset_t *)((size_t)buf + read_uoffset(buf, 0)); bufsiz = read_uoffset(buf, 0); ++buf; return flatcc_verify_struct_as_root(buf, bufsiz, fid, size, align); } int flatcc_verify_table_as_nested_root(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, const char *fid, uint16_t align, flatcc_table_verifier_f tvf) { const uoffset_t *buf; uoffset_t bufsiz; check_result(flatcc_verify_vector_field(td, id, required, align, 1, FLATBUFFERS_COUNT_MAX(1))); if (0 == (buf = get_field_ptr(td, id))) { return flatcc_verify_ok; } buf = (const uoffset_t *)((size_t)buf + read_uoffset(buf, 0)); bufsiz = read_uoffset(buf, 0); ++buf; /* * Don't verify nested buffers identifier - information is difficult to get and * might not be what is desired anyway. User can do it later. */ check_result(flatcc_verify_buffer_header(buf, bufsiz, fid)); return verify_table(buf, bufsiz, 0, read_uoffset(buf, 0), td->ttl, tvf); } int flatcc_verify_union_field(flatcc_table_verifier_descriptor_t *td, voffset_t id, int required, flatcc_union_verifier_f uvf) { voffset_t vte_type, vte_table; const uint8_t *type; uoffset_t base; flatcc_union_verifier_descriptor_t ud; if (0 == (vte_type = read_vt_entry(td, id - 1))) { vte_table = read_vt_entry(td, id); verify(vte_table == 0, flatcc_verify_error_union_cannot_have_a_table_without_a_type); verify(!required, flatcc_verify_error_type_field_absent_from_required_union_field); return flatcc_verify_ok; } /* No need to check required here. */ check_result(verify_field(td, id - 1, 0, 1, 1)); /* Only now is it safe to read the type. */ vte_table = read_vt_entry(td, id); type = (const uint8_t *)td->buf + td->table + vte_type; verify(*type || vte_table == 0, flatcc_verify_error_union_type_NONE_cannot_have_a_value); if (*type == 0) { return flatcc_verify_ok; } check_field(td, id, required, base); ud.buf = td->buf; ud.end = td->end; ud.ttl = td->ttl; ud.base = base; ud.offset = read_uoffset(td->buf, base); ud.type = *type; return uvf(&ud); } int flatcc_verify_union_vector_field(flatcc_table_verifier_descriptor_t *td, flatbuffers_voffset_t id, int required, flatcc_union_verifier_f uvf) { voffset_t vte_type, vte_table; const uoffset_t *buf; const utype_t *types; uoffset_t count, base; if (0 == (vte_type = read_vt_entry(td, id - 1))) { // NOLINT(clang-analyzer-deadcode.DeadStores) if (0 == (vte_table = read_vt_entry(td, id))) { // NOLINT(clang-analyzer-deadcode.DeadStores) verify(!required, flatcc_verify_error_type_field_absent_from_required_union_vector_field); } } check_result(flatcc_verify_vector_field(td, id - 1, required, utype_size, utype_size, FLATBUFFERS_COUNT_MAX(utype_size))); if (0 == (buf = get_field_ptr(td, id - 1))) { return flatcc_verify_ok; } buf = (const uoffset_t *)((size_t)buf + read_uoffset(buf, 0)); count = read_uoffset(buf, 0); ++buf; types = (utype_t *)buf; check_field(td, id, required, base); return verify_union_vector(td->buf, td->end, base, read_uoffset(td->buf, base), count, types, td->ttl, uvf); } /* * Optional file that can be included in runtime library to support DAG * cloning with the builder and may also be used for custom purposes * standalone. See also comments in `flatcc/flatcc_builder.h`. * * Note that dynamic construction takes place and that large offset * vectors might consume significant space if there are not many shared * references. In the basic use case no allocation takes place because a * few references can be held using only a small stack allocated hash * table. */ #include #include #include "flatcc/flatcc_rtconfig.h" #include "flatcc/flatcc_refmap.h" #include "flatcc/flatcc_alloc.h" #include "flatcc/flatcc_assert.h" #define _flatcc_refmap_calloc FLATCC_CALLOC #define _flatcc_refmap_free FLATCC_FREE /* Can be used as a primitive defense against collision attacks. */ #ifdef FLATCC_HASH_SEED #define _flatcc_refmap_seed FLATCC_HASH_SEED #else #define _flatcc_refmap_seed 0x2f693b52 #endif static inline size_t _flatcc_refmap_above_load_factor(size_t count, size_t buckets) { static const size_t d = 256; static const size_t n = (size_t)((FLATCC_REFMAP_LOAD_FACTOR) * 256.0f); return count >= buckets * n / d; } #define _flatcc_refmap_probe(k, i, N) ((k + i) & N) void flatcc_refmap_clear(flatcc_refmap_t *refmap) { if (refmap->table && refmap->table != refmap->min_table) { _flatcc_refmap_free(refmap->table); } flatcc_refmap_init(refmap); } static inline size_t _flatcc_refmap_hash(const void *src) { /* MurmurHash3 64-bit finalizer */ uint64_t x; x = (uint64_t)((size_t)src) ^ _flatcc_refmap_seed; x ^= x >> 33; x *= 0xff51afd7ed558ccdULL; x ^= x >> 33; x *= 0xc4ceb9fe1a85ec53ULL; x ^= x >> 33; return (size_t)x; } void flatcc_refmap_reset(flatcc_refmap_t *refmap) { if (refmap->count) { memset(refmap->table, 0, sizeof(refmap->table[0]) * refmap->buckets); } refmap->count = 0; } /* * Technically resize also supports shrinking which may be useful for * adapations, but the current hash table never deletes individual items. */ int flatcc_refmap_resize(flatcc_refmap_t *refmap, size_t count) { const size_t min_buckets = sizeof(refmap->min_table) / sizeof(refmap->min_table[0]); size_t i; size_t buckets; size_t buckets_old; struct flatcc_refmap_item *T_old; if (count < refmap->count) { count = refmap->count; } buckets = min_buckets; while (_flatcc_refmap_above_load_factor(count, buckets)) { buckets *= 2; } if (refmap->buckets == buckets) { return 0; } T_old = refmap->table; buckets_old = refmap->buckets; if (buckets == min_buckets) { memset(refmap->min_table, 0, sizeof(refmap->min_table)); refmap->table = refmap->min_table; } else { refmap->table = _flatcc_refmap_calloc(buckets, sizeof(refmap->table[0])); if (refmap->table == 0) { refmap->table = T_old; FLATCC_ASSERT(0); /* out of memory */ return -1; } } refmap->buckets = buckets; refmap->count = 0; for (i = 0; i < buckets_old; ++i) { if (T_old[i].src) { flatcc_refmap_insert(refmap, T_old[i].src, T_old[i].ref); } } if (T_old && T_old != refmap->min_table) { _flatcc_refmap_free(T_old); } return 0; } flatcc_refmap_ref_t flatcc_refmap_insert(flatcc_refmap_t *refmap, const void *src, flatcc_refmap_ref_t ref) { struct flatcc_refmap_item *T; size_t N, i, j, k; if (src == 0) return ref; if (_flatcc_refmap_above_load_factor(refmap->count, refmap->buckets)) { if (flatcc_refmap_resize(refmap, refmap->count * 2)) { return flatcc_refmap_not_found; /* alloc failed */ } } T = refmap->table; N = refmap->buckets - 1; k = _flatcc_refmap_hash(src); i = 0; j = _flatcc_refmap_probe(k, i, N); while (T[j].src) { if (T[j].src == src) { return T[j].ref = ref; } ++i; j = _flatcc_refmap_probe(k, i, N); } ++refmap->count; T[j].src = src; return T[j].ref = ref; } flatcc_refmap_ref_t flatcc_refmap_find(flatcc_refmap_t *refmap, const void *src) { struct flatcc_refmap_item *T; size_t N, i, j, k; if (refmap->count == 0) { return flatcc_refmap_not_found; } T = refmap->table; N = refmap->buckets - 1; k = _flatcc_refmap_hash(src); i = 0; j = _flatcc_refmap_probe(k, i, N); while (T[j].src) { if (T[j].src == src) return T[j].ref; ++i; j = _flatcc_refmap_probe(k, i, N); } return flatcc_refmap_not_found; } /* * To run test from project root: * * cc -D FLATCC_REFMAP_TEST -I include src/runtime/refmap.c -o test_refmap && ./test_refmap * */ #ifdef FLATCC_REFMAP_TEST #include #ifndef FLATCC_REFMAP_H #include "flatcc/flatcc_refmap.h" #endif #define test(x) do { if (!(x)) { fprintf(stderr, "%02d: refmap test failed\n", __LINE__); exit(-1); } } while (0) #define test_start() fprintf(stderr, "starting refmap test ...\n") #define test_ok() fprintf(stderr, "refmap test succeeded\n") int main() { int i; int data[1000]; int a = 1; int b = 2; int c = 3; flatcc_refmap_t refmap; flatcc_refmap_init(&refmap); test(flatcc_refmap_find(&refmap, &a) == flatcc_refmap_not_found); test(flatcc_refmap_find(&refmap, &b) == flatcc_refmap_not_found); test(flatcc_refmap_find(&refmap, &c) == flatcc_refmap_not_found); test(flatcc_refmap_find(&refmap, 0) == flatcc_refmap_not_found); test(flatcc_refmap_find(&refmap, &a) == 0); test(flatcc_refmap_insert(&refmap, &a, 42) == 42); test(flatcc_refmap_find(&refmap, &a) == 42); test(flatcc_refmap_find(&refmap, &b) == flatcc_refmap_not_found); test(flatcc_refmap_find(&refmap, &c) == flatcc_refmap_not_found); test(flatcc_refmap_insert(&refmap, &a, 42) == 42); test(flatcc_refmap_find(&refmap, &a) == 42); test(refmap.count == 1); test(flatcc_refmap_insert(&refmap, &a, 43) == 43); test(flatcc_refmap_find(&refmap, &a) == 43); test(refmap.count == 1); test(flatcc_refmap_insert(&refmap, &b, -10) == -10); test(flatcc_refmap_insert(&refmap, &c, 100) == 100); test(refmap.count == 3); test(flatcc_refmap_find(&refmap, &a) == 43); test(flatcc_refmap_find(&refmap, &b) == -10); test(flatcc_refmap_find(&refmap, &c) == 100); test(flatcc_refmap_insert(&refmap, 0, 1000) == 1000); test(flatcc_refmap_find(&refmap, 0) == 0); test(refmap.count == 3); test(flatcc_refmap_insert(&refmap, &b, 0) == 0); test(flatcc_refmap_find(&refmap, &b) == 0); test(refmap.count == 3); flatcc_refmap_reset(&refmap); test(refmap.count == 0); test(refmap.buckets > 0); for (i = 0; i < 1000; ++i) { test(flatcc_refmap_insert(&refmap, data + i, i + 42) == i + 42); } test(refmap.count == 1000); for (i = 0; i < 1000; ++i) { test(flatcc_refmap_find(&refmap, data + i) == i + 42); } flatcc_refmap_clear(&refmap); test(refmap.count == 0); test(refmap.buckets == 0); test_ok(); return 0; } #endif /* FLATCC_REFMAP_TEST */ nanoarrow/NAMESPACE0000644000176200001440000001653614676554240013527 0ustar liggesusers# Generated by roxygen2: do not edit by hand S3method("$",nanoarrow_array) S3method("$",nanoarrow_array_stream) S3method("$",nanoarrow_buffer) S3method("$",nanoarrow_schema) S3method("$<-",nanoarrow_array) S3method("$<-",nanoarrow_schema) S3method("[",nanoarrow_vctr) S3method("[<-",nanoarrow_vctr) S3method("[[",nanoarrow_array) S3method("[[",nanoarrow_array_stream) S3method("[[",nanoarrow_buffer) S3method("[[",nanoarrow_schema) S3method("[[<-",nanoarrow_array) S3method("[[<-",nanoarrow_schema) S3method("[[<-",nanoarrow_vctr) S3method(as.data.frame,nanoarrow_array) S3method(as.data.frame,nanoarrow_array_stream) S3method(as.data.frame,nanoarrow_vctr) S3method(as.raw,nanoarrow_buffer) S3method(as.vector,nanoarrow_array) S3method(as.vector,nanoarrow_array_stream) S3method(as.vector,nanoarrow_buffer) S3method(as_nanoarrow_array,Array) S3method(as_nanoarrow_array,ChunkedArray) S3method(as_nanoarrow_array,Date) S3method(as_nanoarrow_array,POSIXct) S3method(as_nanoarrow_array,POSIXlt) S3method(as_nanoarrow_array,RecordBatch) S3method(as_nanoarrow_array,Table) S3method(as_nanoarrow_array,blob) S3method(as_nanoarrow_array,data.frame) S3method(as_nanoarrow_array,default) S3method(as_nanoarrow_array,difftime) S3method(as_nanoarrow_array,factor) S3method(as_nanoarrow_array,integer64) S3method(as_nanoarrow_array,list) S3method(as_nanoarrow_array,nanoarrow_array) S3method(as_nanoarrow_array,nanoarrow_buffer) S3method(as_nanoarrow_array,vctrs_unspecified) S3method(as_nanoarrow_array_extension,default) S3method(as_nanoarrow_array_extension,nanoarrow_extension_spec_vctrs) S3method(as_nanoarrow_array_stream,Array) S3method(as_nanoarrow_array_stream,ArrowTabular) S3method(as_nanoarrow_array_stream,ChunkedArray) S3method(as_nanoarrow_array_stream,Dataset) S3method(as_nanoarrow_array_stream,RecordBatchReader) S3method(as_nanoarrow_array_stream,Scanner) S3method(as_nanoarrow_array_stream,arrow_dplyr_query) S3method(as_nanoarrow_array_stream,data.frame) S3method(as_nanoarrow_array_stream,default) S3method(as_nanoarrow_array_stream,nanoarrow_array) S3method(as_nanoarrow_array_stream,nanoarrow_array_stream) S3method(as_nanoarrow_array_stream,nanoarrow_vctr) S3method(as_nanoarrow_buffer,default) S3method(as_nanoarrow_buffer,nanoarrow_buffer) S3method(as_nanoarrow_schema,DataType) S3method(as_nanoarrow_schema,Field) S3method(as_nanoarrow_schema,Schema) S3method(as_nanoarrow_schema,nanoarrow_schema) S3method(as_nanoarrow_schema,nanoarrow_vctr) S3method(c,nanoarrow_vctr) S3method(convert_array,default) S3method(convert_array,double) S3method(convert_array,factor) S3method(convert_array,nanoarrow_vctr) S3method(convert_array,vctrs_partial_frame) S3method(convert_array_extension,default) S3method(convert_array_extension,nanoarrow_extension_spec_vctrs) S3method(format,nanoarrow_array) S3method(format,nanoarrow_array_stream) S3method(format,nanoarrow_buffer) S3method(format,nanoarrow_schema) S3method(format,nanoarrow_vctr) S3method(infer_nanoarrow_ptype_extension,default) S3method(infer_nanoarrow_ptype_extension,nanoarrow_extension_spec_vctrs) S3method(infer_nanoarrow_schema,Array) S3method(infer_nanoarrow_schema,ArrowTabular) S3method(infer_nanoarrow_schema,AsIs) S3method(infer_nanoarrow_schema,ChunkedArray) S3method(infer_nanoarrow_schema,Dataset) S3method(infer_nanoarrow_schema,Date) S3method(infer_nanoarrow_schema,Expression) S3method(infer_nanoarrow_schema,POSIXct) S3method(infer_nanoarrow_schema,POSIXlt) S3method(infer_nanoarrow_schema,RecordBatchReader) S3method(infer_nanoarrow_schema,Scalar) S3method(infer_nanoarrow_schema,Scanner) S3method(infer_nanoarrow_schema,arrow_dplyr_query) S3method(infer_nanoarrow_schema,blob) S3method(infer_nanoarrow_schema,character) S3method(infer_nanoarrow_schema,data.frame) S3method(infer_nanoarrow_schema,default) S3method(infer_nanoarrow_schema,difftime) S3method(infer_nanoarrow_schema,double) S3method(infer_nanoarrow_schema,factor) S3method(infer_nanoarrow_schema,hms) S3method(infer_nanoarrow_schema,integer) S3method(infer_nanoarrow_schema,integer64) S3method(infer_nanoarrow_schema,list) S3method(infer_nanoarrow_schema,logical) S3method(infer_nanoarrow_schema,nanoarrow_array) S3method(infer_nanoarrow_schema,nanoarrow_array_stream) S3method(infer_nanoarrow_schema,nanoarrow_vctr) S3method(infer_nanoarrow_schema,raw) S3method(infer_nanoarrow_schema,vctrs_list_of) S3method(infer_nanoarrow_schema,vctrs_unspecified) S3method(length,nanoarrow_array) S3method(length,nanoarrow_array_stream) S3method(length,nanoarrow_buffer) S3method(length,nanoarrow_schema) S3method(names,nanoarrow_array) S3method(names,nanoarrow_array_stream) S3method(names,nanoarrow_buffer) S3method(names,nanoarrow_schema) S3method(print,nanoarrow_array) S3method(print,nanoarrow_array_stream) S3method(print,nanoarrow_buffer) S3method(print,nanoarrow_schema) S3method(print,nanoarrow_vctr) S3method(read_nanoarrow,character) S3method(read_nanoarrow,connection) S3method(read_nanoarrow,raw) S3method(str,nanoarrow_array) S3method(str,nanoarrow_array_stream) S3method(str,nanoarrow_buffer) S3method(str,nanoarrow_schema) S3method(str,nanoarrow_vctr) S3method(write_nanoarrow,character) S3method(write_nanoarrow,connection) export(array_stream_set_finalizer) export(as_nanoarrow_array) export(as_nanoarrow_array_extension) export(as_nanoarrow_array_stream) export(as_nanoarrow_buffer) export(as_nanoarrow_schema) export(as_nanoarrow_vctr) export(basic_array_stream) export(collect_array_stream) export(convert_array) export(convert_array_extension) export(convert_array_stream) export(convert_buffer) export(example_ipc_stream) export(infer_nanoarrow_ptype) export(infer_nanoarrow_ptype_extension) export(infer_nanoarrow_schema) export(na_binary) export(na_binary_view) export(na_bool) export(na_date32) export(na_date64) export(na_decimal128) export(na_decimal256) export(na_dense_union) export(na_dictionary) export(na_double) export(na_duration) export(na_extension) export(na_fixed_size_binary) export(na_fixed_size_list) export(na_float) export(na_half_float) export(na_int16) export(na_int32) export(na_int64) export(na_int8) export(na_interval_day_time) export(na_interval_month_day_nano) export(na_interval_months) export(na_large_binary) export(na_large_list) export(na_large_string) export(na_list) export(na_map) export(na_na) export(na_sparse_union) export(na_string) export(na_string_view) export(na_struct) export(na_time32) export(na_time64) export(na_timestamp) export(na_type) export(na_uint16) export(na_uint32) export(na_uint64) export(na_uint8) export(na_vctrs) export(nanoarrow_allocate_array) export(nanoarrow_allocate_array_stream) export(nanoarrow_allocate_schema) export(nanoarrow_array_init) export(nanoarrow_array_modify) export(nanoarrow_array_set_schema) export(nanoarrow_buffer_append) export(nanoarrow_buffer_init) export(nanoarrow_extension_array) export(nanoarrow_extension_spec) export(nanoarrow_pointer_addr_chr) export(nanoarrow_pointer_addr_dbl) export(nanoarrow_pointer_addr_pretty) export(nanoarrow_pointer_export) export(nanoarrow_pointer_is_valid) export(nanoarrow_pointer_move) export(nanoarrow_pointer_release) export(nanoarrow_pointer_set_protected) export(nanoarrow_schema_modify) export(nanoarrow_schema_parse) export(nanoarrow_vctr) export(nanoarrow_version) export(read_nanoarrow) export(register_nanoarrow_extension) export(resolve_nanoarrow_extension) export(unregister_nanoarrow_extension) export(write_nanoarrow) importFrom(utils,getFromNamespace) importFrom(utils,str) useDynLib(nanoarrow, .registration = TRUE) nanoarrow/NEWS.md0000644000176200001440000000672314702630552013372 0ustar liggesusers # nanoarrow 0.6.0 - Add float16 support for R bindings (#650) - Implement string view support in R bindings (#636) - Allow opt-out of warning for unregistered extension types (#632) - Add bindings to IPC writer (#608) - Avoid flatcc aligned_alloc() call when compiling R package (#494) - Use JSON in experimental R vctrs extension type (#533) # nanoarrow 0.5.0 - Add experimental `nanoarrow_vctr` to wrap a list of arrays (#461) - Add bindings for IPC reader (#390) - Fix tests for platforms where arrow dataset and/or zip is not available (#415) - Remove unnecessary package name call (#381) # nanoarrow 0.4.0 - Fix source links from pkgdown site (#315). - Provide LinkingTo headers for extension packages (#332). - Add more `nanoarrow_array_stream` generics (#349). - Add conversion from integer type to `character()` (#345). - Ensure simple `list()`s can be converted without arrow installed (#344). # nanoarrow 0.3.0.1 - Ensure wrapper array stream eagerly releases the wrapped array stream (#333). # nanoarrow 0.3.0 - Use classed warnings to signal that a lossy conversion occurred (#298) - Add support for `bit64::integer64()` conversions (#293) - Implement extension type registration/conversion (#288) - Implement dictionary conversion (#285) - Ensure `ordered` is reflected in `na_dictionary()` (#299) - Warn for possibly out of range int64 -> double conversions (#294) - Support map conversion to R vector (#282) - Don't link to arrow package R6 class pages (#269) - Use `basic_array_stream()` to improve array stream to data.frame conversion (#279) # nanoarrow 0.2.0-1 - Don't link to arrow package R6 class pages (#269) # nanoarrow 0.2.0 ## New features - Improve printing and conversion of buffers (#208) - Add `enum ArrowType buffer_data_type` member to `struct ArrowLayout` (#207) - Implement ListChildOffset function (#197) - Add ability to deterministically run a finalizer on an array stream (#196) - Union array support (#195) - Add ArrowArrayStream implementation to support keeping a dependent object in scope (#194) - Add `as_nanoarrow_array()` implementation that does not fall back on `arrow::as_arrow_array()` everywhere (#108) - Create nanoarrow_array objects from buffers (#105) - Implement infer schema methods (#104) - Create and modify nanoarrow_schema objects (#101) ## Bugfixes - Fix `convert_array_stream()` for non-record batch stream with zero batches (#212) - clear `release` in `EmptyArrayStream::release_wrapper` (#204) - Release streams when calling `as.vector()` or `as.data.frame()` (#202) - Don't invoke undefined behaviour in conversions to/from Arrow (#167) - Use strict prototypes in all internal C functions (#151) - Don't memcpy NULL when converting buffer to raw (#149) nanoarrow/inst/0000755000176200001440000000000014547575511013253 5ustar liggesusersnanoarrow/inst/include/0000755000176200001440000000000014547575511014676 5ustar liggesusersnanoarrow/inst/include/nanoarrow/0000755000176200001440000000000014635121021016661 5ustar liggesusersnanoarrow/inst/include/nanoarrow/r.h0000644000176200001440000003703214635121021017300 0ustar liggesusers// 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. #ifndef NANOARROW_R_H_INCLUDED #define NANOARROW_R_H_INCLUDED #include #include #include #ifdef __cplusplus extern "C" { #endif /// \defgroup nanoarrow-r Utilities for Arrow R extensions /// /// EXPERIMENTAL: The interface and lifecycle semantics described in this header /// should be considered experimental and may change in a future version based on /// user feedback. /// /// In the nanoarrow R package, an external pointer to an ArrowSchema, ArrowArray, or /// ArrowArrayStream carries the class "nanoarrow_schema", "nanoarrow_array", or /// "nanoarrow_array_stream" (respectively). The pointer must point to valid memory /// or be NULL until the R external pointer object is finalized. /// /// nanoarrow_schema_owning_xptr(), nanoarrow_array_owning_xptr(), and /// nanoarrow_array_stream_owning_xptr() initialize such an external pointer using /// malloc() and a NULL initial release() callback such that it can be distinguished from /// a pointer to an initialized value according to the Arrow C Data/Stream interface /// documentation. This structure is intended to have a valid value initialized into it /// using ArrowXXXMove() or by passing the pointer to a suitable exporting function. /// /// External pointers allocated by nanoarrow_xxxx_owning_xptr() register a finalizer /// that will call the release() callback when its value is non-NULL and points to /// a structure whose release() callback is also non-NULL. External pointers may also /// manage lifecycle by declaring a strong reference to a single R object via /// R_SetExternalPtrProtected(); however, when passing the address of an R external /// pointer to a non-R library, the ownership of the structure must *not* have such SEXP /// dependencies. The nanoarrow R package can wrap such an SEXP dependency into a /// self-contained thread-safe release callback via nanoarrow_pointer_export() that /// manages the SEXP dependency using a preserve/release mechanism similar to /// R_PreserveObject()/ R_ReleaseObject(). /// /// The "tag" of an external pointer to an ArrowArray must be R_NilValue or an external /// pointer to an ArrowSchema that may be used to interpret the pointed-to ArrowArray. The /// "tag" of a nanoarrow external pointer to an ArrowSchema or ArrowArrayStream is /// reserved for future use and must be R_NilValue. /// /// @{ // Extra guard for versions of Arrow without the canonical guard #ifndef ARROW_FLAG_DICTIONARY_ORDERED #ifndef ARROW_C_DATA_INTERFACE #define ARROW_C_DATA_INTERFACE #include #define ARROW_FLAG_DICTIONARY_ORDERED 1 #define ARROW_FLAG_NULLABLE 2 #define ARROW_FLAG_MAP_KEYS_SORTED 4 struct ArrowSchema { // Array type description const char* format; const char* name; const char* metadata; int64_t flags; int64_t n_children; struct ArrowSchema** children; struct ArrowSchema* dictionary; // Release callback void (*release)(struct ArrowSchema*); // Opaque producer-specific data void* private_data; }; struct ArrowArray { // Array data description int64_t length; int64_t null_count; int64_t offset; int64_t n_buffers; int64_t n_children; const void** buffers; struct ArrowArray** children; struct ArrowArray* dictionary; // Release callback void (*release)(struct ArrowArray*); // Opaque producer-specific data void* private_data; }; #endif // ARROW_C_DATA_INTERFACE #ifndef ARROW_C_STREAM_INTERFACE #define ARROW_C_STREAM_INTERFACE struct ArrowArrayStream { // Callback to get the stream type // (will be the same for all arrays in the stream). // // Return value: 0 if successful, an `errno`-compatible error code otherwise. // // If successful, the ArrowSchema must be released independently from the stream. int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out); // Callback to get the next array // (if no error and the array is released, the stream has ended) // // Return value: 0 if successful, an `errno`-compatible error code otherwise. // // If successful, the ArrowArray must be released independently from the stream. int (*get_next)(struct ArrowArrayStream*, struct ArrowArray* out); // Callback to get optional detailed error information. // This must only be called if the last stream operation failed // with a non-0 return code. // // Return value: pointer to a null-terminated character array describing // the last error, or NULL if no description is available. // // The returned pointer is only valid until the next operation on this stream // (including release). const char* (*get_last_error)(struct ArrowArrayStream*); // Release callback: release the stream's own resources. // Note that arrays returned by `get_next` must be individually released. void (*release)(struct ArrowArrayStream*); // Opaque producer-specific data void* private_data; }; #endif // ARROW_C_STREAM_INTERFACE #endif // ARROW_FLAG_DICTIONARY_ORDERED /// \brief Allocate an external pointer to an ArrowSchema /// /// Allocate an external pointer to an uninitialized ArrowSchema with a finalizer that /// ensures that any non-null release callback in a pointed-to structure will be called /// when the external pointer is garbage collected. static inline SEXP nanoarrow_schema_owning_xptr(void); /// \brief Allocate an external pointer to an ArrowArray /// /// Allocate an external pointer to an uninitialized ArrowArray with a finalizer that /// ensures that any non-null release callback in a pointed-to structure will be called /// when the external pointer is garbage collected. static inline SEXP nanoarrow_array_owning_xptr(void); /// \brief Allocate an external pointer to an ArrowArrayStream /// /// Allocate an external pointer to an uninitialized ArrowArrayStream with a finalizer /// that ensures that any non-null release callback in a pointed-to structure will be /// called when the external pointer is garbage collected. static inline SEXP nanoarrow_array_stream_owning_xptr(void); /// \brief Ensure an input SEXP points to an initialized ArrowSchema /// /// This function will always return an ArrowSchema pointer that can be safely /// consumed or raise an error via Rf_error(). This is intended to be used to /// sanitize an *input* ArrowSchema. static inline struct ArrowSchema* nanoarrow_schema_from_xptr(SEXP schema_xptr); /// \brief Ensure an output SEXP points to an uninitialized ArrowSchema /// /// This function will always return an ArrowSchema pointer that can be safely /// used as an output argument or raise an error via Rf_error(). This is intended /// to be used to sanitize an *output* ArrowSchema allocated from R or elsewhere. static inline struct ArrowSchema* nanoarrow_output_schema_from_xptr(SEXP schema_xptr); /// \brief Ensure an input SEXP points to an initialized ArrowArray /// /// This function will always return an ArrowArray pointer that can be safely /// consumed or raise an error via Rf_error(). This is intended to be used to /// sanitize an *input* ArrowArray. static inline struct ArrowArray* nanoarrow_array_from_xptr(SEXP array_xptr); /// \brief Ensure an output SEXP points to an uninitialized ArrowArray /// /// This function will always return an ArrowArray pointer that can be safely /// used as an output argument or raise an error via Rf_error(). This is intended /// to be used to sanitize an *output* ArrowArray allocated from R or elsewhere. static inline struct ArrowArray* nanoarrow_output_array_from_xptr(SEXP array_xptr); /// \brief Ensure an input SEXP points to an initialized ArrowArrayStream /// /// This function will always return an ArrowArrayStream pointer that can be safely /// consumed or raise an error via Rf_error(). This is intended to be used to /// sanitize an *input* ArrowArrayStream. static inline struct ArrowArrayStream* nanoarrow_array_stream_from_xptr( SEXP array_stream_xptr); /// \brief Ensure an output SEXP points to an uninitialized ArrowArrayStream /// /// This function will always return an ArrowArrayStream pointer that can be safely /// used as an output argument or raise an error via Rf_error(). This is intended /// to be used to sanitize an *output* ArrowArrayStream allocated from R or elsewhere. static inline struct ArrowArrayStream* nanoarrow_output_array_stream_from_xptr( SEXP array_stream_xptr); /// \brief Finalize an external pointer to an ArrowSchema /// /// This function is provided for internal use by nanoarrow_schema_owning_xptr() /// and should not be called directly. static void nanoarrow_finalize_schema_xptr(SEXP schema_xptr); /// \brief Finalize an external pointer to an ArrowArray /// /// This function is provided for internal use by nanoarrow_array_owning_xptr() /// and should not be called directly. static void nanoarrow_finalize_array_xptr(SEXP array_xptr); /// \brief Finalize an external pointer to an ArrowArrayStream /// /// This function is provided for internal use by nanoarrow_array_stream_owning_xptr() /// and should not be called directly. static void nanoarrow_finalize_array_stream_xptr(SEXP array_stream_xptr); /// @} // Implementations follow static void nanoarrow_finalize_schema_xptr(SEXP schema_xptr) { struct ArrowSchema* schema = (struct ArrowSchema*)R_ExternalPtrAddr(schema_xptr); if (schema != NULL && schema->release != NULL) { schema->release(schema); } if (schema != NULL) { free(schema); R_ClearExternalPtr(schema_xptr); } } static void nanoarrow_finalize_array_xptr(SEXP array_xptr) { struct ArrowArray* array = (struct ArrowArray*)R_ExternalPtrAddr(array_xptr); if (array != NULL && array->release != NULL) { array->release(array); } if (array != NULL) { free(array); R_ClearExternalPtr(array_xptr); } } static void nanoarrow_finalize_array_stream_xptr(SEXP array_stream_xptr) { struct ArrowArrayStream* array_stream = (struct ArrowArrayStream*)R_ExternalPtrAddr(array_stream_xptr); if (array_stream != NULL && array_stream->release != NULL) { array_stream->release(array_stream); } if (array_stream != NULL) { free(array_stream); R_ClearExternalPtr(array_stream_xptr); } } static inline SEXP nanoarrow_schema_owning_xptr(void) { struct ArrowSchema* schema = (struct ArrowSchema*)malloc(sizeof(struct ArrowSchema)); if (schema == NULL) { Rf_error("Failed to allocate ArrowSchema"); } schema->release = NULL; SEXP schema_xptr = PROTECT(R_MakeExternalPtr(schema, R_NilValue, R_NilValue)); SEXP schema_cls = PROTECT(Rf_mkString("nanoarrow_schema")); Rf_setAttrib(schema_xptr, R_ClassSymbol, schema_cls); R_RegisterCFinalizer(schema_xptr, &nanoarrow_finalize_schema_xptr); UNPROTECT(2); return schema_xptr; } static inline SEXP nanoarrow_array_owning_xptr(void) { struct ArrowArray* array = (struct ArrowArray*)malloc(sizeof(struct ArrowArray)); array->release = NULL; SEXP array_xptr = PROTECT(R_MakeExternalPtr(array, R_NilValue, R_NilValue)); SEXP array_cls = PROTECT(Rf_mkString("nanoarrow_array")); Rf_setAttrib(array_xptr, R_ClassSymbol, array_cls); R_RegisterCFinalizer(array_xptr, &nanoarrow_finalize_array_xptr); UNPROTECT(2); return array_xptr; } static inline SEXP nanoarrow_array_stream_owning_xptr(void) { struct ArrowArrayStream* array_stream = (struct ArrowArrayStream*)malloc(sizeof(struct ArrowArrayStream)); array_stream->release = NULL; SEXP array_stream_xptr = PROTECT(R_MakeExternalPtr(array_stream, R_NilValue, R_NilValue)); SEXP array_stream_cls = PROTECT(Rf_mkString("nanoarrow_array_stream")); Rf_setAttrib(array_stream_xptr, R_ClassSymbol, array_stream_cls); R_RegisterCFinalizer(array_stream_xptr, &nanoarrow_finalize_array_stream_xptr); UNPROTECT(2); return array_stream_xptr; } static inline struct ArrowSchema* nanoarrow_schema_from_xptr(SEXP schema_xptr) { if (!Rf_inherits(schema_xptr, "nanoarrow_schema")) { Rf_error("`schema` argument that does not inherit from 'nanoarrow_schema'"); } struct ArrowSchema* schema = (struct ArrowSchema*)R_ExternalPtrAddr(schema_xptr); if (schema == NULL) { Rf_error("nanoarrow_schema() is an external pointer to NULL"); } if (schema->release == NULL) { Rf_error("nanoarrow_schema() has already been released"); } return schema; } static inline struct ArrowSchema* nanoarrow_output_schema_from_xptr(SEXP schema_xptr) { if (!Rf_inherits(schema_xptr, "nanoarrow_schema")) { Rf_error("`schema` argument that does not inherit from 'nanoarrow_schema'"); } struct ArrowSchema* schema = (struct ArrowSchema*)R_ExternalPtrAddr(schema_xptr); if (schema == NULL) { Rf_error("nanoarrow_schema() is an external pointer to NULL"); } if (schema->release != NULL) { Rf_error("nanoarrow_schema() output has already been initialized"); } return schema; } static inline struct ArrowArray* nanoarrow_array_from_xptr(SEXP array_xptr) { if (!Rf_inherits(array_xptr, "nanoarrow_array")) { Rf_error("`array` argument that is not a nanoarrow_array()"); } struct ArrowArray* array = (struct ArrowArray*)R_ExternalPtrAddr(array_xptr); if (array == NULL) { Rf_error("nanoarrow_array() is an external pointer to NULL"); } if (array->release == NULL) { Rf_error("nanoarrow_array() has already been released"); } return array; } static inline struct ArrowArray* nanoarrow_output_array_from_xptr(SEXP array_xptr) { if (!Rf_inherits(array_xptr, "nanoarrow_array")) { Rf_error("`array` argument that is not a nanoarrow_array()"); } struct ArrowArray* array = (struct ArrowArray*)R_ExternalPtrAddr(array_xptr); if (array == NULL) { Rf_error("nanoarrow_array() is an external pointer to NULL"); } if (array->release != NULL) { Rf_error("nanoarrow_array() output has already been initialized"); } return array; } static inline struct ArrowArrayStream* nanoarrow_array_stream_from_xptr( SEXP array_stream_xptr) { if (!Rf_inherits(array_stream_xptr, "nanoarrow_array_stream")) { Rf_error("`array_stream` argument that is not a nanoarrow_array_stream()"); } struct ArrowArrayStream* array_stream = (struct ArrowArrayStream*)R_ExternalPtrAddr(array_stream_xptr); if (array_stream == NULL) { Rf_error("nanoarrow_array_stream() is an external pointer to NULL"); } if (array_stream->release == NULL) { Rf_error("nanoarrow_array_stream() has already been released"); } return array_stream; } static inline struct ArrowArrayStream* nanoarrow_output_array_stream_from_xptr( SEXP array_stream_xptr) { if (!Rf_inherits(array_stream_xptr, "nanoarrow_array_stream")) { Rf_error("`array_stream` argument that is not a nanoarrow_array_stream()"); } struct ArrowArrayStream* array_stream = (struct ArrowArrayStream*)R_ExternalPtrAddr(array_stream_xptr); if (array_stream == NULL) { Rf_error("nanoarrow_array_stream() is an external pointer to NULL"); } if (array_stream->release != NULL) { Rf_error("nanoarrow_array_stream() output has already been initialized"); } return array_stream; } #ifdef __cplusplus } #endif #endif nanoarrow/tools/0000755000176200001440000000000014643132461013424 5ustar liggesusersnanoarrow/tools/make-callentries.R0000644000176200001440000000470314643132461016773 0ustar liggesusers# 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. # This file updates the call entries in src/init.c such that R code # can use .Call(nanoarrow_c_some_function_name) for all C functions # with the signature SEXP nanoarrow_c_some_function_name(...). library(tidyverse) src_files <- list.files("src", "\\.(c|cpp)$", full.names = TRUE) %>% setdiff("src/init.c") src_sources <- src_files %>% set_names() %>% map_chr(readr::read_file) defs <- tibble( def = src_sources %>% str_extract_all(regex("SEXP nanoarrow_c_[^\\)]+\\)", multiline = TRUE)) %>% unlist() %>% unique() %>% str_replace_all("\\s+", " ") %>% str_trim(), name = def %>% str_extract("nanoarrow_c_[^\\(]+"), return_type = "SEXP", args = def %>% str_remove("SEXP nanoarrow_c_[^\\(]+\\(") %>% str_remove("\\)$") %>% str_split("\\s*,\\s*") %>% map(~{if(identical(.x, "") || identical(.x, "void")) character(0) else .x}), n_args = map(args, length) ) call_headers <- paste0( "extern ", defs$def, ";", collapse = "\n" ) call_entries <- paste0( '{"', defs$name, '", (DL_FUNC)&', defs$name, ', ', defs$n_args, "},", collapse = "\n " ) header <- glue::glue(' /* generated by tools/make-callentries.R */ {call_headers} static const R_CallMethodDef CallEntries[] = {{ {call_entries} {{NULL, NULL, 0}}}}; /* end generated by tools/make-callentries.R */ ') # rewrite relevant portion of init.c init <- read_file("src/init.c") pattern <- regex( "\n/\\* generated by tools/make-callentries\\.R \\*/.*?/\\* end generated by tools/make-callentries\\.R \\*/", multiline = TRUE, dotall = TRUE ) stopifnot(str_detect(init, pattern)) init %>% str_replace(pattern, header) %>% write_file("src/init.c") system("clang-format -i src/init.c") nanoarrow/README.md0000644000176200001440000001730014635121021013533 0ustar liggesusers # nanoarrow The goal of nanoarrow is to provide minimal useful bindings to the [Arrow C Data](https://arrow.apache.org/docs/format/CDataInterface.html) and [Arrow C Stream](https://arrow.apache.org/docs/format/CStreamInterface.html) interfaces using the [nanoarrow C library](https://arrow.apache.org/nanoarrow/). ## Installation You can install the released version of nanoarrow from [CRAN](https://cran.r-project.org/) with: ``` r install.packages("nanoarrow") ``` You can install the development version of nanoarrow from [GitHub](https://github.com/) with: ``` r # install.packages("remotes") remotes::install_github("apache/arrow-nanoarrow/r") ``` If you can load the package, you’re good to go! ``` r library(nanoarrow) ``` ## Example The Arrow C Data and Arrow C Stream interfaces are comprised of three structures: the `ArrowSchema` which represents a data type of an array, the `ArrowArray` which represents the values of an array, and an `ArrowArrayStream`, which represents zero or more `ArrowArray`s with a common `ArrowSchema`. All three can be wrapped by R objects using the nanoarrow R package. ### Schemas Use `infer_nanoarrow_schema()` to get the ArrowSchema object that corresponds to a given R vector type; use `as_nanoarrow_schema()` to convert an object from some other data type representation (e.g., an arrow R package `DataType` like `arrow::int32()`); or use `na_XXX()` functions to construct them. ``` r infer_nanoarrow_schema(1:5) #> #> $ format : chr "i" #> $ name : chr "" #> $ metadata : list() #> $ flags : int 2 #> $ children : list() #> $ dictionary: NULL as_nanoarrow_schema(arrow::schema(col1 = arrow::float64())) #> #> $ format : chr "+s" #> $ name : chr "" #> $ metadata : list() #> $ flags : int 0 #> $ children :List of 1 #> ..$ col1: #> .. ..$ format : chr "g" #> .. ..$ name : chr "col1" #> .. ..$ metadata : list() #> .. ..$ flags : int 2 #> .. ..$ children : list() #> .. ..$ dictionary: NULL #> $ dictionary: NULL na_int64() #> #> $ format : chr "l" #> $ name : chr "" #> $ metadata : list() #> $ flags : int 2 #> $ children : list() #> $ dictionary: NULL ``` ### Arrays Use `as_nanoarrow_array()` to convert an object to an ArrowArray object: ``` r as_nanoarrow_array(1:5) #> #> $ length : int 5 #> $ null_count: int 0 #> $ offset : int 0 #> $ buffers :List of 2 #> ..$ :[0][0 b]> `` #> ..$ :[5][20 b]> `1 2 3 4 5` #> $ dictionary: NULL #> $ children : list() as_nanoarrow_array(data.frame(col1 = c(1.1, 2.2))) #> #> $ length : int 2 #> $ null_count: int 0 #> $ offset : int 0 #> $ buffers :List of 1 #> ..$ :[0][0 b]> `` #> $ children :List of 1 #> ..$ col1: #> .. ..$ length : int 2 #> .. ..$ null_count: int 0 #> .. ..$ offset : int 0 #> .. ..$ buffers :List of 2 #> .. .. ..$ :[0][0 b]> `` #> .. .. ..$ :[2][16 b]> `1.1 2.2` #> .. ..$ dictionary: NULL #> .. ..$ children : list() #> $ dictionary: NULL ``` You can use `as.vector()` or `as.data.frame()` to get the R representation of the object back: ``` r array <- as_nanoarrow_array(data.frame(col1 = c(1.1, 2.2))) as.data.frame(array) #> col1 #> 1 1.1 #> 2 2.2 ``` Even though at the C level the ArrowArray is distinct from the ArrowSchema, at the R level we attach a schema wherever possible. You can access the attached schema using `infer_nanoarrow_schema()`: ``` r infer_nanoarrow_schema(array) #> #> $ format : chr "+s" #> $ name : chr "" #> $ metadata : list() #> $ flags : int 0 #> $ children :List of 1 #> ..$ col1: #> .. ..$ format : chr "g" #> .. ..$ name : chr "col1" #> .. ..$ metadata : list() #> .. ..$ flags : int 2 #> .. ..$ children : list() #> .. ..$ dictionary: NULL #> $ dictionary: NULL ``` ### Array Streams The easiest way to create an ArrowArrayStream is from a list of arrays or objects that can be converted to an array using `as_nanoarrow_array()`: ``` r stream <- basic_array_stream( list( data.frame(col1 = c(1.1, 2.2)), data.frame(col1 = c(3.3, 4.4)) ) ) ``` You can pull batches from the stream using the `$get_next()` method. The last batch will return `NULL`. ``` r stream$get_next() #> #> $ length : int 2 #> $ null_count: int 0 #> $ offset : int 0 #> $ buffers :List of 1 #> ..$ :[0][0 b]> `` #> $ children :List of 1 #> ..$ col1: #> .. ..$ length : int 2 #> .. ..$ null_count: int 0 #> .. ..$ offset : int 0 #> .. ..$ buffers :List of 2 #> .. .. ..$ :[0][0 b]> `` #> .. .. ..$ :[2][16 b]> `1.1 2.2` #> .. ..$ dictionary: NULL #> .. ..$ children : list() #> $ dictionary: NULL stream$get_next() #> #> $ length : int 2 #> $ null_count: int 0 #> $ offset : int 0 #> $ buffers :List of 1 #> ..$ :[0][0 b]> `` #> $ children :List of 1 #> ..$ col1: #> .. ..$ length : int 2 #> .. ..$ null_count: int 0 #> .. ..$ offset : int 0 #> .. ..$ buffers :List of 2 #> .. .. ..$ :[0][0 b]> `` #> .. .. ..$ :[2][16 b]> `3.3 4.4` #> .. ..$ dictionary: NULL #> .. ..$ children : list() #> $ dictionary: NULL stream$get_next() #> NULL ``` You can pull all the batches into a `data.frame()` by calling `as.data.frame()` or `as.vector()`: ``` r stream <- basic_array_stream( list( data.frame(col1 = c(1.1, 2.2)), data.frame(col1 = c(3.3, 4.4)) ) ) as.data.frame(stream) #> col1 #> 1 1.1 #> 2 2.2 #> 3 3.3 #> 4 4.4 ``` After consuming a stream, you should call the release method as soon as you can. This lets the implementation of the stream release any resources (like open files) it may be holding in a more predictable way than waiting for the garbage collector to clean up the object. ## Integration with the arrow package The nanoarrow package implements `as_nanoarrow_schema()`, `as_nanoarrow_array()`, and `as_nanoarrow_array_stream()` for most arrow package types. Similarly, it implements `arrow::as_arrow_array()`, `arrow::as_record_batch()`, `arrow::as_arrow_table()`, `arrow::as_record_batch_reader()`, `arrow::infer_type()`, `arrow::as_data_type()`, and `arrow::as_schema()` for nanoarrow objects such that you can pass equivalent nanoarrow objects into many arrow functions and vice versa. nanoarrow/man/0000755000176200001440000000000014676554240013050 5ustar liggesusersnanoarrow/man/as_nanoarrow_array_stream.Rd0000644000176200001440000000262614315437207020600 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/array-stream.R \name{as_nanoarrow_array_stream} \alias{as_nanoarrow_array_stream} \title{Convert an object to a nanoarrow array_stream} \usage{ as_nanoarrow_array_stream(x, ..., schema = NULL) } \arguments{ \item{x}{An object to convert to a array_stream} \item{...}{Passed to S3 methods} \item{schema}{An optional schema used to enforce conversion to a particular type. Defaults to \code{\link[=infer_nanoarrow_schema]{infer_nanoarrow_schema()}}.} } \value{ An object of class 'nanoarrow_array_stream' } \description{ In nanoarrow, an 'array stream' corresponds to the \verb{struct ArrowArrayStream} as defined in the Arrow C Stream interface. This object is used to represent a stream of \link[=as_nanoarrow_array]{arrays} with a common \link[=as_nanoarrow_schema]{schema}. This is similar to an \link[arrow:RecordBatchReader]{arrow::RecordBatchReader} except it can be used to represent a stream of any type (not just record batches). Note that a stream of record batches and a stream of non-nullable struct arrays are represented identically. Also note that array streams are mutable objects and are passed by reference and not by value. } \examples{ (stream <- as_nanoarrow_array_stream(data.frame(x = 1:5))) stream$get_schema() stream$get_next() # The last batch is returned as NULL stream$get_next() # Release the stream stream$release() } nanoarrow/man/as_nanoarrow_buffer.Rd0000644000176200001440000000114714502402506017345 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/buffer.R \name{as_nanoarrow_buffer} \alias{as_nanoarrow_buffer} \title{Convert an object to a nanoarrow buffer} \usage{ as_nanoarrow_buffer(x, ...) } \arguments{ \item{x}{An object to convert to a buffer} \item{...}{Passed to S3 methods} } \value{ An object of class 'nanoarrow_buffer' } \description{ Convert an object to a nanoarrow buffer } \examples{ array <- as_nanoarrow_array(c(NA, 1:4)) array$buffers as.raw(array$buffers[[1]]) as.raw(array$buffers[[2]]) convert_buffer(array$buffers[[1]]) convert_buffer(array$buffers[[2]]) } nanoarrow/man/nanoarrow_array_init.Rd0000644000176200001440000000425014377444470017570 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/array.R \name{nanoarrow_array_init} \alias{nanoarrow_array_init} \alias{nanoarrow_array_set_schema} \alias{nanoarrow_array_modify} \title{Modify nanoarrow arrays} \usage{ nanoarrow_array_init(schema) nanoarrow_array_set_schema(array, schema, validate = TRUE) nanoarrow_array_modify(array, new_values, validate = TRUE) } \arguments{ \item{schema}{A \link[=as_nanoarrow_schema]{nanoarrow_schema} to attach to this \code{array}.} \item{array}{A \link[=as_nanoarrow_array]{nanoarrow_array}.} \item{validate}{Use \code{FALSE} to skip validation. Skipping validation may result in creating an array that will crash R.} \item{new_values}{A named \code{list()} of values to replace.} } \value{ \itemize{ \item \code{nanoarrow_array_init()} returns a possibly invalid but initialized array with a given \code{schema}. \item \code{nanoarrow_array_set_schema()} returns \code{array}, invisibly. Note that \code{array} is modified in place by reference. \item \code{nanoarrow_array_modify()} returns a shallow copy of \code{array} with the modified parameters such that the original array remains valid. } } \description{ Create a new array or from an existing array, modify one or more parameters. When importing an array from elsewhere, \code{nanoarrow_array_set_schema()} is useful to attach the data type information to the array (without this information there is little that nanoarrow can do with the array since its content cannot be otherwise interpreted). \code{nanoarrow_array_modify()} can create a shallow copy and modify various parameters to create a new array, including setting children and buffers recursively. These functions power the \verb{$<-} operator, which can modify one parameter at a time. } \examples{ nanoarrow_array_init(na_string()) # Modify an array using $ and <- array <- as_nanoarrow_array(1:5) array$length <- 4 as.vector(array) # Modify potentially more than one component at a time array <- as_nanoarrow_array(1:5) as.vector(nanoarrow_array_modify(array, list(length = 4))) # Attach a schema to an array array <- as_nanoarrow_array(-1L) nanoarrow_array_set_schema(array, na_uint32()) as.vector(array) } nanoarrow/man/nanoarrow_version.Rd0000644000176200001440000000100314355103326017071 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/nanoarrow-package.R \name{nanoarrow_version} \alias{nanoarrow_version} \title{Underlying 'nanoarrow' C library build} \usage{ nanoarrow_version(runtime = TRUE) } \arguments{ \item{runtime}{Compare TRUE and FALSE values to detect a possible ABI mismatch.} } \value{ A string identifying the version of nanoarrow this package was compiled against. } \description{ Underlying 'nanoarrow' C library build } \examples{ nanoarrow_version() } nanoarrow/man/nanoarrow-package.Rd0000644000176200001440000000231514672341746016740 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/nanoarrow-package.R \docType{package} \name{nanoarrow-package} \alias{nanoarrow} \alias{nanoarrow-package} \title{nanoarrow: Interface to the 'nanoarrow' 'C' Library} \description{ Provides an 'R' interface to the 'nanoarrow' 'C' library and the 'Apache Arrow' application binary interface. Functions to import and export 'ArrowArray', 'ArrowSchema', and 'ArrowArrayStream' 'C' structures to and from 'R' objects are provided alongside helpers to facilitate zero-copy data transfer among 'R' bindings to libraries implementing the 'Arrow' 'C' data interface. } \seealso{ Useful links: \itemize{ \item \url{https://arrow.apache.org/nanoarrow/latest/r/} \item \url{https://github.com/apache/arrow-nanoarrow} \item Report bugs at \url{https://github.com/apache/arrow-nanoarrow/issues} } } \author{ \strong{Maintainer}: Dewey Dunnington \email{dewey@dunnington.ca} (\href{https://orcid.org/0000-0002-9415-4582}{ORCID}) Authors: \itemize{ \item Apache Arrow \email{dev@arrow.apache.org} [copyright holder] } Other contributors: \itemize{ \item Apache Software Foundation \email{dev@arrow.apache.org} [copyright holder] } } \keyword{internal} nanoarrow/man/convert_array.Rd0000644000176200001440000001012414674150567016215 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/convert-array.R \name{convert_array} \alias{convert_array} \title{Convert an Array into an R vector} \usage{ convert_array(array, to = NULL, ...) } \arguments{ \item{array}{A \link[=as_nanoarrow_array]{nanoarrow_array}.} \item{to}{A target prototype object describing the type to which \code{array} should be converted, or \code{NULL} to use the default conversion as returned by \code{\link[=infer_nanoarrow_ptype]{infer_nanoarrow_ptype()}}. Alternatively, a function can be passed to perform an alternative calculation of the default ptype as a function of \code{array} and the default inference of the prototype.} \item{...}{Passed to S3 methods} } \value{ An R vector of type \code{to}. } \description{ Converts \code{array} to the type specified by \code{to}. This is a low-level interface; most users should use \code{as.data.frame()} or \code{as.vector()} unless finer-grained control is needed over the conversion. This function is an S3 generic dispatching on \code{to}: developers may implement their own S3 methods for custom vector types. } \details{ Note that unregistered extension types will by default issue a warning. Use \code{options(nanoarrow.warn_unregistered_extension = FALSE)} to disable this behaviour. Conversions are implemented for the following R vector types: \itemize{ \item \code{\link[=logical]{logical()}}: Any numeric type can be converted to \code{\link[=logical]{logical()}} in addition to the bool type. For numeric types, any non-zero value is considered \code{TRUE}. \item \code{\link[=integer]{integer()}}: Any numeric type can be converted to \code{\link[=integer]{integer()}}; however, a warning will be signaled if the any value is outside the range of the 32-bit integer. \item \code{\link[=double]{double()}}: Any numeric type can be converted to \code{\link[=double]{double()}}. This conversion currently does not warn for values that may not roundtrip through a floating-point double (e.g., very large uint64 and int64 values). \item \code{\link[=character]{character()}}: String and large string types can be converted to \code{\link[=character]{character()}}. The conversion does not check for valid UTF-8: if you need finer-grained control over encodings, use \code{to = blob::blob()}. \item \code{\link[=factor]{factor()}}: Dictionary-encoded arrays of strings can be converted to \code{factor()}; however, this must be specified explicitly (i.e., \code{convert_array(array, factor())}) because arrays arriving in chunks can have dictionaries that contain different levels. Use \code{convert_array(array, factor(levels = c(...)))} to materialize an array into a vector with known levels. \item \link[=as.Date]{Date}: Only the date32 type can be converted to an R Date vector. \item \code{\link[hms:hms]{hms::hms()}}: Time32 and time64 types can be converted to \code{\link[hms:hms]{hms::hms()}}. \item \code{\link[=difftime]{difftime()}}: Time32, time64, and duration types can be converted to R \code{\link[=difftime]{difftime()}} vectors. The value is converted to match the \code{\link[=units]{units()}} attribute of \code{to}. \item \code{\link[blob:blob]{blob::blob()}}: String, large string, binary, and large binary types can be converted to \code{\link[blob:blob]{blob::blob()}}. \item \code{\link[vctrs:list_of]{vctrs::list_of()}}: List, large list, and fixed-size list types can be converted to \code{\link[vctrs:list_of]{vctrs::list_of()}}. \item \code{\link[=data.frame]{data.frame()}}: Struct types can be converted to \code{\link[=data.frame]{data.frame()}}. \item \code{\link[vctrs:unspecified]{vctrs::unspecified()}}: Any type can be converted to \code{\link[vctrs:unspecified]{vctrs::unspecified()}}; however, a warning will be raised if any non-null values are encountered. } In addition to the above conversions, a null array may be converted to any target prototype except \code{\link[=data.frame]{data.frame()}}. Extension arrays are currently converted as their storage type. } \examples{ array <- as_nanoarrow_array(data.frame(x = 1:5)) str(convert_array(array)) str(convert_array(array, to = data.frame(x = double()))) } nanoarrow/man/nanoarrow_extension_array.Rd0000644000176200001440000000161214502402562020622 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/extension.R \name{nanoarrow_extension_array} \alias{nanoarrow_extension_array} \title{Create Arrow extension arrays} \usage{ nanoarrow_extension_array( storage_array, extension_name, extension_metadata = NULL ) } \arguments{ \item{storage_array}{A \link[=as_nanoarrow_array]{nanoarrow_array}.} \item{extension_name}{For \code{\link[=na_extension]{na_extension()}}, the extension name. This is typically namespaced separated by dots (e.g., arrow.r.vctrs).} \item{extension_metadata}{A string or raw vector defining extension metadata. Most Arrow extension types define extension metadata as a JSON object.} } \value{ A \link[=as_nanoarrow_array]{nanoarrow_array} with attached extension schema. } \description{ Create Arrow extension arrays } \examples{ nanoarrow_extension_array(1:10, "some_ext", '{"key": "value"}') } nanoarrow/man/as_nanoarrow_array.Rd0000644000176200001440000000210314502402562017205 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/array.R \name{as_nanoarrow_array} \alias{as_nanoarrow_array} \title{Convert an object to a nanoarrow array} \usage{ as_nanoarrow_array(x, ..., schema = NULL) } \arguments{ \item{x}{An object to convert to a array} \item{...}{Passed to S3 methods} \item{schema}{An optional schema used to enforce conversion to a particular type. Defaults to \code{\link[=infer_nanoarrow_schema]{infer_nanoarrow_schema()}}.} } \value{ An object of class 'nanoarrow_array' } \description{ In nanoarrow an 'array' refers to the \verb{struct ArrowArray} definition in the Arrow C data interface. At the R level, we attach a \link[=as_nanoarrow_schema]{schema} such that functionally the nanoarrow_array class can be used in a similar way as an \code{arrow::Array}. Note that in nanoarrow an \code{arrow::RecordBatch} and a non-nullable \code{arrow::StructArray} are represented identically. } \examples{ (array <- as_nanoarrow_array(1:5)) as.vector(array) (array <- as_nanoarrow_array(data.frame(x = 1:5))) as.data.frame(array) } nanoarrow/man/array_stream_set_finalizer.Rd0000644000176200001440000000246114547575511020752 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/array-stream.R \name{array_stream_set_finalizer} \alias{array_stream_set_finalizer} \title{Register an array stream finalizer} \usage{ array_stream_set_finalizer(array_stream, finalizer) } \arguments{ \item{array_stream}{A \link[=as_nanoarrow_array_stream]{nanoarrow_array_stream}} \item{finalizer}{A function that will be called with zero arguments.} } \value{ A newly allocated \code{array_stream} whose release callback will call the supplied finalizer. } \description{ In some cases, R functions that return a \link[=as_nanoarrow_array_stream]{nanoarrow_array_stream} may require that the scope of some other object outlive that of the array stream. If there is a need for that object to be released deterministically (e.g., to close open files), you can register a function to run after the stream's release callback is invoked from the R thread. Note that this finalizer will \strong{not} be run if the stream's release callback is invoked from a \strong{non}-R thread. In this case, the finalizer and its chain of environments will be garbage-collected when \code{nanoarrow:::preserved_empty()} is run. } \examples{ stream <- array_stream_set_finalizer( basic_array_stream(list(1:5)), function() message("All done!") ) stream$release() } nanoarrow/man/infer_nanoarrow_ptype.Rd0000644000176200001440000000333514355103326017742 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/infer-ptype.R \name{infer_nanoarrow_ptype} \alias{infer_nanoarrow_ptype} \title{Infer an R vector prototype} \usage{ infer_nanoarrow_ptype(x) } \arguments{ \item{x}{A \link[=as_nanoarrow_schema]{nanoarrow_schema}, \link[=as_nanoarrow_array]{nanoarrow_array}, or \link[=as_nanoarrow_array_stream]{nanoarrow_array_stream}.} } \value{ An R vector of zero size describing the target into which the array should be materialized. } \description{ Resolves the default \code{to} value to use in \code{\link[=convert_array]{convert_array()}} and \code{\link[=convert_array_stream]{convert_array_stream()}}. The default conversions are: } \details{ \itemize{ \item null to \code{\link[vctrs:unspecified]{vctrs::unspecified()}} \item boolean to \code{\link[=logical]{logical()}} \item int8, uint8, int16, uint16, and int13 to \code{\link[=integer]{integer()}} \item uint32, int64, uint64, float, and double to \code{\link[=double]{double()}} \item string and large string to \code{\link[=character]{character()}} \item struct to \code{\link[=data.frame]{data.frame()}} \item binary and large binary to \code{\link[blob:blob]{blob::blob()}} \item list, large_list, and fixed_size_list to \code{\link[vctrs:list_of]{vctrs::list_of()}} \item time32 and time64 to \code{\link[hms:hms]{hms::hms()}} \item duration to \code{\link[=difftime]{difftime()}} \item date32 to \code{\link[=as.Date]{as.Date()}} \item timestamp to \code{\link[=as.POSIXct]{as.POSIXct()}} } Additional conversions are possible by specifying an explicit value for \code{to}. For details of each conversion, see \code{\link[=convert_array]{convert_array()}}. } \examples{ infer_nanoarrow_ptype(as_nanoarrow_array(1:10)) } nanoarrow/man/as_nanoarrow_schema.Rd0000644000176200001440000000251214556776026017355 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/schema.R \name{as_nanoarrow_schema} \alias{as_nanoarrow_schema} \alias{infer_nanoarrow_schema} \alias{nanoarrow_schema_parse} \alias{nanoarrow_schema_modify} \title{Convert an object to a nanoarrow schema} \usage{ as_nanoarrow_schema(x, ...) infer_nanoarrow_schema(x, ...) nanoarrow_schema_parse(x, recursive = FALSE) nanoarrow_schema_modify(x, new_values, validate = TRUE) } \arguments{ \item{x}{An object to convert to a schema} \item{...}{Passed to S3 methods} \item{recursive}{Use \code{TRUE} to include a \code{children} member when parsing schemas.} \item{new_values}{New schema component to assign} \item{validate}{Use \code{FALSE} to skip schema validation} } \value{ An object of class 'nanoarrow_schema' } \description{ In nanoarrow a 'schema' refers to a \verb{struct ArrowSchema} as defined in the Arrow C Data interface. This data structure can be used to represent an \code{\link[arrow:schema]{arrow::schema()}}, an \code{\link[arrow:Field]{arrow::field()}}, or an \code{arrow::DataType}. Note that in nanoarrow, an \code{\link[arrow:schema]{arrow::schema()}} and a non-nullable \code{\link[arrow:data-type]{arrow::struct()}} are represented identically. } \examples{ infer_nanoarrow_schema(integer()) infer_nanoarrow_schema(data.frame(x = integer())) } nanoarrow/man/as_nanoarrow_vctr.Rd0000644000176200001440000000435014672341746017071 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vctr.R \name{as_nanoarrow_vctr} \alias{as_nanoarrow_vctr} \alias{nanoarrow_vctr} \title{Experimental Arrow encoded arrays as R vectors} \usage{ as_nanoarrow_vctr(x, ..., schema = NULL, subclass = character()) nanoarrow_vctr(schema = NULL, subclass = character()) } \arguments{ \item{x}{An object that works with \code{\link[=as_nanoarrow_array_stream]{as_nanoarrow_array_stream()}}.} \item{...}{Passed to \code{\link[=as_nanoarrow_array_stream]{as_nanoarrow_array_stream()}}} \item{schema}{An optional \code{schema}} \item{subclass}{An optional subclass of nanoarrow_vctr to prepend to the final class name.} } \value{ A vctr of class 'nanoarrow_vctr' } \description{ This experimental vctr class allows zero or more Arrow arrays to present as an R vector without converting them. This is useful for arrays with types that do not have a non-lossy R equivalent, and helps provide an intermediary object type where the default conversion is prohibitively expensive (e.g., a nested list of data frames). These objects will not survive many vctr transformations; however, they can be sliced without copying the underlying arrays. } \details{ The nanoarrow_vctr is currently implemented similarly to \code{factor()}: its storage type is an \code{integer()} that is a sequence along the total length of the vctr and there are attributes that are required to resolve these indices to an array + offset. Sequences typically have a very compact representation in recent versions of R such that this has a cheap storage footprint even for large arrays. The attributes are currently: \itemize{ \item \code{schema}: The \link[=as_nanoarrow_schema]{nanoarrow_schema} shared by each chunk. \item \code{chunks}: A \code{list()} of \code{nanoarrow_array}. \item \code{offsets}: An \code{integer()} vector beginning with \code{0} and followed by the cumulative length of each chunk. This allows the chunk index + offset to be resolved from a logical index with \code{log(n)} complexity. } This implementation is preliminary and may change; however, the result of \code{as_nanoarrow_array_stream(some_vctr[begin:end])} should remain stable. } \examples{ array <- as_nanoarrow_array(1:5) as_nanoarrow_vctr(array) } nanoarrow/man/na_type.Rd0000644000176200001440000001315614676554240015004 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/type.R \name{na_type} \alias{na_type} \alias{na_na} \alias{na_bool} \alias{na_int8} \alias{na_uint8} \alias{na_int16} \alias{na_uint16} \alias{na_int32} \alias{na_uint32} \alias{na_int64} \alias{na_uint64} \alias{na_half_float} \alias{na_float} \alias{na_double} \alias{na_string} \alias{na_large_string} \alias{na_string_view} \alias{na_binary} \alias{na_large_binary} \alias{na_fixed_size_binary} \alias{na_binary_view} \alias{na_date32} \alias{na_date64} \alias{na_time32} \alias{na_time64} \alias{na_duration} \alias{na_interval_months} \alias{na_interval_day_time} \alias{na_interval_month_day_nano} \alias{na_timestamp} \alias{na_decimal128} \alias{na_decimal256} \alias{na_struct} \alias{na_sparse_union} \alias{na_dense_union} \alias{na_list} \alias{na_large_list} \alias{na_fixed_size_list} \alias{na_map} \alias{na_dictionary} \alias{na_extension} \title{Create type objects} \usage{ na_type( type_name, byte_width = NULL, unit = NULL, timezone = NULL, column_types = NULL, item_type = NULL, key_type = NULL, value_type = NULL, index_type = NULL, ordered = NULL, list_size = NULL, keys_sorted = NULL, storage_type = NULL, extension_name = NULL, extension_metadata = NULL, nullable = NULL ) na_na(nullable = TRUE) na_bool(nullable = TRUE) na_int8(nullable = TRUE) na_uint8(nullable = TRUE) na_int16(nullable = TRUE) na_uint16(nullable = TRUE) na_int32(nullable = TRUE) na_uint32(nullable = TRUE) na_int64(nullable = TRUE) na_uint64(nullable = TRUE) na_half_float(nullable = TRUE) na_float(nullable = TRUE) na_double(nullable = TRUE) na_string(nullable = TRUE) na_large_string(nullable = TRUE) na_string_view(nullable = TRUE) na_binary(nullable = TRUE) na_large_binary(nullable = TRUE) na_fixed_size_binary(byte_width, nullable = TRUE) na_binary_view(nullable = TRUE) na_date32(nullable = TRUE) na_date64(nullable = TRUE) na_time32(unit = c("ms", "s"), nullable = TRUE) na_time64(unit = c("us", "ns"), nullable = TRUE) na_duration(unit = c("ms", "s", "us", "ns"), nullable = TRUE) na_interval_months(nullable = TRUE) na_interval_day_time(nullable = TRUE) na_interval_month_day_nano(nullable = TRUE) na_timestamp(unit = c("us", "ns", "s", "ms"), timezone = "", nullable = TRUE) na_decimal128(precision, scale, nullable = TRUE) na_decimal256(precision, scale, nullable = TRUE) na_struct(column_types = list(), nullable = FALSE) na_sparse_union(column_types = list()) na_dense_union(column_types = list()) na_list(item_type, nullable = TRUE) na_large_list(item_type, nullable = TRUE) na_fixed_size_list(item_type, list_size, nullable = TRUE) na_map(key_type, item_type, keys_sorted = FALSE, nullable = TRUE) na_dictionary(value_type, index_type = na_int32(), ordered = FALSE) na_extension(storage_type, extension_name, extension_metadata = "") } \arguments{ \item{type_name}{The name of the type (e.g., "int32"). This form of the constructor is useful for writing tests that loop over many types.} \item{byte_width}{For \code{\link[=na_fixed_size_binary]{na_fixed_size_binary()}}, the number of bytes occupied by each item.} \item{unit}{One of 's' (seconds), 'ms' (milliseconds), 'us' (microseconds), or 'ns' (nanoseconds).} \item{timezone}{A string representing a timezone name. The empty string "" represents a naive point in time (i.e., one that has no associated timezone).} \item{column_types}{A \code{list()} of \link[=as_nanoarrow_schema]{nanoarrow_schema}s.} \item{item_type}{For \code{\link[=na_list]{na_list()}}, \code{\link[=na_large_list]{na_large_list()}}, \code{\link[=na_fixed_size_list]{na_fixed_size_list()}}, and \code{\link[=na_map]{na_map()}}, the \link[=as_nanoarrow_schema]{nanoarrow_schema} representing the item type.} \item{key_type}{The \link[=as_nanoarrow_schema]{nanoarrow_schema} representing the \code{\link[=na_map]{na_map()}} key type.} \item{value_type}{The \link[=as_nanoarrow_schema]{nanoarrow_schema} representing the \code{\link[=na_dictionary]{na_dictionary()}} or \code{\link[=na_map]{na_map()}} value type.} \item{index_type}{The \link[=as_nanoarrow_schema]{nanoarrow_schema} representing the \code{\link[=na_dictionary]{na_dictionary()}} index type.} \item{ordered}{Use \code{TRUE} to assert that the order of values in the dictionary are meaningful.} \item{list_size}{The number of elements in each item in a \code{\link[=na_fixed_size_list]{na_fixed_size_list()}}.} \item{keys_sorted}{Use \code{TRUE} to assert that keys are sorted.} \item{storage_type}{For \code{\link[=na_extension]{na_extension()}}, the underlying value type.} \item{extension_name}{For \code{\link[=na_extension]{na_extension()}}, the extension name. This is typically namespaced separated by dots (e.g., arrow.r.vctrs).} \item{extension_metadata}{A string or raw vector defining extension metadata. Most Arrow extension types define extension metadata as a JSON object.} \item{nullable}{Use \code{FALSE} to assert that this field cannot contain null values.} \item{precision}{The total number of digits representable by the decimal type} \item{scale}{The number of digits after the decimal point in a decimal type} } \value{ A \link[=as_nanoarrow_schema]{nanoarrow_schema} } \description{ In nanoarrow, types, fields, and schemas are all represented by a \link[=as_nanoarrow_schema]{nanoarrow_schema}. These functions are convenience constructors to create these objects in a readable way. Use \code{\link[=na_type]{na_type()}} to construct types based on the constructor name, which is also the name that prints/is returned by \code{\link[=nanoarrow_schema_parse]{nanoarrow_schema_parse()}}. } \examples{ na_int32() na_struct(list(col1 = na_int32())) } nanoarrow/man/nanoarrow_extension_spec.Rd0000644000176200001440000000272114502402562020440 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/extension.R \name{nanoarrow_extension_spec} \alias{nanoarrow_extension_spec} \alias{register_nanoarrow_extension} \alias{unregister_nanoarrow_extension} \alias{resolve_nanoarrow_extension} \title{Register Arrow extension types} \usage{ nanoarrow_extension_spec(data = list(), subclass = character()) register_nanoarrow_extension(extension_name, extension_spec) unregister_nanoarrow_extension(extension_name) resolve_nanoarrow_extension(extension_name) } \arguments{ \item{data}{Optional data to include in the extension type specification} \item{subclass}{A subclass for the extension type specification. Extension methods will dispatch on this object.} \item{extension_name}{An Arrow extension type name (e.g., arrow.r.vctrs)} \item{extension_spec}{An extension specification inheriting from 'nanoarrow_extension_spec'.} } \value{ \itemize{ \item \code{nanoarrow_extension_spec()} returns an object of class 'nanoarrow_extension_spec'. \item \code{register_nanoarrow_extension()} returns \code{extension_spec}, invisibly. \item \code{unregister_nanoarrow_extension()} returns \code{extension_name}, invisibly. \item \code{resolve_nanoarrow_extension()} returns an object of class 'nanoarrow_extension_spec' or NULL if the extension type was not registered. } } \description{ Register Arrow extension types } \examples{ nanoarrow_extension_spec("mynamespace.mytype", subclass = "mypackage_mytype_spec") } nanoarrow/man/na_vctrs.Rd0000644000176200001440000000257014672341746015163 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/extension-vctrs.R \name{na_vctrs} \alias{na_vctrs} \title{Vctrs extension type} \usage{ na_vctrs(ptype, storage_type = NULL) } \arguments{ \item{ptype}{A vctrs prototype as returned by \code{\link[vctrs:vec_ptype]{vctrs::vec_ptype()}}. The prototype can be of arbitrary size, but a zero-size vector is sufficient here.} \item{storage_type}{For \code{\link[=na_extension]{na_extension()}}, the underlying value type.} } \value{ A \link[=as_nanoarrow_schema]{nanoarrow_schema}. } \description{ The Arrow format provides a rich type system that can handle most R vector types; however, many R vector types do not roundtrip perfectly through Arrow memory. The vctrs extension type uses \code{\link[vctrs:vec_data]{vctrs::vec_data()}}, \code{\link[vctrs:vec_proxy]{vctrs::vec_restore()}}, and \code{\link[vctrs:vec_ptype]{vctrs::vec_ptype()}} in calls to \code{\link[=as_nanoarrow_array]{as_nanoarrow_array()}} and \code{\link[=convert_array]{convert_array()}} to ensure roundtrip fidelity. } \examples{ \dontshow{if (requireNamespace("jsonlite", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} vctr <- as.POSIXlt("2000-01-02 03:45", tz = "UTC") array <- as_nanoarrow_array(vctr, schema = na_vctrs(vctr)) infer_nanoarrow_ptype(array) convert_array(array) \dontshow{\}) # examplesIf} } nanoarrow/man/nanoarrow_pointer_is_valid.Rd0000644000176200001440000001125614502402506020745 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pointers.R \name{nanoarrow_pointer_is_valid} \alias{nanoarrow_pointer_is_valid} \alias{nanoarrow_pointer_addr_dbl} \alias{nanoarrow_pointer_addr_chr} \alias{nanoarrow_pointer_addr_pretty} \alias{nanoarrow_pointer_release} \alias{nanoarrow_pointer_move} \alias{nanoarrow_pointer_export} \alias{nanoarrow_allocate_schema} \alias{nanoarrow_allocate_array} \alias{nanoarrow_allocate_array_stream} \alias{nanoarrow_pointer_set_protected} \title{Danger zone: low-level pointer operations} \usage{ nanoarrow_pointer_is_valid(ptr) nanoarrow_pointer_addr_dbl(ptr) nanoarrow_pointer_addr_chr(ptr) nanoarrow_pointer_addr_pretty(ptr) nanoarrow_pointer_release(ptr) nanoarrow_pointer_move(ptr_src, ptr_dst) nanoarrow_pointer_export(ptr_src, ptr_dst) nanoarrow_allocate_schema() nanoarrow_allocate_array() nanoarrow_allocate_array_stream() nanoarrow_pointer_set_protected(ptr_src, protected) } \arguments{ \item{ptr, ptr_src, ptr_dst}{An external pointer to a \verb{struct ArrowSchema}, \verb{struct ArrowArray}, or \verb{struct ArrowArrayStream}.} \item{protected}{An object whose scope must outlive that of \code{ptr}. This is useful for array streams since at least two specifications involving the array stream specify that the stream is only valid for the lifecycle of another object (e.g., an AdbcStatement or OGRDataset).} } \value{ \itemize{ \item \code{nanoarrow_pointer_is_valid()} returns TRUE if the pointer is non-null and has a non-null release callback. \item \code{nanoarrow_pointer_addr_dbl()} and \code{nanoarrow_pointer_addr_chr()} return pointer representations that may be helpful to facilitate moving or exporting nanoarrow objects to other libraries. \item \code{nanoarrow_pointer_addr_pretty()} gives a pointer representation suitable for printing or error messages. \item \code{nanoarrow_pointer_release()} returns \code{ptr}, invisibly. \item \code{nanoarrow_pointer_move()} and \code{nanoarrow_pointer_export()} reeturn \code{ptr_dst}, invisibly. \item \code{nanoarrow_allocate_array()}, \code{nanoarrow_allocate_schema()}, and \code{nanoarrow_allocate_array_stream()} return an \link[=as_nanoarrow_array]{array}, a \link[=as_nanoarrow_schema]{schema}, and an \link[=as_nanoarrow_array_stream]{array stream}, respectively. } } \description{ The \link[=as_nanoarrow_schema]{nanoarrow_schema}, \link[=as_nanoarrow_array]{nanoarrow_array}, and \link[=as_nanoarrow_array_stream]{nanoarrow_array_stream} classes are represented in R as external pointers (\code{EXTPTRSXP}). When these objects go out of scope (i.e., when they are garbage collected or shortly thereafter), the underlying object's \code{release()} callback is called if the underlying pointer is non-null and if the \code{release()} callback is non-null. } \details{ When interacting with other C Data Interface implementations, it is important to keep in mind that the R object wrapping these pointers is always passed by reference (because it is an external pointer) and may be referred to by another R object (e.g., an element in a \code{list()} or as a variable assigned in a user's environment). When importing a schema, array, or array stream into nanoarrow this is not a problem: the R object takes ownership of the lifecycle and memory is released when the R object is garbage collected. In this case, one can use \code{\link[=nanoarrow_pointer_move]{nanoarrow_pointer_move()}} where \code{ptr_dst} was created using \verb{nanoarrow_allocate_*()}. The case of exporting is more complicated and as such has a dedicated function, \code{\link[=nanoarrow_pointer_export]{nanoarrow_pointer_export()}}, that implements different logic schemas, arrays, and array streams: \itemize{ \item Schema objects are (deep) copied such that a fresh copy of the schema is exported and made the responsibility of some other C data interface implementation. \item Array objects are exported as a shell around the original array that preserves a reference to the R object. This ensures that the buffers and children pointed to by the array are not copied and that any references to the original array are not invalidated. \item Array stream objects are moved: the responsibility for the object is transferred to the other C data interface implementation and any references to the original R object are invalidated. Because these objects are mutable, this is typically what you want (i.e., you should not be pulling arrays from a stream accidentally from two places). } If you know the lifecycle of your object (i.e., you created the R object yourself and never passed references to it elsewhere), you can slightly more efficiently call \code{\link[=nanoarrow_pointer_move]{nanoarrow_pointer_move()}} for all three pointer types. } nanoarrow/man/read_nanoarrow.Rd0000644000176200001440000000374614672714403016345 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ipc.R \name{read_nanoarrow} \alias{read_nanoarrow} \alias{write_nanoarrow} \alias{example_ipc_stream} \title{Read/write serialized streams of Arrow data} \usage{ read_nanoarrow(x, ..., lazy = FALSE) write_nanoarrow(data, x, ...) example_ipc_stream() } \arguments{ \item{x}{A \code{raw()} vector, connection, or file path from which to read binary data. Common extensions indicating compression (.gz, .bz2, .zip) are automatically uncompressed.} \item{...}{Currently unused.} \item{lazy}{By default, \code{read_nanoarrow()} will read and discard a copy of the reader's schema to ensure that invalid streams are discovered as soon as possible. Use \code{lazy = TRUE} to defer this check until the reader is actually consumed.} \item{data}{An object to write as an Arrow IPC stream, converted using \code{\link[=as_nanoarrow_array_stream]{as_nanoarrow_array_stream()}}. Notably, this includes a \code{\link[=data.frame]{data.frame()}}.} } \value{ A \link[=as_nanoarrow_array_stream]{nanoarrow_array_stream} } \description{ Reads/writes connections, file paths, URLs, or raw vectors from/to serialized Arrow data. Arrow documentation typically refers to this format as "Arrow IPC", since its origin was as a means to transmit tables between processes (e.g., multiple R sessions). This format can also be written to and read from files or URLs and is essentially a high performance equivalent of a CSV file that does a better job maintaining types. } \details{ The nanoarrow package implements an IPC writer; however, you can also use \code{\link[arrow:write_ipc_stream]{arrow::write_ipc_stream()}} to write data from R, or use the equivalent writer from another Arrow implementation in Python, C++, Rust, JavaScript, Julia, C#, and beyond. The media type of an Arrow stream is \code{application/vnd.apache.arrow.stream} and the recommended file extension is \code{.arrows}. } \examples{ as.data.frame(read_nanoarrow(example_ipc_stream())) } nanoarrow/man/basic_array_stream.Rd0000644000176200001440000000165114355103326017161 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/array-stream.R \name{basic_array_stream} \alias{basic_array_stream} \title{Create ArrayStreams from batches} \usage{ basic_array_stream(batches, schema = NULL, validate = TRUE) } \arguments{ \item{batches}{A \code{\link[=list]{list()}} of \link[=as_nanoarrow_array]{nanoarrow_array} objects or objects that can be coerced via \code{\link[=as_nanoarrow_array]{as_nanoarrow_array()}}.} \item{schema}{A \link[=as_nanoarrow_schema]{nanoarrow_schema} or \code{NULL} to guess based on the first schema.} \item{validate}{Use \code{FALSE} to skip the validation step (i.e., if you know that the arrays are valid).} } \value{ An \link[=as_nanoarrow_array_stream]{nanoarrow_array_stream} } \description{ Create ArrayStreams from batches } \examples{ (stream <- basic_array_stream(list(data.frame(a = 1, b = 2)))) as.data.frame(stream$get_next()) stream$get_next() } nanoarrow/man/infer_nanoarrow_ptype_extension.Rd0000644000176200001440000000261514502402562022034 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/extension.R \name{infer_nanoarrow_ptype_extension} \alias{infer_nanoarrow_ptype_extension} \alias{convert_array_extension} \alias{as_nanoarrow_array_extension} \title{Implement Arrow extension types} \usage{ infer_nanoarrow_ptype_extension( extension_spec, x, ..., warn_unregistered = TRUE ) convert_array_extension( extension_spec, array, to, ..., warn_unregistered = TRUE ) as_nanoarrow_array_extension(extension_spec, x, ..., schema = NULL) } \arguments{ \item{extension_spec}{An extension specification inheriting from 'nanoarrow_extension_spec'.} \item{x, array, to, schema, ...}{Passed from \code{\link[=infer_nanoarrow_ptype]{infer_nanoarrow_ptype()}}, \code{\link[=convert_array]{convert_array()}}, \code{\link[=as_nanoarrow_array]{as_nanoarrow_array()}}, and/or \code{\link[=as_nanoarrow_array_stream]{as_nanoarrow_array_stream()}}.} \item{warn_unregistered}{Use \code{FALSE} to infer/convert based on the storage type without a warning.} } \value{ \itemize{ \item \code{infer_nanoarrow_ptype_extension()}: The R vector prototype to be used as the default conversion target. \item \code{convert_array_extension()}: An R vector of type \code{to}. \item \code{as_nanoarrow_array_extension()}: A \link[=as_nanoarrow_array]{nanoarrow_array} of type \code{schema}. } } \description{ Implement Arrow extension types } nanoarrow/man/convert_array_stream.Rd0000644000176200001440000000423114502402562017553 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/convert-array-stream.R \name{convert_array_stream} \alias{convert_array_stream} \alias{collect_array_stream} \title{Convert an Array Stream into an R vector} \usage{ convert_array_stream(array_stream, to = NULL, size = NULL, n = Inf) collect_array_stream(array_stream, n = Inf, schema = NULL, validate = TRUE) } \arguments{ \item{array_stream}{A \link[=as_nanoarrow_array_stream]{nanoarrow_array_stream}.} \item{to}{A target prototype object describing the type to which \code{array} should be converted, or \code{NULL} to use the default conversion as returned by \code{\link[=infer_nanoarrow_ptype]{infer_nanoarrow_ptype()}}. Alternatively, a function can be passed to perform an alternative calculation of the default ptype as a function of \code{array} and the default inference of the prototype.} \item{size}{The exact size of the output, if known. If specified, slightly more efficient implementation may be used to collect the output.} \item{n}{The maximum number of batches to pull from the array stream.} \item{schema}{A \link[=as_nanoarrow_schema]{nanoarrow_schema} or \code{NULL} to guess based on the first schema.} \item{validate}{Use \code{FALSE} to skip the validation step (i.e., if you know that the arrays are valid).} } \value{ \itemize{ \item \code{convert_array_stream()}: An R vector of type \code{to}. \item \code{collect_array_stream()}: A \code{list()} of \link[=as_nanoarrow_array]{nanoarrow_array} } } \description{ Converts \code{array_stream} to the type specified by \code{to}. This is a low-level interface; most users should use \code{as.data.frame()} or \code{as.vector()} unless finer-grained control is needed over the conversion. See \code{\link[=convert_array]{convert_array()}} for details of the conversion process; see \code{\link[=infer_nanoarrow_ptype]{infer_nanoarrow_ptype()}} for default inferences of \code{to}. } \examples{ stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) str(convert_array_stream(stream)) str(convert_array_stream(stream, to = data.frame(x = double()))) stream <- as_nanoarrow_array_stream(data.frame(x = 1:5)) collect_array_stream(stream) } nanoarrow/man/nanoarrow_buffer_init.Rd0000644000176200001440000000250714502402506017706 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/buffer.R \name{nanoarrow_buffer_init} \alias{nanoarrow_buffer_init} \alias{nanoarrow_buffer_append} \alias{convert_buffer} \title{Create and modify nanoarrow buffers} \usage{ nanoarrow_buffer_init() nanoarrow_buffer_append(buffer, new_buffer) convert_buffer(buffer, to = NULL) } \arguments{ \item{buffer, new_buffer}{\link[=as_nanoarrow_buffer]{nanoarrow_buffer}s.} \item{to}{A target prototype object describing the type to which \code{array} should be converted, or \code{NULL} to use the default conversion as returned by \code{\link[=infer_nanoarrow_ptype]{infer_nanoarrow_ptype()}}. Alternatively, a function can be passed to perform an alternative calculation of the default ptype as a function of \code{array} and the default inference of the prototype.} } \value{ \itemize{ \item \code{nanoarrow_buffer_init()}: An object of class 'nanoarrow_buffer' \item \code{nanoarrow_buffer_append()}: Returns \code{buffer}, invisibly. Note that \code{buffer} is modified in place by reference. } } \description{ Create and modify nanoarrow buffers } \examples{ buffer <- nanoarrow_buffer_init() nanoarrow_buffer_append(buffer, 1:5) array <- nanoarrow_array_modify( nanoarrow_array_init(na_int32()), list(length = 5, buffers = list(NULL, buffer)) ) as.vector(array) } nanoarrow/DESCRIPTION0000644000176200001440000000306714702646313014002 0ustar liggesusersPackage: nanoarrow Title: Interface to the 'nanoarrow' 'C' Library Version: 0.6.0 Authors@R: c( person(given = "Dewey", family = "Dunnington", role = c("aut", "cre"), email = "dewey@dunnington.ca", comment = c(ORCID = "0000-0002-9415-4582")), person("Apache Arrow", email = "dev@arrow.apache.org", role = c("aut", "cph")), person("Apache Software Foundation", email = "dev@arrow.apache.org", role = c("cph")) ) Description: Provides an 'R' interface to the 'nanoarrow' 'C' library and the 'Apache Arrow' application binary interface. Functions to import and export 'ArrowArray', 'ArrowSchema', and 'ArrowArrayStream' 'C' structures to and from 'R' objects are provided alongside helpers to facilitate zero-copy data transfer among 'R' bindings to libraries implementing the 'Arrow' 'C' data interface. License: Apache License (>= 2) Encoding: UTF-8 RoxygenNote: 7.3.2 URL: https://arrow.apache.org/nanoarrow/latest/r/, https://github.com/apache/arrow-nanoarrow BugReports: https://github.com/apache/arrow-nanoarrow/issues Suggests: arrow (>= 9.0.0), bit64, blob, hms, jsonlite, rlang, testthat (>= 3.0.0), tibble, vctrs, withr Config/testthat/edition: 3 Config/build/bootstrap: TRUE NeedsCompilation: yes Packaged: 2024-10-13 02:45:31 UTC; deweydunnington Author: Dewey Dunnington [aut, cre] (), Apache Arrow [aut, cph], Apache Software Foundation [cph] Maintainer: Dewey Dunnington Repository: CRAN Date/Publication: 2024-10-13 04:30:03 UTC