From a3753e205d82d44d0cb1827154839d63608bdf32 Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Wed, 16 Sep 2026 01:39:58 +0000 Subject: [PATCH] feat(vectordata): read manifests under the YAML 1.2 core schema The engine's default JSON schema reads a tilde as the string it spells; the reference writes a naming tag in a profile_tags schema as a tilde, and reads under the core schema, where it is null. --- .../io/nosqlbench/vectordata/internal/YamlData.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nb-vectordata/src/main/java/io/nosqlbench/vectordata/internal/YamlData.java b/nb-vectordata/src/main/java/io/nosqlbench/vectordata/internal/YamlData.java index a0327a46a..2ece24428 100644 --- a/nb-vectordata/src/main/java/io/nosqlbench/vectordata/internal/YamlData.java +++ b/nb-vectordata/src/main/java/io/nosqlbench/vectordata/internal/YamlData.java @@ -18,18 +18,25 @@ package io.nosqlbench.vectordata.internal; import io.nosqlbench.vectordata.VectorDataException; import org.snakeyaml.engine.v2.api.Load; import org.snakeyaml.engine.v2.api.LoadSettings; +import org.snakeyaml.engine.v2.schema.CoreSchema; import java.util.LinkedHashMap; import java.util.Map; -/** Checked conversion helpers for permissive YAML object trees. */ +/// Checked conversion helpers for permissive YAML object trees. +/// +/// Documents are read under the YAML 1.2 **core** schema, the dialect +/// the reference writes and reads: `~`, `null`, and `Null` are null — +/// a naming tag in a `profile_tags` schema is declared as `~` — and +/// `0x10` is an integer, while `yes` and `1_000` stay strings. The +/// engine's default JSON schema would read `~` as the string it spells. public final class YamlData { private YamlData() { } public static Map map(Object value, String label) { if (!(value instanceof Map raw)) throw new VectorDataException(label + " must be a YAML mapping"); Map result = new LinkedHashMap<>(); raw.forEach((key, item) -> result.put(String.valueOf(key), item)); return result; } - public static Object parseValue(String text, String label) { return new Load(LoadSettings.builder().setLabel(label).build()).loadFromString(text); } + public static Object parseValue(String text, String label) { return new Load(LoadSettings.builder().setLabel(label).setSchema(new CoreSchema()).build()).loadFromString(text); } public static Map parse(String text, String label) { return map(parseValue(text, label), label); } public static String string(Object value, String label) { if (value == null) throw new VectorDataException("Missing " + label); return String.valueOf(value); } public static String optionalString(Object value) { return value == null ? null : String.valueOf(value); }