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.
This commit is contained in:
Jonathan Shook committed 2026-09-16 01:39:58 +00:00
1 parent 0b7ebc12a9
commit a3753e205d
1 file changed
+9 -2
@@ -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<String, Object> map(Object value, String label) {
if (!(value instanceof Map<?, ?> raw)) throw new VectorDataException(label + " must be a YAML mapping");
Map<String, Object> 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<String, Object> 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); }