tranfi 0.0.1 → 0.1.2
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.
- package/README.md +395 -0
- package/app/assets/index-6quYZ5Ap.css +5 -0
- package/app/assets/index-pDFMluyz.js +160 -0
- package/app/assets/materialdesignicons-webfont-B7mPwVP_.ttf +0 -0
- package/app/assets/materialdesignicons-webfont-CSr8KVlo.eot +0 -0
- package/app/assets/materialdesignicons-webfont-Dp5v-WZN.woff2 +0 -0
- package/app/assets/materialdesignicons-webfont-PXm3-2wK.woff +0 -0
- package/app/index.html +13 -0
- package/binding.gyp +69 -0
- package/csrc/arena.c +91 -0
- package/csrc/batch.c +229 -0
- package/csrc/buffer.c +78 -0
- package/csrc/cJSON.c +3143 -0
- package/csrc/cJSON.h +300 -0
- package/csrc/codec_csv.c +1058 -0
- package/csrc/codec_jsonl.c +374 -0
- package/csrc/codec_table.c +218 -0
- package/csrc/codec_text.c +229 -0
- package/csrc/compiler.c +102 -0
- package/csrc/date_utils.h +94 -0
- package/csrc/dsl.c +1180 -0
- package/csrc/dsl.h +22 -0
- package/csrc/expr.c +1245 -0
- package/csrc/expr.h +56 -0
- package/csrc/internal.h +250 -0
- package/csrc/ir.c +119 -0
- package/csrc/ir.h +167 -0
- package/csrc/ir_schema.c +60 -0
- package/csrc/ir_serialize.c +104 -0
- package/csrc/ir_sql.c +1211 -0
- package/csrc/ir_validate.c +120 -0
- package/csrc/main.c +392 -0
- package/csrc/op_acf.c +133 -0
- package/csrc/op_anomaly.c +120 -0
- package/csrc/op_bin.c +109 -0
- package/csrc/op_cast.c +195 -0
- package/csrc/op_clip.c +88 -0
- package/csrc/op_date_trunc.c +181 -0
- package/csrc/op_datetime.c +212 -0
- package/csrc/op_derive.c +248 -0
- package/csrc/op_diff.c +134 -0
- package/csrc/op_ewma.c +103 -0
- package/csrc/op_explode.c +108 -0
- package/csrc/op_fill_down.c +163 -0
- package/csrc/op_fill_null.c +123 -0
- package/csrc/op_filter.c +132 -0
- package/csrc/op_frequency.c +193 -0
- package/csrc/op_grep.c +163 -0
- package/csrc/op_group_agg.c +285 -0
- package/csrc/op_hash.c +126 -0
- package/csrc/op_head.c +149 -0
- package/csrc/op_interpolate.c +239 -0
- package/csrc/op_join.c +384 -0
- package/csrc/op_label_encode.c +144 -0
- package/csrc/op_lead.c +190 -0
- package/csrc/op_normalize.c +226 -0
- package/csrc/op_onehot.c +185 -0
- package/csrc/op_pivot.c +370 -0
- package/csrc/op_registry.c +1148 -0
- package/csrc/op_rename.c +138 -0
- package/csrc/op_replace.c +202 -0
- package/csrc/op_sample.c +101 -0
- package/csrc/op_select.c +140 -0
- package/csrc/op_skip.c +152 -0
- package/csrc/op_sort.c +273 -0
- package/csrc/op_split.c +114 -0
- package/csrc/op_split_data.c +87 -0
- package/csrc/op_stack.c +315 -0
- package/csrc/op_stats.c +779 -0
- package/csrc/op_step.c +171 -0
- package/csrc/op_tail.c +96 -0
- package/csrc/op_top.c +150 -0
- package/csrc/op_trim.c +109 -0
- package/csrc/op_unique.c +300 -0
- package/csrc/op_unpivot.c +159 -0
- package/csrc/op_validate.c +71 -0
- package/csrc/op_window.c +150 -0
- package/csrc/pipeline.c +315 -0
- package/csrc/plan.c +206 -0
- package/csrc/recipes.c +102 -0
- package/csrc/recipes.h +27 -0
- package/csrc/report.c +463 -0
- package/csrc/report.h +22 -0
- package/csrc/tranfi.h +123 -0
- package/csrc/wasm_api.c +157 -0
- package/napi_api.c +326 -0
- package/package.json +46 -57
- package/src/cli.js +193 -0
- package/src/engines/duckdb.js +109 -0
- package/src/index.js +306 -0
- package/src/native.js +22 -0
- package/src/pipeline.js +286 -0
- package/src/server.js +277 -0
- package/src/wasm.js +19 -0
- package/wasm/index.js +244 -0
- package/wasm/package.json +1 -0
- package/wasm/tranfi_core.js +0 -0
- package/LICENSE +0 -21
- package/dist/bundle.js +0 -1
- package/index.html +0 -18
- package/logo.png +0 -0
- package/src/app.css +0 -160
- package/src/app.js +0 -203
- package/src/app.vue +0 -253
- package/src/bulma-input.vue +0 -110
- package/src/common-inputs.js +0 -28
- package/src/main.js +0 -18
- package/src/transforms.js +0 -166
- package/webpack.config.js +0 -108
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ir_serialize.c — IR plan ↔ JSON serialization.
|
|
3
|
+
*
|
|
4
|
+
* JSON format (the .tfp format):
|
|
5
|
+
* {
|
|
6
|
+
* "steps": [
|
|
7
|
+
* {"op": "codec.csv.decode", "args": {"delimiter": ","}},
|
|
8
|
+
* {"op": "filter", "args": {"expr": "col('age') > 25"}},
|
|
9
|
+
* {"op": "codec.csv.encode", "args": {}}
|
|
10
|
+
* ]
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#include "ir.h"
|
|
15
|
+
#include "cJSON.h"
|
|
16
|
+
#include <stdlib.h>
|
|
17
|
+
#include <string.h>
|
|
18
|
+
#include <stdio.h>
|
|
19
|
+
|
|
20
|
+
static void set_error(char **error, const char *msg) {
|
|
21
|
+
if (error) {
|
|
22
|
+
free(*error);
|
|
23
|
+
size_t len = strlen(msg) + 1;
|
|
24
|
+
*error = malloc(len);
|
|
25
|
+
if (*error) memcpy(*error, msg, len);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
tf_ir_plan *tf_ir_from_json(const char *json, size_t len, char **error) {
|
|
30
|
+
if (error) *error = NULL;
|
|
31
|
+
|
|
32
|
+
cJSON *root = cJSON_ParseWithLength(json, len);
|
|
33
|
+
if (!root) {
|
|
34
|
+
set_error(error, "invalid JSON in plan");
|
|
35
|
+
return NULL;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
cJSON *steps_arr = cJSON_GetObjectItemCaseSensitive(root, "steps");
|
|
39
|
+
if (!cJSON_IsArray(steps_arr)) {
|
|
40
|
+
set_error(error, "plan must have a 'steps' array");
|
|
41
|
+
cJSON_Delete(root);
|
|
42
|
+
return NULL;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
int n = cJSON_GetArraySize(steps_arr);
|
|
46
|
+
if (n == 0) {
|
|
47
|
+
set_error(error, "plan has no steps");
|
|
48
|
+
cJSON_Delete(root);
|
|
49
|
+
return NULL;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
tf_ir_plan *plan = tf_ir_plan_create();
|
|
53
|
+
if (!plan) {
|
|
54
|
+
set_error(error, "out of memory");
|
|
55
|
+
cJSON_Delete(root);
|
|
56
|
+
return NULL;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (int i = 0; i < n; i++) {
|
|
60
|
+
cJSON *step = cJSON_GetArrayItem(steps_arr, i);
|
|
61
|
+
cJSON *op = cJSON_GetObjectItemCaseSensitive(step, "op");
|
|
62
|
+
cJSON *args = cJSON_GetObjectItemCaseSensitive(step, "args");
|
|
63
|
+
|
|
64
|
+
if (!cJSON_IsString(op)) {
|
|
65
|
+
char buf[64];
|
|
66
|
+
snprintf(buf, sizeof(buf), "step %d missing 'op' string", i);
|
|
67
|
+
set_error(error, buf);
|
|
68
|
+
tf_ir_plan_free(plan);
|
|
69
|
+
cJSON_Delete(root);
|
|
70
|
+
return NULL;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (tf_ir_plan_add_node(plan, op->valuestring, args) != 0) {
|
|
74
|
+
set_error(error, "out of memory adding node");
|
|
75
|
+
tf_ir_plan_free(plan);
|
|
76
|
+
cJSON_Delete(root);
|
|
77
|
+
return NULL;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
cJSON_Delete(root);
|
|
82
|
+
return plan;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
char *tf_ir_to_json(const tf_ir_plan *plan) {
|
|
86
|
+
cJSON *root = cJSON_CreateObject();
|
|
87
|
+
cJSON *steps = cJSON_AddArrayToObject(root, "steps");
|
|
88
|
+
|
|
89
|
+
for (size_t i = 0; i < plan->n_nodes; i++) {
|
|
90
|
+
const tf_ir_node *node = &plan->nodes[i];
|
|
91
|
+
cJSON *step = cJSON_CreateObject();
|
|
92
|
+
cJSON_AddStringToObject(step, "op", node->op);
|
|
93
|
+
if (node->args) {
|
|
94
|
+
cJSON_AddItemToObject(step, "args", cJSON_Duplicate(node->args, 1));
|
|
95
|
+
} else {
|
|
96
|
+
cJSON_AddItemToObject(step, "args", cJSON_CreateObject());
|
|
97
|
+
}
|
|
98
|
+
cJSON_AddItemToArray(steps, step);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
char *out = cJSON_PrintUnformatted(root);
|
|
102
|
+
cJSON_Delete(root);
|
|
103
|
+
return out;
|
|
104
|
+
}
|