tranfi 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +8 -0
  3. package/README.md +443 -51
  4. package/app/assets/{index-pDFMluyz.js → index-BIAIKnrp.js} +1 -1
  5. package/app/index.html +1 -1
  6. package/binding.gyp +55 -3
  7. package/csrc/arena.c +7 -5
  8. package/csrc/batch.c +818 -71
  9. package/csrc/buffer.c +84 -8
  10. package/csrc/cJSON.c +262 -19
  11. package/csrc/cJSON.h +17 -1
  12. package/csrc/codec_csv.c +1074 -181
  13. package/csrc/codec_jsonl.c +830 -118
  14. package/csrc/codec_table.c +108 -78
  15. package/csrc/codec_text.c +286 -68
  16. package/csrc/compiler.c +31 -3
  17. package/csrc/config.h +21 -0
  18. package/csrc/dsl.c +4722 -485
  19. package/csrc/expr.c +363 -55
  20. package/csrc/expr.h +2 -0
  21. package/csrc/internal.h +316 -27
  22. package/csrc/ir.c +65 -18
  23. package/csrc/ir.h +41 -0
  24. package/csrc/ir_schema.c +20 -5
  25. package/csrc/ir_serialize.c +68 -6
  26. package/csrc/ir_sql.c +796 -185
  27. package/csrc/ir_validate.c +462 -6
  28. package/csrc/json_path.c +210 -0
  29. package/csrc/main.c +879 -30
  30. package/csrc/memory_estimate.c +477 -0
  31. package/csrc/op_acf.c +171 -21
  32. package/csrc/op_across.c +477 -0
  33. package/csrc/op_anomaly.c +167 -32
  34. package/csrc/op_assert.c +761 -0
  35. package/csrc/op_bin.c +168 -29
  36. package/csrc/op_cast.c +383 -55
  37. package/csrc/op_clip.c +30 -19
  38. package/csrc/op_date_trunc.c +208 -34
  39. package/csrc/op_datetime.c +259 -77
  40. package/csrc/op_derive.c +65 -97
  41. package/csrc/op_diff.c +146 -30
  42. package/csrc/op_ewma.c +149 -30
  43. package/csrc/op_explode.c +124 -26
  44. package/csrc/op_fill_down.c +125 -53
  45. package/csrc/op_fill_null.c +176 -31
  46. package/csrc/op_filter.c +89 -40
  47. package/csrc/op_frequency.c +571 -43
  48. package/csrc/op_grep.c +36 -18
  49. package/csrc/op_group_agg.c +1790 -119
  50. package/csrc/op_hash.c +48 -15
  51. package/csrc/op_head.c +21 -86
  52. package/csrc/op_interpolate.c +268 -62
  53. package/csrc/op_join.c +2700 -182
  54. package/csrc/op_json_extract.c +227 -0
  55. package/csrc/op_json_filter.c +384 -0
  56. package/csrc/op_json_flatten.c +293 -0
  57. package/csrc/op_json_schema.c +503 -0
  58. package/csrc/op_label_encode.c +328 -53
  59. package/csrc/op_lag.c +181 -0
  60. package/csrc/op_lead.c +141 -89
  61. package/csrc/op_normalize.c +363 -79
  62. package/csrc/op_onehot.c +345 -73
  63. package/csrc/op_pivot.c +1546 -162
  64. package/csrc/op_quarantine.c +189 -0
  65. package/csrc/op_registry.c +2062 -166
  66. package/csrc/op_rename.c +41 -50
  67. package/csrc/op_replace.c +270 -118
  68. package/csrc/op_rleid.c +297 -0
  69. package/csrc/op_rowid.c +559 -0
  70. package/csrc/op_sample.c +80 -23
  71. package/csrc/op_schema.c +1341 -0
  72. package/csrc/op_schema_infer.c +252 -0
  73. package/csrc/op_select.c +265 -65
  74. package/csrc/op_set.c +3449 -0
  75. package/csrc/op_skip.c +30 -87
  76. package/csrc/op_sort.c +670 -124
  77. package/csrc/op_source_name.c +120 -0
  78. package/csrc/op_split.c +65 -28
  79. package/csrc/op_split_data.c +41 -9
  80. package/csrc/op_stack.c +178 -222
  81. package/csrc/op_stats.c +206 -110
  82. package/csrc/op_step.c +217 -55
  83. package/csrc/op_tail.c +21 -12
  84. package/csrc/op_tee.c +338 -0
  85. package/csrc/op_top.c +260 -53
  86. package/csrc/op_trim.c +48 -19
  87. package/csrc/op_unique.c +1193 -150
  88. package/csrc/op_unpivot.c +100 -66
  89. package/csrc/op_validate.c +601 -24
  90. package/csrc/op_window.c +492 -51
  91. package/csrc/path_policy.c +85 -0
  92. package/csrc/pipeline.c +872 -99
  93. package/csrc/recipes.c +3 -1
  94. package/csrc/report.c +73 -30
  95. package/csrc/selector.c +1097 -0
  96. package/csrc/size_utils.c +352 -0
  97. package/csrc/spill.c +317 -0
  98. package/csrc/spill.h +21 -0
  99. package/csrc/tranfi.h +169 -1
  100. package/csrc/transform.h +209 -0
  101. package/csrc/transform_api.c +2237 -0
  102. package/csrc/transform_categorical.c +923 -0
  103. package/csrc/transform_internal.h +472 -0
  104. package/csrc/transform_json.c +3812 -0
  105. package/csrc/transform_numeric.c +1966 -0
  106. package/csrc/transform_sha256.c +154 -0
  107. package/csrc/transform_wasm.h +162 -0
  108. package/csrc/transform_wasm_api.c +1373 -0
  109. package/csrc/wasm_api.c +70 -9
  110. package/napi_api.c +219 -11
  111. package/napi_transform.c +1648 -0
  112. package/napi_transform.h +8 -0
  113. package/package.json +27 -11
  114. package/scripts/install-native.js +76 -0
  115. package/scripts/prepack.js +64 -0
  116. package/scripts/sync-csrc.js +23 -0
  117. package/src/cli.js +81 -41
  118. package/src/engines/duckdb.js +45 -12
  119. package/src/index.js +661 -42
  120. package/src/memory_policy.js +411 -0
  121. package/src/native.js +1 -5
  122. package/src/pipeline.js +454 -31
  123. package/src/recipe_json.js +80 -0
  124. package/src/server.js +10 -8
  125. package/src/transform.js +403 -0
  126. package/src/transform_error.js +10 -0
  127. package/src/wasm.js +6 -4
  128. package/wasm/index.js +498 -10
  129. package/wasm/tranfi_core.js +0 -0
  130. package/wasm/transform.js +1156 -0
  131. package/wasm/worker.js +786 -0
  132. package/csrc/plan.c +0 -206
package/csrc/tranfi.h CHANGED
@@ -9,8 +9,11 @@
9
9
  #ifndef TRANFI_H
10
10
  #define TRANFI_H
11
11
 
12
+ #include "config.h"
12
13
  #include <stddef.h>
13
14
  #include <stdint.h>
15
+ #include <stdio.h>
16
+ #include <stdbool.h>
14
17
 
15
18
  #ifdef __cplusplus
16
19
  extern "C" {
@@ -25,10 +28,92 @@ extern "C" {
25
28
 
26
29
  /* Return codes */
27
30
  #define TF_OK 0
31
+ #define TF_DONE 1
28
32
  #define TF_ERROR (-1)
29
33
 
30
- /* Opaque pipeline handle */
34
+ /* Shared value types used by schemas and public batch accessors. */
35
+ #ifndef TF_TYPE_DEFINED
36
+ #define TF_TYPE_DEFINED
37
+ typedef enum tf_type {
38
+ TF_TYPE_NULL = 0,
39
+ TF_TYPE_BOOL,
40
+ TF_TYPE_INT64,
41
+ TF_TYPE_FLOAT64,
42
+ TF_TYPE_STRING,
43
+ TF_TYPE_DATE, /* int32_t: days since 1970-01-01 */
44
+ TF_TYPE_TIMESTAMP, /* int64_t: microseconds since 1970-01-01T00:00:00Z */
45
+ } tf_type;
46
+ #endif
47
+
48
+ /* Opaque pipeline and columnar batch handles. */
31
49
  typedef struct tf_pipeline tf_pipeline;
50
+ typedef struct tf_batch tf_batch;
51
+
52
+ /*
53
+ * Sink callback used by tf_pipeline_set_sink() and tf_pipeline_drain().
54
+ * Return TF_OK to continue, TF_ERROR to stop the pipeline with an error.
55
+ * The data pointer is valid only for the duration of the callback.
56
+ */
57
+ typedef int (*tf_pipeline_sink_fn)(int channel, const uint8_t *data, size_t len, void *user);
58
+
59
+ /*
60
+ * Batch callback for embedders that consume transformed columnar batches before
61
+ * encoding. The batch and any returned string pointers are valid only for the
62
+ * duration of the callback; copy data that must outlive the callback.
63
+ */
64
+ typedef int (*tf_pipeline_batch_sink_fn)(const tf_batch *batch, void *user);
65
+
66
+ /* Progress snapshot passed to tf_pipeline_progress_fn. */
67
+ typedef struct tf_pipeline_progress {
68
+ size_t bytes_in;
69
+ size_t bytes_out;
70
+ size_t rows_in;
71
+ size_t rows_out;
72
+ size_t batches_in;
73
+ size_t batches_out;
74
+ const char *phase; /* push, decoder_flush, step_flush, encoder_flush, stats, done */
75
+ int finished;
76
+ } tf_pipeline_progress;
77
+
78
+ /*
79
+ * Progress callback invoked at batch/flush boundaries. Return TF_OK to continue
80
+ * or TF_ERROR to stop the pipeline with `progress callback failed`.
81
+ */
82
+ typedef int (*tf_pipeline_progress_fn)(const tf_pipeline_progress *progress, void *user);
83
+
84
+
85
+ /*
86
+ * Host policy for embedded or untrusted execution surfaces.
87
+ * File-taking pipeline args are validated before native construction; when
88
+ * workspace_root or resolve_path is provided, accepted paths are rewritten to
89
+ * the resolved host path in the mutable IR used for execution.
90
+ */
91
+ typedef int (*tf_resolve_path_fn)(const char *logical, char *out, size_t out_sz, void *user);
92
+
93
+ typedef struct tf_host_policy {
94
+ bool allow_fs;
95
+ bool allow_net;
96
+ bool allow_spill;
97
+ bool allow_blocking;
98
+ bool allow_rules_file;
99
+ const char *workspace_root;
100
+ tf_resolve_path_fn resolve_path;
101
+ void *user;
102
+ } tf_host_policy;
103
+
104
+ /* Read-only columnar batch accessors for batch callbacks. */
105
+ size_t tf_batch_num_rows(const tf_batch *b);
106
+ size_t tf_batch_num_cols(const tf_batch *b);
107
+ const char *tf_batch_col_name(const tf_batch *b, size_t col);
108
+ tf_type tf_batch_col_type(const tf_batch *b, size_t col);
109
+ int tf_batch_col_index(const tf_batch *b, const char *name);
110
+ bool tf_batch_is_null(const tf_batch *b, size_t row, size_t col);
111
+ bool tf_batch_get_bool(const tf_batch *b, size_t row, size_t col);
112
+ int64_t tf_batch_get_int64(const tf_batch *b, size_t row, size_t col);
113
+ double tf_batch_get_float64(const tf_batch *b, size_t row, size_t col);
114
+ const char *tf_batch_get_string(const tf_batch *b, size_t row, size_t col);
115
+ int32_t tf_batch_get_date(const tf_batch *b, size_t row, size_t col);
116
+ int64_t tf_batch_get_timestamp(const tf_batch *b, size_t row, size_t col);
32
117
 
33
118
  /*
34
119
  * Create a pipeline from a JSON plan.
@@ -36,6 +121,8 @@ typedef struct tf_pipeline tf_pipeline;
36
121
  * use tf_last_error() instead).
37
122
  */
38
123
  tf_pipeline *tf_pipeline_create(const char *plan_json, size_t len);
124
+ tf_pipeline *tf_pipeline_create_with_host_policy(const char *plan_json, size_t len,
125
+ const tf_host_policy *policy);
39
126
 
40
127
  /* Free all resources associated with a pipeline. */
41
128
  void tf_pipeline_free(tf_pipeline *p);
@@ -52,6 +139,14 @@ int tf_pipeline_push(tf_pipeline *p, const uint8_t *data, size_t len);
52
139
  */
53
140
  int tf_pipeline_finish(tf_pipeline *p);
54
141
 
142
+ /*
143
+ * Advance finish processing by at most one flush boundary.
144
+ * Returns TF_OK while more finish work remains, TF_DONE once final stats are
145
+ * emitted, or TF_ERROR on failure. Hosts can call pull()/drain() between calls
146
+ * to avoid retaining finish-time output in the pipeline buffer.
147
+ */
148
+ int tf_pipeline_finish_step(tf_pipeline *p);
149
+
55
150
  /*
56
151
  * Pull output bytes from a channel.
57
152
  * Writes up to buf_len bytes into buf.
@@ -59,6 +154,74 @@ int tf_pipeline_finish(tf_pipeline *p);
59
154
  */
60
155
  size_t tf_pipeline_pull(tf_pipeline *p, int channel, uint8_t *buf, size_t buf_len);
61
156
 
157
+ /*
158
+ * Drain all currently buffered bytes from one channel to a callback.
159
+ * Returns TF_OK on success or TF_ERROR if arguments are invalid or the callback fails.
160
+ */
161
+ int tf_pipeline_drain(tf_pipeline *p, int channel, tf_pipeline_sink_fn sink, void *user);
162
+
163
+ /*
164
+ * Register or clear an automatic sink for a channel. When set, the pipeline drains
165
+ * that channel after each push()/finish() batch boundary, so embedders can write to
166
+ * FILE*, file descriptors, sockets, or host stream adapters without retaining all
167
+ * output in the pipeline buffer. Pass NULL as sink to clear the registered sink.
168
+ */
169
+ int tf_pipeline_set_sink(tf_pipeline *p, int channel, tf_pipeline_sink_fn sink, void *user);
170
+
171
+ /*
172
+ * Register or clear an automatic sink for transformed output batches before
173
+ * encoding. This is the columnar-batch counterpart to byte sinks: it is invoked
174
+ * at output batch boundaries during push()/finish_step()/finish(). Pass NULL as
175
+ * sink to clear the registered batch sink.
176
+ */
177
+ int tf_pipeline_set_batch_sink(tf_pipeline *p, tf_pipeline_batch_sink_fn sink, void *user);
178
+
179
+ /*
180
+ * Enable or disable encoded main byte output. Enabled by default. Batch-only
181
+ * embedders can disable it after setting a batch sink to avoid CSV/JSONL byte
182
+ * generation while still keeping side channels and row stats available.
183
+ */
184
+ int tf_pipeline_set_encode_output(tf_pipeline *p, int enabled);
185
+
186
+ /*
187
+ * Register or clear a progress callback. If interval_rows is 0, the callback is
188
+ * invoked at every batch/flush boundary; otherwise it is invoked when rows_in or
189
+ * rows_out advances by at least interval_rows, plus once at finish.
190
+ */
191
+ int tf_pipeline_set_progress_callback(tf_pipeline *p, tf_pipeline_progress_fn cb,
192
+ void *user, size_t interval_rows);
193
+
194
+ /*
195
+ * Set or clear the current host source name. Row-local transforms such as
196
+ * source-name can append this value without the core opening files itself.
197
+ * Pass NULL or an empty string to clear it.
198
+ */
199
+ int tf_pipeline_set_source_name(tf_pipeline *p, const char *name);
200
+
201
+ /*
202
+ * Flush only the decoder input boundary and process any decoded batches, without
203
+ * finishing transforms, encoders, or stats. Hosts use this between sequential
204
+ * input files so partial records and decoder batches keep the correct source
205
+ * metadata while the pipeline state remains global.
206
+ */
207
+ int tf_pipeline_flush_input(tf_pipeline *p);
208
+
209
+ /*
210
+ * Run a pipeline from an input FILE* to an output FILE* using bounded chunks.
211
+ * Main output is streamed to out; side channels remain available via pull().
212
+ * If chunk_size is 0, a 64 KiB default is used. The pipeline is finished on
213
+ * success and must not be pushed again.
214
+ */
215
+ int tf_pipeline_run_file(tf_pipeline *p, FILE *in, FILE *out, size_t chunk_size);
216
+
217
+ /*
218
+ * Run a pipeline from POSIX input/output file descriptors using bounded chunks.
219
+ * Main output is streamed to out_fd; side channels remain available via pull().
220
+ * If chunk_size is 0, a 64 KiB default is used. Returns TF_ERROR on
221
+ * non-POSIX platforms.
222
+ */
223
+ int tf_pipeline_run_fd(tf_pipeline *p, int in_fd, int out_fd, size_t chunk_size);
224
+
62
225
  /* Get the last error message, or NULL if no error. */
63
226
  const char *tf_pipeline_error(tf_pipeline *p);
64
227
 
@@ -81,6 +244,7 @@ char *tf_ir_plan_to_json(const tf_ir_plan *plan);
81
244
 
82
245
  /* Validate an IR plan. Returns TF_OK or TF_ERROR. */
83
246
  int tf_ir_plan_validate(tf_ir_plan *plan);
247
+ int tf_ir_plan_validate_with_host_policy(tf_ir_plan *plan, const tf_host_policy *policy);
84
248
 
85
249
  /* Infer schemas through an IR plan. Best-effort, non-fatal. */
86
250
  int tf_ir_plan_infer_schema(tf_ir_plan *plan);
@@ -90,9 +254,13 @@ void tf_ir_plan_destroy(tf_ir_plan *plan);
90
254
 
91
255
  /* Create a pipeline from a pre-built IR plan. */
92
256
  tf_pipeline *tf_pipeline_create_from_ir(const tf_ir_plan *plan);
257
+ tf_pipeline *tf_pipeline_create_from_ir_with_host_policy(const tf_ir_plan *plan,
258
+ const tf_host_policy *policy);
93
259
 
94
260
  /* Compile a DSL string to a JSON recipe. Caller frees with tf_string_free(). */
95
261
  char *tf_compile_dsl(const char *dsl, size_t len, char **error);
262
+ char *tf_compile_dsl_with_host_policy(const char *dsl, size_t len,
263
+ const tf_host_policy *policy, char **error);
96
264
 
97
265
  /* Compile a DSL string directly to SQL. Caller frees with tf_string_free(). */
98
266
  char *tf_compile_to_sql(const char *dsl, size_t len, char **error);
@@ -0,0 +1,209 @@
1
+ /* Generic prepared-transform C API. */
2
+
3
+ #ifndef TRANFI_TRANSFORM_H
4
+ #define TRANFI_TRANSFORM_H
5
+
6
+ #include "tranfi.h"
7
+ #include <stddef.h>
8
+ #include <stdint.h>
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+
14
+ typedef enum tf_transform_code {
15
+ TF_TRANSFORM_OK = 0,
16
+ TF_TRANSFORM_INVALID_ARGUMENT = 100,
17
+ TF_TRANSFORM_INVALID_RECIPE = 101,
18
+ TF_TRANSFORM_SCHEMA_MISMATCH = 102,
19
+ TF_TRANSFORM_INSUFFICIENT_DATA = 103,
20
+ TF_TRANSFORM_RESOURCE_LIMIT = 104,
21
+ TF_TRANSFORM_UNSUPPORTED_VERSION = 105,
22
+ TF_TRANSFORM_CORRUPT_PLAN = 106,
23
+ TF_TRANSFORM_NUMERIC_DOMAIN = 107,
24
+ TF_TRANSFORM_UNKNOWN_CATEGORY = 108,
25
+ TF_TRANSFORM_CANCELLED = 109,
26
+ TF_TRANSFORM_ALLOCATION = 110,
27
+ TF_TRANSFORM_IO = 111,
28
+ TF_TRANSFORM_INVALID_STATE = 112,
29
+ TF_TRANSFORM_UNSUPPORTED_RUNTIME = 113,
30
+ TF_TRANSFORM_INTERNAL = 199
31
+ } tf_transform_code;
32
+
33
+ enum {
34
+ TF_VIEW_FLOAT32 = 0x0101,
35
+ TF_VIEW_FLOAT64 = 0x0102
36
+ };
37
+
38
+ #define TF_TRANSFORM_SCHEMA_INPUT 1u
39
+ #define TF_TRANSFORM_SCHEMA_OUTPUT 2u
40
+
41
+ #define TF_TRANSFORM_CANCEL_ROWS_V1 4096u
42
+ #define TF_TRANSFORM_CANCEL_ELEMENTS_V1 65536u
43
+ #define TF_TRANSFORM_CANCEL_BYTES_V1 65536u
44
+ #define TF_TRANSFORM_CANCEL_ITERS_V1 4096u
45
+ #define TF_TRANSFORM_CANCEL_IO_BYTES_V1 1048576u
46
+
47
+ typedef struct tf_transform_recipe tf_transform_recipe;
48
+ typedef struct tf_transform_analyzer tf_transform_analyzer;
49
+ typedef struct tf_transform_plan tf_transform_plan;
50
+ typedef struct tf_transform_apply tf_transform_apply;
51
+ typedef struct tf_transform_schema tf_transform_schema;
52
+ typedef struct tf_transform_error tf_transform_error;
53
+
54
+ typedef int (*tf_transform_cancel_fn)(void *user);
55
+
56
+ typedef struct tf_transform_limits_v1 {
57
+ uint32_t abi_version;
58
+ uint32_t struct_size;
59
+ uint64_t max_recipe_bytes;
60
+ uint64_t max_plan_bytes;
61
+ uint64_t max_json_depth;
62
+ uint64_t max_object_keys;
63
+ uint64_t max_steps;
64
+ uint64_t max_input_columns;
65
+ uint64_t max_output_columns;
66
+ uint64_t max_categories_per_column;
67
+ uint64_t max_total_categories;
68
+ uint64_t max_string_bytes;
69
+ uint64_t max_decoded_string_bytes;
70
+ uint64_t max_analyzer_rows;
71
+ uint64_t max_analyzer_input_bytes;
72
+ uint64_t max_resident_state_bytes;
73
+ uint64_t max_spill_bytes;
74
+ uint64_t max_apply_rows;
75
+ uint64_t max_apply_input_bytes;
76
+ uint64_t max_output_elements_per_call;
77
+ uint64_t max_allocation_bytes;
78
+ uint64_t max_allocations_per_session;
79
+ uint64_t max_live_handles;
80
+ uint64_t max_retired_handle_slots;
81
+ } tf_transform_limits_v1;
82
+
83
+ typedef struct tf_transform_runtime_v1 {
84
+ uint32_t abi_version;
85
+ uint32_t struct_size;
86
+ const tf_transform_limits_v1 *limits;
87
+ const tf_host_policy *host_policy;
88
+ const uint8_t *spill_dir_utf8;
89
+ size_t spill_dir_bytes;
90
+ tf_transform_cancel_fn cancel;
91
+ void *cancel_user;
92
+ uint32_t flags;
93
+ uint32_t reserved;
94
+ } tf_transform_runtime_v1;
95
+
96
+ typedef struct tf_field_view_v1 {
97
+ uint32_t abi_version;
98
+ uint32_t struct_size;
99
+ uint32_t dtype;
100
+ uint32_t flags;
101
+ const uint8_t *id_utf8;
102
+ size_t id_bytes;
103
+ const uint8_t *name_utf8;
104
+ size_t name_bytes;
105
+ } tf_field_view_v1;
106
+
107
+ typedef struct tf_schema_view_v1 {
108
+ uint32_t abi_version;
109
+ uint32_t struct_size;
110
+ size_t column_count;
111
+ const tf_field_view_v1 *fields;
112
+ size_t fields_bytes;
113
+ } tf_schema_view_v1;
114
+
115
+ typedef struct tf_column_view_v1 {
116
+ uint32_t abi_version;
117
+ uint32_t struct_size;
118
+ const void *data;
119
+ size_t data_bytes;
120
+ size_t stride_bytes;
121
+ const uint8_t *validity;
122
+ size_t validity_bytes;
123
+ size_t validity_bit_offset;
124
+ size_t validity_bit_stride;
125
+ } tf_column_view_v1;
126
+
127
+ typedef struct tf_table_view_v1 {
128
+ uint32_t abi_version;
129
+ uint32_t struct_size;
130
+ size_t row_count;
131
+ size_t column_count;
132
+ const tf_column_view_v1 *columns;
133
+ size_t columns_bytes;
134
+ } tf_table_view_v1;
135
+
136
+ typedef struct tf_owned_dense_v1 {
137
+ uint32_t abi_version;
138
+ uint32_t struct_size;
139
+ uint32_t dtype;
140
+ uint32_t flags;
141
+ size_t rows;
142
+ size_t columns;
143
+ void *data;
144
+ size_t data_bytes;
145
+ } tf_owned_dense_v1;
146
+
147
+ tf_transform_code tf_transform_limits_init_safe_v1(
148
+ tf_transform_limits_v1 *out, size_t out_size);
149
+
150
+ tf_transform_code tf_transform_recipe_from_json(
151
+ const uint8_t *json, size_t json_len,
152
+ const tf_transform_limits_v1 *limits,
153
+ tf_transform_recipe **out, tf_transform_error **error);
154
+ tf_transform_code tf_transform_analyzer_create(
155
+ const tf_transform_recipe *recipe, const tf_schema_view_v1 *input_schema,
156
+ const tf_transform_runtime_v1 *runtime,
157
+ tf_transform_analyzer **out, tf_transform_error **error);
158
+ tf_transform_code tf_transform_analyzer_push(
159
+ tf_transform_analyzer *analyzer, const tf_table_view_v1 *table,
160
+ tf_transform_error **error);
161
+ tf_transform_code tf_transform_analyzer_finalize(
162
+ tf_transform_analyzer *analyzer, tf_transform_plan **out,
163
+ tf_transform_error **error);
164
+ tf_transform_code tf_transform_plan_export(
165
+ const tf_transform_plan *plan, const tf_transform_limits_v1 *limits,
166
+ uint8_t **out, size_t *out_len, tf_transform_error **error);
167
+ tf_transform_code tf_transform_plan_import(
168
+ const uint8_t *bytes, size_t len, const tf_transform_runtime_v1 *runtime,
169
+ tf_transform_plan **out, tf_transform_error **error);
170
+ tf_transform_code tf_transform_apply_create(
171
+ const tf_transform_plan *plan, const tf_schema_view_v1 *runtime_schema,
172
+ const tf_transform_runtime_v1 *runtime,
173
+ tf_transform_apply **out, tf_transform_error **error);
174
+ tf_transform_code tf_transform_apply_run(
175
+ tf_transform_apply *apply, const tf_table_view_v1 *table,
176
+ tf_owned_dense_v1 *out, tf_transform_error **error);
177
+
178
+ void tf_transform_recipe_destroy(tf_transform_recipe **recipe);
179
+ void tf_transform_analyzer_destroy(tf_transform_analyzer **analyzer);
180
+ void tf_transform_plan_destroy(tf_transform_plan **plan);
181
+ void tf_transform_apply_destroy(tf_transform_apply **apply);
182
+ void tf_transform_error_destroy(tf_transform_error **error);
183
+ void tf_transform_bytes_free(uint8_t **bytes, size_t *len);
184
+ void tf_owned_dense_free(tf_owned_dense_v1 *dense);
185
+
186
+ tf_transform_code tf_transform_error_get_code(const tf_transform_error *error);
187
+ const uint8_t *tf_transform_error_message(
188
+ const tf_transform_error *error, size_t *len);
189
+
190
+ tf_transform_code tf_transform_plan_schema(
191
+ const tf_transform_plan *plan, uint32_t which,
192
+ const tf_transform_schema **out, tf_transform_error **error);
193
+ size_t tf_transform_schema_field_count(const tf_transform_schema *schema);
194
+ tf_transform_code tf_transform_schema_field(
195
+ const tf_transform_schema *schema, size_t index,
196
+ tf_field_view_v1 *out, tf_transform_error **error);
197
+ tf_transform_code tf_transform_plan_schema_json(
198
+ const tf_transform_plan *plan, uint32_t which,
199
+ const tf_transform_limits_v1 *limits,
200
+ uint8_t **out, size_t *out_len, tf_transform_error **error);
201
+ tf_transform_code tf_transform_plan_recipe_sha256(
202
+ const tf_transform_plan *plan, const tf_transform_limits_v1 *limits,
203
+ uint8_t out_hex[65], tf_transform_error **error);
204
+
205
+ #ifdef __cplusplus
206
+ }
207
+ #endif
208
+
209
+ #endif