{"modulePath":"github.com/apache/skywalking-banyandb","version":"v0.11.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package vararray\n\nPackage vararray holds the escaped, delimiter-separated variable-length array codec (MarshalVarArray / UnmarshalVarArray and the delimiter/escape bytes). It is a dependency-free leaf (imports only stdlib), so consumers that need only this codec — e.g. the plugin SDK at pkg/pipeline/sdk — can use it without transitively pulling in pkg/encoding's logging dependencies. pkg/encoding forwards to these functions, so existing encoding.\\*VarArray callers are unaffected.\n\n## Constants\n\n```go\nconst (\n\t// EntityDelimiter is the delimiter for entities in a variable-length array.\n\tEntityDelimiter = '|'\n\t// Escape is the escape character for entities in a variable-length array.\n\tEscape = '\\\\'\n)\n```\n\n## Functions\n\n```go\nfunc MarshalVarArray(dest, src []byte) []byte\n```\nMarshalVarArray marshals a byte slice into a variable-length array format. It escapes delimiter and escape characters within the source slice.\n\n```go\nfunc UnmarshalVarArray(src []byte, idx int) (int, int, error)\n```\nUnmarshalVarArray unmarshals a variable-length array from src starting at idx.\n\nWARNING: This function mutates src when the entry contains an escape. Decoding is then performed in-place by overwriting bytes in src\\[idx:next) to remove escape characters. The decoded value is the view src\\[idx:end] into the same backing array; copy it (for example, with bytes.Clone or append(\\[]byte(nil), ...)) if you need to preserve the original encoded buffer or keep the decoded value independent of subsequent in-place decoding on the same buffer.\n\nAn entry with no escape byte is decoded without writing to src at all. Do NOT read that as \"src is safe from mutation\": whether a write happens is a property of the DATA, not of the call. A caller may only skip its defensive copy behind its own escape check (e.g. bytes.IndexByte(row, Escape) \\\u003c 0) — never unconditionally.\n\nIt returns:\n\n  - end: the index of the first byte after the decoded value (exclusive)\n  - next: the index of the next element (the byte after the delimiter)\n\nThe caller can iterate without creating subslices by tracking indices:\n\n\tfor idx \u003c len(src) {\n\t    end, next, err := UnmarshalVarArray(src, idx)\n\t    // use src[idx:end]\n\t    idx = next\n\t}\n\n","path":"github.com/apache/skywalking-banyandb/pkg/encoding/vararray","name":"vararray","synopsis":"Package vararray holds the escaped, delimiter-separated variable-length array codec (MarshalVarArray / UnmarshalVarArray and the delimiter/escape bytes).","isRedistributable":true}
