Skip to content

Commit 4c73ec0

Browse files
committed
read array
1 parent e1d453f commit 4c73ec0

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

app/src/metadata_reader.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ parser_error_t read_immediate(parser_context_t *ctx, primitive_t *primitive) {
222222
break;
223223
case PRIMITIVE_BYTE_VEC:
224224
print_string("Primitive byte vec");
225+
CHECK_ERROR(read_byte_display(ctx, &primitive->byte_vec.display));
225226
break;
226227
case PRIMITIVE_FLOAT32:
227228
print_string("Primitive float32");
@@ -504,6 +505,20 @@ parser_error_t read_tuple(parser_context_t *ctx, schema_tuple_t *schema_tuple) {
504505
return parser_ok;
505506
}
506507

508+
parser_error_t read_array(parser_context_t *ctx, schema_array_t *schema_array) {
509+
CHECK_INPUT(schema_array);
510+
CHECK_INPUT(ctx);
511+
512+
//read length
513+
CHECK_ERROR(read_u64(ctx, (uint64_t*)&schema_array->len));
514+
printf("array length: %llu\n", schema_array->len);
515+
516+
//read vec_type
517+
CHECK_ERROR(read_link(ctx, &schema_array->value));
518+
519+
return parser_ok;
520+
}
521+
507522
parser_error_t metadata_read(parser_context_t *ctx, parser_tx_t *txObj) {
508523
CHECK_INPUT(ctx);
509524
CHECK_INPUT(txObj);
@@ -515,7 +530,7 @@ parser_error_t metadata_read(parser_context_t *ctx, parser_tx_t *txObj) {
515530
}
516531

517532
// TODO: go through all schemes
518-
for (uint32_t i = 0; i < 18; i++) {
533+
for (uint32_t i = 0; i < 36; i++) {
519534
// read type
520535
CHECK_ERROR(read_u8(ctx, (uint8_t*)&txObj->schema.types.schemes[i].type));
521536
switch (txObj->schema.types.schemes[i].type) {
@@ -539,6 +554,11 @@ parser_error_t metadata_read(parser_context_t *ctx, parser_tx_t *txObj) {
539554
CHECK_ERROR(read_link(ctx, &txObj->schema.types.schemes[i].option_type));
540555
print_string("READING OPTION DONE\n");
541556
break;
557+
case LINKING_SCHEME_ARRAY:
558+
print_string("READING ARRAY");
559+
CHECK_ERROR(read_array(ctx, &txObj->schema.types.schemes[i].array_type));
560+
print_string("READING ARRAY DONE\n");
561+
break;
542562
case LINKING_SCHEME_VEC:
543563
print_string("READING VEC");
544564
CHECK_ERROR(read_link(ctx, &txObj->schema.types.schemes[i].vec_type));

app/src/parser_txdef.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ typedef struct {
139139
} primitive_byte_array_t;
140140

141141
typedef struct {
142-
byte_display_type_t display;
142+
byte_display_t display;
143143
} primitive_byte_vec_t;
144144

145145
typedef struct {
@@ -230,6 +230,11 @@ typedef struct {
230230
unnamed_field_t fields[MAX_FIELDS_QTY];
231231
} schema_option_t;
232232

233+
typedef struct {
234+
uint64_t len;
235+
link_t value;
236+
} schema_array_t;
237+
233238
typedef struct {
234239
linking_scheme_type_t type;
235240
union {
@@ -238,6 +243,7 @@ typedef struct {
238243
schema_tuple_t tuple_type;
239244
link_t option_type;
240245
link_t vec_type;
246+
schema_array_t array_type;
241247
};
242248
} linking_scheme_t;
243249

0 commit comments

Comments
 (0)