diff options
author | YDBot <[email protected]> | 2025-07-26 00:52:12 +0000 |
---|---|---|
committer | YDBot <[email protected]> | 2025-07-26 00:52:12 +0000 |
commit | c641bf9f3666236b4c2e81273c2c5563c54e4df4 (patch) | |
tree | 1ff5c8e694c9a78ee0e2ad3b0ff5bb5b03818bc7 | |
parent | ff32dad4c0a4ac13a90dfb44fdd19a5454cfe13e (diff) | |
parent | 8261eb9dc960f33f6454ac242c06ee8c8bcef5b0 (diff) |
Sync branches 250726-0050
114 files changed, 2460 insertions, 1174 deletions
diff --git a/build/conf/python.conf b/build/conf/python.conf index 4b824fa7db6..a82ae33a474 100644 --- a/build/conf/python.conf +++ b/build/conf/python.conf @@ -1043,7 +1043,7 @@ macro NO_CYTHON_COVERAGE() { ### It is strongly advised to make this conversion explicit. Never use PY_SRCS in a LIBRARY if you plan to use it from external Python extension module. ### ### Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs/#modulipylibrarypy3libraryimakrospysrcs -macro PY_SRCS() { +macro PY_SRCS(Args...) { DEFAULT(MODULE_TAG PY3) } diff --git a/build/export_generators/ide-gradle/plugins.jinja b/build/export_generators/ide-gradle/plugins.jinja index db19095720c..991d9d43132 100644 --- a/build/export_generators/ide-gradle/plugins.jinja +++ b/build/export_generators/ide-gradle/plugins.jinja @@ -33,7 +33,7 @@ plugins { {%- endif -%} {%- if with_lombok_plugin %} - id("io.freefair.lombok") version "8.6" + id("io.freefair.lombok") version "8.14" {%- endif %} } diff --git a/build/export_generators/ide-gradle/source_sets.jinja b/build/export_generators/ide-gradle/source_sets.jinja index 9fdd81a46bf..befb7d09705 100644 --- a/build/export_generators/ide-gradle/source_sets.jinja +++ b/build/export_generators/ide-gradle/source_sets.jinja @@ -14,22 +14,46 @@ #} {{ module }}.srcDir({{ PatchRoots(dir) }}) {%- endif -%} -{%- endmacro %} +{%- endmacro -%} -sourceSets { -{%- if target.source_sets|length or target.resource_sets|length or proto_template %} - main { -{%- if target.source_sets|length -%} -{%- for source_set in target.source_sets -%} -{{ SomeSet(source_set, "java") }} +{%- macro TargetSets(current_target, target_subdir, reldir = "") -%} +{%- if current_target.source_sets|length -%} +{%- if auto_resource_sets -%} +{%- set source_sets = current_target.source_sets|rejectattr('dir', 'eq', 'resources')|rejectattr('dir', 'eq', 'src/' + target_subdir + '/resources') -%} +{%- else -%} +{%- set source_sets = current_target.source_sets -%} +{%- endif -%} +{%- else -%} +{%- set source_sets = [] -%} +{%- endif -%} +{%- if source_sets|length -%} +{%- for source_set in source_sets -%} +{{ SomeSet(source_set, "java", reldir) }} {%- endfor -%} {%- endif -%} - -{%- if target.resource_sets|length -%} -{%- for resource_set in target.resource_sets -%} -{{ SomeSet(resource_set, "resources") }} +{%- if current_target.resource_sets|length -%} +{%- set resource_sets = current_target.resource_sets -%} +{%- else -%} +{%- set resource_sets = [] -%} +{%- endif -%} +{%- if auto_resource_sets and current_target.source_sets|length -%} +{%- set source2resource_sets = current_target.source_sets|selectattr('dir', 'in', ['resources', 'src/' + target_subdir + '/resources']) -%} +{%- if source2resource_sets|length -%} +{%- set resource_sets = resource_sets + source2resource_sets -%} +{%- endif -%} +{%- endif -%} +{%- if resource_sets|length -%} +{%- for resource_set in resource_sets -%} +{{ SomeSet(resource_set, "resources", reldir) }} {%- endfor -%} {%- endif -%} +{%- endmacro %} + +sourceSets { +{%- if target.source_sets|length or target.resource_sets|length or proto_template %} + main { +{#- glue -#} +{{ TargetSets(target, "main") }} {%- if proto_template and symlinks_to_generated %} java.srcDir("generated/source/proto/main/java") @@ -53,12 +77,7 @@ sourceSets { {%- if extra_target.test_reldir -%} {%- set reldir = extra_target.test_reldir + "/" -%} {%- endif -%} -{%- for source_set in extra_target.source_sets -%} -{{ SomeSet(source_set, "java", reldir) }} -{%- endfor -%} -{%- for resource_set in extra_target.resource_sets -%} -{{ SomeSet(resource_set, "resources", reldir) }} -{%- endfor -%} +{{ TargetSets(extra_target, "test", reldir) }} {%- endfor %} } {% else %} diff --git a/build/platform/lld/ya.make b/build/platform/lld/ya.make index 568b9c652f1..b6f67da9bf4 100644 --- a/build/platform/lld/ya.make +++ b/build/platform/lld/ya.make @@ -7,7 +7,9 @@ VERSION(${LLD_VERSION}) # There is no backward compatibility between LLVM IR versions 16 and 18. # So, we need to select lld18 when using clang18 to compile src in LTO mode. -IF (LLD_VERSION == 18) +IF (LLD_VERSION == 20) + DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE_BY_JSON(LLD_ROOT lld20.json) +ELSEIF (LLD_VERSION == 18) DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE_BY_JSON(LLD_ROOT lld18.json) ELSEIF (LLD_VERSION == 16) DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE_BY_JSON(LLD_ROOT lld16.json) diff --git a/build/sysincl/libc-to-nothing.yml b/build/sysincl/libc-to-nothing.yml index 389ecd717f0..ba21103bb3b 100644 --- a/build/sysincl/libc-to-nothing.yml +++ b/build/sysincl/libc-to-nothing.yml @@ -130,6 +130,7 @@ - sys/fanotify.h - sys/fcntl.h - sys/file.h + - sys/frame.h - sys/fsuid.h - sys/ifunc.h - sys/inotify.h diff --git a/build/ya.conf.json b/build/ya.conf.json index cf651686025..c0bb67952cb 100644 --- a/build/ya.conf.json +++ b/build/ya.conf.json @@ -200,6 +200,55 @@ }, "formula": "build/platform/clang/clang18.json" }, + "clang20": { + "executable": { + "c++": [ + "bin", + "clang++" + ], + "c++filt": [ + "bin", + "llvm-cxxfilt" + ], + "cc": [ + "bin", + "clang" + ], + "clang-rename": [ + "bin", + "clang-rename" + ], + "llvm-cov": [ + "bin", + "llvm-cov" + ], + "llvm-gcov": [ + "bin", + "llvm-gcov" + ], + "llvm-nm": [ + "bin", + "llvm-nm" + ], + "llvm-objcopy": [ + "bin", + "llvm-objcopy" + ], + "llvm-profdata": [ + "bin", + "llvm-profdata" + ], + "llvm-strip": [ + "bin", + "llvm-strip" + ], + "llvm-symbolizer": [ + "bin", + "llvm-symbolizer" + ] + }, + "formula": "build/platform/clang/clang20.json" + }, "clangd": { "executable": { "clangd": [ @@ -1971,6 +2020,704 @@ } } }, + "clang20": { + "env": { + "CPATH": [ + "" + ], + "LIBRARY_PATH": [ + "" + ], + "SDKROOT": [ + "" + ] + }, + "params": { + "c_compiler": "$(CLANG)/bin/clang", + "cxx_compiler": "$(CLANG)/bin/clang++", + "llvm-symbolizer": "$(CLANG)/bin/llvm-symbolizer", + "match_root": "CLANG", + "nm": "$(CLANG)/bin/llvm-nm", + "objcopy": "$(CLANG)/bin/llvm-objcopy", + "profiles": "$(XCODE_TOOLS_ROOT-sbr:799017771)/Xcode/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles", + "simctl": "$(XCODE_TOOLS_ROOT-sbr:799017771)/Xcode/SystemRoot/PrivateFrameworks/CoreSimulator.framework/Resources/bin/simctl", + "strip": "$(CLANG)/bin/llvm-strip", + "type": "clang", + "use_bundle": true, + "version": "20" + }, + "platforms": [ + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "x86_64", + "os": "FREEBSD" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "x86_64", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "aarch64", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "aarch64", + "os": "LINUX" + }, + "target": { + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "aarch64", + "os": "LINUX" + }, + "target": { + "arch": "aarch64", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "ppc64le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "power9le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "x86_64", + "os": "DARWIN" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "arm64", + "os": "DARWIN" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "i386", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "x86_64", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv7", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "arm64", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "arm64", + "os": "IOSSIM" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv7a", + "os": "YOCTO" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "x86_64", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "aarch64", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "ppc64le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "power9le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "x86_64", + "os": "DARWIN" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "arm64", + "os": "DARWIN" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "i386", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "x86_64", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "armv7", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "arm64", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "arm64", + "os": "IOSSIM" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "x86_64", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "aarch64", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "ppc64le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "power9le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "x86_64", + "os": "DARWIN" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "arm64", + "os": "DARWIN" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "i386", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "x86_64", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "armv7", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "arm64", + "os": "IOS" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "arm64", + "os": "IOSSIM" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv6hf", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv7a", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv7a_cortex_a9", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv7ahf_cortex_a35", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv7ahf_cortex_a53", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv7ahf", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv8a_cortex_a35", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "armv8a_cortex_a53", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "ppc64le", + "os": "LINUX" + }, + "target": { + "arch": "ppc64le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "arch": "ppc64le", + "os": "LINUX" + }, + "target": { + "arch": "power9le", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "DARWIN" + }, + "target": { + "arch": "armv7ahf_cortex_a53", + "os": "LINUX" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "wasm32", + "os": "EMSCRIPTEN" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "wasm64", + "os": "EMSCRIPTEN" + } + }, + { + "default": false, + "host": { + "arch": "arm64", + "os": "DARWIN" + }, + "target": { + "arch": "armv7ahf_cortex_a53", + "os": "LINUX" + } + } + ], + "tools": { + "c++": { + "bottle": "clang20", + "executable": "c++" + }, + "c++filt": { + "bottle": "clang20", + "executable": "c++filt" + }, + "cc": { + "bottle": "clang20", + "executable": "cc" + }, + "clang-rename": { + "bottle": "clang20", + "executable": "clang-rename" + }, + "gcov": { + "bottle": "clang20", + "executable": "llvm-gcov" + }, + "llvm-cov": { + "bottle": "clang20", + "executable": "llvm-cov" + }, + "llvm-profdata": { + "bottle": "clang20", + "executable": "llvm-profdata" + }, + "llvm-symbolizer": { + "bottle": "clang20", + "executable": "llvm-symbolizer" + }, + "nm": { + "bottle": "clang20", + "executable": "llvm-nm" + }, + "objcopy": { + "bottle": "clang20", + "executable": "llvm-objcopy" + }, + "strip": { + "bottle": "clang20", + "executable": "llvm-strip" + } + } + }, + "clang20-windows": { + "name": "clang20", + "params": { + "c_compiler": "$(CLANG)/bin/clang-cl", + "cxx_compiler": "$(CLANG)/bin/clang-cl", + "cxx_std": "c++20", + "llvm-symbolizer": "$(CLANG)/bin/llvm-symbolizer", + "match_root": "CLANG", + "type": "msvc", + "use_bundle": true, + "use_clang": true, + "version": "20" + }, + "platforms": [ + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "x86_64", + "os": "WIN" + } + }, + { + "default": false, + "host": { + "os": "LINUX" + }, + "target": { + "arch": "i686", + "os": "WIN" + } + }, + { + "default": false, + "host": { + "os": "WIN" + }, + "target": { + "arch": "x86_64", + "os": "WIN" + } + }, + { + "default": false, + "host": { + "os": "WIN" + }, + "target": { + "arch": "i686", + "os": "WIN" + } + } + ], + "tools": { + "c++": { + "bottle": "clang20", + "executable": "c++" + }, + "c++filt": { + "bottle": "clang20", + "executable": "c++filt" + }, + "cc": { + "bottle": "clang20", + "executable": "cc" + }, + "gcov": { + "bottle": "clang20", + "executable": "llvm-gcov" + }, + "llvm-cov": { + "bottle": "clang20", + "executable": "llvm-cov" + }, + "llvm-profdata": { + "bottle": "clang20", + "executable": "llvm-profdata" + }, + "llvm-symbolizer": { + "bottle": "clang20", + "executable": "llvm-symbolizer" + }, + "nm": { + "bottle": "clang20", + "executable": "llvm-nm" + }, + "objcopy": { + "bottle": "clang20", + "executable": "llvm-objcopy" + }, + "strip": { + "bottle": "clang20", + "executable": "llvm-strip" + } + } + }, "clangd": { "platforms": [ { diff --git a/build/ymake.core.conf b/build/ymake.core.conf index 68878248a82..a88e1fca8be 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -2337,6 +2337,7 @@ module _PACKAGE_FINAL: _BASE_UNIT { multimodule PACKAGE { module PACKAGE_FINAL: _PACKAGE_FINAL { .PEERDIRSELF=PACKAGE_UNION + .IGNORED=DECLARE_IN_DIRS } module PACKAGE_UNION: UNION { diff --git a/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix b/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix index 39257f117d8..9025d8985fe 100644 --- a/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix +++ b/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix @@ -1,10 +1,10 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "0.12.3"; + version = "0.12.4"; src = fetchFromGitHub { owner = "awslabs"; repo = "aws-c-common"; rev = "v${version}"; - hash = "sha256-mOn2JZnqWHZ0M6PYkkckCyDjCdp9kKup6CYEew8AgKw="; + hash = "sha256-hKCIPZlLPyH7D3Derk2onyqTzWGUtCx+f2+EKtAKlwA="; }; } diff --git a/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt b/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt index 4a3e34675de..876ab4ea789 100644 --- a/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt +++ b/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt @@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------ -** cJSON; version 1.7.16 -- https://github.com/DaveGamble/cJSON +** cJSON; version 1.7.18 -- https://github.com/DaveGamble/cJSON Copyright (c) 2009-2017 Dave Gamble and cJSON contributors Permission is hereby granted, free of charge, to any person obtaining a copy @@ -57,7 +57,7 @@ THE SOFTWARE. ------ -** libcbor; version 0.11.0 -- https://github.com/PJK/libcbor +** libcbor; version 0.12.0 -- https://github.com/PJK/libcbor Copyright (c) 2014-2017 Pavel Kalvoda MIT License diff --git a/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl b/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl index 1204be06a1c..d485ac38bc1 100644 --- a/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl +++ b/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl @@ -35,10 +35,8 @@ AWS_STATIC_IMPL uint64_t aws_hton64(uint64_t x) { if (aws_is_big_endian()) { return x; } -#if defined(__x86_64__) && (defined(__GNUC__) || defined(__clang__)) && !defined(CBMC) - uint64_t v; - __asm__("bswap %q0" : "=r"(v) : "0"(x)); - return v; +#if (defined(__GNUC__) || defined(__clang__)) && !defined(CBMC) + return __builtin_bswap64(x); #elif defined(_MSC_VER) return _byteswap_uint64(x); #else diff --git a/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h b/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h index e3d9b1adeba..60e12d703f1 100644 --- a/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h +++ b/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h @@ -18,12 +18,15 @@ struct aws_uuid { /* 36 bytes for the UUID plus one more for the null terminator. */ enum { AWS_UUID_STR_LEN = 37 }; +/* 32 bytes for the UUID (no dashes) plus one more for the null terminator. */ +enum { AWS_UUID_STR_COMPACT_LEN = 33 }; AWS_EXTERN_C_BEGIN AWS_COMMON_API int aws_uuid_init(struct aws_uuid *uuid); AWS_COMMON_API int aws_uuid_init_from_str(struct aws_uuid *uuid, const struct aws_byte_cursor *uuid_str); AWS_COMMON_API int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output); +AWS_COMMON_API int aws_uuid_to_str_compact(const struct aws_uuid *uuid, struct aws_byte_buf *output); AWS_COMMON_API bool aws_uuid_equals(const struct aws_uuid *a, const struct aws_uuid *b); AWS_EXTERN_C_END diff --git a/contrib/restricted/aws/aws-c-common/source/external/cJSON.h b/contrib/restricted/aws/aws-c-common/source/external/cJSON.h index 48cdda9acb0..d5a402f1790 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/cJSON.h +++ b/contrib/restricted/aws/aws-c-common/source/external/cJSON.h @@ -264,7 +264,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. - * The input pointer json cannot point to a read-only address area, such as a string constant, + * The input pointer json cannot point to a read-only address area, such as a string constant, * but should point to a readable and writable address area. */ CJSON_PUBLIC(void) cJSON_Minify(char *json); diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c index a8b4bcd7a08..819ff6077c3 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c @@ -9,9 +9,8 @@ #include "cbor/internal/builder_callbacks.h" #include "cbor/internal/loaders.h" -#pragma clang diagnostic push -cbor_item_t *cbor_load(cbor_data source, size_t source_size, - struct cbor_load_result *result) { +cbor_item_t* cbor_load(cbor_data source, size_t source_size, + struct cbor_load_result* result) { /* Context stack */ static struct cbor_callbacks callbacks = { .uint8 = &cbor_builder_uint8_callback, @@ -115,8 +114,8 @@ error: return NULL; } -static cbor_item_t *_cbor_copy_int(cbor_item_t *item, bool negative) { - cbor_item_t *res; +static cbor_item_t* _cbor_copy_int(cbor_item_t* item, bool negative) { + cbor_item_t* res = NULL; switch (cbor_int_get_width(item)) { case CBOR_INT_8: res = cbor_build_uint8(cbor_get_uint8(item)); @@ -137,8 +136,7 @@ static cbor_item_t *_cbor_copy_int(cbor_item_t *item, bool negative) { return res; } -static cbor_item_t *_cbor_copy_float_ctrl(cbor_item_t *item) { - // cppcheck-suppress missingReturn +static cbor_item_t* _cbor_copy_float_ctrl(cbor_item_t* item) { switch (cbor_float_get_width(item)) { case CBOR_FLOAT_0: return cbor_build_ctrl(cbor_ctrl_value(item)); @@ -148,11 +146,13 @@ static cbor_item_t *_cbor_copy_float_ctrl(cbor_item_t *item) { return cbor_build_float4(cbor_float_get_float4(item)); case CBOR_FLOAT_64: return cbor_build_float8(cbor_float_get_float8(item)); + default: + _CBOR_UNREACHABLE; + return NULL; } } -cbor_item_t *cbor_copy(cbor_item_t *item) { - // cppcheck-suppress missingReturn +cbor_item_t* cbor_copy(cbor_item_t* item) { switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: return _cbor_copy_int(item, false); @@ -163,13 +163,13 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return cbor_build_bytestring(cbor_bytestring_handle(item), cbor_bytestring_length(item)); } else { - cbor_item_t *res = cbor_new_indefinite_bytestring(); + cbor_item_t* res = cbor_new_indefinite_bytestring(); if (res == NULL) { return NULL; } for (size_t i = 0; i < cbor_bytestring_chunk_count(item); i++) { - cbor_item_t *chunk_copy = + cbor_item_t* chunk_copy = cbor_copy(cbor_bytestring_chunks_handle(item)[i]); if (chunk_copy == NULL) { cbor_decref(&res); @@ -186,16 +186,16 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { } case CBOR_TYPE_STRING: if (cbor_string_is_definite(item)) { - return cbor_build_stringn((const char *)cbor_string_handle(item), + return cbor_build_stringn((const char*)cbor_string_handle(item), cbor_string_length(item)); } else { - cbor_item_t *res = cbor_new_indefinite_string(); + cbor_item_t* res = cbor_new_indefinite_string(); if (res == NULL) { return NULL; } for (size_t i = 0; i < cbor_string_chunk_count(item); i++) { - cbor_item_t *chunk_copy = + cbor_item_t* chunk_copy = cbor_copy(cbor_string_chunks_handle(item)[i]); if (chunk_copy == NULL) { cbor_decref(&res); @@ -211,7 +211,7 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return res; } case CBOR_TYPE_ARRAY: { - cbor_item_t *res; + cbor_item_t* res; if (cbor_array_is_definite(item)) { res = cbor_new_definite_array(cbor_array_size(item)); } else { @@ -222,7 +222,7 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { } for (size_t i = 0; i < cbor_array_size(item); i++) { - cbor_item_t *entry_copy = cbor_copy(cbor_move(cbor_array_get(item, i))); + cbor_item_t* entry_copy = cbor_copy(cbor_move(cbor_array_get(item, i))); if (entry_copy == NULL) { cbor_decref(&res); return NULL; @@ -237,7 +237,7 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return res; } case CBOR_TYPE_MAP: { - cbor_item_t *res; + cbor_item_t* res; if (cbor_map_is_definite(item)) { res = cbor_new_definite_map(cbor_map_size(item)); } else { @@ -247,14 +247,14 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return NULL; } - struct cbor_pair *it = cbor_map_handle(item); + struct cbor_pair* it = cbor_map_handle(item); for (size_t i = 0; i < cbor_map_size(item); i++) { - cbor_item_t *key_copy = cbor_copy(it[i].key); + cbor_item_t* key_copy = cbor_copy(it[i].key); if (key_copy == NULL) { cbor_decref(&res); return NULL; } - cbor_item_t *value_copy = cbor_copy(it[i].value); + cbor_item_t* value_copy = cbor_copy(it[i].value); if (value_copy == NULL) { cbor_decref(&res); cbor_decref(&key_copy); @@ -273,16 +273,19 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return res; } case CBOR_TYPE_TAG: { - cbor_item_t *item_copy = cbor_copy(cbor_move(cbor_tag_item(item))); + cbor_item_t* item_copy = cbor_copy(cbor_move(cbor_tag_item(item))); if (item_copy == NULL) { return NULL; } - cbor_item_t *tag = cbor_build_tag(cbor_tag_value(item), item_copy); + cbor_item_t* tag = cbor_build_tag(cbor_tag_value(item), item_copy); cbor_decref(&item_copy); return tag; } case CBOR_TYPE_FLOAT_CTRL: return _cbor_copy_float_ctrl(item); + default: + _CBOR_UNREACHABLE; + return NULL; } } @@ -301,11 +304,11 @@ static int _pow(int b, int ex) { return res; } -static void _cbor_type_marquee(FILE *out, char *label, int indent) { +static void _cbor_type_marquee(FILE* out, char* label, int indent) { fprintf(out, "%*.*s[%s] ", indent, indent, " ", label); } -static void _cbor_nested_describe(cbor_item_t *item, FILE *out, int indent) { +static void _cbor_nested_describe(cbor_item_t* item, FILE* out, int indent) { const int indent_offset = 4; switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: { @@ -329,7 +332,7 @@ static void _cbor_nested_describe(cbor_item_t *item, FILE *out, int indent) { _cbor_nested_describe(cbor_bytestring_chunks_handle(item)[i], out, indent + indent_offset); } else { - const unsigned char *data = cbor_bytestring_handle(item); + const unsigned char* data = cbor_bytestring_handle(item); fprintf(out, "Definite, Length: %zuB, Data:\n", cbor_bytestring_length(item)); fprintf(out, "%*s", indent + indent_offset, " "); @@ -418,7 +421,7 @@ static void _cbor_nested_describe(cbor_item_t *item, FILE *out, int indent) { } } -void cbor_describe(cbor_item_t *item, FILE *out) { +void cbor_describe(cbor_item_t* item, FILE* out) { _cbor_nested_describe(item, out, 0); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c index a23bbe3cd15..174c97e9a61 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c @@ -9,21 +9,21 @@ #include <string.h> #include "internal/memory_utils.h" -size_t cbor_array_size(const cbor_item_t *item) { +size_t cbor_array_size(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.end_ptr; } -size_t cbor_array_allocated(const cbor_item_t *item) { +size_t cbor_array_allocated(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.allocated; } -cbor_item_t *cbor_array_get(const cbor_item_t *item, size_t index) { - return cbor_incref(((cbor_item_t **)item->data)[index]); +cbor_item_t* cbor_array_get(const cbor_item_t* item, size_t index) { + return cbor_incref(((cbor_item_t**)item->data)[index]); } -bool cbor_array_set(cbor_item_t *item, size_t index, cbor_item_t *value) { +bool cbor_array_set(cbor_item_t* item, size_t index, cbor_item_t* value) { if (index == item->metadata.array_metadata.end_ptr) { return cbor_array_push(item, value); } else if (index < item->metadata.array_metadata.end_ptr) { @@ -33,19 +33,19 @@ bool cbor_array_set(cbor_item_t *item, size_t index, cbor_item_t *value) { } } -bool cbor_array_replace(cbor_item_t *item, size_t index, cbor_item_t *value) { +bool cbor_array_replace(cbor_item_t* item, size_t index, cbor_item_t* value) { if (index >= item->metadata.array_metadata.end_ptr) return false; /* We cannot use cbor_array_get as that would increase the refcount */ - cbor_intermediate_decref(((cbor_item_t **)item->data)[index]); - ((cbor_item_t **)item->data)[index] = cbor_incref(value); + cbor_intermediate_decref(((cbor_item_t**)item->data)[index]); + ((cbor_item_t**)item->data)[index] = cbor_incref(value); return true; } -bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee) { +bool cbor_array_push(cbor_item_t* array, cbor_item_t* pushee) { CBOR_ASSERT(cbor_isa_array(array)); - struct _cbor_array_metadata *metadata = - (struct _cbor_array_metadata *)&array->metadata; - cbor_item_t **data = (cbor_item_t **)array->data; + struct _cbor_array_metadata* metadata = + (struct _cbor_array_metadata*)&array->metadata; + cbor_item_t** data = (cbor_item_t**)array->data; if (cbor_array_is_definite(array)) { /* Do not reallocate definite arrays */ if (metadata->end_ptr >= metadata->allocated) { @@ -64,8 +64,8 @@ bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee) { ? 1 : CBOR_BUFFER_GROWTH * metadata->allocated; - unsigned char *new_data = _cbor_realloc_multiple( - array->data, sizeof(cbor_item_t *), new_allocation); + unsigned char* new_data = _cbor_realloc_multiple( + array->data, sizeof(cbor_item_t*), new_allocation); if (new_data == NULL) { return false; } @@ -73,31 +73,31 @@ bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee) { array->data = new_data; metadata->allocated = new_allocation; } - ((cbor_item_t **)array->data)[metadata->end_ptr++] = pushee; + ((cbor_item_t**)array->data)[metadata->end_ptr++] = pushee; } cbor_incref(pushee); return true; } -bool cbor_array_is_definite(const cbor_item_t *item) { +bool cbor_array_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_array_is_indefinite(const cbor_item_t *item) { +bool cbor_array_is_indefinite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.type == _CBOR_METADATA_INDEFINITE; } -cbor_item_t **cbor_array_handle(const cbor_item_t *item) { +cbor_item_t** cbor_array_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); - return (cbor_item_t **)item->data; + return (cbor_item_t**)item->data; } -cbor_item_t *cbor_new_definite_array(size_t size) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_array(size_t size) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); - cbor_item_t **data = _cbor_alloc_multiple(sizeof(cbor_item_t *), size); + cbor_item_t** data = _cbor_alloc_multiple(sizeof(cbor_item_t*), size); _CBOR_DEPENDENT_NOTNULL(item, data); for (size_t i = 0; i < size; i++) { @@ -110,13 +110,13 @@ cbor_item_t *cbor_new_definite_array(size_t size) { .metadata = {.array_metadata = {.type = _CBOR_METADATA_DEFINITE, .allocated = size, .end_ptr = 0}}, - .data = (unsigned char *)data}; + .data = (unsigned char*)data}; return item; } -cbor_item_t *cbor_new_indefinite_array(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_array(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c index 528937179ae..f8290a56328 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c @@ -9,27 +9,27 @@ #include <string.h> #include "internal/memory_utils.h" -size_t cbor_bytestring_length(const cbor_item_t *item) { +size_t cbor_bytestring_length(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); return item->metadata.bytestring_metadata.length; } -unsigned char *cbor_bytestring_handle(const cbor_item_t *item) { +unsigned char* cbor_bytestring_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); return item->data; } -bool cbor_bytestring_is_definite(const cbor_item_t *item) { +bool cbor_bytestring_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); return item->metadata.bytestring_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_bytestring_is_indefinite(const cbor_item_t *item) { +bool cbor_bytestring_is_indefinite(const cbor_item_t* item) { return !cbor_bytestring_is_definite(item); } -cbor_item_t *cbor_new_definite_bytestring(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_bytestring(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, @@ -39,8 +39,8 @@ cbor_item_t *cbor_new_definite_bytestring(void) { return item; } -cbor_item_t *cbor_new_indefinite_bytestring(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_bytestring(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, @@ -49,7 +49,7 @@ cbor_item_t *cbor_new_indefinite_bytestring(void) { .length = 0}}, .data = _cbor_malloc(sizeof(struct cbor_indefinite_string_data))}; _CBOR_DEPENDENT_NOTNULL(item, item->data); - *((struct cbor_indefinite_string_data *)item->data) = + *((struct cbor_indefinite_string_data*)item->data) = (struct cbor_indefinite_string_data){ .chunk_count = 0, .chunk_capacity = 0, @@ -58,17 +58,17 @@ cbor_item_t *cbor_new_indefinite_bytestring(void) { return item; } -cbor_item_t *cbor_build_bytestring(cbor_data handle, size_t length) { - cbor_item_t *item = cbor_new_definite_bytestring(); +cbor_item_t* cbor_build_bytestring(cbor_data handle, size_t length) { + cbor_item_t* item = cbor_new_definite_bytestring(); _CBOR_NOTNULL(item); - void *content = _cbor_malloc(length); + void* content = _cbor_malloc(length); _CBOR_DEPENDENT_NOTNULL(item, content); memcpy(content, handle, length); cbor_bytestring_set_handle(item, content, length); return item; } -void cbor_bytestring_set_handle(cbor_item_t *item, +void cbor_bytestring_set_handle(cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length) { CBOR_ASSERT(cbor_isa_bytestring(item)); @@ -77,25 +77,25 @@ void cbor_bytestring_set_handle(cbor_item_t *item, item->metadata.bytestring_metadata.length = length; } -cbor_item_t **cbor_bytestring_chunks_handle(const cbor_item_t *item) { +cbor_item_t** cbor_bytestring_chunks_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); CBOR_ASSERT(cbor_bytestring_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunks; + return ((struct cbor_indefinite_string_data*)item->data)->chunks; } -size_t cbor_bytestring_chunk_count(const cbor_item_t *item) { +size_t cbor_bytestring_chunk_count(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); CBOR_ASSERT(cbor_bytestring_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunk_count; + return ((struct cbor_indefinite_string_data*)item->data)->chunk_count; } -bool cbor_bytestring_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { +bool cbor_bytestring_add_chunk(cbor_item_t* item, cbor_item_t* chunk) { CBOR_ASSERT(cbor_isa_bytestring(item)); CBOR_ASSERT(cbor_bytestring_is_indefinite(item)); CBOR_ASSERT(cbor_isa_bytestring(chunk)); CBOR_ASSERT(cbor_bytestring_is_definite(chunk)); - struct cbor_indefinite_string_data *data = - (struct cbor_indefinite_string_data *)item->data; + struct cbor_indefinite_string_data* data = + (struct cbor_indefinite_string_data*)item->data; if (data->chunk_count == data->chunk_capacity) { if (!_cbor_safe_to_multiply(CBOR_BUFFER_GROWTH, data->chunk_capacity)) { return false; @@ -105,8 +105,8 @@ bool cbor_bytestring_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { data->chunk_capacity == 0 ? 1 : CBOR_BUFFER_GROWTH * (data->chunk_capacity); - cbor_item_t **new_chunks_data = _cbor_realloc_multiple( - data->chunks, sizeof(cbor_item_t *), new_chunk_capacity); + cbor_item_t** new_chunks_data = _cbor_realloc_multiple( + data->chunks, sizeof(cbor_item_t*), new_chunk_capacity); if (new_chunks_data == NULL) { return false; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h index cacd1adf95f..59cae2add7f 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h @@ -29,7 +29,7 @@ extern "C" { * @return length of the binary data. Zero if no chunk has been attached yet */ _CBOR_NODISCARD -CBOR_EXPORT size_t cbor_bytestring_length(const cbor_item_t *item); +CBOR_EXPORT size_t cbor_bytestring_length(const cbor_item_t* item); /** Is the byte string definite? * @@ -37,7 +37,7 @@ CBOR_EXPORT size_t cbor_bytestring_length(const cbor_item_t *item); * @return Is the byte string definite? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_bytestring_is_definite(const cbor_item_t *item); +CBOR_EXPORT bool cbor_bytestring_is_definite(const cbor_item_t* item); /** Is the byte string indefinite? * @@ -45,7 +45,7 @@ CBOR_EXPORT bool cbor_bytestring_is_definite(const cbor_item_t *item); * @return Is the byte string indefinite? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_bytestring_is_indefinite(const cbor_item_t *item); +CBOR_EXPORT bool cbor_bytestring_is_indefinite(const cbor_item_t* item); /** Get the handle to the binary data * @@ -58,7 +58,7 @@ CBOR_EXPORT bool cbor_bytestring_is_indefinite(const cbor_item_t *item); * yet. */ _CBOR_NODISCARD -CBOR_EXPORT cbor_mutable_data cbor_bytestring_handle(const cbor_item_t *item); +CBOR_EXPORT cbor_mutable_data cbor_bytestring_handle(const cbor_item_t* item); /** Set the handle to the binary data * @@ -69,7 +69,7 @@ CBOR_EXPORT cbor_mutable_data cbor_bytestring_handle(const cbor_item_t *item); * @param length Length of the data block */ CBOR_EXPORT void cbor_bytestring_set_handle( - cbor_item_t *item, cbor_mutable_data CBOR_RESTRICT_POINTER data, + cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length); /** Get the handle to the array of chunks @@ -81,8 +81,8 @@ CBOR_EXPORT void cbor_bytestring_set_handle( * @return array of #cbor_bytestring_chunk_count definite bytestrings */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t **cbor_bytestring_chunks_handle( - const cbor_item_t *item); +CBOR_EXPORT cbor_item_t** cbor_bytestring_chunks_handle( + const cbor_item_t* item); /** Get the number of chunks this string consist of * @@ -90,7 +90,7 @@ CBOR_EXPORT cbor_item_t **cbor_bytestring_chunks_handle( * @return The chunk count. 0 for freshly created items. */ _CBOR_NODISCARD -CBOR_EXPORT size_t cbor_bytestring_chunk_count(const cbor_item_t *item); +CBOR_EXPORT size_t cbor_bytestring_chunk_count(const cbor_item_t* item); /** Appends a chunk to the bytestring * @@ -105,8 +105,8 @@ CBOR_EXPORT size_t cbor_bytestring_chunk_count(const cbor_item_t *item); * of `chunk` is not increased and the `item` is left intact. */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_bytestring_add_chunk(cbor_item_t *item, - cbor_item_t *chunk); +CBOR_EXPORT bool cbor_bytestring_add_chunk(cbor_item_t* item, + cbor_item_t* chunk); /** Creates a new definite byte string * @@ -117,7 +117,7 @@ CBOR_EXPORT bool cbor_bytestring_add_chunk(cbor_item_t *item, * @return `NULL` if memory allocation fails */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_new_definite_bytestring(void); +CBOR_EXPORT cbor_item_t* cbor_new_definite_bytestring(void); /** Creates a new indefinite byte string * @@ -128,7 +128,7 @@ CBOR_EXPORT cbor_item_t *cbor_new_definite_bytestring(void); * @return `NULL` if memory allocation fails */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_new_indefinite_bytestring(void); +CBOR_EXPORT cbor_item_t* cbor_new_indefinite_bytestring(void); /** Creates a new byte string and initializes it * @@ -141,7 +141,7 @@ CBOR_EXPORT cbor_item_t *cbor_new_indefinite_bytestring(void); * @return `NULL` if memory allocation fails */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_build_bytestring(cbor_data handle, size_t length); +CBOR_EXPORT cbor_item_t* cbor_build_bytestring(cbor_data handle, size_t length); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c index bdf3f79eee6..2b58edaa0bc 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c @@ -7,72 +7,72 @@ #include "callbacks.h" -void cbor_null_uint8_callback(void *_CBOR_UNUSED(_ctx), - uint8_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint8_callback(void* _ctx _CBOR_UNUSED, + uint8_t _CBOR_UNUSED _val) {} -void cbor_null_uint16_callback(void *_CBOR_UNUSED(_ctx), - uint16_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint16_callback(void* _ctx _CBOR_UNUSED, + uint16_t _CBOR_UNUSED _val) {} -void cbor_null_uint32_callback(void *_CBOR_UNUSED(_ctx), - uint32_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint32_callback(void* _ctx _CBOR_UNUSED, + uint32_t _CBOR_UNUSED _val) {} -void cbor_null_uint64_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint64_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_negint8_callback(void *_CBOR_UNUSED(_ctx), - uint8_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint8_callback(void* _ctx _CBOR_UNUSED, + uint8_t _CBOR_UNUSED _val) {} -void cbor_null_negint16_callback(void *_CBOR_UNUSED(_ctx), - uint16_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint16_callback(void* _ctx _CBOR_UNUSED, + uint16_t _CBOR_UNUSED _val) {} -void cbor_null_negint32_callback(void *_CBOR_UNUSED(_ctx), - uint32_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint32_callback(void* _ctx _CBOR_UNUSED, + uint32_t _CBOR_UNUSED _val) {} -void cbor_null_negint64_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint64_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_string_callback(void *_CBOR_UNUSED(_ctx), - cbor_data _CBOR_UNUSED(_val), - uint64_t _CBOR_UNUSED(_val2)) {} +void cbor_null_string_callback(void* _ctx _CBOR_UNUSED, + cbor_data _CBOR_UNUSED _val, + uint64_t _CBOR_UNUSED _val2) {} -void cbor_null_string_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_string_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_byte_string_callback(void *_CBOR_UNUSED(_ctx), - cbor_data _CBOR_UNUSED(_val), - uint64_t _CBOR_UNUSED(_val2)) {} +void cbor_null_byte_string_callback(void* _ctx _CBOR_UNUSED, + cbor_data _CBOR_UNUSED _val, + uint64_t _CBOR_UNUSED _val2) {} -void cbor_null_byte_string_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_byte_string_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_array_start_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_array_start_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_indef_array_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_indef_array_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_map_start_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_map_start_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_indef_map_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_indef_map_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_tag_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_tag_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_float2_callback(void *_CBOR_UNUSED(_ctx), - float _CBOR_UNUSED(_val)) {} +void cbor_null_float2_callback(void* _ctx _CBOR_UNUSED, + float _CBOR_UNUSED _val) {} -void cbor_null_float4_callback(void *_CBOR_UNUSED(_ctx), - float _CBOR_UNUSED(_val)) {} +void cbor_null_float4_callback(void* _ctx _CBOR_UNUSED, + float _CBOR_UNUSED _val) {} -void cbor_null_float8_callback(void *_CBOR_UNUSED(_ctx), - double _CBOR_UNUSED(_val)) {} +void cbor_null_float8_callback(void* _ctx _CBOR_UNUSED, + double _CBOR_UNUSED _val) {} -void cbor_null_null_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_null_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_undefined_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_undefined_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_boolean_callback(void *_CBOR_UNUSED(_ctx), - bool _CBOR_UNUSED(_val)) {} +void cbor_null_boolean_callback(void* _ctx _CBOR_UNUSED, + bool _CBOR_UNUSED _val) {} -void cbor_null_indef_break_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_indef_break_callback(void* _ctx _CBOR_UNUSED) {} CBOR_EXPORT const struct cbor_callbacks cbor_empty_callbacks = { /* Type 0 - Unsigned integers */ diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h index c7ae20568dc..f5fab43bc71 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h @@ -18,34 +18,34 @@ extern "C" { #endif /** Callback prototype */ -typedef void (*cbor_int8_callback)(void *, uint8_t); +typedef void (*cbor_int8_callback)(void*, uint8_t); /** Callback prototype */ -typedef void (*cbor_int16_callback)(void *, uint16_t); +typedef void (*cbor_int16_callback)(void*, uint16_t); /** Callback prototype */ -typedef void (*cbor_int32_callback)(void *, uint32_t); +typedef void (*cbor_int32_callback)(void*, uint32_t); /** Callback prototype */ -typedef void (*cbor_int64_callback)(void *, uint64_t); +typedef void (*cbor_int64_callback)(void*, uint64_t); /** Callback prototype */ -typedef void (*cbor_simple_callback)(void *); +typedef void (*cbor_simple_callback)(void*); /** Callback prototype */ -typedef void (*cbor_string_callback)(void *, cbor_data, uint64_t); +typedef void (*cbor_string_callback)(void*, cbor_data, uint64_t); /** Callback prototype */ -typedef void (*cbor_collection_callback)(void *, uint64_t); +typedef void (*cbor_collection_callback)(void*, uint64_t); /** Callback prototype */ -typedef void (*cbor_float_callback)(void *, float); +typedef void (*cbor_float_callback)(void*, float); /** Callback prototype */ -typedef void (*cbor_double_callback)(void *, double); +typedef void (*cbor_double_callback)(void*, double); /** Callback prototype */ -typedef void (*cbor_bool_callback)(void *, bool); +typedef void (*cbor_bool_callback)(void*, bool); /** Callback bundle -- passed to the decoder */ struct cbor_callbacks { @@ -108,76 +108,76 @@ struct cbor_callbacks { }; /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint8_callback(void *, uint8_t); +CBOR_EXPORT void cbor_null_uint8_callback(void*, uint8_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint16_callback(void *, uint16_t); +CBOR_EXPORT void cbor_null_uint16_callback(void*, uint16_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint32_callback(void *, uint32_t); +CBOR_EXPORT void cbor_null_uint32_callback(void*, uint32_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint64_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_uint64_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint8_callback(void *, uint8_t); +CBOR_EXPORT void cbor_null_negint8_callback(void*, uint8_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint16_callback(void *, uint16_t); +CBOR_EXPORT void cbor_null_negint16_callback(void*, uint16_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint32_callback(void *, uint32_t); +CBOR_EXPORT void cbor_null_negint32_callback(void*, uint32_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint64_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_negint64_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_string_callback(void *, cbor_data, uint64_t); +CBOR_EXPORT void cbor_null_string_callback(void*, cbor_data, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_string_start_callback(void *); +CBOR_EXPORT void cbor_null_string_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_byte_string_callback(void *, cbor_data, uint64_t); +CBOR_EXPORT void cbor_null_byte_string_callback(void*, cbor_data, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_byte_string_start_callback(void *); +CBOR_EXPORT void cbor_null_byte_string_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_array_start_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_array_start_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_indef_array_start_callback(void *); +CBOR_EXPORT void cbor_null_indef_array_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_map_start_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_map_start_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_indef_map_start_callback(void *); +CBOR_EXPORT void cbor_null_indef_map_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_tag_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_tag_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_float2_callback(void *, float); +CBOR_EXPORT void cbor_null_float2_callback(void*, float); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_float4_callback(void *, float); +CBOR_EXPORT void cbor_null_float4_callback(void*, float); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_float8_callback(void *, double); +CBOR_EXPORT void cbor_null_float8_callback(void*, double); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_null_callback(void *); +CBOR_EXPORT void cbor_null_null_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_undefined_callback(void *); +CBOR_EXPORT void cbor_null_undefined_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_boolean_callback(void *, bool); +CBOR_EXPORT void cbor_null_boolean_callback(void*, bool); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_indef_break_callback(void *); +CBOR_EXPORT void cbor_null_indef_break_callback(void*); /** Dummy callback bundle - does nothing */ CBOR_EXPORT extern const struct cbor_callbacks cbor_empty_callbacks; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c index efbd37ed79d..704dd0c3205 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c @@ -19,69 +19,69 @@ bool _cbor_enable_assert = true; #endif -bool cbor_isa_uint(const cbor_item_t *item) { +bool cbor_isa_uint(const cbor_item_t* item) { return item->type == CBOR_TYPE_UINT; } -bool cbor_isa_negint(const cbor_item_t *item) { +bool cbor_isa_negint(const cbor_item_t* item) { return item->type == CBOR_TYPE_NEGINT; } -bool cbor_isa_bytestring(const cbor_item_t *item) { +bool cbor_isa_bytestring(const cbor_item_t* item) { return item->type == CBOR_TYPE_BYTESTRING; } -bool cbor_isa_string(const cbor_item_t *item) { +bool cbor_isa_string(const cbor_item_t* item) { return item->type == CBOR_TYPE_STRING; } -bool cbor_isa_array(const cbor_item_t *item) { +bool cbor_isa_array(const cbor_item_t* item) { return item->type == CBOR_TYPE_ARRAY; } -bool cbor_isa_map(const cbor_item_t *item) { +bool cbor_isa_map(const cbor_item_t* item) { return item->type == CBOR_TYPE_MAP; } -bool cbor_isa_tag(const cbor_item_t *item) { +bool cbor_isa_tag(const cbor_item_t* item) { return item->type == CBOR_TYPE_TAG; } -bool cbor_isa_float_ctrl(const cbor_item_t *item) { +bool cbor_isa_float_ctrl(const cbor_item_t* item) { return item->type == CBOR_TYPE_FLOAT_CTRL; } -cbor_type cbor_typeof(const cbor_item_t *item) { return item->type; } +cbor_type cbor_typeof(const cbor_item_t* item) { return item->type; } -bool cbor_is_int(const cbor_item_t *item) { +bool cbor_is_int(const cbor_item_t* item) { return cbor_isa_uint(item) || cbor_isa_negint(item); } -bool cbor_is_bool(const cbor_item_t *item) { +bool cbor_is_bool(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && (cbor_ctrl_value(item) == CBOR_CTRL_FALSE || cbor_ctrl_value(item) == CBOR_CTRL_TRUE); } -bool cbor_is_null(const cbor_item_t *item) { +bool cbor_is_null(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && cbor_ctrl_value(item) == CBOR_CTRL_NULL; } -bool cbor_is_undef(const cbor_item_t *item) { +bool cbor_is_undef(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && cbor_ctrl_value(item) == CBOR_CTRL_UNDEF; } -bool cbor_is_float(const cbor_item_t *item) { +bool cbor_is_float(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && !cbor_float_ctrl_is_ctrl(item); } -cbor_item_t *cbor_incref(cbor_item_t *item) { +cbor_item_t* cbor_incref(cbor_item_t* item) { item->refcount++; return item; } -void cbor_decref(cbor_item_t **item_ref) { - cbor_item_t *item = *item_ref; +void cbor_decref(cbor_item_t** item_ref) { + cbor_item_t* item = *item_ref; CBOR_ASSERT(item->refcount > 0); if (--item->refcount == 0) { switch (item->type) { @@ -95,11 +95,10 @@ void cbor_decref(cbor_item_t **item_ref) { _cbor_free(item->data); } else { /* We need to decref all chunks */ - cbor_item_t **handle = cbor_bytestring_chunks_handle(item); + cbor_item_t** handle = cbor_bytestring_chunks_handle(item); for (size_t i = 0; i < cbor_bytestring_chunk_count(item); i++) cbor_decref(&handle[i]); - _cbor_free( - ((struct cbor_indefinite_string_data *)item->data)->chunks); + _cbor_free(((struct cbor_indefinite_string_data*)item->data)->chunks); _cbor_free(item->data); } break; @@ -109,18 +108,17 @@ void cbor_decref(cbor_item_t **item_ref) { _cbor_free(item->data); } else { /* We need to decref all chunks */ - cbor_item_t **handle = cbor_string_chunks_handle(item); + cbor_item_t** handle = cbor_string_chunks_handle(item); for (size_t i = 0; i < cbor_string_chunk_count(item); i++) cbor_decref(&handle[i]); - _cbor_free( - ((struct cbor_indefinite_string_data *)item->data)->chunks); + _cbor_free(((struct cbor_indefinite_string_data*)item->data)->chunks); _cbor_free(item->data); } break; } case CBOR_TYPE_ARRAY: { /* Get all items and decref them */ - cbor_item_t **handle = cbor_array_handle(item); + cbor_item_t** handle = cbor_array_handle(item); size_t size = cbor_array_size(item); for (size_t i = 0; i < size; i++) if (handle[i] != NULL) cbor_decref(&handle[i]); @@ -128,7 +126,7 @@ void cbor_decref(cbor_item_t **item_ref) { break; } case CBOR_TYPE_MAP: { - struct cbor_pair *handle = cbor_map_handle(item); + struct cbor_pair* handle = cbor_map_handle(item); for (size_t i = 0; i < item->metadata.map_metadata.end_ptr; i++, handle++) { cbor_decref(&handle->key); @@ -153,11 +151,11 @@ void cbor_decref(cbor_item_t **item_ref) { } } -void cbor_intermediate_decref(cbor_item_t *item) { cbor_decref(&item); } +void cbor_intermediate_decref(cbor_item_t* item) { cbor_decref(&item); } -size_t cbor_refcount(const cbor_item_t *item) { return item->refcount; } +size_t cbor_refcount(const cbor_item_t* item) { return item->refcount; } -cbor_item_t *cbor_move(cbor_item_t *item) { +cbor_item_t* cbor_move(cbor_item_t* item) { item->refcount--; return item; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h index 1d0b426cff4..89968db9544 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h @@ -81,21 +81,27 @@ extern bool _cbor_enable_assert; #define _CBOR_TO_STR(x) _CBOR_TO_STR_(x) /* enables proper double expansion */ #ifdef __GNUC__ -#define _CBOR_UNUSED(x) __attribute__((__unused__)) x +#define _CBOR_UNUSED __attribute__((__unused__)) // TODO(https://github.com/PJK/libcbor/issues/247): Prefer [[nodiscard]] if // available #define _CBOR_NODISCARD __attribute__((warn_unused_result)) #elif defined(_MSC_VER) -#define _CBOR_UNUSED(x) __pragma(warning(suppress : 4100 4101)) x +#define _CBOR_UNUSED __pragma(warning(suppress : 4100 4101)) #define _CBOR_NODISCARD #else -#define _CBOR_UNUSED(x) x +#define _CBOR_UNUSED #define _CBOR_NODISCARD #endif -typedef void *(*_cbor_malloc_t)(size_t); -typedef void *(*_cbor_realloc_t)(void *, size_t); -typedef void (*_cbor_free_t)(void *); +#ifdef CBOR_HAS_BUILTIN_UNREACHABLE +#define _CBOR_UNREACHABLE __builtin_unreachable() +#else +#define _CBOR_UNREACHABLE +#endif + +typedef void* (*_cbor_malloc_t)(size_t); +typedef void* (*_cbor_realloc_t)(void*, size_t); +typedef void (*_cbor_free_t)(void*); CBOR_EXPORT extern _cbor_malloc_t _cbor_malloc; CBOR_EXPORT extern _cbor_realloc_t _cbor_realloc; @@ -155,7 +161,7 @@ CBOR_EXPORT void cbor_set_allocs(_cbor_malloc_t custom_malloc, */ _CBOR_NODISCARD CBOR_EXPORT cbor_type cbor_typeof( - const cbor_item_t *item); /* Will be inlined iff link-time opt is enabled */ + const cbor_item_t* item); /* Will be inlined iff link-time opt is enabled */ /* Standard CBOR Major item types */ @@ -164,56 +170,56 @@ CBOR_EXPORT cbor_type cbor_typeof( * @return Is the item an #CBOR_TYPE_UINT? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_uint(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_uint(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_NEGINT? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_negint(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_negint(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_BYTESTRING? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_bytestring(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_bytestring(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_STRING? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_string(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_string(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item an #CBOR_TYPE_ARRAY? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_array(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_array(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_MAP? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_map(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_map(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_TAG? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_tag(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_tag(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_FLOAT_CTRL? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_float_ctrl(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_float_ctrl(const cbor_item_t* item); /* Practical types with respect to their semantics (but not tag values) */ @@ -222,21 +228,21 @@ CBOR_EXPORT bool cbor_isa_float_ctrl(const cbor_item_t *item); * @return Is the item an integer, either positive or negative? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_int(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_int(const cbor_item_t* item); /** Is the item an a floating point number? * @param item the item * @return Is the item a floating point number? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_float(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_float(const cbor_item_t* item); /** Is the item an a boolean? * @param item the item * @return Is the item a boolean? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_bool(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_bool(const cbor_item_t* item); /** Does this item represent `null` * @@ -249,7 +255,7 @@ CBOR_EXPORT bool cbor_is_bool(const cbor_item_t *item); * @return Is the item (CBOR logical) null? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_null(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_null(const cbor_item_t* item); /** Does this item represent `undefined` * @@ -262,7 +268,7 @@ CBOR_EXPORT bool cbor_is_null(const cbor_item_t *item); * @return Is the item (CBOR logical) undefined? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_undef(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_undef(const cbor_item_t* item); /* * ============================================================================ @@ -280,7 +286,7 @@ CBOR_EXPORT bool cbor_is_undef(const cbor_item_t *item); * @param item Reference to an item * @return The input \p item */ -CBOR_EXPORT cbor_item_t *cbor_incref(cbor_item_t *item); +CBOR_EXPORT cbor_item_t* cbor_incref(cbor_item_t* item); /** Decreases the item's reference count by one, deallocating the item if needed * @@ -289,7 +295,7 @@ CBOR_EXPORT cbor_item_t *cbor_incref(cbor_item_t *item); * * @param item Reference to an item. Will be set to `NULL` if deallocated */ -CBOR_EXPORT void cbor_decref(cbor_item_t **item); +CBOR_EXPORT void cbor_decref(cbor_item_t** item); /** Decreases the item's reference count by one, deallocating the item if needed * @@ -298,7 +304,7 @@ CBOR_EXPORT void cbor_decref(cbor_item_t **item); * * @param item Reference to an item */ -CBOR_EXPORT void cbor_intermediate_decref(cbor_item_t *item); +CBOR_EXPORT void cbor_intermediate_decref(cbor_item_t* item); /** Get the item's reference count * @@ -312,7 +318,7 @@ CBOR_EXPORT void cbor_intermediate_decref(cbor_item_t *item); * @return the reference count */ _CBOR_NODISCARD -CBOR_EXPORT size_t cbor_refcount(const cbor_item_t *item); +CBOR_EXPORT size_t cbor_refcount(const cbor_item_t* item); /** Provides CPP-like move construct * @@ -330,7 +336,7 @@ CBOR_EXPORT size_t cbor_refcount(const cbor_item_t *item); * @return the item with reference count decreased by one */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_move(cbor_item_t *item); +CBOR_EXPORT cbor_item_t* cbor_move(cbor_item_t* item); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h index 83fe90bd356..b7278293329 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h @@ -9,7 +9,7 @@ #define LIBCBOR_CONFIGURATION_H #define CBOR_MAJOR_VERSION 0 -#define CBOR_MINOR_VERSION 11 +#define CBOR_MINOR_VERSION 12 #define CBOR_PATCH_VERSION 0 #define CBOR_BUFFER_GROWTH 2 diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c index 9d931d17570..76be4de9da3 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c @@ -6,64 +6,67 @@ */ #include "encoding.h" + +#include <math.h> + #include "internal/encoders.h" -size_t cbor_encode_uint8(uint8_t value, unsigned char *buffer, +size_t cbor_encode_uint8(uint8_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint8(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint16(uint16_t value, unsigned char *buffer, +size_t cbor_encode_uint16(uint16_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint16(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint32(uint32_t value, unsigned char *buffer, +size_t cbor_encode_uint32(uint32_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint32(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint64(uint64_t value, unsigned char *buffer, +size_t cbor_encode_uint64(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint64(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint(uint64_t value, unsigned char *buffer, +size_t cbor_encode_uint(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_negint8(uint8_t value, unsigned char *buffer, +size_t cbor_encode_negint8(uint8_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint8(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint16(uint16_t value, unsigned char *buffer, +size_t cbor_encode_negint16(uint16_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint16(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint32(uint32_t value, unsigned char *buffer, +size_t cbor_encode_negint32(uint32_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint32(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint64(uint64_t value, unsigned char *buffer, +size_t cbor_encode_negint64(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint64(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint(uint64_t value, unsigned char *buffer, +size_t cbor_encode_negint(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_bytestring_start(size_t length, unsigned char *buffer, +size_t cbor_encode_bytestring_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0x40); } -size_t _cbor_encode_byte(uint8_t value, unsigned char *buffer, +size_t _cbor_encode_byte(uint8_t value, unsigned char* buffer, size_t buffer_size) { if (buffer_size >= 1) { buffer[0] = value; @@ -72,60 +75,61 @@ size_t _cbor_encode_byte(uint8_t value, unsigned char *buffer, return 0; } -size_t cbor_encode_indef_bytestring_start(unsigned char *buffer, +size_t cbor_encode_indef_bytestring_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0x5F, buffer, buffer_size); } -size_t cbor_encode_string_start(size_t length, unsigned char *buffer, +size_t cbor_encode_string_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0x60); } -size_t cbor_encode_indef_string_start(unsigned char *buffer, +size_t cbor_encode_indef_string_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0x7F, buffer, buffer_size); } -size_t cbor_encode_array_start(size_t length, unsigned char *buffer, +size_t cbor_encode_array_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0x80); } -size_t cbor_encode_indef_array_start(unsigned char *buffer, +size_t cbor_encode_indef_array_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0x9F, buffer, buffer_size); } -size_t cbor_encode_map_start(size_t length, unsigned char *buffer, +size_t cbor_encode_map_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0xA0); } -size_t cbor_encode_indef_map_start(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_indef_map_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xBF, buffer, buffer_size); } -size_t cbor_encode_tag(uint64_t value, unsigned char *buffer, +size_t cbor_encode_tag(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint(value, buffer, buffer_size, 0xC0); } -size_t cbor_encode_bool(bool value, unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_bool(bool value, unsigned char* buffer, size_t buffer_size) { return value ? _cbor_encode_byte(0xF5, buffer, buffer_size) : _cbor_encode_byte(0xF4, buffer, buffer_size); } -size_t cbor_encode_null(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_null(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xF6, buffer, buffer_size); } -size_t cbor_encode_undef(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_undef(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xF7, buffer, buffer_size); } -size_t cbor_encode_half(float value, unsigned char *buffer, +size_t cbor_encode_half(float value, unsigned char* buffer, size_t buffer_size) { + // TODO: Broken on systems that do not use IEEE 754 /* Assuming value is normalized */ uint32_t val = ((union _cbor_float_helper){.as_float = value}).as_uint; uint16_t res; @@ -134,11 +138,8 @@ size_t cbor_encode_half(float value, unsigned char *buffer, uint32_t mant = val & 0x7FFFFFu; /* 0b0000_0000_0111_1111_1111_1111_1111_1111 */ if (exp == 0xFF) { /* Infinity or NaNs */ - if (value != value) { - // We discard information bits in half-float NaNs. This is - // not required for the core CBOR protocol (it is only a suggestion in - // Section 3.9). - // See https://github.com/PJK/libcbor/issues/215 + if (isnan(value)) { + // Note: Values of signaling NaNs are discarded. See `cbor_encode_single`. res = (uint16_t)0x007e00; } else { // If the mantissa is non-zero, we have a NaN, but those are handled @@ -176,25 +177,38 @@ size_t cbor_encode_half(float value, unsigned char *buffer, return _cbor_encode_uint16(res, buffer, buffer_size, 0xE0); } -size_t cbor_encode_single(float value, unsigned char *buffer, +size_t cbor_encode_single(float value, unsigned char* buffer, size_t buffer_size) { + // Note: Values of signaling NaNs are discarded. There is no standard + // way to extract it without assumptions about the internal float + // representation. + if (isnan(value)) { + return _cbor_encode_uint32(0x7FC0 << 16, buffer, buffer_size, 0xE0); + } + // TODO: Broken on systems that do not use IEEE 754 return _cbor_encode_uint32( ((union _cbor_float_helper){.as_float = value}).as_uint, buffer, buffer_size, 0xE0); } -size_t cbor_encode_double(double value, unsigned char *buffer, +size_t cbor_encode_double(double value, unsigned char* buffer, size_t buffer_size) { + // Note: Values of signaling NaNs are discarded. See `cbor_encode_single`. + if (isnan(value)) { + return _cbor_encode_uint64((uint64_t)0x7FF8 << 48, buffer, buffer_size, + 0xE0); + } + // TODO: Broken on systems that do not use IEEE 754 return _cbor_encode_uint64( ((union _cbor_double_helper){.as_double = value}).as_uint, buffer, buffer_size, 0xE0); } -size_t cbor_encode_break(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_break(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xFF, buffer, buffer_size); } -size_t cbor_encode_ctrl(uint8_t value, unsigned char *buffer, +size_t cbor_encode_ctrl(uint8_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint8(value, buffer, buffer_size, 0xE0); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h index bcc04f8a98e..c05bbc54573 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h @@ -27,76 +27,72 @@ extern "C" { * case it is not modified). */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint8(uint8_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint8(uint8_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint16(uint16_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint16(uint16_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint32(uint32_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint32(uint32_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint64(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint64(uint64_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint(uint64_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint8(uint8_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint8(uint8_t, unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint16(uint16_t, - unsigned char *, - size_t); + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint32(uint32_t, - unsigned char *, - size_t); + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint64(uint64_t, - unsigned char *, - size_t); + unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint(uint64_t, unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bytestring_start(size_t, - unsigned char *, + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_encode_indef_bytestring_start(unsigned char *, size_t); +cbor_encode_indef_bytestring_start(unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_string_start(size_t, - unsigned char *, + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_encode_indef_string_start(unsigned char *, size_t); +cbor_encode_indef_string_start(unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_array_start(size_t, - unsigned char *, + unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t -cbor_encode_indef_array_start(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_array_start(unsigned char*, + size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_map_start(size_t, - unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_map_start(size_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_map_start(unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_map_start(unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_tag(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_tag(uint64_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bool(bool, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bool(bool, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_null(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_null(unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_undef(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_undef(unsigned char*, size_t); /** Encodes a half-precision float * @@ -118,19 +114,28 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_undef(unsigned char *, size_t); * lost. * - In all other cases, the sign bit, the exponent, and 10 most significant * bits of the significand are kept + * + * Note: Signaling NaNs are encoded as a standard, "quiet" NaN. */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_half(float, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_half(float, unsigned char*, size_t); - -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_single(float, unsigned char *, +/** Encodes a single precision float + * + * Note: Signaling NaNs are encoded as a standard, "quiet" NaN. + */ +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_single(float, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_double(double, unsigned char *, +/** Encodes a double precision float + * + * Note: Signaling NaNs are encoded as a standard, "quiet" NaN. + */ +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_double(double, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_break(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_break(unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_ctrl(uint8_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_ctrl(uint8_t, unsigned char*, size_t); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c index 57bf477d4d3..705e78cb20c 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c @@ -9,43 +9,42 @@ #include <math.h> #include "assert.h" -cbor_float_width cbor_float_get_width(const cbor_item_t *item) { +cbor_float_width cbor_float_get_width(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); return item->metadata.float_ctrl_metadata.width; } -uint8_t cbor_ctrl_value(const cbor_item_t *item) { +uint8_t cbor_ctrl_value(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_0); return item->metadata.float_ctrl_metadata.ctrl; } -bool cbor_float_ctrl_is_ctrl(const cbor_item_t *item) { +bool cbor_float_ctrl_is_ctrl(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); return cbor_float_get_width(item) == CBOR_FLOAT_0; } -float cbor_float_get_float2(const cbor_item_t *item) { +float cbor_float_get_float2(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_16); - return *(float *)item->data; + return *(float*)item->data; } -float cbor_float_get_float4(const cbor_item_t *item) { +float cbor_float_get_float4(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_32); - return *(float *)item->data; + return *(float*)item->data; } -double cbor_float_get_float8(const cbor_item_t *item) { +double cbor_float_get_float8(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_64); - return *(double *)item->data; + return *(double*)item->data; } -double cbor_float_get_float(const cbor_item_t *item) { +double cbor_float_get_float(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); - // cppcheck-suppress missingReturn switch (cbor_float_get_width(item)) { case CBOR_FLOAT_0: return NAN; @@ -55,46 +54,49 @@ double cbor_float_get_float(const cbor_item_t *item) { return cbor_float_get_float4(item); case CBOR_FLOAT_64: return cbor_float_get_float8(item); + default: + _CBOR_UNREACHABLE; + return 0; } } -bool cbor_get_bool(const cbor_item_t *item) { +bool cbor_get_bool(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_bool(item)); return item->metadata.float_ctrl_metadata.ctrl == CBOR_CTRL_TRUE; } -void cbor_set_float2(cbor_item_t *item, float value) { +void cbor_set_float2(cbor_item_t* item, float value) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_16); - *((float *)item->data) = value; + *((float*)item->data) = value; } -void cbor_set_float4(cbor_item_t *item, float value) { +void cbor_set_float4(cbor_item_t* item, float value) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_32); - *((float *)item->data) = value; + *((float*)item->data) = value; } -void cbor_set_float8(cbor_item_t *item, double value) { +void cbor_set_float8(cbor_item_t* item, double value) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_64); - *((double *)item->data) = value; + *((double*)item->data) = value; } -void cbor_set_ctrl(cbor_item_t *item, uint8_t value) { +void cbor_set_ctrl(cbor_item_t* item, uint8_t value) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_0); item->metadata.float_ctrl_metadata.ctrl = value; } -void cbor_set_bool(cbor_item_t *item, bool value) { +void cbor_set_bool(cbor_item_t* item, bool value) { CBOR_ASSERT(cbor_is_bool(item)); item->metadata.float_ctrl_metadata.ctrl = value ? CBOR_CTRL_TRUE : CBOR_CTRL_FALSE; } -cbor_item_t *cbor_new_ctrl(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_ctrl(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -106,83 +108,83 @@ cbor_item_t *cbor_new_ctrl(void) { return item; } -cbor_item_t *cbor_new_float2(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 4); +cbor_item_t* cbor_new_float2(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 4); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .type = CBOR_TYPE_FLOAT_CTRL, - .data = (unsigned char *)item + sizeof(cbor_item_t), + .data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.float_ctrl_metadata = {.width = CBOR_FLOAT_16}}}; return item; } -cbor_item_t *cbor_new_float4(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 4); +cbor_item_t* cbor_new_float4(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 4); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .type = CBOR_TYPE_FLOAT_CTRL, - .data = (unsigned char *)item + sizeof(cbor_item_t), + .data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.float_ctrl_metadata = {.width = CBOR_FLOAT_32}}}; return item; } -cbor_item_t *cbor_new_float8(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 8); +cbor_item_t* cbor_new_float8(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 8); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .type = CBOR_TYPE_FLOAT_CTRL, - .data = (unsigned char *)item + sizeof(cbor_item_t), + .data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.float_ctrl_metadata = {.width = CBOR_FLOAT_64}}}; return item; } -cbor_item_t *cbor_new_null(void) { - cbor_item_t *item = cbor_new_ctrl(); +cbor_item_t* cbor_new_null(void) { + cbor_item_t* item = cbor_new_ctrl(); _CBOR_NOTNULL(item); cbor_set_ctrl(item, CBOR_CTRL_NULL); return item; } -cbor_item_t *cbor_new_undef(void) { - cbor_item_t *item = cbor_new_ctrl(); +cbor_item_t* cbor_new_undef(void) { + cbor_item_t* item = cbor_new_ctrl(); _CBOR_NOTNULL(item); cbor_set_ctrl(item, CBOR_CTRL_UNDEF); return item; } -cbor_item_t *cbor_build_bool(bool value) { +cbor_item_t* cbor_build_bool(bool value) { return cbor_build_ctrl(value ? CBOR_CTRL_TRUE : CBOR_CTRL_FALSE); } -cbor_item_t *cbor_build_float2(float value) { - cbor_item_t *item = cbor_new_float2(); +cbor_item_t* cbor_build_float2(float value) { + cbor_item_t* item = cbor_new_float2(); _CBOR_NOTNULL(item); cbor_set_float2(item, value); return item; } -cbor_item_t *cbor_build_float4(float value) { - cbor_item_t *item = cbor_new_float4(); +cbor_item_t* cbor_build_float4(float value) { + cbor_item_t* item = cbor_new_float4(); _CBOR_NOTNULL(item); cbor_set_float4(item, value); return item; } -cbor_item_t *cbor_build_float8(double value) { - cbor_item_t *item = cbor_new_float8(); +cbor_item_t* cbor_build_float8(double value) { + cbor_item_t* item = cbor_new_float8(); _CBOR_NOTNULL(item); cbor_set_float8(item, value); return item; } -cbor_item_t *cbor_build_ctrl(uint8_t value) { - cbor_item_t *item = cbor_new_ctrl(); +cbor_item_t* cbor_build_ctrl(uint8_t value) { + cbor_item_t* item = cbor_new_ctrl(); _CBOR_NOTNULL(item); cbor_set_ctrl(item, value); return item; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h index 335eab8328b..6a792534695 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h @@ -27,7 +27,7 @@ extern "C" { * @return Is this a ctrl value? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_float_ctrl_is_ctrl( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the float width * @@ -35,7 +35,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_float_ctrl_is_ctrl( * @return The width. */ _CBOR_NODISCARD CBOR_EXPORT cbor_float_width -cbor_float_get_width(const cbor_item_t *item); +cbor_float_get_width(const cbor_item_t* item); /** Get a half precision float * @@ -45,7 +45,7 @@ cbor_float_get_width(const cbor_item_t *item); * @return half precision value */ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float2( - const cbor_item_t *item); + const cbor_item_t* item); /** Get a single precision float * @@ -55,7 +55,7 @@ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float2( * @return single precision value */ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float4( - const cbor_item_t *item); + const cbor_item_t* item); /** Get a double precision float * @@ -65,7 +65,7 @@ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float4( * @return double precision value */ _CBOR_NODISCARD CBOR_EXPORT double cbor_float_get_float8( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the float value represented as double * @@ -75,14 +75,14 @@ _CBOR_NODISCARD CBOR_EXPORT double cbor_float_get_float8( * @return double precision value */ _CBOR_NODISCARD CBOR_EXPORT double cbor_float_get_float( - const cbor_item_t *item); + const cbor_item_t* item); /** Get value from a boolean ctrl item * * @param item A ctrl item * @return boolean value */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_get_bool(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT bool cbor_get_bool(const cbor_item_t* item); /** Constructs a new ctrl item * @@ -92,7 +92,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_get_bool(const cbor_item_t *item); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_ctrl(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_ctrl(void); /** Constructs a new float item * @@ -102,7 +102,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_ctrl(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float2(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_float2(void); /** Constructs a new float item * @@ -112,7 +112,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float2(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float4(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_float4(void); /** Constructs a new float item * @@ -122,7 +122,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float4(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float8(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_float8(void); /** Constructs new null ctrl item * @@ -130,7 +130,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float8(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_null(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_null(void); /** Constructs new undef ctrl item * @@ -138,7 +138,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_null(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_undef(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_undef(void); /** Constructs new boolean ctrl item * @@ -147,7 +147,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_undef(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_bool(bool value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_bool(bool value); /** Assign a control value * @@ -160,42 +160,42 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_bool(bool value); * @param value The simple value to assign. Please consult the standard for * allowed values */ -CBOR_EXPORT void cbor_set_ctrl(cbor_item_t *item, uint8_t value); +CBOR_EXPORT void cbor_set_ctrl(cbor_item_t* item, uint8_t value); /** Assign a boolean value to a boolean ctrl item * * @param item A ctrl item * @param value The simple value to assign. */ -CBOR_EXPORT void cbor_set_bool(cbor_item_t *item, bool value); +CBOR_EXPORT void cbor_set_bool(cbor_item_t* item, bool value); /** Assigns a float value * * @param item A half precision float * @param value The value to assign */ -CBOR_EXPORT void cbor_set_float2(cbor_item_t *item, float value); +CBOR_EXPORT void cbor_set_float2(cbor_item_t* item, float value); /** Assigns a float value * * @param item A single precision float * @param value The value to assign */ -CBOR_EXPORT void cbor_set_float4(cbor_item_t *item, float value); +CBOR_EXPORT void cbor_set_float4(cbor_item_t* item, float value); /** Assigns a float value * * @param item A double precision float * @param value The value to assign */ -CBOR_EXPORT void cbor_set_float8(cbor_item_t *item, double value); +CBOR_EXPORT void cbor_set_float8(cbor_item_t* item, double value); /** Reads the control value * * @param item A ctrl item * @return the simple value */ -_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_ctrl_value(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_ctrl_value(const cbor_item_t* item); /** Constructs a new float * @@ -204,7 +204,7 @@ _CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_ctrl_value(const cbor_item_t *item); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float2(float value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_float2(float value); /** Constructs a new float * @@ -213,7 +213,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float2(float value); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float4(float value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_float4(float value); /** Constructs a new float * @@ -222,7 +222,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float4(float value); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float8(double value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_float8(double value); /** Constructs a ctrl item * @@ -231,7 +231,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float8(double value); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_ctrl(uint8_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_ctrl(uint8_t value); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c index 257cef3adbd..24e7708da3e 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c @@ -21,8 +21,8 @@ // `_cbor_builder_append` takes ownership of `item`. If adding the item to // parent container fails, `item` will be deallocated to prevent memory. -void _cbor_builder_append(cbor_item_t *item, - struct _cbor_decoder_context *ctx) { +void _cbor_builder_append(cbor_item_t* item, + struct _cbor_decoder_context* ctx) { if (ctx->stack->size == 0) { /* Top level item */ ctx->root = item; @@ -49,7 +49,7 @@ void _cbor_builder_append(cbor_item_t *item, cbor_decref(&item); ctx->stack->top->subitems--; if (ctx->stack->top->subitems == 0) { - cbor_item_t *stack_item = ctx->stack->top->item; + cbor_item_t* stack_item = ctx->stack->top->item; _cbor_stack_pop(ctx->stack); _cbor_builder_append(stack_item, ctx); } @@ -86,7 +86,7 @@ void _cbor_builder_append(cbor_item_t *item, CBOR_ASSERT(ctx->stack->top->subitems > 0); ctx->stack->top->subitems--; if (ctx->stack->top->subitems == 0) { - cbor_item_t *map_entry = ctx->stack->top->item; + cbor_item_t* map_entry = ctx->stack->top->item; _cbor_stack_pop(ctx->stack); _cbor_builder_append(map_entry, ctx); } @@ -100,7 +100,7 @@ void _cbor_builder_append(cbor_item_t *item, CBOR_ASSERT(ctx->stack->top->subitems == 1); cbor_tag_set_item(ctx->stack->top->item, item); cbor_decref(&item); /* Give up on our reference */ - cbor_item_t *tagged_item = ctx->stack->top->item; + cbor_item_t* tagged_item = ctx->stack->top->item; _cbor_stack_pop(ctx->stack); _cbor_builder_append(tagged_item, ctx); break; @@ -139,90 +139,90 @@ void _cbor_builder_append(cbor_item_t *item, } \ } while (0) -void cbor_builder_uint8_callback(void *context, uint8_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int8(); +void cbor_builder_uint8_callback(void* context, uint8_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int8(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint8(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_uint16_callback(void *context, uint16_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int16(); +void cbor_builder_uint16_callback(void* context, uint16_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int16(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint16(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_uint32_callback(void *context, uint32_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int32(); +void cbor_builder_uint32_callback(void* context, uint32_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int32(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint32(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_uint64_callback(void *context, uint64_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int64(); +void cbor_builder_uint64_callback(void* context, uint64_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int64(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint64(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint8_callback(void *context, uint8_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int8(); +void cbor_builder_negint8_callback(void* context, uint8_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int8(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint8(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint16_callback(void *context, uint16_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int16(); +void cbor_builder_negint16_callback(void* context, uint16_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int16(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint16(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint32_callback(void *context, uint32_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int32(); +void cbor_builder_negint32_callback(void* context, uint32_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int32(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint32(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint64_callback(void *context, uint64_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int64(); +void cbor_builder_negint64_callback(void* context, uint64_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int64(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint64(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_byte_string_callback(void *context, cbor_data data, +void cbor_builder_byte_string_callback(void* context, cbor_data data, uint64_t length) { - struct _cbor_decoder_context *ctx = context; + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, length); - unsigned char *new_handle = _cbor_malloc(length); + unsigned char* new_handle = _cbor_malloc(length); if (new_handle == NULL) { ctx->creation_failed = true; return; } memcpy(new_handle, data, length); - cbor_item_t *new_chunk = cbor_new_definite_bytestring(); + cbor_item_t* new_chunk = cbor_new_definite_bytestring(); if (new_chunk == NULL) { _cbor_free(new_handle); @@ -245,26 +245,26 @@ void cbor_builder_byte_string_callback(void *context, cbor_data data, } } -void cbor_builder_byte_string_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_bytestring(); +void cbor_builder_byte_string_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_bytestring(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_string_callback(void *context, cbor_data data, +void cbor_builder_string_callback(void* context, cbor_data data, uint64_t length) { - struct _cbor_decoder_context *ctx = context; + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, length); - unsigned char *new_handle = _cbor_malloc(length); + unsigned char* new_handle = _cbor_malloc(length); if (new_handle == NULL) { ctx->creation_failed = true; return; } memcpy(new_handle, data, length); - cbor_item_t *new_chunk = cbor_new_definite_string(); + cbor_item_t* new_chunk = cbor_new_definite_string(); if (new_chunk == NULL) { _cbor_free(new_handle); ctx->creation_failed = true; @@ -285,17 +285,17 @@ void cbor_builder_string_callback(void *context, cbor_data data, } } -void cbor_builder_string_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_string(); +void cbor_builder_string_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_string(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_array_start_callback(void *context, uint64_t size) { - struct _cbor_decoder_context *ctx = context; +void cbor_builder_array_start_callback(void* context, uint64_t size) { + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, size); - cbor_item_t *res = cbor_new_definite_array(size); + cbor_item_t* res = cbor_new_definite_array(size); CHECK_RES(ctx, res); if (size > 0) { PUSH_CTX_STACK(ctx, res, size); @@ -304,24 +304,24 @@ void cbor_builder_array_start_callback(void *context, uint64_t size) { } } -void cbor_builder_indef_array_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_array(); +void cbor_builder_indef_array_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_array(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_indef_map_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_map(); +void cbor_builder_indef_map_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_map(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_map_start_callback(void *context, uint64_t size) { - struct _cbor_decoder_context *ctx = context; +void cbor_builder_map_start_callback(void* context, uint64_t size) { + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, size); - cbor_item_t *res = cbor_new_definite_map(size); + cbor_item_t* res = cbor_new_definite_map(size); CHECK_RES(ctx, res); if (size > 0) { PUSH_CTX_STACK(ctx, res, size * 2); @@ -333,7 +333,7 @@ void cbor_builder_map_start_callback(void *context, uint64_t size) { /** * Is the (partially constructed) item indefinite? */ -bool _cbor_is_indefinite(cbor_item_t *item) { +bool _cbor_is_indefinite(cbor_item_t* item) { switch (item->type) { case CBOR_TYPE_BYTESTRING: return cbor_bytestring_is_indefinite(item); @@ -350,11 +350,11 @@ bool _cbor_is_indefinite(cbor_item_t *item) { } } -void cbor_builder_indef_break_callback(void *context) { - struct _cbor_decoder_context *ctx = context; +void cbor_builder_indef_break_callback(void* context) { + struct _cbor_decoder_context* ctx = context; /* There must be an item to break out of*/ if (ctx->stack->size > 0) { - cbor_item_t *item = ctx->stack->top->item; + cbor_item_t* item = ctx->stack->top->item; if (_cbor_is_indefinite( item) && /* Only indefinite items can be terminated by 0xFF */ /* Special case: we cannot append up if an indefinite map is incomplete @@ -369,54 +369,54 @@ void cbor_builder_indef_break_callback(void *context) { ctx->syntax_error = true; } -void cbor_builder_float2_callback(void *context, float value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_float2(); +void cbor_builder_float2_callback(void* context, float value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_float2(); CHECK_RES(ctx, res); cbor_set_float2(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_float4_callback(void *context, float value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_float4(); +void cbor_builder_float4_callback(void* context, float value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_float4(); CHECK_RES(ctx, res); cbor_set_float4(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_float8_callback(void *context, double value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_float8(); +void cbor_builder_float8_callback(void* context, double value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_float8(); CHECK_RES(ctx, res); cbor_set_float8(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_null_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_null(); +void cbor_builder_null_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_null(); CHECK_RES(ctx, res); _cbor_builder_append(res, ctx); } -void cbor_builder_undefined_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_undef(); +void cbor_builder_undefined_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_undef(); CHECK_RES(ctx, res); _cbor_builder_append(res, ctx); } -void cbor_builder_boolean_callback(void *context, bool value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_build_bool(value); +void cbor_builder_boolean_callback(void* context, bool value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_build_bool(value); CHECK_RES(ctx, res); _cbor_builder_append(res, ctx); } -void cbor_builder_tag_callback(void *context, uint64_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_tag(value); +void cbor_builder_tag_callback(void* context, uint64_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_tag(value); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 1); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h index 7893960e413..0e034306952 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h @@ -22,61 +22,61 @@ struct _cbor_decoder_context { bool creation_failed; /** Stack expectation mismatch */ bool syntax_error; - cbor_item_t *root; - struct _cbor_stack *stack; + cbor_item_t* root; + struct _cbor_stack* stack; }; /** Internal helper: Append item to the top of the stack while handling errors. */ -void _cbor_builder_append(cbor_item_t *item, struct _cbor_decoder_context *ctx); +void _cbor_builder_append(cbor_item_t* item, struct _cbor_decoder_context* ctx); -void cbor_builder_uint8_callback(void *, uint8_t); +void cbor_builder_uint8_callback(void*, uint8_t); -void cbor_builder_uint16_callback(void *, uint16_t); +void cbor_builder_uint16_callback(void*, uint16_t); -void cbor_builder_uint32_callback(void *, uint32_t); +void cbor_builder_uint32_callback(void*, uint32_t); -void cbor_builder_uint64_callback(void *, uint64_t); +void cbor_builder_uint64_callback(void*, uint64_t); -void cbor_builder_negint8_callback(void *, uint8_t); +void cbor_builder_negint8_callback(void*, uint8_t); -void cbor_builder_negint16_callback(void *, uint16_t); +void cbor_builder_negint16_callback(void*, uint16_t); -void cbor_builder_negint32_callback(void *, uint32_t); +void cbor_builder_negint32_callback(void*, uint32_t); -void cbor_builder_negint64_callback(void *, uint64_t); +void cbor_builder_negint64_callback(void*, uint64_t); -void cbor_builder_string_callback(void *, cbor_data, uint64_t); +void cbor_builder_string_callback(void*, cbor_data, uint64_t); -void cbor_builder_string_start_callback(void *); +void cbor_builder_string_start_callback(void*); -void cbor_builder_byte_string_callback(void *, cbor_data, uint64_t); +void cbor_builder_byte_string_callback(void*, cbor_data, uint64_t); -void cbor_builder_byte_string_start_callback(void *); +void cbor_builder_byte_string_start_callback(void*); -void cbor_builder_array_start_callback(void *, uint64_t); +void cbor_builder_array_start_callback(void*, uint64_t); -void cbor_builder_indef_array_start_callback(void *); +void cbor_builder_indef_array_start_callback(void*); -void cbor_builder_map_start_callback(void *, uint64_t); +void cbor_builder_map_start_callback(void*, uint64_t); -void cbor_builder_indef_map_start_callback(void *); +void cbor_builder_indef_map_start_callback(void*); -void cbor_builder_tag_callback(void *, uint64_t); +void cbor_builder_tag_callback(void*, uint64_t); -void cbor_builder_float2_callback(void *, float); +void cbor_builder_float2_callback(void*, float); -void cbor_builder_float4_callback(void *, float); +void cbor_builder_float4_callback(void*, float); -void cbor_builder_float8_callback(void *, double); +void cbor_builder_float8_callback(void*, double); -void cbor_builder_null_callback(void *); +void cbor_builder_null_callback(void*); -void cbor_builder_undefined_callback(void *); +void cbor_builder_undefined_callback(void*); -void cbor_builder_boolean_callback(void *, bool); +void cbor_builder_boolean_callback(void*, bool); -void cbor_builder_indef_break_callback(void *); +void cbor_builder_indef_break_callback(void*); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c index 49d4d7f33d2..773df7970c2 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c @@ -6,9 +6,10 @@ */ #include "encoders.h" + #include <string.h> -size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, +size_t _cbor_encode_uint8(uint8_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { if (value <= 23) { if (buffer_size >= 1) { @@ -25,43 +26,43 @@ size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, return 0; } -size_t _cbor_encode_uint16(uint16_t value, unsigned char *buffer, +size_t _cbor_encode_uint16(uint16_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { - if (buffer_size >= 3) { - buffer[0] = 0x19 + offset; + if (buffer_size < 3) { + return 0; + } + buffer[0] = 0x19 + offset; #ifdef IS_BIG_ENDIAN - memcpy(buffer + 1, &value, 2); + memcpy(buffer + 1, &value, 2); #else - buffer[1] = (unsigned char)(value >> 8); - buffer[2] = (unsigned char)value; + buffer[1] = (unsigned char)(value >> 8); + buffer[2] = (unsigned char)value; #endif - return 3; - } else - return 0; + return 3; } -size_t _cbor_encode_uint32(uint32_t value, unsigned char *buffer, +size_t _cbor_encode_uint32(uint32_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { - if (buffer_size >= 5) { - buffer[0] = 0x1A + offset; + if (buffer_size < 5) { + return 0; + } + buffer[0] = 0x1A + offset; #ifdef IS_BIG_ENDIAN - memcpy(buffer + 1, &value, 4); + memcpy(buffer + 1, &value, 4); #else - buffer[1] = (unsigned char)(value >> 24); - buffer[2] = (unsigned char)(value >> 16); - buffer[3] = (unsigned char)(value >> 8); - buffer[4] = (unsigned char)value; + buffer[1] = (unsigned char)(value >> 24); + buffer[2] = (unsigned char)(value >> 16); + buffer[3] = (unsigned char)(value >> 8); + buffer[4] = (unsigned char)value; #endif - return 5; - } else - return 0; + return 5; } -size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint64(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { if (buffer_size >= 9) { buffer[0] = 0x1B + offset; @@ -84,7 +85,7 @@ size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, return 0; } -size_t _cbor_encode_uint(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { if (value <= UINT16_MAX) if (value <= UINT8_MAX) diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h index 7eadb712164..162b0bad2c1 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h @@ -15,23 +15,23 @@ extern "C" { #endif _CBOR_NODISCARD -size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, +size_t _cbor_encode_uint8(uint8_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint16(uint16_t value, unsigned char *buffer, +size_t _cbor_encode_uint16(uint16_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint32(uint32_t value, unsigned char *buffer, +size_t _cbor_encode_uint32(uint32_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint64(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c index cfa173de790..b89cf72235c 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c @@ -11,7 +11,7 @@ uint8_t _cbor_load_uint8(cbor_data source) { return (uint8_t)*source; } -uint16_t _cbor_load_uint16(const unsigned char *source) { +uint16_t _cbor_load_uint16(const unsigned char* source) { #ifdef IS_BIG_ENDIAN uint16_t result; memcpy(&result, source, 2); @@ -21,7 +21,7 @@ uint16_t _cbor_load_uint16(const unsigned char *source) { #endif } -uint32_t _cbor_load_uint32(const unsigned char *source) { +uint32_t _cbor_load_uint32(const unsigned char* source) { #ifdef IS_BIG_ENDIAN uint32_t result; memcpy(&result, source, 4); @@ -33,7 +33,7 @@ uint32_t _cbor_load_uint32(const unsigned char *source) { #endif } -uint64_t _cbor_load_uint64(const unsigned char *source) { +uint64_t _cbor_load_uint64(const unsigned char* source) { #ifdef IS_BIG_ENDIAN uint64_t result; memcpy(&result, source, 8); @@ -50,7 +50,9 @@ uint64_t _cbor_load_uint64(const unsigned char *source) { } /* As per https://www.rfc-editor.org/rfc/rfc8949.html#name-half-precision */ -float _cbor_decode_half(unsigned char *halfp) { +float _cbor_decode_half(unsigned char* halfp) { + // TODO: Broken if we are not on IEEE 754 + // (https://github.com/PJK/libcbor/issues/336) int half = (halfp[0] << 8) + halfp[1]; int exp = (half >> 10) & 0x1f; int mant = half & 0x3ff; @@ -66,15 +68,19 @@ float _cbor_decode_half(unsigned char *halfp) { float _cbor_load_half(cbor_data source) { /* Discard const */ - return _cbor_decode_half((unsigned char *)source); + return _cbor_decode_half((unsigned char*)source); } float _cbor_load_float(cbor_data source) { + // TODO: Broken if we are not on IEEE 754 + // (https://github.com/PJK/libcbor/issues/336) union _cbor_float_helper helper = {.as_uint = _cbor_load_uint32(source)}; return helper.as_float; } double _cbor_load_double(cbor_data source) { + // TODO: Broken if we are not on IEEE 754 + // (https://github.com/PJK/libcbor/issues/336) union _cbor_double_helper helper = {.as_uint = _cbor_load_uint64(source)}; return helper.as_double; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h index ce37563a3d8..9e8eb68e29a 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h @@ -16,16 +16,16 @@ extern "C" { /* Read the given uint from the given location, no questions asked */ _CBOR_NODISCARD -uint8_t _cbor_load_uint8(const unsigned char *source); +uint8_t _cbor_load_uint8(const unsigned char* source); _CBOR_NODISCARD -uint16_t _cbor_load_uint16(const unsigned char *source); +uint16_t _cbor_load_uint16(const unsigned char* source); _CBOR_NODISCARD -uint32_t _cbor_load_uint32(const unsigned char *source); +uint32_t _cbor_load_uint32(const unsigned char* source); _CBOR_NODISCARD -uint64_t _cbor_load_uint64(const unsigned char *source); +uint64_t _cbor_load_uint64(const unsigned char* source); _CBOR_NODISCARD float _cbor_load_half(cbor_data source); diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c index 2db03cbbf08..00e6aed5237 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c @@ -11,18 +11,18 @@ struct _cbor_stack _cbor_stack_init(void) { return (struct _cbor_stack){.top = NULL, .size = 0}; } -void _cbor_stack_pop(struct _cbor_stack *stack) { - struct _cbor_stack_record *top = stack->top; +void _cbor_stack_pop(struct _cbor_stack* stack) { + struct _cbor_stack_record* top = stack->top; stack->top = stack->top->lower; _cbor_free(top); stack->size--; } -struct _cbor_stack_record *_cbor_stack_push(struct _cbor_stack *stack, - cbor_item_t *item, +struct _cbor_stack_record* _cbor_stack_push(struct _cbor_stack* stack, + cbor_item_t* item, size_t subitems) { if (stack->size == CBOR_MAX_STACK_SIZE) return NULL; - struct _cbor_stack_record *new_top = + struct _cbor_stack_record* new_top = _cbor_malloc(sizeof(struct _cbor_stack_record)); if (new_top == NULL) return NULL; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h index cf2206b40e5..7bc43ac09f9 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h @@ -17,9 +17,9 @@ extern "C" { /** Simple stack record for the parser */ struct _cbor_stack_record { /** Pointer to the parent stack frame */ - struct _cbor_stack_record *lower; + struct _cbor_stack_record* lower; /** Item under construction */ - cbor_item_t *item; + cbor_item_t* item; /** * How many outstanding subitems are expected. * @@ -33,17 +33,17 @@ struct _cbor_stack_record { /** Stack handle - contents and size */ struct _cbor_stack { - struct _cbor_stack_record *top; + struct _cbor_stack_record* top; size_t size; }; _CBOR_NODISCARD struct _cbor_stack _cbor_stack_init(void); -void _cbor_stack_pop(struct _cbor_stack *); +void _cbor_stack_pop(struct _cbor_stack*); _CBOR_NODISCARD -struct _cbor_stack_record *_cbor_stack_push(struct _cbor_stack *, cbor_item_t *, +struct _cbor_stack_record* _cbor_stack_push(struct _cbor_stack*, cbor_item_t*, size_t); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c index b4d035a1897..272d82550c4 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c @@ -7,36 +7,36 @@ #include "ints.h" -cbor_int_width cbor_int_get_width(const cbor_item_t *item) { +cbor_int_width cbor_int_get_width(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); return item->metadata.int_metadata.width; } -uint8_t cbor_get_uint8(const cbor_item_t *item) { +uint8_t cbor_get_uint8(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_8); return *item->data; } -uint16_t cbor_get_uint16(const cbor_item_t *item) { +uint16_t cbor_get_uint16(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_16); - return *(uint16_t *)item->data; + return *(uint16_t*)item->data; } -uint32_t cbor_get_uint32(const cbor_item_t *item) { +uint32_t cbor_get_uint32(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_32); - return *(uint32_t *)item->data; + return *(uint32_t*)item->data; } -uint64_t cbor_get_uint64(const cbor_item_t *item) { +uint64_t cbor_get_uint64(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_64); - return *(uint64_t *)item->data; + return *(uint64_t*)item->data; } -uint64_t cbor_get_int(const cbor_item_t *item) { +uint64_t cbor_get_int(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); // cppcheck-suppress missingReturn switch (cbor_int_get_width(item)) { @@ -48,141 +48,144 @@ uint64_t cbor_get_int(const cbor_item_t *item) { return cbor_get_uint32(item); case CBOR_INT_64: return cbor_get_uint64(item); + default: + _CBOR_UNREACHABLE; + return 0; } } -void cbor_set_uint8(cbor_item_t *item, uint8_t value) { +void cbor_set_uint8(cbor_item_t* item, uint8_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_8); *item->data = value; } -void cbor_set_uint16(cbor_item_t *item, uint16_t value) { +void cbor_set_uint16(cbor_item_t* item, uint16_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_16); - *(uint16_t *)item->data = value; + *(uint16_t*)item->data = value; } -void cbor_set_uint32(cbor_item_t *item, uint32_t value) { +void cbor_set_uint32(cbor_item_t* item, uint32_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_32); - *(uint32_t *)item->data = value; + *(uint32_t*)item->data = value; } -void cbor_set_uint64(cbor_item_t *item, uint64_t value) { +void cbor_set_uint64(cbor_item_t* item, uint64_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_64); - *(uint64_t *)item->data = value; + *(uint64_t*)item->data = value; } -void cbor_mark_uint(cbor_item_t *item) { +void cbor_mark_uint(cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); item->type = CBOR_TYPE_UINT; } -void cbor_mark_negint(cbor_item_t *item) { +void cbor_mark_negint(cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); item->type = CBOR_TYPE_NEGINT; } -cbor_item_t *cbor_new_int8(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 1); +cbor_item_t* cbor_new_int8(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 1); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_8}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_new_int16(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 2); +cbor_item_t* cbor_new_int16(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 2); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_16}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_new_int32(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 4); +cbor_item_t* cbor_new_int32(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 4); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_32}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_new_int64(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 8); +cbor_item_t* cbor_new_int64(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 8); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_64}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_build_uint8(uint8_t value) { - cbor_item_t *item = cbor_new_int8(); +cbor_item_t* cbor_build_uint8(uint8_t value) { + cbor_item_t* item = cbor_new_int8(); _CBOR_NOTNULL(item); cbor_set_uint8(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_uint16(uint16_t value) { - cbor_item_t *item = cbor_new_int16(); +cbor_item_t* cbor_build_uint16(uint16_t value) { + cbor_item_t* item = cbor_new_int16(); _CBOR_NOTNULL(item); cbor_set_uint16(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_uint32(uint32_t value) { - cbor_item_t *item = cbor_new_int32(); +cbor_item_t* cbor_build_uint32(uint32_t value) { + cbor_item_t* item = cbor_new_int32(); _CBOR_NOTNULL(item); cbor_set_uint32(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_uint64(uint64_t value) { - cbor_item_t *item = cbor_new_int64(); +cbor_item_t* cbor_build_uint64(uint64_t value) { + cbor_item_t* item = cbor_new_int64(); _CBOR_NOTNULL(item); cbor_set_uint64(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_negint8(uint8_t value) { - cbor_item_t *item = cbor_new_int8(); +cbor_item_t* cbor_build_negint8(uint8_t value) { + cbor_item_t* item = cbor_new_int8(); _CBOR_NOTNULL(item); cbor_set_uint8(item, value); cbor_mark_negint(item); return item; } -cbor_item_t *cbor_build_negint16(uint16_t value) { - cbor_item_t *item = cbor_new_int16(); +cbor_item_t* cbor_build_negint16(uint16_t value) { + cbor_item_t* item = cbor_new_int16(); _CBOR_NOTNULL(item); cbor_set_uint16(item, value); cbor_mark_negint(item); return item; } -cbor_item_t *cbor_build_negint32(uint32_t value) { - cbor_item_t *item = cbor_new_int32(); +cbor_item_t* cbor_build_negint32(uint32_t value) { + cbor_item_t* item = cbor_new_int32(); _CBOR_NOTNULL(item); cbor_set_uint32(item, value); cbor_mark_negint(item); return item; } -cbor_item_t *cbor_build_negint64(uint64_t value) { - cbor_item_t *item = cbor_new_int64(); +cbor_item_t* cbor_build_negint64(uint64_t value) { + cbor_item_t* item = cbor_new_int64(); _CBOR_NOTNULL(item); cbor_set_uint64(item, value); cbor_mark_negint(item); diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h index 006aa428e0a..30d061035fe 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h @@ -26,35 +26,35 @@ extern "C" { * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_get_uint8(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_get_uint8(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint16_t cbor_get_uint16(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint16_t cbor_get_uint16(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint32_t cbor_get_uint32(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint32_t cbor_get_uint32(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_uint64(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_uint64(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value, extended to `uint64_t` */ -_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_int(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_int(const cbor_item_t* item); /** Assigns the integer value * @@ -62,7 +62,7 @@ _CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_int(const cbor_item_t *item); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint8(cbor_item_t *item, uint8_t value); +CBOR_EXPORT void cbor_set_uint8(cbor_item_t* item, uint8_t value); /** Assigns the integer value * @@ -70,7 +70,7 @@ CBOR_EXPORT void cbor_set_uint8(cbor_item_t *item, uint8_t value); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint16(cbor_item_t *item, uint16_t value); +CBOR_EXPORT void cbor_set_uint16(cbor_item_t* item, uint16_t value); /** Assigns the integer value * @@ -78,7 +78,7 @@ CBOR_EXPORT void cbor_set_uint16(cbor_item_t *item, uint16_t value); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint32(cbor_item_t *item, uint32_t value); +CBOR_EXPORT void cbor_set_uint32(cbor_item_t* item, uint32_t value); /** Assigns the integer value * @@ -86,7 +86,7 @@ CBOR_EXPORT void cbor_set_uint32(cbor_item_t *item, uint32_t value); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint64(cbor_item_t *item, uint64_t value); +CBOR_EXPORT void cbor_set_uint64(cbor_item_t* item, uint64_t value); /** Queries the integer width * @@ -94,7 +94,7 @@ CBOR_EXPORT void cbor_set_uint64(cbor_item_t *item, uint64_t value); * @return the width */ _CBOR_NODISCARD CBOR_EXPORT cbor_int_width -cbor_int_get_width(const cbor_item_t *item); +cbor_int_get_width(const cbor_item_t* item); /** Marks the integer item as a positive integer * @@ -102,7 +102,7 @@ cbor_int_get_width(const cbor_item_t *item); * * @param item positive or negative integer item */ -CBOR_EXPORT void cbor_mark_uint(cbor_item_t *item); +CBOR_EXPORT void cbor_mark_uint(cbor_item_t* item); /** Marks the integer item as a negative integer * @@ -110,7 +110,7 @@ CBOR_EXPORT void cbor_mark_uint(cbor_item_t *item); * * @param item positive or negative integer item */ -CBOR_EXPORT void cbor_mark_negint(cbor_item_t *item); +CBOR_EXPORT void cbor_mark_negint(cbor_item_t* item); /** Allocates new integer with 1B width * @@ -119,7 +119,7 @@ CBOR_EXPORT void cbor_mark_negint(cbor_item_t *item); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int8(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int8(void); /** Allocates new integer with 2B width * @@ -128,7 +128,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int8(void); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int16(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int16(void); /** Allocates new integer with 4B width * @@ -137,7 +137,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int16(void); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int32(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int32(void); /** Allocates new integer with 8B width * @@ -146,63 +146,63 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int32(void); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int64(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int64(void); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint8(uint8_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint8(uint8_t value); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint16(uint16_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint16(uint16_t value); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint32(uint32_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint32(uint32_t value); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint64(uint64_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint64(uint64_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint8(uint8_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint8(uint8_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint16(uint16_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint16(uint16_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint32(uint32_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint32(uint32_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint64(uint64_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint64(uint64_t value); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c index 8a3bd607568..7ce168a1ed7 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c @@ -8,18 +8,18 @@ #include "maps.h" #include "internal/memory_utils.h" -size_t cbor_map_size(const cbor_item_t *item) { +size_t cbor_map_size(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); return item->metadata.map_metadata.end_ptr; } -size_t cbor_map_allocated(const cbor_item_t *item) { +size_t cbor_map_allocated(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); return item->metadata.map_metadata.allocated; } -cbor_item_t *cbor_new_definite_map(size_t size) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_map(size_t size) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -34,8 +34,8 @@ cbor_item_t *cbor_new_definite_map(size_t size) { return item; } -cbor_item_t *cbor_new_indefinite_map(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_map(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -49,12 +49,12 @@ cbor_item_t *cbor_new_indefinite_map(void) { return item; } -bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { +bool _cbor_map_add_key(cbor_item_t* item, cbor_item_t* key) { CBOR_ASSERT(cbor_isa_map(item)); - struct _cbor_map_metadata *metadata = - (struct _cbor_map_metadata *)&item->metadata; + struct _cbor_map_metadata* metadata = + (struct _cbor_map_metadata*)&item->metadata; if (cbor_map_is_definite(item)) { - struct cbor_pair *data = cbor_map_handle(item); + struct cbor_pair* data = cbor_map_handle(item); if (metadata->end_ptr >= metadata->allocated) { /* Don't realloc definite preallocated map */ return false; @@ -74,7 +74,7 @@ bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { ? 1 : CBOR_BUFFER_GROWTH * metadata->allocated; - unsigned char *new_data = _cbor_realloc_multiple( + unsigned char* new_data = _cbor_realloc_multiple( item->data, sizeof(struct cbor_pair), new_allocation); if (new_data == NULL) { @@ -84,7 +84,7 @@ bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { item->data = new_data; metadata->allocated = new_allocation; } - struct cbor_pair *data = cbor_map_handle(item); + struct cbor_pair* data = cbor_map_handle(item); data[metadata->end_ptr].key = key; data[metadata->end_ptr++].value = NULL; } @@ -92,7 +92,7 @@ bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { return true; } -bool _cbor_map_add_value(cbor_item_t *item, cbor_item_t *value) { +bool _cbor_map_add_value(cbor_item_t* item, cbor_item_t* value) { CBOR_ASSERT(cbor_isa_map(item)); cbor_incref(value); cbor_map_handle(item)[ @@ -104,22 +104,22 @@ bool _cbor_map_add_value(cbor_item_t *item, cbor_item_t *value) { } // TODO: Add a more convenient API like add(item, key, val) -bool cbor_map_add(cbor_item_t *item, struct cbor_pair pair) { +bool cbor_map_add(cbor_item_t* item, struct cbor_pair pair) { CBOR_ASSERT(cbor_isa_map(item)); if (!_cbor_map_add_key(item, pair.key)) return false; return _cbor_map_add_value(item, pair.value); } -bool cbor_map_is_definite(const cbor_item_t *item) { +bool cbor_map_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); return item->metadata.map_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_map_is_indefinite(const cbor_item_t *item) { +bool cbor_map_is_indefinite(const cbor_item_t* item) { return !cbor_map_is_definite(item); } -struct cbor_pair *cbor_map_handle(const cbor_item_t *item) { +struct cbor_pair* cbor_map_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); - return (struct cbor_pair *)item->data; + return (struct cbor_pair*)item->data; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h index 5c05b542bd8..d8b5f53b9e2 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h @@ -26,14 +26,14 @@ extern "C" { * @param item A map * @return The number of pairs */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_size(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_size(const cbor_item_t* item); /** Get the size of the allocated storage * * @param item A map * @return Allocated storage size (as the number of #cbor_pair items) */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_allocated(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_allocated(const cbor_item_t* item); /** Create a new definite map * @@ -42,7 +42,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_allocated(const cbor_item_t *item); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_map(size_t size); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_definite_map(size_t size); /** Create a new indefinite map * @@ -50,7 +50,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_map(size_t size); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_map(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_indefinite_map(void); /** Add a pair to the map * @@ -63,7 +63,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_map(void); * @return `true` on success, `false` if memory allocation failed (indefinite * maps) or the preallocated storage is full (definite maps) */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_add(cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_add(cbor_item_t* item, struct cbor_pair pair); /** Add a key to the map @@ -75,8 +75,8 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_add(cbor_item_t *item, * @return `true` on success, `false` if either reallocation failed or the * preallocated storage is full */ -_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_key(cbor_item_t *item, - cbor_item_t *key); +_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_key(cbor_item_t* item, + cbor_item_t* key); /** Add a value to the map * @@ -87,15 +87,15 @@ _CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_key(cbor_item_t *item, * @return `true` on success, `false` if either reallocation failed or the * preallocated storage is full */ -_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_value(cbor_item_t *item, - cbor_item_t *value); +_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_value(cbor_item_t* item, + cbor_item_t* value); /** Is this map definite? * * @param item A map * @return Is this map definite? */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_definite(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_definite(const cbor_item_t* item); /** Is this map indefinite? * @@ -103,7 +103,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_definite(const cbor_item_t *item); * @return Is this map indefinite? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_indefinite( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the pairs storage * @@ -111,8 +111,8 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_indefinite( * @return Array of #cbor_map_size pairs. Manipulation is possible as long as * references remain valid. */ -_CBOR_NODISCARD CBOR_EXPORT struct cbor_pair *cbor_map_handle( - const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT struct cbor_pair* cbor_map_handle( + const cbor_item_t* item); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c index 40f4c531d57..dbfc8c37138 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c @@ -17,9 +17,8 @@ #include "encoding.h" #include "internal/memory_utils.h" -size_t cbor_serialize(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { - // cppcheck-suppress missingReturn switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: return cbor_serialize_uint(item, buffer, buffer_size); @@ -37,6 +36,9 @@ size_t cbor_serialize(const cbor_item_t *item, unsigned char *buffer, return cbor_serialize_tag(item, buffer, buffer_size); case CBOR_TYPE_FLOAT_CTRL: return cbor_serialize_float_ctrl(item, buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } @@ -58,8 +60,7 @@ size_t _cbor_encoded_header_size(uint64_t size) { return 9; } -size_t cbor_serialized_size(const cbor_item_t *item) { - // cppcheck-suppress missingReturn +size_t cbor_serialized_size(const cbor_item_t* item) { switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: case CBOR_TYPE_NEGINT: @@ -73,6 +74,9 @@ size_t cbor_serialized_size(const cbor_item_t *item) { return 5; case CBOR_INT_64: return 9; + default: + _CBOR_UNREACHABLE; + return 0; } // Note: We do not _cbor_safe_signaling_add zero-length definite strings, // they would cause zeroes to propagate. All other items are at least one @@ -86,7 +90,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { cbor_bytestring_length(item)); } size_t indef_bytestring_size = 2; // Leading byte + break - cbor_item_t **chunks = cbor_bytestring_chunks_handle(item); + cbor_item_t** chunks = cbor_bytestring_chunks_handle(item); for (size_t i = 0; i < cbor_bytestring_chunk_count(item); i++) { indef_bytestring_size = _cbor_safe_signaling_add( indef_bytestring_size, cbor_serialized_size(chunks[i])); @@ -101,7 +105,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { return _cbor_safe_signaling_add(header_size, cbor_string_length(item)); } size_t indef_string_size = 2; // Leading byte + break - cbor_item_t **chunks = cbor_string_chunks_handle(item); + cbor_item_t** chunks = cbor_string_chunks_handle(item); for (size_t i = 0; i < cbor_string_chunk_count(item); i++) { indef_string_size = _cbor_safe_signaling_add( indef_string_size, cbor_serialized_size(chunks[i])); @@ -112,7 +116,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { size_t array_size = cbor_array_is_definite(item) ? _cbor_encoded_header_size(cbor_array_size(item)) : 2; // Leading byte + break - cbor_item_t **items = cbor_array_handle(item); + cbor_item_t** items = cbor_array_handle(item); for (size_t i = 0; i < cbor_array_size(item); i++) { array_size = _cbor_safe_signaling_add(array_size, cbor_serialized_size(items[i])); @@ -123,7 +127,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { size_t map_size = cbor_map_is_definite(item) ? _cbor_encoded_header_size(cbor_map_size(item)) : 2; // Leading byte + break - struct cbor_pair *items = cbor_map_handle(item); + struct cbor_pair* items = cbor_map_handle(item); for (size_t i = 0; i < cbor_map_size(item); i++) { map_size = _cbor_safe_signaling_add( map_size, @@ -147,12 +151,18 @@ size_t cbor_serialized_size(const cbor_item_t *item) { return 5; case CBOR_FLOAT_64: return 9; + default: + _CBOR_UNREACHABLE; + return 0; } + default: + _CBOR_UNREACHABLE; + return 0; } } -size_t cbor_serialize_alloc(const cbor_item_t *item, unsigned char **buffer, - size_t *buffer_size) { +size_t cbor_serialize_alloc(const cbor_item_t* item, unsigned char** buffer, + size_t* buffer_size) { *buffer = NULL; size_t serialized_size = cbor_serialized_size(item); if (serialized_size == 0) { @@ -171,7 +181,7 @@ size_t cbor_serialize_alloc(const cbor_item_t *item, unsigned char **buffer, return written; } -size_t cbor_serialize_uint(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_uint(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_uint(item)); // cppcheck-suppress missingReturn @@ -184,10 +194,13 @@ size_t cbor_serialize_uint(const cbor_item_t *item, unsigned char *buffer, return cbor_encode_uint32(cbor_get_uint32(item), buffer, buffer_size); case CBOR_INT_64: return cbor_encode_uint64(cbor_get_uint64(item), buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } -size_t cbor_serialize_negint(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_negint(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_negint(item)); // cppcheck-suppress missingReturn @@ -200,10 +213,13 @@ size_t cbor_serialize_negint(const cbor_item_t *item, unsigned char *buffer, return cbor_encode_negint32(cbor_get_uint32(item), buffer, buffer_size); case CBOR_INT_64: return cbor_encode_negint64(cbor_get_uint64(item), buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } -size_t cbor_serialize_bytestring(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_bytestring(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_bytestring(item)); if (cbor_bytestring_is_definite(item)) { @@ -220,7 +236,7 @@ size_t cbor_serialize_bytestring(const cbor_item_t *item, unsigned char *buffer, size_t written = cbor_encode_indef_bytestring_start(buffer, buffer_size); if (written == 0) return 0; - cbor_item_t **chunks = cbor_bytestring_chunks_handle(item); + cbor_item_t** chunks = cbor_bytestring_chunks_handle(item); for (size_t i = 0; i < chunk_count; i++) { size_t chunk_written = cbor_serialize_bytestring( chunks[i], buffer + written, buffer_size - written); @@ -235,7 +251,7 @@ size_t cbor_serialize_bytestring(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_string(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_string(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_string(item)); if (cbor_string_is_definite(item)) { @@ -252,7 +268,7 @@ size_t cbor_serialize_string(const cbor_item_t *item, unsigned char *buffer, size_t written = cbor_encode_indef_string_start(buffer, buffer_size); if (written == 0) return 0; - cbor_item_t **chunks = cbor_string_chunks_handle(item); + cbor_item_t** chunks = cbor_string_chunks_handle(item); for (size_t i = 0; i < chunk_count; i++) { size_t chunk_written = cbor_serialize_string(chunks[i], buffer + written, buffer_size - written); @@ -267,11 +283,11 @@ size_t cbor_serialize_string(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_array(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_array(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_array(item)); size_t size = cbor_array_size(item), written = 0; - cbor_item_t **handle = cbor_array_handle(item); + cbor_item_t** handle = cbor_array_handle(item); if (cbor_array_is_definite(item)) { written = cbor_encode_array_start(size, buffer, buffer_size); } else { @@ -298,11 +314,11 @@ size_t cbor_serialize_array(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_map(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_map(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_map(item)); size_t size = cbor_map_size(item), written = 0; - struct cbor_pair *handle = cbor_map_handle(item); + struct cbor_pair* handle = cbor_map_handle(item); if (cbor_map_is_definite(item)) { written = cbor_encode_map_start(size, buffer, buffer_size); @@ -336,7 +352,7 @@ size_t cbor_serialize_map(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_tag(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_tag(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_tag(item)); size_t written = cbor_encode_tag(cbor_tag_value(item), buffer, buffer_size); @@ -348,7 +364,7 @@ size_t cbor_serialize_tag(const cbor_item_t *item, unsigned char *buffer, return written + item_written; } -size_t cbor_serialize_float_ctrl(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_float_ctrl(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); // cppcheck-suppress missingReturn @@ -364,5 +380,8 @@ size_t cbor_serialize_float_ctrl(const cbor_item_t *item, unsigned char *buffer, case CBOR_FLOAT_64: return cbor_encode_double(cbor_float_get_float8(item), buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h index 228ae75d601..10f5784a5b2 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h @@ -28,7 +28,7 @@ extern "C" { * @param buffer_size Size of the \p buffer * @return Length of the result. 0 on failure. */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -42,7 +42,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize(const cbor_item_t *item, * `size_t`. */ _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_serialized_size(const cbor_item_t *item); +cbor_serialized_size(const cbor_item_t* item); /** Serialize the given item, allocating buffers as needed * @@ -62,9 +62,9 @@ cbor_serialized_size(const cbor_item_t *item); * @return Length of the result in bytes * @return 0 on memory allocation failure, in which case \p buffer is `NULL`. */ -CBOR_EXPORT size_t cbor_serialize_alloc(const cbor_item_t *item, - unsigned char **buffer, - size_t *buffer_size); +CBOR_EXPORT size_t cbor_serialize_alloc(const cbor_item_t* item, + unsigned char** buffer, + size_t* buffer_size); /** Serialize an uint * @@ -74,7 +74,7 @@ CBOR_EXPORT size_t cbor_serialize_alloc(const cbor_item_t *item, * @return Length of the result * @return 0 if the \p buffer_size doesn't fit the result */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_uint(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_uint(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -87,7 +87,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_uint(const cbor_item_t *item, * @return 0 if the \p buffer_size doesn't fit the result */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_negint( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize a bytestring * @@ -99,7 +99,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_negint( * still be modified */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_bytestring( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize a string * @@ -111,7 +111,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_bytestring( * still be modified */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_string( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize an array * * @param item An array @@ -122,7 +122,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_string( * still be modified */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_array( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize a map * @@ -133,7 +133,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_array( * @return 0 if the \p buffer_size doesn't fit the result. The \p buffer may * still be modified */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_map(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_map(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -146,7 +146,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_map(const cbor_item_t *item, * @return 0 if the \p buffer_size doesn't fit the result. The \p buffer may * still be modified */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_tag(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_tag(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -159,7 +159,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_tag(const cbor_item_t *item, * @return 0 if the \p buffer_size doesn't fit the result */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_float_ctrl( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c index 4b37701143a..595c85805f1 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c @@ -9,7 +9,7 @@ #include "internal/loaders.h" static bool claim_bytes(size_t required, size_t provided, - struct cbor_decoder_result *result) { + struct cbor_decoder_result* result) { if (required > (provided - result->read)) { result->required = required + result->read; result->read = 0; @@ -42,7 +42,7 @@ static bool claim_bytes(size_t required, size_t provided, struct cbor_decoder_result cbor_stream_decode( cbor_data source, size_t source_size, - const struct cbor_callbacks *callbacks, void *context) { + const struct cbor_callbacks* callbacks, void* context) { // Attempt to claim the initial MTB byte struct cbor_decoder_result result = {.status = CBOR_DECODER_FINISHED}; if (!claim_bytes(1, source_size, &result)) { @@ -592,9 +592,10 @@ struct cbor_decoder_result cbor_stream_decode( case 0xFF: /* Break */ callbacks->indef_break(context); - // Never happens, the switch statement is exhaustive on the 1B range; make - // compiler happy + return result; default: + // Never happens, the switch statement is exhaustive on the 1B range + _CBOR_UNREACHABLE; return result; } } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c index 6ae96545cfe..4ef4fa3c9b7 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c @@ -10,18 +10,20 @@ #include "internal/memory_utils.h" #include "internal/unicode.h" -cbor_item_t *cbor_new_definite_string(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_string(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, .type = CBOR_TYPE_STRING, - .metadata = {.string_metadata = {_CBOR_METADATA_DEFINITE, 0}}}; + .metadata = {.string_metadata = {.type = _CBOR_METADATA_DEFINITE, + .codepoint_count = 0, + .length = 0}}}; return item; } -cbor_item_t *cbor_new_indefinite_string(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_string(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, @@ -30,7 +32,7 @@ cbor_item_t *cbor_new_indefinite_string(void) { .length = 0}}, .data = _cbor_malloc(sizeof(struct cbor_indefinite_string_data))}; _CBOR_DEPENDENT_NOTNULL(item, item->data); - *((struct cbor_indefinite_string_data *)item->data) = + *((struct cbor_indefinite_string_data*)item->data) = (struct cbor_indefinite_string_data){ .chunk_count = 0, .chunk_capacity = 0, @@ -39,28 +41,28 @@ cbor_item_t *cbor_new_indefinite_string(void) { return item; } -cbor_item_t *cbor_build_string(const char *val) { - cbor_item_t *item = cbor_new_definite_string(); +cbor_item_t* cbor_build_string(const char* val) { + cbor_item_t* item = cbor_new_definite_string(); _CBOR_NOTNULL(item); size_t len = strlen(val); - unsigned char *handle = _cbor_malloc(len); + unsigned char* handle = _cbor_malloc(len); _CBOR_DEPENDENT_NOTNULL(item, handle); memcpy(handle, val, len); cbor_string_set_handle(item, handle, len); return item; } -cbor_item_t *cbor_build_stringn(const char *val, size_t length) { - cbor_item_t *item = cbor_new_definite_string(); +cbor_item_t* cbor_build_stringn(const char* val, size_t length) { + cbor_item_t* item = cbor_new_definite_string(); _CBOR_NOTNULL(item); - unsigned char *handle = _cbor_malloc(length); + unsigned char* handle = _cbor_malloc(length); _CBOR_DEPENDENT_NOTNULL(item, handle); memcpy(handle, val, length); cbor_string_set_handle(item, handle, length); return item; } -void cbor_string_set_handle(cbor_item_t *item, +void cbor_string_set_handle(cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length) { CBOR_ASSERT(cbor_isa_string(item)); @@ -78,23 +80,23 @@ void cbor_string_set_handle(cbor_item_t *item, } } -cbor_item_t **cbor_string_chunks_handle(const cbor_item_t *item) { +cbor_item_t** cbor_string_chunks_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); CBOR_ASSERT(cbor_string_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunks; + return ((struct cbor_indefinite_string_data*)item->data)->chunks; } -size_t cbor_string_chunk_count(const cbor_item_t *item) { +size_t cbor_string_chunk_count(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); CBOR_ASSERT(cbor_string_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunk_count; + return ((struct cbor_indefinite_string_data*)item->data)->chunk_count; } -bool cbor_string_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { +bool cbor_string_add_chunk(cbor_item_t* item, cbor_item_t* chunk) { CBOR_ASSERT(cbor_isa_string(item)); CBOR_ASSERT(cbor_string_is_indefinite(item)); - struct cbor_indefinite_string_data *data = - (struct cbor_indefinite_string_data *)item->data; + struct cbor_indefinite_string_data* data = + (struct cbor_indefinite_string_data*)item->data; if (data->chunk_count == data->chunk_capacity) { if (!_cbor_safe_to_multiply(CBOR_BUFFER_GROWTH, data->chunk_capacity)) { return false; @@ -103,8 +105,8 @@ bool cbor_string_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { size_t new_chunk_capacity = data->chunk_capacity == 0 ? 1 : CBOR_BUFFER_GROWTH * (data->chunk_capacity); - cbor_item_t **new_chunks_data = _cbor_realloc_multiple( - data->chunks, sizeof(cbor_item_t *), new_chunk_capacity); + cbor_item_t** new_chunks_data = _cbor_realloc_multiple( + data->chunks, sizeof(cbor_item_t*), new_chunk_capacity); if (new_chunks_data == NULL) { return false; @@ -117,26 +119,26 @@ bool cbor_string_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { return true; } -size_t cbor_string_length(const cbor_item_t *item) { +size_t cbor_string_length(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->metadata.string_metadata.length; } -unsigned char *cbor_string_handle(const cbor_item_t *item) { +unsigned char* cbor_string_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->data; } -size_t cbor_string_codepoint_count(const cbor_item_t *item) { +size_t cbor_string_codepoint_count(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->metadata.string_metadata.codepoint_count; } -bool cbor_string_is_definite(const cbor_item_t *item) { +bool cbor_string_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->metadata.string_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_string_is_indefinite(const cbor_item_t *item) { +bool cbor_string_is_indefinite(const cbor_item_t* item) { return !cbor_string_is_definite(item); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h index 3e03f81385f..a21133b3012 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h @@ -29,7 +29,7 @@ extern "C" { * @param item a definite string * @return length of the string. Zero if no chunk has been attached yet */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_string_length(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_string_length(const cbor_item_t* item); /** The number of codepoints in this string * @@ -40,7 +40,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_string_length(const cbor_item_t *item); * @return The number of codepoints in this string */ _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_string_codepoint_count(const cbor_item_t *item); +cbor_string_codepoint_count(const cbor_item_t* item); /** Is the string definite? * @@ -48,7 +48,7 @@ cbor_string_codepoint_count(const cbor_item_t *item); * @return Is the string definite? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_definite( - const cbor_item_t *item); + const cbor_item_t* item); /** Is the string indefinite? * @@ -56,7 +56,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_definite( * @return Is the string indefinite? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_indefinite( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the handle to the underlying string * @@ -68,7 +68,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_indefinite( * @return `NULL` if no data have been assigned yet. */ _CBOR_NODISCARD CBOR_EXPORT cbor_mutable_data -cbor_string_handle(const cbor_item_t *item); +cbor_string_handle(const cbor_item_t* item); /** Set the handle to the underlying string * @@ -87,7 +87,7 @@ cbor_string_handle(const cbor_item_t *item); * @param length Length of the data block */ CBOR_EXPORT void cbor_string_set_handle( - cbor_item_t *item, cbor_mutable_data CBOR_RESTRICT_POINTER data, + cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length); /** Get the handle to the array of chunks @@ -98,8 +98,8 @@ CBOR_EXPORT void cbor_string_set_handle( * @param item A indefinite string * @return array of #cbor_string_chunk_count definite strings */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t **cbor_string_chunks_handle( - const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t** cbor_string_chunks_handle( + const cbor_item_t* item); /** Get the number of chunks this string consist of * @@ -107,7 +107,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t **cbor_string_chunks_handle( * @return The chunk count. 0 for freshly created items. */ _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_string_chunk_count(const cbor_item_t *item); +cbor_string_chunk_count(const cbor_item_t* item); /** Appends a chunk to the string * @@ -122,8 +122,8 @@ cbor_string_chunk_count(const cbor_item_t *item); * case, the refcount of @p `chunk` is not increased and the @p `item` is left * intact. */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_string_add_chunk(cbor_item_t *item, - cbor_item_t *chunk); +_CBOR_NODISCARD CBOR_EXPORT bool cbor_string_add_chunk(cbor_item_t* item, + cbor_item_t* chunk); /** Creates a new definite string * @@ -133,7 +133,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_add_chunk(cbor_item_t *item, * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_string(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_definite_string(void); /** Creates a new indefinite string * @@ -143,7 +143,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_string(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_string(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_indefinite_string(void); /** Creates a new string and initializes it * @@ -158,7 +158,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_string(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_string(const char *val); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_string(const char* val); /** Creates a new string and initializes it * @@ -173,7 +173,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_string(const char *val); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_stringn(const char *val, +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_stringn(const char* val, size_t length); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c index 3f3edb0b0e1..343a1cda560 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c @@ -7,8 +7,8 @@ #include "tags.h" -cbor_item_t *cbor_new_tag(uint64_t value) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_tag(uint64_t value) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -20,24 +20,24 @@ cbor_item_t *cbor_new_tag(uint64_t value) { return item; } -cbor_item_t *cbor_tag_item(const cbor_item_t *item) { - CBOR_ASSERT(cbor_isa_tag(item)); - return cbor_incref(item->metadata.tag_metadata.tagged_item); +cbor_item_t* cbor_tag_item(const cbor_item_t* tag) { + CBOR_ASSERT(cbor_isa_tag(tag)); + return cbor_incref(tag->metadata.tag_metadata.tagged_item); } -uint64_t cbor_tag_value(const cbor_item_t *item) { - CBOR_ASSERT(cbor_isa_tag(item)); - return item->metadata.tag_metadata.value; +uint64_t cbor_tag_value(const cbor_item_t* tag) { + CBOR_ASSERT(cbor_isa_tag(tag)); + return tag->metadata.tag_metadata.value; } -void cbor_tag_set_item(cbor_item_t *item, cbor_item_t *tagged_item) { - CBOR_ASSERT(cbor_isa_tag(item)); +void cbor_tag_set_item(cbor_item_t* tag, cbor_item_t* tagged_item) { + CBOR_ASSERT(cbor_isa_tag(tag)); cbor_incref(tagged_item); - item->metadata.tag_metadata.tagged_item = tagged_item; + tag->metadata.tag_metadata.tagged_item = tagged_item; } -cbor_item_t *cbor_build_tag(uint64_t value, cbor_item_t *item) { - cbor_item_t *res = cbor_new_tag(value); +cbor_item_t* cbor_build_tag(uint64_t value, cbor_item_t* item) { + cbor_item_t* res = cbor_new_tag(value); if (res == NULL) { return NULL; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h index a7365df1020..360cc861a53 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h @@ -21,51 +21,55 @@ extern "C" { * ============================================================================ */ -/** Create a new tag +/** Create a new tag. * - * @param value The tag value. Please consult the tag repository - * @return Reference to the new tag item. The item's reference count is - * initialized to one. - * @return `NULL` if memory allocation fails + * @param value The tag value (number). + * @return Reference to the new tag. Its reference count is initialized to one + * and it points to a `NULL` item. + * @return `NULL` if memory allocation fails. */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_tag(uint64_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_tag(uint64_t value); -/** Get the tagged item +/** Get the tagged item (what the tag points to). * - * @param item A tag - * @return Reference to the tagged item + * @param tag A #CBOR_TYPE_TAG tag. + * @return Reference to the tagged item. * * Increases the reference count of the underlying item. The returned reference * must be released using #cbor_decref. */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_tag_item(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_tag_item(const cbor_item_t* tag); -/** Get tag value +/** Get the tag value. * - * @param item A tag - * @return The tag value. Please consult the tag repository + * @param tag A #CBOR_TYPE_TAG tag. + * @return The tag value (number). */ -_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_tag_value(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_tag_value(const cbor_item_t* tag); -/** Set the tagged item +/** Assign a tag to an item. * - * @param item A tag + * @param tag A #CBOR_TYPE_TAG tag. * @param tagged_item The item to tag. Its reference count will be increased * by one. + * + * If the tag already points to an item, the pointer will be replaced, without a + * reference count change on the previous item. + * TODO: Should we release the reference automatically? */ -CBOR_EXPORT void cbor_tag_set_item(cbor_item_t *item, cbor_item_t *tagged_item); +CBOR_EXPORT void cbor_tag_set_item(cbor_item_t* tag, cbor_item_t* tagged_item); -/** Build a new tag +/** Build a new tag. * * @param item The item to tag. Its reference count will be increased by * one. - * @param value Tag value + * @param value The tag value (number). * @return Reference to the new tag item. The item's reference count is * initialized to one. - * @return `NULL` if memory allocation fails + * @return `NULL` if memory allocation fails. */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_tag(uint64_t value, - cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_tag(uint64_t value, + cbor_item_t* item); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/uuid.c b/contrib/restricted/aws/aws-c-common/source/uuid.c index f880c0d95dd..f94f7d0dd1a 100644 --- a/contrib/restricted/aws/aws-c-common/source/uuid.c +++ b/contrib/restricted/aws/aws-c-common/source/uuid.c @@ -17,6 +17,10 @@ "-" HEX_CHAR_FMT HEX_CHAR_FMT "-" HEX_CHAR_FMT HEX_CHAR_FMT "-" HEX_CHAR_FMT HEX_CHAR_FMT \ "-" HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT +#define UUID_FORMAT_COMPACT \ + HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT \ + HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT + #include <stdio.h> #ifdef _MSC_VER @@ -66,14 +70,18 @@ int aws_uuid_init_from_str(struct aws_uuid *uuid, const struct aws_byte_cursor * return AWS_OP_SUCCESS; } -int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output) { +static int s_uuid_to_str( + const struct aws_uuid *uuid, + struct aws_byte_buf *output, + const char *format_string, + size_t padded_formatted_length) { size_t space_remaining = output->capacity - output->len; - AWS_ERROR_PRECONDITION(space_remaining >= AWS_UUID_STR_LEN, AWS_ERROR_SHORT_BUFFER); + AWS_ERROR_PRECONDITION(space_remaining >= padded_formatted_length, AWS_ERROR_SHORT_BUFFER); snprintf( (char *)(output->buffer + output->len), space_remaining, - UUID_FORMAT, + format_string, uuid->uuid_data[0], uuid->uuid_data[1], uuid->uuid_data[2], @@ -91,11 +99,19 @@ int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output) { uuid->uuid_data[14], uuid->uuid_data[15]); - output->len += AWS_UUID_STR_LEN - 1; + output->len += padded_formatted_length - 1; return AWS_OP_SUCCESS; } +int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output) { + return s_uuid_to_str(uuid, output, UUID_FORMAT, AWS_UUID_STR_LEN); +} + +int aws_uuid_to_str_compact(const struct aws_uuid *uuid, struct aws_byte_buf *output) { + return s_uuid_to_str(uuid, output, UUID_FORMAT_COMPACT, AWS_UUID_STR_COMPACT_LEN); +} + bool aws_uuid_equals(const struct aws_uuid *a, const struct aws_uuid *b) { return 0 == memcmp(a->uuid_data, b->uuid_data, sizeof(a->uuid_data)); } diff --git a/contrib/restricted/aws/aws-c-common/ya.make b/contrib/restricted/aws/aws-c-common/ya.make index 7705eaa56e4..262ec0bae73 100644 --- a/contrib/restricted/aws/aws-c-common/ya.make +++ b/contrib/restricted/aws/aws-c-common/ya.make @@ -12,9 +12,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(0.12.3) +VERSION(0.12.4) -ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-common/archive/v0.12.3.tar.gz) +ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-common/archive/v0.12.4.tar.gz) ADDINCL( GLOBAL contrib/restricted/aws/aws-c-common/generated/include diff --git a/library/cpp/tld/tlds-alpha-by-domain.txt b/library/cpp/tld/tlds-alpha-by-domain.txt index 39822f30866..d5887966aee 100644 --- a/library/cpp/tld/tlds-alpha-by-domain.txt +++ b/library/cpp/tld/tlds-alpha-by-domain.txt @@ -1,4 +1,4 @@ -# Version 2025072200, Last Updated Tue Jul 22 07:07:01 2025 UTC +# Version 2025072500, Last Updated Fri Jul 25 07:07:01 2025 UTC AAA AARP ABB diff --git a/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp b/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp index 188c4845c6c..4483106009e 100644 --- a/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp +++ b/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp @@ -146,27 +146,6 @@ TExprNode::TPtr RebuildArgumentsOnlyLambdaForBlocks(const TExprNode& lambda, TEx return ctx.NewLambda(lambda.Pos(), ctx.NewArguments(lambda.Pos(), std::move(newArgs)), std::move(newRoots)); } -TExprNode::TPtr SwapFlowNodeWithStreamNode(const TExprNode::TPtr& flowNode, const TExprNode::TPtr& streamNode, TExprContext& ctx) { - const auto streamInput = streamNode->HeadPtr(); - // If streamInput is FromFlow, its input is WideFlow and can - // be used intact; Otherwise the input is WideStream, so the - // new input should be converted to WideFlow. - auto flowInput = streamInput->IsCallable("FromFlow") ? streamInput->HeadPtr() - : ctx.NewCallable(streamInput->Pos(), "ToFlow", { streamInput }); - // XXX: ChangeChild has to be used here and below, since - // the callable might have more than one input, but only - // the first one should be substituted. - const auto newFlowNode = ctx.ChangeChild(*flowNode, 0, std::move(flowInput)); - const auto newStreamNode = ctx.ChangeChild(*streamNode, 0, { - ctx.NewCallable(newFlowNode->Pos(), "FromFlow", { newFlowNode }) - }); - return ctx.Builder(flowNode->Pos()) - .Callable("ToFlow") - .Add(0, newStreamNode) - .Seal() - .Build(); -} - TExprNode::TPtr OptimizeWideToBlocks(const TExprNode::TPtr& node, TExprContext& ctx, TTypeAnnotationContext& types) { Y_UNUSED(types); const auto& input = node->Head(); @@ -275,30 +254,26 @@ TExprNode::TPtr OptimizeWideTakeSkipBlocks(const TExprNode::TPtr& node, TExprCon TExprNode::TPtr OptimizeBlockCompress(const TExprNode::TPtr& node, TExprContext& ctx, TTypeAnnotationContext& types) { Y_UNUSED(types); const auto& input = node->HeadPtr(); - if (input->IsCallable("ToFlow") && input->Head().IsCallable("ReplicateScalars")) { - const auto& replicateScalars = input->HeadPtr(); + if (input->IsCallable("ReplicateScalars")) { // Technically, the code below rewrites the following sequence - // (BlockCompress (ToFlow (ReplicateScalars (<input>)))) - // into (ToFlow (ReplicateScalars (FromFlow (BlockCompress (<input>))))), - // but ToFlow/FromFlow wrappers will be removed when all other - // nodes in block pipeline start using WideStream instead of the - // WideFlow. Hence, the logging is left intact. - YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << replicateScalars->Content(); - if (replicateScalars->ChildrenSize() == 1) { - return SwapFlowNodeWithStreamNode(node, replicateScalars, ctx); + // (BlockCompress (ReplicateScalars (<input>))) + // into (ReplicateScalars (BlockCompress (<input>))). + YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << input->Content(); + if (input->ChildrenSize() == 1) { + return ctx.SwapWithHead(*node); } const ui32 compressIndex = FromString<ui32>(node->Child(1)->Content()); TExprNodeList newReplicateIndexes; - for (auto atom : replicateScalars->Child(1)->ChildrenList()) { + for (auto atom : input->Child(1)->ChildrenList()) { ui32 idx = FromString<ui32>(atom->Content()); if (idx != compressIndex) { newReplicateIndexes.push_back((idx < compressIndex) ? atom : ctx.NewAtom(atom->Pos(), idx - 1)); } } - const auto& newReplicateScalars = ctx.ChangeChild(*replicateScalars, 1, - ctx.NewList(replicateScalars->Child(1)->Pos(), std::move(newReplicateIndexes))); - return SwapFlowNodeWithStreamNode(node, newReplicateScalars, ctx); + auto newReplicateScalars = ctx.ChangeChild(*input, 1, + ctx.NewList(input->Child(1)->Pos(), std::move(newReplicateIndexes))); + return ctx.SwapWithHead(*ctx.ChangeChild(*node, 0, std::move(newReplicateScalars))); } return node; @@ -6785,9 +6760,13 @@ TExprNode::TPtr OptimizeWideFilterBlocks(const TExprNode::TPtr& node, TExprConte // lambda is block-friendly YQL_ENSURE(it->second == multiInputType->GetSize(), "Block filter column must follow original input columns"); auto result = ctx.Builder(node->Pos()) - .Callable("BlockCompress") - .Add(0, blockMapped) - .Atom(1, it->second) + .Callable("ToFlow") + .Callable(0, "BlockCompress") + .Callable(0, "FromFlow") + .Add(0, blockMapped) + .Seal() + .Atom(1, it->second) + .Seal() .Seal() .Build(); @@ -7038,7 +7017,7 @@ TExprNode::TPtr OptimizeBlockCombine(const TExprNode::TPtr& node, TExprContext& if (input.IsCallable("BlockCompress") && node->Child(1)->IsCallable("Void")) { auto filterIndex = FromString<ui32>(input.Child(1)->Content()); TVector<ui32> argIndices; - argIndices.resize(input.GetTypeAnn()->Cast<TFlowExprType>()->GetItemType()->Cast<TMultiExprType>()->GetSize()); + argIndices.resize(input.GetTypeAnn()->Cast<TStreamExprType>()->GetItemType()->Cast<TMultiExprType>()->GetSize()); for (ui32 i = 0; i < argIndices.size(); ++i) { argIndices[i] = (i < filterIndex) ? i : i + 1; } @@ -7191,15 +7170,18 @@ TExprNode::TPtr OptimizeWideMaps(const TExprNode::TPtr& node, TExprContext& ctx) .Add(0, ctx.ChangeChild(input, 5U, ctx.DeepCopyLambda(input.Tail(), DropUnused(GetLambdaBody(input.Tail()), unused)))) .Add(1, DropUnusedArgs(node->Tail(), unused, ctx)) .Seal().Build(); - } else if (input.IsCallable("BlockCompress")) { - YQL_CLOG(DEBUG, CorePeepHole) << node->Content() << " over " << input.Content() << " with " << unused.size() << " unused fields."; - const auto index = FromString<ui32>(input.Tail().Content()); + } else if (input.IsCallable("ToFlow") && input.Head().IsCallable("BlockCompress")) { + auto& blockCompress = input.Head(); + YQL_CLOG(DEBUG, CorePeepHole) << node->Content() << " over " << blockCompress.Content() << " with " << unused.size() << " unused fields."; + const auto index = FromString<ui32>(blockCompress.Tail().Content()); const auto delta = std::distance(unused.cbegin(), std::find_if(unused.cbegin(), unused.cend(), std::bind(std::less<ui32>(), index, std::placeholders::_1))); return ctx.Builder(node->Pos()) .Callable(node->Content()) - .Callable(0, input.Content()) - .Add(0, MakeWideMapForDropUnused(input.HeadPtr(), unused, ctx)) - .Atom(1, index - delta) + .Callable(0, "ToFlow") + .Callable(0, blockCompress.Content()) + .Add(0, MakeWideMapForDropUnused(blockCompress.HeadPtr(), unused, ctx)) + .Atom(1, index - delta) + .Seal() .Seal() .Add(1, DropUnusedArgs(node->Tail(), unused, ctx)) .Seal().Build(); diff --git a/yql/essentials/core/type_ann/type_ann_blocks.cpp b/yql/essentials/core/type_ann/type_ann_blocks.cpp index f0caba7e5f4..67f9dfc5c8c 100644 --- a/yql/essentials/core/type_ann/type_ann_blocks.cpp +++ b/yql/essentials/core/type_ann/type_ann_blocks.cpp @@ -153,7 +153,7 @@ IGraphTransformer::TStatus BlockCompressWrapper(const TExprNode::TPtr& input, TE } TTypeAnnotationNode::TListType blockItemTypes; - if (!EnsureWideFlowBlockType(input->Head(), blockItemTypes, ctx.Expr)) { + if (!EnsureWideStreamBlockType(input->Head(), blockItemTypes, ctx.Expr)) { return IGraphTransformer::TStatus::Error; } @@ -186,11 +186,11 @@ IGraphTransformer::TStatus BlockCompressWrapper(const TExprNode::TPtr& input, TE return IGraphTransformer::TStatus::Error; } - auto flowItemTypes = input->Head().GetTypeAnn()->Cast<TFlowExprType>()->GetItemType()->Cast<TMultiExprType>()->GetItems(); + auto flowItemTypes = input->Head().GetTypeAnn()->Cast<TStreamExprType>()->GetItemType()->Cast<TMultiExprType>()->GetItems(); flowItemTypes.erase(flowItemTypes.begin() + index); auto outputItemType = ctx.Expr.MakeType<TMultiExprType>(flowItemTypes); - input->SetTypeAnn(ctx.Expr.MakeType<TFlowExprType>(outputItemType)); + input->SetTypeAnn(ctx.Expr.MakeType<TStreamExprType>(outputItemType)); return IGraphTransformer::TStatus::Ok; } diff --git a/yql/essentials/minikql/comp_nodes/mkql_block_compress.cpp b/yql/essentials/minikql/comp_nodes/mkql_block_compress.cpp index f9bf1dc376c..d1000082dc2 100644 --- a/yql/essentials/minikql/comp_nodes/mkql_block_compress.cpp +++ b/yql/essentials/minikql/comp_nodes/mkql_block_compress.cpp @@ -17,15 +17,15 @@ namespace NMiniKQL { namespace { -class TCompressWithScalarBitmap : public TStatefulWideFlowCodegeneratorNode<TCompressWithScalarBitmap> { -using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TCompressWithScalarBitmap>; +class TCompressWithScalarBitmapFlowWrapper : public TStatefulWideFlowCodegeneratorNode<TCompressWithScalarBitmapFlowWrapper> { +using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TCompressWithScalarBitmapFlowWrapper>; public: - TCompressWithScalarBitmap(TComputationMutables& mutables, IComputationWideFlowNode* flow, ui32 bitmapIndex, ui32 width) + TCompressWithScalarBitmapFlowWrapper(TComputationMutables& mutables, IComputationWideFlowNode* flow, ui32 bitmapIndex, ui32 inputWidth) : TBaseComputation(mutables, flow, EValueRepresentation::Embedded) , Flow_(flow) , BitmapIndex_(bitmapIndex) - , Width_(width) - , WideFieldsIndex_(mutables.IncrementWideFieldsIndex(Width_)) + , InputWidth_(inputWidth) + , WideFieldsIndex_(mutables.IncrementWideFieldsIndex(InputWidth_)) { } @@ -35,7 +35,7 @@ public: const auto fields = ctx.WideFields.data() + WideFieldsIndex_; NUdf::TUnboxedValue bitmap; - for (ui32 i = 0, outIndex = 0; i < Width_; ++i) { + for (ui32 i = 0, outIndex = 0; i < InputWidth_; ++i) { fields[i] = i == BitmapIndex_ ? &bitmap : output[outIndex++]; } @@ -113,26 +113,26 @@ private: IComputationWideFlowNode *const Flow_; const ui32 BitmapIndex_; - const ui32 Width_; + const ui32 InputWidth_; const ui32 WideFieldsIndex_; }; -class TCompressScalars : public TStatelessWideFlowCodegeneratorNode<TCompressScalars> { -using TBaseComputation = TStatelessWideFlowCodegeneratorNode<TCompressScalars>; +class TCompressScalarsFlowWrapper : public TStatelessWideFlowCodegeneratorNode<TCompressScalarsFlowWrapper> { +using TBaseComputation = TStatelessWideFlowCodegeneratorNode<TCompressScalarsFlowWrapper>; public: - TCompressScalars(TComputationMutables& mutables, IComputationWideFlowNode* flow, ui32 bitmapIndex, ui32 width) + TCompressScalarsFlowWrapper(TComputationMutables& mutables, IComputationWideFlowNode* flow, ui32 bitmapIndex, ui32 inputWidth) : TBaseComputation(flow) , Flow_(flow) , BitmapIndex_(bitmapIndex) - , Width_(width) - , WideFieldsIndex_(mutables.IncrementWideFieldsIndex(Width_)) + , InputWidth_(inputWidth) + , WideFieldsIndex_(mutables.IncrementWideFieldsIndex(InputWidth_)) { } EFetchResult DoCalculate(TComputationContext& ctx, NUdf::TUnboxedValue*const* output) const { const auto fields = ctx.WideFields.data() + WideFieldsIndex_; NUdf::TUnboxedValue bitmap; - for (ui32 i = 0, outIndex = 0; i < Width_; ++i) { + for (ui32 i = 0, outIndex = 0; i < InputWidth_; ++i) { fields[i] = i == BitmapIndex_ ? &bitmap : output[outIndex++]; } @@ -141,7 +141,7 @@ public: return result; if (const auto popCount = GetBitmapPopCountCount(bitmap)) { - if (const auto out = output[Width_ - 2]) + if (const auto out = output[InputWidth_ - 2]) *out = ctx.HolderFactory.CreateArrowBlock(arrow::Datum(std::make_shared<arrow::UInt64Scalar>(popCount))); break; } @@ -225,7 +225,7 @@ private: IComputationWideFlowNode *const Flow_; const ui32 BitmapIndex_; - const ui32 Width_; + const ui32 InputWidth_; const ui32 WideFieldsIndex_; }; @@ -236,10 +236,120 @@ size_t GetBitmapPopCount(const std::shared_ptr<arrow::ArrayData>& arr) { return GetSparseBitmapPopCount(src, len); } -class TCompressBlocks : public TStatefulWideFlowCodegeneratorNode<TCompressBlocks> { -using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TCompressBlocks>; +struct TCompressBlocksState: public TBlockState { + size_t InputSize_ = 0; + size_t OutputPos_ = 0; + bool IsFinished_ = false; + + const size_t MaxLength_; + + std::vector<std::shared_ptr<arrow::ArrayData>> Arrays_; + std::vector<std::unique_ptr<IArrayBuilder>> Builders_; + + NYql::NUdf::TCounter CounterOutputRows_; + + TCompressBlocksState(TMemoryUsageInfo* memInfo, TComputationContext& ctx, const TVector<TBlockType*>& types) + : TBlockState(memInfo, types.size() + 1U) + , MaxLength_(CalcBlockLen(std::accumulate(types.cbegin(), types.cend(), 0ULL, [](size_t max, const TBlockType* type) { return std::max(max, CalcMaxBlockItemSize(type->GetItemType())); }))) + , Arrays_(types.size() + 1U) + , Builders_(types.size()) + { + for (ui32 i = 0; i < types.size(); ++i) { + if (types[i]->GetShape() != TBlockType::EShape::Scalar) { + Builders_[i] = MakeArrayBuilder(TTypeInfoHelper(), types[i]->GetItemType(), ctx.ArrowMemoryPool, MaxLength_, &ctx.Builder->GetPgBuilder()); + } + } + if (ctx.CountersProvider) { + // id will be assigned externally in future versions + TString id = TString(Operator_Filter) + "0"; + CounterOutputRows_ = ctx.CountersProvider->GetCounter(id, Counter_OutputRows, false); + } + } + + enum class EStep: i8 { + Copy = -1, + Skip = 0, + Pass = 1 + }; + + EStep Check(const NUdf::TUnboxedValuePod bitmapValue) { + Y_ABORT_UNLESS(!IsFinished_); + Y_ABORT_UNLESS(!InputSize_); + auto& bitmap = Arrays_.back(); + bitmap = TArrowBlock::From(bitmapValue).GetDatum().array(); + + if (!bitmap->length) { + return EStep::Skip; + } + + const auto popCount = GetBitmapPopCount(bitmap); + + CounterOutputRows_.Add(popCount); + + if (!popCount) { + return EStep::Skip; + } + + if (!OutputPos_ && ui64(bitmap->length) == popCount) { + return EStep::Copy; + } + + return EStep::Pass; + } + + bool Sparse() { + auto& bitmap = Arrays_.back(); + if (!InputSize_) { + InputSize_ = bitmap->length; + for (size_t i = 0; i < Builders_.size(); ++i) { + if (Builders_[i]) { + Arrays_[i] = TArrowBlock::From(Values[i]).GetDatum().array(); + Y_ABORT_UNLESS(ui64(Arrays_[i]->length) == InputSize_); + } + } + } + + size_t outputAvail = MaxLength_ - OutputPos_; + size_t takeInputLen = 0; + size_t takeInputPopcnt = 0; + + const auto bitmapData = bitmap->GetValues<ui8>(1); + while (takeInputPopcnt < outputAvail && takeInputLen < InputSize_) { + takeInputPopcnt += bitmapData[takeInputLen++]; + } + Y_ABORT_UNLESS(takeInputLen > 0); + for (size_t i = 0; i < Builders_.size(); ++i) { + if (Builders_[i]) { + auto& arr = Arrays_[i]; + auto& builder = Builders_[i]; + auto slice = Chop(arr, takeInputLen); + builder->AddMany(*slice, takeInputPopcnt, bitmapData, takeInputLen); + } + } + + Chop(bitmap, takeInputLen); + OutputPos_ += takeInputPopcnt; + InputSize_ -= takeInputLen; + return MaxLength_ > OutputPos_; + } + + void FlushBuffers(const THolderFactory& holderFactory) { + for (ui32 i = 0; i < Builders_.size(); ++i) { + if (Builders_[i]) { + Values[i] = holderFactory.CreateArrowBlock(Builders_[i]->Build(IsFinished_)); + } + } + + Values.back() = MakeBlockCount(holderFactory, OutputPos_); + OutputPos_ = 0; + FillArrays(); + } +}; + +class TCompressBlocksFlowWrapper : public TStatefulWideFlowCodegeneratorNode<TCompressBlocksFlowWrapper> { +using TBaseComputation = TStatefulWideFlowCodegeneratorNode<TCompressBlocksFlowWrapper>; public: - TCompressBlocks(TComputationMutables& mutables, IComputationWideFlowNode* flow, ui32 bitmapIndex, TVector<TBlockType*>&& types) + TCompressBlocksFlowWrapper(TComputationMutables& mutables, IComputationWideFlowNode* flow, ui32 bitmapIndex, TVector<TBlockType*>&& types) : TBaseComputation(mutables, flow, EValueRepresentation::Boxed) , Flow_(flow) , BitmapIndex_(bitmapIndex) @@ -271,16 +381,16 @@ public: break; case EFetchResult::One: switch (s.Check(bitmap)) { - case TState::EStep::Copy: + case TCompressBlocksState::EStep::Copy: for (ui32 i = 0; i < s.Values.size(); ++i) { if (const auto out = output[i]) { *out = s.Values[i]; } } return EFetchResult::One; - case TState::EStep::Skip: + case TCompressBlocksState::EStep::Skip: continue; - case TState::EStep::Pass: + case TCompressBlocksState::EStep::Pass: break; } break; @@ -320,7 +430,7 @@ public: const auto atTop = &ctx.Func->getEntryBlock().back(); - const auto getFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TState::Get>()); + const auto getFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocksState::Get>()); const auto getType = FunctionType::get(valueType, {statePtrType, indexType, ctx.GetFactory()->getType(), indexType}, false); const auto getPtr = CastInst::Create(Instruction::IntToPtr, getFunc, PointerType::getUnqual(getType), "get", atTop); @@ -349,7 +459,7 @@ public: const auto ptrType = PointerType::getUnqual(StructType::get(context)); const auto self = CastInst::Create(Instruction::IntToPtr, ConstantInt::get(Type::getInt64Ty(context), uintptr_t(this)), ptrType, "self", block); - const auto makeFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocks::MakeState>()); + const auto makeFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocksFlowWrapper::MakeState>()); const auto makeType = FunctionType::get(Type::getVoidTy(context), {self->getType(), ctx.Ctx->getType(), statePtr->getType()}, false); const auto makeFuncPtr = CastInst::Create(Instruction::IntToPtr, makeFunc, PointerType::getUnqual(makeType), "function", block); CallInst::Create(makeType, makeFuncPtr, {self, ctx.Ctx, statePtr}, "", block); @@ -383,7 +493,7 @@ public: block = read; - const auto clearFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TState::ClearValues>()); + const auto clearFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocksState::ClearValues>()); const auto clearType = FunctionType::get(Type::getVoidTy(context), {statePtrType}, false); const auto clearPtr = CastInst::Create(Instruction::IntToPtr, clearFunc, PointerType::getUnqual(clearType), "clear", block); CallInst::Create(clearType, clearPtr, {stateArg}, "", block); @@ -410,7 +520,7 @@ public: const auto bitmapArg = bitmap; const auto stepType = Type::getInt8Ty(context); - const auto checkFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TState::Check>()); + const auto checkFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocksState::Check>()); const auto checkType = FunctionType::get(stepType, {statePtrType, bitmapArg->getType()}, false); const auto checkPtr = CastInst::Create(Instruction::IntToPtr, checkFunc, PointerType::getUnqual(checkType), "check_func", block); const auto check = CallInst::Create(checkType, checkPtr, {stateArg, bitmapArg}, "check", block); @@ -420,8 +530,8 @@ public: result->addIncoming(ConstantInt::get(statusType, static_cast<i32>(EFetchResult::One)), block); const auto step = SwitchInst::Create(check, save, 2U, block); - step->addCase(ConstantInt::get(stepType, i8(TState::EStep::Skip)), read); - step->addCase(ConstantInt::get(stepType, i8(TState::EStep::Copy)), over); + step->addCase(ConstantInt::get(stepType, i8(TCompressBlocksState::EStep::Skip)), read); + step->addCase(ConstantInt::get(stepType, i8(TCompressBlocksState::EStep::Copy)), over); block = save; @@ -438,7 +548,7 @@ public: block = work; - const auto sparseFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TState::Sparse>()); + const auto sparseFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocksState::Sparse>()); const auto sparseType = FunctionType::get(Type::getInt1Ty(context), {statePtrType}, false); const auto sparsePtr = CastInst::Create(Instruction::IntToPtr, sparseFunc, PointerType::getUnqual(sparseType), "sparse_func", block); const auto sparse = CallInst::Create(sparseType, sparsePtr, {stateArg}, "sparse", block); @@ -457,7 +567,7 @@ public: block = done; - const auto flushFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TState::FlushBuffers>()); + const auto flushFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocksState::FlushBuffers>()); const auto flushType = FunctionType::get(Type::getVoidTy(context), {statePtrType, ctx.GetFactory()->getType()}, false); const auto flushPtr = CastInst::Create(Instruction::IntToPtr, flushFunc, PointerType::getUnqual(flushType), "flush_func", block); CallInst::Create(flushType, flushPtr, {stateArg, ctx.GetFactory()}, "", block); @@ -466,7 +576,7 @@ public: block = fill; - const auto sliceFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TState::Slice>()); + const auto sliceFunc = ConstantInt::get(Type::getInt64Ty(context), GetMethodPtr<&TCompressBlocksState::Slice>()); const auto sliceType = FunctionType::get(indexType, {statePtrType}, false); const auto slicePtr = CastInst::Create(Instruction::IntToPtr, sliceFunc, PointerType::getUnqual(sliceType), "slice_func", block); const auto slice = CallInst::Create(sliceType, slicePtr, {stateArg}, "slice", block); @@ -515,111 +625,6 @@ public: } #endif private: - struct TState : public TBlockState { - size_t InputSize_ = 0; - size_t OutputPos_ = 0; - bool IsFinished_ = false; - - const size_t MaxLength_; - - std::vector<std::shared_ptr<arrow::ArrayData>> Arrays_; - std::vector<std::unique_ptr<IArrayBuilder>> Builders_; - - NYql::NUdf::TCounter CounterOutputRows_; - - TState(TMemoryUsageInfo* memInfo, TComputationContext& ctx, const TVector<TBlockType*>& types) - : TBlockState(memInfo, types.size() + 1U) - , MaxLength_(CalcBlockLen(std::accumulate(types.cbegin(), types.cend(), 0ULL, [](size_t max, const TBlockType* type){ return std::max(max, CalcMaxBlockItemSize(type->GetItemType())); }))) - , Arrays_(types.size() + 1U) - , Builders_(types.size()) - { - for (ui32 i = 0; i < types.size(); ++i) { - if (types[i]->GetShape() != TBlockType::EShape::Scalar) { - Builders_[i] = MakeArrayBuilder(TTypeInfoHelper(), types[i]->GetItemType(), ctx.ArrowMemoryPool, MaxLength_, &ctx.Builder->GetPgBuilder()); - } - } - if (ctx.CountersProvider) { - // id will be assigned externally in future versions - TString id = TString(Operator_Filter) + "0"; - CounterOutputRows_ = ctx.CountersProvider->GetCounter(id, Counter_OutputRows, false); - } - } - - enum class EStep : i8 { - Copy = -1, - Skip = 0, - Pass = 1 - }; - - EStep Check(const NUdf::TUnboxedValuePod bitmapValue) { - Y_ABORT_UNLESS(!IsFinished_); - Y_ABORT_UNLESS(!InputSize_); - auto& bitmap = Arrays_.back(); - bitmap = TArrowBlock::From(bitmapValue).GetDatum().array(); - - if (!bitmap->length) - return EStep::Skip; - - const auto popCount = GetBitmapPopCount(bitmap); - - CounterOutputRows_.Add(popCount); - - if (!popCount) - return EStep::Skip; - - if (!OutputPos_ && ui64(bitmap->length) == popCount) - return EStep::Copy; - - return EStep::Pass; - } - - bool Sparse() { - auto& bitmap = Arrays_.back(); - if (!InputSize_) { - InputSize_ = bitmap->length; - for (size_t i = 0; i < Builders_.size(); ++i) { - if (Builders_[i]) { - Arrays_[i] = TArrowBlock::From(Values[i]).GetDatum().array(); - Y_ABORT_UNLESS(ui64(Arrays_[i]->length) == InputSize_); - } - } - } - - size_t outputAvail = MaxLength_ - OutputPos_; - size_t takeInputLen = 0; - size_t takeInputPopcnt = 0; - - const auto bitmapData = bitmap->GetValues<ui8>(1); - while (takeInputPopcnt < outputAvail && takeInputLen < InputSize_) { - takeInputPopcnt += bitmapData[takeInputLen++]; - } - Y_ABORT_UNLESS(takeInputLen > 0); - for (size_t i = 0; i < Builders_.size(); ++i) { - if (Builders_[i]) { - auto& arr = Arrays_[i]; - auto& builder = Builders_[i]; - auto slice = Chop(arr, takeInputLen); - builder->AddMany(*slice, takeInputPopcnt, bitmapData, takeInputLen); - } - } - - Chop(bitmap, takeInputLen); - OutputPos_ += takeInputPopcnt; - InputSize_ -= takeInputLen; - return MaxLength_ > OutputPos_; - } - - void FlushBuffers(const THolderFactory& holderFactory) { - for (ui32 i = 0; i < Builders_.size(); ++i) { - if (Builders_[i]) - Values[i] = holderFactory.CreateArrowBlock(Builders_[i]->Build(IsFinished_)); - } - - Values.back() = MakeBlockCount(holderFactory, OutputPos_); - OutputPos_ = 0; - FillArrays(); - } - }; #ifndef MKQL_DISABLE_CODEGEN class TLLVMFieldsStructureState: public TLLVMFieldsStructureBlockState { private: @@ -663,13 +668,13 @@ private: } void MakeState(TComputationContext& ctx, NUdf::TUnboxedValue& state) const { - state = ctx.HolderFactory.Create<TState>(ctx, Types_); + state = ctx.HolderFactory.Create<TCompressBlocksState>(ctx, Types_); } - TState& GetState(NUdf::TUnboxedValue& state, TComputationContext& ctx) const { + TCompressBlocksState& GetState(NUdf::TUnboxedValue& state, TComputationContext& ctx) const { if (state.IsInvalid()) MakeState(ctx, state); - return *static_cast<TState*>(state.AsBoxed().Get()); + return *static_cast<TCompressBlocksState*>(state.AsBoxed().Get()); } @@ -679,35 +684,249 @@ private: const size_t WideFieldsIndex_; }; +enum class ECompressType { + BitmapIsScalar, + AllScalars, + Blocks +}; + +template <ECompressType CompressType> +class TCompressStreamWrapper: public TMutableComputationNode<TCompressStreamWrapper<CompressType>> { + using TBaseComputation = TMutableComputationNode<TCompressStreamWrapper<CompressType>>; + +public: + TCompressStreamWrapper(TComputationMutables& mutables, IComputationNode* stream, ui32 bitmapIndex, ui32 inputWidth, TVector<TBlockType*>&& types) + : TBaseComputation(mutables, EValueRepresentation::Boxed) + , Stream_(stream) + , BitmapIndex_(bitmapIndex) + , InputWidth_(inputWidth) + , Types_(std::move(types)) + , WideFieldsIndex_(mutables.IncrementWideFieldsIndex(Types_.size() + 2U)) + { + } + + NYql::NUdf::TUnboxedValuePod DoCalculate(TComputationContext& ctx) const { + NYql::NUdf::TUnboxedValue state; + if constexpr (CompressType == ECompressType::Blocks) { + state = ctx.HolderFactory.Create<TCompressBlocksState>(ctx, Types_); + } else { + state = NYql::NUdf::TUnboxedValuePod(); + } + return ctx.HolderFactory.Create<TStreamValue>(ctx.HolderFactory, + std::move(Stream_->GetValue(ctx)), + std::move(state), + BitmapIndex_, + Types_, + InputWidth_); + } + +private: + class TStreamValue: public TComputationValue<TStreamValue> { + using TBase = TComputationValue<TStreamValue>; + + public: + TStreamValue(TMemoryUsageInfo* memInfo, const THolderFactory& holderFactory, NYql::NUdf::TUnboxedValue stream, NYql::NUdf::TUnboxedValue state, ui32 bitmapIndex, const TVector<TBlockType*>& types, ui32 inputWidth) + : TBase(memInfo) + , HolderFactory_(holderFactory) + , Stream_(std::move(stream)) + , State_(std::move(state)) + , BitmapIndex_(bitmapIndex) + , Types_(types) + , Input_(inputWidth, NYql::NUdf::TUnboxedValuePod()) + { + } + + NUdf::EFetchStatus WideFetch(NUdf::TUnboxedValue* output, ui32 width) final { + if constexpr (CompressType == ECompressType::BitmapIsScalar) { + return BitmapIsScalar(output, width); + } else if constexpr(CompressType == ECompressType::AllScalars) { + return AllScalars(output, width); + } else if constexpr (CompressType == ECompressType::Blocks) { + return Blocks(output, width); + } else { + static_assert(0, "Unhandled case"); + } + } + + private: + void MoveAllExceptBitmap(NYql::NUdf::TUnboxedValue* output) { + for (ui32 i = 0, outIndex = 0; i < Input_.size(); ++i) { + if (i == BitmapIndex_) { + continue; + } + output[outIndex++] = std::move(Input_[i]); + } + } + + NUdf::EFetchStatus BitmapIsScalar(NUdf::TUnboxedValue* output, ui32 width) { + MKQL_ENSURE(width == OutputWidth(), "Width must be the same as output width."); + if (State_.IsFinish()) { + return NUdf::EFetchStatus::Finish; + } + + if (const auto result = Stream_.WideFetch(Input_.data(), Input_.size()); NUdf::EFetchStatus::Ok != result) { + return result; + } + MoveAllExceptBitmap(output); + + auto& bitmap = Input_[BitmapIndex_]; + const bool bitmapValue = GetBitmapScalarValue(bitmap) & 1; + State_ = bitmapValue ? NUdf::TUnboxedValuePod() : NUdf::TUnboxedValuePod::MakeFinish(); + + return bitmapValue ? NUdf::EFetchStatus::Ok : NUdf::EFetchStatus::Finish; + } + + NUdf::EFetchStatus AllScalars(NUdf::TUnboxedValue* output, ui32 width) { + MKQL_ENSURE(width == OutputWidth(), "Width must be the same as output width."); + + auto& bitmap = Input_[BitmapIndex_]; + for (;;) { + if (const auto result = Stream_.WideFetch(Input_.data(), Input_.size()); NUdf::EFetchStatus::Ok != result) { + return result; + } + MoveAllExceptBitmap(output); + + if (const auto popCount = GetBitmapPopCountCount(bitmap)) { + output[Input_.size() - 2] = HolderFactory_.CreateArrowBlock(arrow::Datum(std::make_shared<arrow::UInt64Scalar>(popCount))); + break; + } + } + return NUdf::EFetchStatus::Ok; + } + + NUdf::EFetchStatus Blocks(NUdf::TUnboxedValue* output, ui32 width) { + MKQL_ENSURE(width == OutputWidth(), "Width must be the same as output width."); + Y_DEBUG_ABORT_UNLESS(OutputWidth() == Input_.size() - 1); + Y_DEBUG_ABORT_UNLESS(OutputWidth() == Types_.size() + 1); + + auto& state = *static_cast<TCompressBlocksState*>(State_.AsBoxed().Get()); + Y_DEBUG_ABORT_UNLESS(state.Values.size() == OutputWidth()); + + auto& bitmap = Input_[BitmapIndex_]; + + if (!state.Count) { + do { + if (!state.InputSize_) { + state.ClearValues(); + auto wideFetchResult = Stream_.WideFetch(Input_.data(), Input_.size()); + MoveAllExceptBitmap(state.Values.data()); + + switch (wideFetchResult) { + case NUdf::EFetchStatus::Yield: + return NUdf::EFetchStatus::Yield; + case NUdf::EFetchStatus::Finish: + state.IsFinished_ = true; + break; + case NUdf::EFetchStatus::Ok: + switch (state.Check(bitmap)) { + case TCompressBlocksState::EStep::Copy: + for (ui32 i = 0; i < state.Values.size(); ++i) { + output[i] = state.Values[i]; + } + return NUdf::EFetchStatus::Ok; + case TCompressBlocksState::EStep::Skip: + continue; + case TCompressBlocksState::EStep::Pass: + break; + } + break; + } + } + } while (!state.IsFinished_ && state.Sparse()); + + if (state.OutputPos_) { + state.FlushBuffers(HolderFactory_); + } else { + return NUdf::EFetchStatus::Finish; + } + } + + const auto sliceSize = state.Slice(); + for (size_t i = 0; i < OutputWidth(); ++i) { + output[i] = state.Get(sliceSize, HolderFactory_, i); + } + + return NUdf::EFetchStatus::Ok; + } + + ui32 OutputWidth() { + return Input_.size() - 1; + } + + const THolderFactory& HolderFactory_; + NYql::NUdf::TUnboxedValue Stream_; + NUdf::TUnboxedValue State_; + ui32 BitmapIndex_; + const TVector<TBlockType*>& Types_; + TUnboxedValueVector Input_; + }; + + void RegisterDependencies() const final { + this->DependsOn(Stream_); + } + + IComputationNode* const Stream_; + const ui32 BitmapIndex_; + const ui32 InputWidth_; + const TVector<TBlockType*> Types_; + const size_t WideFieldsIndex_; +}; + +IComputationNode* WrapCompressWithScalarBitmap(TComputationMutables& mutables, IComputationNode* compressArg, ui32 bitmapIndex, ui32 inputWidth, TVector<TBlockType*>&& types) { + if (auto* flowCompressArg = dynamic_cast<IComputationWideFlowNode*>(compressArg)) { + return new TCompressWithScalarBitmapFlowWrapper(mutables, flowCompressArg, bitmapIndex, inputWidth); + } else { + return new TCompressStreamWrapper<ECompressType::BitmapIsScalar>(mutables, compressArg, bitmapIndex, inputWidth, std::move(types)); + } +} + +IComputationNode* WrapCompressScalars(TComputationMutables& mutables, IComputationNode* compressArg, ui32 bitmapIndex, ui32 inputWidth, TVector<TBlockType*>&& types) { + if (auto* flowCompressArg = dynamic_cast<IComputationWideFlowNode*>(compressArg)) { + return new TCompressScalarsFlowWrapper(mutables, flowCompressArg, bitmapIndex, inputWidth); + } else { + return new TCompressStreamWrapper<ECompressType::AllScalars>(mutables, compressArg, bitmapIndex, inputWidth, std::move(types)); + } +} + +IComputationNode* WrapCompressBlocks(TComputationMutables& mutables, IComputationNode* compressArg, ui32 bitmapIndex, ui32 inputWidth, TVector<TBlockType*>&& types) { + if (auto* flowCompressArg = dynamic_cast<IComputationWideFlowNode*>(compressArg)) { + return new TCompressBlocksFlowWrapper(mutables, flowCompressArg, bitmapIndex, std::move(types)); + } else { + return new TCompressStreamWrapper<ECompressType::Blocks>(mutables, compressArg, bitmapIndex, inputWidth, std::move(types)); + } +} + } // namespace IComputationNode* WrapBlockCompress(TCallable& callable, const TComputationNodeFactoryContext& ctx) { MKQL_ENSURE(callable.GetInputsCount() == 2, "Expected 2 args, got " << callable.GetInputsCount()); - const auto flowType = AS_TYPE(TFlowType, callable.GetInput(0).GetStaticType()); - const auto wideComponents = GetWideComponents(flowType); - const ui32 width = wideComponents.size(); - MKQL_ENSURE(width > 1, "Expected at least two columns"); + const auto streamOrFlowType = callable.GetInput(0).GetStaticType(); + MKQL_ENSURE(streamOrFlowType->IsStream() || streamOrFlowType->IsFlow(), "Expected stream or flow type."); + + const auto wideComponents = GetWideComponents(streamOrFlowType); + const ui32 inputWidth = wideComponents.size(); + MKQL_ENSURE(inputWidth > 1, "Expected at least two columns"); const auto indexData = AS_VALUE(TDataLiteral, callable.GetInput(1U)); - const auto index = indexData->AsValue().Get<ui32>(); - MKQL_ENSURE(index < width - 1, "Bad bitmap index"); + const auto bitmapIndex = indexData->AsValue().Get<ui32>(); + MKQL_ENSURE(bitmapIndex < inputWidth - 1, "Bad bitmap index"); TVector<TBlockType*> types; - types.reserve(width - 2U); + types.reserve(inputWidth - 2U); bool bitmapIsScalar = false; bool allScalars = true; - for (ui32 i = 0; i < width; ++i) { + for (ui32 i = 0; i < inputWidth; ++i) { types.push_back(AS_TYPE(TBlockType, wideComponents[i])); const bool isScalar = types.back()->GetShape() == TBlockType::EShape::Scalar; - if (i == width - 1) { + if (i == inputWidth - 1) { MKQL_ENSURE(isScalar, "Expecting scalar block size as last column"); bool isOptional; TDataType* unpacked = UnpackOptionalData(types.back()->GetItemType(), isOptional); auto slot = *unpacked->GetDataSlot(); MKQL_ENSURE(!isOptional && slot == NUdf::EDataSlot::Uint64, "Expecting Uint64 as last column"); types.pop_back(); - } else if (i == index) { + } else if (i == bitmapIndex) { bool isOptional; TDataType* unpacked = UnpackOptionalData(types.back()->GetItemType(), isOptional); auto slot = *unpacked->GetDataSlot(); @@ -719,16 +938,13 @@ IComputationNode* WrapBlockCompress(TCallable& callable, const TComputationNodeF } } - const auto wideFlow = dynamic_cast<IComputationWideFlowNode*>(LocateNode(ctx.NodeLocator, callable, 0)); - MKQL_ENSURE(wideFlow != nullptr, "Expected wide flow node"); - + const auto compressArg = LocateNode(ctx.NodeLocator, callable, 0); if (bitmapIsScalar) { - return new TCompressWithScalarBitmap(ctx.Mutables, wideFlow, index, width); + return WrapCompressWithScalarBitmap(ctx.Mutables, compressArg, bitmapIndex, inputWidth, std::move(types)); } else if (allScalars) { - return new TCompressScalars(ctx.Mutables, wideFlow, index, width); + return WrapCompressScalars(ctx.Mutables, compressArg, bitmapIndex, inputWidth, std::move(types)); } - - return new TCompressBlocks(ctx.Mutables, wideFlow, index, std::move(types)); + return WrapCompressBlocks(ctx.Mutables, compressArg, bitmapIndex, inputWidth, std::move(types)); } } // namespace NMiniKQL diff --git a/yql/essentials/minikql/comp_nodes/mkql_blocks.cpp b/yql/essentials/minikql/comp_nodes/mkql_blocks.cpp index b131b43a9b2..779298e8cd0 100644 --- a/yql/essentials/minikql/comp_nodes/mkql_blocks.cpp +++ b/yql/essentials/minikql/comp_nodes/mkql_blocks.cpp @@ -1756,7 +1756,9 @@ public: NUdf::TUnboxedValuePod DoCalculate(TComputationContext& ctx) const { return ctx.HolderFactory.Create<TExpanderState>(ctx, std::move(Stream_->GetValue(ctx)), Width_); } - void RegisterDependencies() const override {} + void RegisterDependencies() const override { + DependsOn(Stream_); + } private: IComputationNode* const Stream_; const size_t Width_; diff --git a/yql/essentials/minikql/comp_nodes/ut/mkql_block_compress_ut.cpp b/yql/essentials/minikql/comp_nodes/ut/mkql_block_compress_ut.cpp index ff531cde561..150c59f495f 100644 --- a/yql/essentials/minikql/comp_nodes/ut/mkql_block_compress_ut.cpp +++ b/yql/essentials/minikql/comp_nodes/ut/mkql_block_compress_ut.cpp @@ -84,9 +84,9 @@ void DoNestedTuplesCompressTest() { node = pb.ToFlow(pb.WideToBlocks(pb.FromFlow(node))); node = pb.BlockExpandChunked(node); - node = pb.ToFlow(pb.WideSkipBlocks(pb.FromFlow(node), pb.template NewDataLiteral<ui64>(19))); + node = pb.WideSkipBlocks(pb.FromFlow(node), pb.template NewDataLiteral<ui64>(19)); node = pb.BlockCompress(node, 2); - node = pb.ToFlow(pb.WideFromBlocks(pb.FromFlow(node))); + node = pb.ToFlow(pb.WideFromBlocks(node)); node = pb.NarrowMap(node, [&](TRuntimeNode::TList items) -> TRuntimeNode { return pb.NewTuple(resultTupleType, {items[0], items[1]}); @@ -186,9 +186,9 @@ Y_UNIT_TEST_LLVM(CompressBasic) { const auto wideFlow = pb.ExpandMap(flow, [&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth(item, 0U), pb.Nth(item, 1U), pb.Nth(item, 2U)}; }); - const auto uncompressedBlocks = pb.ToFlow(pb.WideToBlocks(pb.FromFlow(wideFlow))); + const auto uncompressedBlocks = pb.WideToBlocks(pb.FromFlow(wideFlow)); const auto compressedBlocks = pb.BlockCompress(uncompressedBlocks, 0); - const auto compressedFlow = pb.ToFlow(pb.WideFromBlocks(pb.FromFlow(compressedBlocks))); + const auto compressedFlow = pb.ToFlow(pb.WideFromBlocks(compressedBlocks)); const auto narrowFlow = pb.NarrowMap(compressedFlow, [&](TRuntimeNode::TList items) -> TRuntimeNode { return pb.NewTuple({items[0], items[1]}); }); diff --git a/yql/essentials/minikql/dom/json.cpp b/yql/essentials/minikql/dom/json.cpp index acd70667cc6..4d4b093f18a 100644 --- a/yql/essentials/minikql/dom/json.cpp +++ b/yql/essentials/minikql/dom/json.cpp @@ -251,11 +251,11 @@ void WriteMap(const TUnboxedValuePod value, TJsonWriter& writer) { const TStringBuf str = key.AsStringRef(); if constexpr (EncodeUtf8) if (const auto from = AsciiSize(str); from < str.size()) - writer.WriteKey(EncodeUtf(str, from)); + writer.Write(EncodeUtf(str, from)); else - writer.WriteKey(str); + writer.Write(str); else - writer.WriteKey(str); + writer.Write(str); WriteValue<SkipMapEntity, EncodeUtf8>(payload, writer); } } diff --git a/yql/essentials/minikql/mkql_program_builder.cpp b/yql/essentials/minikql/mkql_program_builder.cpp index 472a20b5bb3..93c808e51db 100644 --- a/yql/essentials/minikql/mkql_program_builder.cpp +++ b/yql/essentials/minikql/mkql_program_builder.cpp @@ -1610,26 +1610,31 @@ TRuntimeNode TProgramBuilder::ReplicateScalar(TRuntimeNode value, TRuntimeNode c return TRuntimeNode(callableBuilder.Build(), false); } -TRuntimeNode TProgramBuilder::BlockCompress(TRuntimeNode flow, ui32 bitmapIndex) { - auto blockItemTypes = ValidateBlockFlowType(flow.GetStaticType()); +TRuntimeNode TProgramBuilder::BlockCompress(TRuntimeNode stream, ui32 bitmapIndex) { + auto blockItemTypes = ValidateBlockStreamType(stream.GetStaticType()); MKQL_ENSURE(blockItemTypes.size() >= 2, "Expected at least two input columns"); MKQL_ENSURE(bitmapIndex < blockItemTypes.size() - 1, "Invalid bitmap index"); MKQL_ENSURE(AS_TYPE(TDataType, blockItemTypes[bitmapIndex])->GetSchemeType() == NUdf::TDataType<bool>::Id, "Expected Bool as bitmap column type"); - - const auto wideComponents = GetWideComponents(AS_TYPE(TFlowType, flow.GetStaticType())); + const auto wideComponents = GetWideComponents(stream.GetStaticType()); MKQL_ENSURE(wideComponents.size() == blockItemTypes.size(), "Unexpected tuple size"); - std::vector<TType*> flowItems; + std::vector<TType*> streamItems; for (size_t i = 0; i < wideComponents.size(); ++i) { if (i == bitmapIndex) { continue; } - flowItems.push_back(wideComponents[i]); + streamItems.push_back(wideComponents[i]); } - TCallableBuilder callableBuilder(Env_, __func__, NewFlowType(NewMultiType(flowItems))); - callableBuilder.Add(flow); + if constexpr (RuntimeVersion < 66) { + TCallableBuilder callableBuilder(Env_, __func__, NewFlowType(NewMultiType(streamItems))); + callableBuilder.Add(ToFlow(stream)); + callableBuilder.Add(NewDataLiteral<ui32>(bitmapIndex)); + return FromFlow(TRuntimeNode(callableBuilder.Build(), false)); + } + TCallableBuilder callableBuilder(Env_, __func__, NewStreamType(NewMultiType(streamItems))); + callableBuilder.Add(stream); callableBuilder.Add(NewDataLiteral<ui32>(bitmapIndex)); return TRuntimeNode(callableBuilder.Build(), false); } diff --git a/yql/essentials/minikql/mkql_runtime_version.h b/yql/essentials/minikql/mkql_runtime_version.h index 3b08da55bc9..c8021c6bfa6 100644 --- a/yql/essentials/minikql/mkql_runtime_version.h +++ b/yql/essentials/minikql/mkql_runtime_version.h @@ -24,7 +24,7 @@ namespace NMiniKQL { // 1. Bump this version every time incompatible runtime nodes are introduced. // 2. Make sure you provide runtime node generation for previous runtime versions. #ifndef MKQL_RUNTIME_VERSION -#define MKQL_RUNTIME_VERSION 65U +#define MKQL_RUNTIME_VERSION 66U #endif // History: diff --git a/yql/essentials/sql/v1/context.cpp b/yql/essentials/sql/v1/context.cpp index ba64bdc5939..f0cca2687dd 100644 --- a/yql/essentials/sql/v1/context.cpp +++ b/yql/essentials/sql/v1/context.cpp @@ -112,6 +112,10 @@ TContext::TContext(const TLexers& lexers, const TParsers& parsers, GroupByExprAfterWhere = true; } + if (settings.LangVer >= MakeLangVersion(2025, 3)) { + PersistableFlattenAndAggrExprs = true; + } + for (auto lib : settings.Libraries) { Libraries.emplace(lib, TLibraryStuff()); } diff --git a/yql/essentials/sql/v1/context.h b/yql/essentials/sql/v1/context.h index 10f5d2ebf79..a4027f8668d 100644 --- a/yql/essentials/sql/v1/context.h +++ b/yql/essentials/sql/v1/context.h @@ -378,6 +378,7 @@ namespace NSQLTranslationV1 { bool FailOnGroupByExprOverride = false; bool EmitUnionMerge = false; bool OptimizeSimpleIlike = false; + bool PersistableFlattenAndAggrExprs = false; TVector<size_t> ForAllStatementsParts; TMaybe<TString> Engine; diff --git a/yql/essentials/sql/v1/source.cpp b/yql/essentials/sql/v1/source.cpp index 94ef5c290fd..853421c8952 100644 --- a/yql/essentials/sql/v1/source.cpp +++ b/yql/essentials/sql/v1/source.cpp @@ -488,7 +488,7 @@ TNodePtr ISource::BuildFlattenColumns(const TString& label) { namespace { -TNodePtr BuildLambdaBodyForExprAliases(TPosition pos, const TVector<TNodePtr>& exprs, bool override) { +TNodePtr BuildLambdaBodyForExprAliases(TPosition pos, const TVector<TNodePtr>& exprs, bool override, bool persistable) { auto structObj = BuildAtom(pos, "row", TNodeFlags::Default); for (const auto& exprNode: exprs) { const auto name = exprNode->GetLabel(); @@ -503,7 +503,7 @@ TNodePtr BuildLambdaBodyForExprAliases(TPosition pos, const TVector<TNodePtr>& e if (dynamic_cast<const THoppingWindow*>(exprNode.Get())) { continue; } - structObj = structObj->Y("AddMember", structObj, structObj->Q(name), exprNode); + structObj = structObj->Y("AddMember", structObj, structObj->Q(name), persistable ? structObj->Y("PersistableRepr", exprNode) : exprNode); } return structObj->Y("AsList", structObj); } @@ -518,12 +518,20 @@ TNodePtr ISource::BuildPreaggregatedMap(TContext& ctx) { TNodePtr res; if (groupByExprs) { - auto body = BuildLambdaBodyForExprAliases(Pos_, groupByExprs, ctx.GroupByExprAfterWhere || !ctx.FailOnGroupByExprOverride); + auto body = BuildLambdaBodyForExprAliases( + Pos_, + groupByExprs, + ctx.GroupByExprAfterWhere || !ctx.FailOnGroupByExprOverride, + ctx.PersistableFlattenAndAggrExprs); res = Y("FlatMap", "core", BuildLambda(Pos_, Y("row"), body)); } if (distinctAggrExprs) { - auto body = BuildLambdaBodyForExprAliases(Pos_, distinctAggrExprs, ctx.GroupByExprAfterWhere || !ctx.FailOnGroupByExprOverride); + auto body = BuildLambdaBodyForExprAliases( + Pos_, + distinctAggrExprs, + ctx.GroupByExprAfterWhere || !ctx.FailOnGroupByExprOverride, + ctx.PersistableFlattenAndAggrExprs); auto lambda = BuildLambda(Pos_, Y("row"), body); res = res ? Y("FlatMap", res, lambda) : Y("FlatMap", "core", lambda); } @@ -533,7 +541,7 @@ TNodePtr ISource::BuildPreaggregatedMap(TContext& ctx) { TNodePtr ISource::BuildPreFlattenMap(TContext& ctx) { Y_UNUSED(ctx); YQL_ENSURE(IsFlattenByExprs()); - return BuildLambdaBodyForExprAliases(Pos_, Expressions(EExprSeat::FlattenByExpr), true); + return BuildLambdaBodyForExprAliases(Pos_, Expressions(EExprSeat::FlattenByExpr), true, ctx.PersistableFlattenAndAggrExprs); } TNodePtr ISource::BuildPrewindowMap(TContext& ctx) { diff --git a/yql/essentials/tests/sql/minirun/part5/canondata/result.json b/yql/essentials/tests/sql/minirun/part5/canondata/result.json index fe83c9cab87..afde9520ca1 100644 --- a/yql/essentials/tests/sql/minirun/part5/canondata/result.json +++ b/yql/essentials/tests/sql/minirun/part5/canondata/result.json @@ -424,9 +424,9 @@ ], "test.test[blocks-filter-default.txt-Peephole]": [ { - "checksum": "d57ebdb1176a6d15f700ed7c6e64f31b", - "size": 730, - "uri": "https://{canondata_backend}/1809005/02f459fce1f16d89b3444e6e8728b9747bb52b53/resource.tar.gz#test.test_blocks-filter-default.txt-Peephole_/opt.yql" + "checksum": "82b4953e1e8b82170f7679a66695f31d", + "size": 750, + "uri": "https://{canondata_backend}/1937001/df335b76812f126c746955ac4c4352068fe0e8b7/resource.tar.gz#test.test_blocks-filter-default.txt-Peephole_/opt.yql" } ], "test.test[blocks-filter-default.txt-Results]": [ @@ -1055,6 +1055,20 @@ "uri": "https://{canondata_backend}/1937367/c9a10a0bc7822717cc99c9a45cdc1b343d7ea5bf/resource.tar.gz#test.test_flatten_by-flatten_expr_where--Results_/results.txt" } ], + "test.test[flatten_by-flatten_persist_resource_2025_02--Debug]": [ + { + "checksum": "c7fb83f29f27350103885785d46b81be", + "size": 1351, + "uri": "https://{canondata_backend}/1936273/d66852662453816d40746f99af3ea0f2852c7b98/resource.tar.gz#test.test_flatten_by-flatten_persist_resource_2025_02--Debug_/opt.yql" + } + ], + "test.test[flatten_by-flatten_persist_resource_2025_02--Results]": [ + { + "checksum": "766f701e256f20d8569e89a7c2f4c52d", + "size": 1591, + "uri": "https://{canondata_backend}/1936273/d66852662453816d40746f99af3ea0f2852c7b98/resource.tar.gz#test.test_flatten_by-flatten_persist_resource_2025_02--Results_/results.txt" + } + ], "test.test[in-in_noansi_list_dict-default.txt-Debug]": [ { "checksum": "d1c11a9b8257ed4054032185c8ab6ae8", diff --git a/yql/essentials/tests/sql/minirun/part6/canondata/result.json b/yql/essentials/tests/sql/minirun/part6/canondata/result.json index 194f386973c..96dfc176a0c 100644 --- a/yql/essentials/tests/sql/minirun/part6/canondata/result.json +++ b/yql/essentials/tests/sql/minirun/part6/canondata/result.json @@ -209,6 +209,20 @@ "uri": "https://{canondata_backend}/1925842/9a344928381729abc8381a7e8ada7e10e2ba51fe/resource.tar.gz#test.test_aggregate-group_by_expr_after_where-default.txt-Results_/results.txt" } ], + "test.test[aggregate-group_by_expr_persist_resource--Debug]": [ + { + "checksum": "b6b941807503a83d09fb709c52ef37bd", + "size": 1319, + "uri": "https://{canondata_backend}/1784117/50a6a95d692fe6fe621fc12bc6b4cf35e12aaf07/resource.tar.gz#test.test_aggregate-group_by_expr_persist_resource--Debug_/opt.yql" + } + ], + "test.test[aggregate-group_by_expr_persist_resource--Results]": [ + { + "checksum": "88b4890e84c8c54e2e8b0cff2244b07c", + "size": 1430, + "uri": "https://{canondata_backend}/1784117/50a6a95d692fe6fe621fc12bc6b4cf35e12aaf07/resource.tar.gz#test.test_aggregate-group_by_expr_persist_resource--Results_/results.txt" + } + ], "test.test[aggregate-yql-20121-default.txt-Debug]": [ { "checksum": "5061f0e42c2162494941729bfbad7d35", @@ -410,9 +424,9 @@ ], "test.test[blocks-projection_add_ints_filter-default.txt-Peephole]": [ { - "checksum": "b48a57d896cdabf3db3480cd86cc8e2a", - "size": 871, - "uri": "https://{canondata_backend}/1917492/9722518a50ef2685c59301cc045eae38584b9f63/resource.tar.gz#test.test_blocks-projection_add_ints_filter-default.txt-Peephole_/opt.yql" + "checksum": "01f95e929504c5aa0b7649319635242b", + "size": 891, + "uri": "https://{canondata_backend}/1130705/45cb0500363a371da052fdfab03d172e95a23b9c/resource.tar.gz#test.test_blocks-projection_add_ints_filter-default.txt-Peephole_/opt.yql" } ], "test.test[blocks-projection_add_ints_filter-default.txt-Results]": [ diff --git a/yql/essentials/tests/sql/minirun/part9/canondata/result.json b/yql/essentials/tests/sql/minirun/part9/canondata/result.json index 935388a50fc..005566d0129 100644 --- a/yql/essentials/tests/sql/minirun/part9/canondata/result.json +++ b/yql/essentials/tests/sql/minirun/part9/canondata/result.json @@ -751,6 +751,20 @@ "uri": "https://{canondata_backend}/1942525/67e48e62cc0c5eb3bc9702e8bca0cc2d86a18994/resource.tar.gz#test.test_expr-type_as_key-default.txt-Results_/results.txt" } ], + "test.test[flatten_by-flatten_persist_resource--Debug]": [ + { + "checksum": "5ac2cddb4782ec64eee344a71cd9f6c0", + "size": 1351, + "uri": "https://{canondata_backend}/1130705/3e06a0b7cc71d9c51c38a7a12aef94d93a3c3316/resource.tar.gz#test.test_flatten_by-flatten_persist_resource--Debug_/opt.yql" + } + ], + "test.test[flatten_by-flatten_persist_resource--Results]": [ + { + "checksum": "b9b8ca1a31a5e2e1a633d24bb3f61d54", + "size": 1537, + "uri": "https://{canondata_backend}/1130705/3e06a0b7cc71d9c51c38a7a12aef94d93a3c3316/resource.tar.gz#test.test_flatten_by-flatten_persist_resource--Results_/results.txt" + } + ], "test.test[in-in_ansi_dict-default.txt-Debug]": [ { "checksum": "20d219dd5f07a17acf65ffd03ed9bda8", diff --git a/yql/essentials/tests/sql/sql2yql/canondata/result.json b/yql/essentials/tests/sql/sql2yql/canondata/result.json index 94faaaebfad..08f0c46a088 100644 --- a/yql/essentials/tests/sql/sql2yql/canondata/result.json +++ b/yql/essentials/tests/sql/sql2yql/canondata/result.json @@ -965,6 +965,20 @@ "uri": "https://{canondata_backend}/1937027/20da4ae4ed8ef86446356b94288d2f22b76637b5/resource.tar.gz#test_sql2yql.test_aggregate-group_by_expr_after_where_ver_/sql.yql" } ], + "test_sql2yql.test[aggregate-group_by_expr_persist_resource]": [ + { + "checksum": "0ff76b38f28e17ca625d2f32a1b55a08", + "size": 3528, + "uri": "https://{canondata_backend}/1773845/e1506e4a285ab9aacf8d90981405d591d579bfac/resource.tar.gz#test_sql2yql.test_aggregate-group_by_expr_persist_resource_/sql.yql" + } + ], + "test_sql2yql.test[aggregate-group_by_expr_persist_resource_2025_02]": [ + { + "checksum": "f4b11a7fc2c9972d9adfbbd655c0f73d", + "size": 3492, + "uri": "https://{canondata_backend}/1773845/e1506e4a285ab9aacf8d90981405d591d579bfac/resource.tar.gz#test_sql2yql.test_aggregate-group_by_expr_persist_resource_2025_02_/sql.yql" + } + ], "test_sql2yql.test[aggregate-group_by_rollup_rename]": [ { "checksum": "bc5b27508587d82ba3e9d0a752d25dcc", @@ -3828,6 +3842,20 @@ "uri": "https://{canondata_backend}/1942173/99e88108149e222741552e7e6cddef041d6a2846/resource.tar.gz#test_sql2yql.test_flatten_by-flatten_expr_where_/sql.yql" } ], + "test_sql2yql.test[flatten_by-flatten_persist_resource]": [ + { + "checksum": "fa408182ff6ce4a7393a7d79cfac33a0", + "size": 1666, + "uri": "https://{canondata_backend}/1936273/e9e39c487d6c666152f8f3db979f0f62caacbd95/resource.tar.gz#test_sql2yql.test_flatten_by-flatten_persist_resource_/sql.yql" + } + ], + "test_sql2yql.test[flatten_by-flatten_persist_resource_2025_02]": [ + { + "checksum": "719b314080a1611b56193a12376e69d0", + "size": 1648, + "uri": "https://{canondata_backend}/1936273/e9e39c487d6c666152f8f3db979f0f62caacbd95/resource.tar.gz#test_sql2yql.test_flatten_by-flatten_persist_resource_2025_02_/sql.yql" + } + ], "test_sql2yql.test[flexible_types-basic]": [ { "checksum": "90f01a5828973fffa784c7428f186302", @@ -8564,6 +8592,16 @@ "uri": "file://test_sql_format.test_aggregate-group_by_expr_after_where_ver_/formatted.sql" } ], + "test_sql_format.test[aggregate-group_by_expr_persist_resource]": [ + { + "uri": "file://test_sql_format.test_aggregate-group_by_expr_persist_resource_/formatted.sql" + } + ], + "test_sql_format.test[aggregate-group_by_expr_persist_resource_2025_02]": [ + { + "uri": "file://test_sql_format.test_aggregate-group_by_expr_persist_resource_2025_02_/formatted.sql" + } + ], "test_sql_format.test[aggregate-group_by_rollup_rename]": [ { "uri": "file://test_sql_format.test_aggregate-group_by_rollup_rename_/formatted.sql" @@ -10609,6 +10647,16 @@ "uri": "file://test_sql_format.test_flatten_by-flatten_expr_where_/formatted.sql" } ], + "test_sql_format.test[flatten_by-flatten_persist_resource]": [ + { + "uri": "file://test_sql_format.test_flatten_by-flatten_persist_resource_/formatted.sql" + } + ], + "test_sql_format.test[flatten_by-flatten_persist_resource_2025_02]": [ + { + "uri": "file://test_sql_format.test_flatten_by-flatten_persist_resource_2025_02_/formatted.sql" + } + ], "test_sql_format.test[flexible_types-basic]": [ { "uri": "file://test_sql_format.test_flexible_types-basic_/formatted.sql" diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_aggregate-group_by_expr_persist_resource_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_aggregate-group_by_expr_persist_resource_/formatted.sql new file mode 100644 index 00000000000..99cdab467d9 --- /dev/null +++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_aggregate-group_by_expr_persist_resource_/formatted.sql @@ -0,0 +1,16 @@ +SELECT + FormatType(TypeOf(some(DISTINCT DateTime::ShiftMonths(x, 1)))) +FROM ( + SELECT + CurrentUtcDate() AS x +); + +SELECT + FormatType(TypeOf(y)) +FROM ( + SELECT + CurrentUtcDate() AS x +) +GROUP BY + DateTime::ShiftMonths(x, 1) AS y +; diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_aggregate-group_by_expr_persist_resource_2025_02_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_aggregate-group_by_expr_persist_resource_2025_02_/formatted.sql new file mode 100644 index 00000000000..2dfdd9b13ab --- /dev/null +++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_aggregate-group_by_expr_persist_resource_2025_02_/formatted.sql @@ -0,0 +1,18 @@ +/* custom error: Expected hashable and equatable type for distinct column */ +SELECT + FormatType(TypeOf(some(DISTINCT DateTime::ShiftMonths(x, 1)))) +FROM ( + SELECT + CurrentUtcDate() AS x +); + +/* custom error: Expected hashable and equatable type for key column */ +SELECT + FormatType(TypeOf(y)) +FROM ( + SELECT + CurrentUtcDate() AS x +) +GROUP BY + DateTime::ShiftMonths(x, 1) AS y +; diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_flatten_by-flatten_persist_resource_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_flatten_by-flatten_persist_resource_/formatted.sql new file mode 100644 index 00000000000..749a2f3ee00 --- /dev/null +++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_flatten_by-flatten_persist_resource_/formatted.sql @@ -0,0 +1,9 @@ +SELECT + y, + FormatType(TypeOf(y)) +FROM + AS_TABLE([<|x: Yson('[1;2;3]')|>]) + FLATTEN LIST BY ( + Yson::ConvertToList(x) AS y + ) +; diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_flatten_by-flatten_persist_resource_2025_02_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_flatten_by-flatten_persist_resource_2025_02_/formatted.sql new file mode 100644 index 00000000000..749a2f3ee00 --- /dev/null +++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_flatten_by-flatten_persist_resource_2025_02_/formatted.sql @@ -0,0 +1,9 @@ +SELECT + y, + FormatType(TypeOf(y)) +FROM + AS_TABLE([<|x: Yson('[1;2;3]')|>]) + FLATTEN LIST BY ( + Yson::ConvertToList(x) AS y + ) +; diff --git a/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource.cfg b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource.cfg new file mode 100644 index 00000000000..5f8bed980fd --- /dev/null +++ b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource.cfg @@ -0,0 +1,2 @@ +langver 2025.03 +udf datetime2_udf diff --git a/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource.sql b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource.sql new file mode 100644 index 00000000000..2f17890cbff --- /dev/null +++ b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource.sql @@ -0,0 +1,2 @@ +select FormatType(TypeOf(some(distinct DateTime::ShiftMonths(x,1)))) from (select CurrentUtcDate() as x); +select FormatType(TypeOf(y)) from (select CurrentUtcDate() as x) group by DateTime::ShiftMonths(x,1) as y; diff --git a/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource_2025_02.cfg b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource_2025_02.cfg new file mode 100644 index 00000000000..429dd390f3f --- /dev/null +++ b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource_2025_02.cfg @@ -0,0 +1,3 @@ +xfail +langver 2025.02 +udf datetime2_udf diff --git a/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource_2025_02.sql b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource_2025_02.sql new file mode 100644 index 00000000000..f36972e9f29 --- /dev/null +++ b/yql/essentials/tests/sql/suites/aggregate/group_by_expr_persist_resource_2025_02.sql @@ -0,0 +1,5 @@ +/* custom error: Expected hashable and equatable type for distinct column */ +select FormatType(TypeOf(some(distinct DateTime::ShiftMonths(x,1)))) from (select CurrentUtcDate() as x); + +/* custom error: Expected hashable and equatable type for key column */ +select FormatType(TypeOf(y)) from (select CurrentUtcDate() as x) group by DateTime::ShiftMonths(x,1) as y; diff --git a/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource.cfg b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource.cfg new file mode 100644 index 00000000000..5febfd4925c --- /dev/null +++ b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource.cfg @@ -0,0 +1,2 @@ +langver 2025.03 +udf yson2_udf diff --git a/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource.sql b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource.sql new file mode 100644 index 00000000000..99fe575472f --- /dev/null +++ b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource.sql @@ -0,0 +1,2 @@ +select y, FormatType(TypeOf(y)) from AS_TABLE([<|x:Yson("[1;2;3]")|>]) +flatten list by (Yson::ConvertToList(x) as y); diff --git a/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource_2025_02.cfg b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource_2025_02.cfg new file mode 100644 index 00000000000..7f12e8e7577 --- /dev/null +++ b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource_2025_02.cfg @@ -0,0 +1,2 @@ +langver 2025.02 +udf yson2_udf diff --git a/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource_2025_02.sql b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource_2025_02.sql new file mode 100644 index 00000000000..99fe575472f --- /dev/null +++ b/yql/essentials/tests/sql/suites/flatten_by/flatten_persist_resource_2025_02.sql @@ -0,0 +1,2 @@ +select y, FormatType(TypeOf(y)) from AS_TABLE([<|x:Yson("[1;2;3]")|>]) +flatten list by (Yson::ConvertToList(x) as y); diff --git a/yql/essentials/udfs/common/datetime2/datetime_udf.cpp b/yql/essentials/udfs/common/datetime2/datetime_udf.cpp index 952b369d094..acc42ad2cbe 100644 --- a/yql/essentials/udfs/common/datetime2/datetime_udf.cpp +++ b/yql/essentials/udfs/common/datetime2/datetime_udf.cpp @@ -783,7 +783,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: Split(arg, Reference<TMResourceName>(res), *valueBuilder); sink(res); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << e.what()).data()); + UdfTerminate((TStringBuilder() << e.what()).c_str()); } } }; @@ -928,7 +928,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDate(builder, args[0].Get<ui16>()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -945,7 +945,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDate32(valueBuilder->GetDateBuilder(), args[0].Get<i32>()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -963,7 +963,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDatetime(builder, args[0].Get<ui32>()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -980,7 +980,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDatetime64(valueBuilder->GetDateBuilder(), args[0].Get<i64>()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -998,7 +998,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromTimestamp(builder, args[0].Get<ui64>()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1015,7 +1015,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromTimestamp64(valueBuilder->GetDateBuilder(), args[0].Get<i64>()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1033,7 +1033,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDate(builder, args[0].Get<ui16>(), args[0].GetTimezoneId()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1051,7 +1051,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDate32(builder, args[0].Get<i32>(), args[0].GetTimezoneId()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1070,7 +1070,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDatetime(builder, args[0].Get<ui32>(), args[0].GetTimezoneId()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1088,7 +1088,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromDatetime64(builder, args[0].Get<i64>(), args[0].GetTimezoneId()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1107,7 +1107,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromTimestamp(builder, args[0].Get<ui64>(), args[0].GetTimezoneId()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1125,7 +1125,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: storage.FromTimestamp64(builder, args[0].Get<i64>(), args[0].GetTimezoneId()); return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -1212,7 +1212,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: UdfTerminate((TStringBuilder() << Pos_ << "Timestamp " << storage.ToString() << " cannot be casted to TzDate" - ).data()); + ).c_str()); } } END_SIMPLE_ARROW_UDF(TMakeTzDate, TMakeDateKernelExec<TTzDate>::Do); @@ -1271,7 +1271,7 @@ TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf: UdfTerminate((TStringBuilder() << Pos_ << "Timestamp " << storage.ToString() << " cannot be casted to TzDate32" - ).data()); + ).c_str()); } } @@ -2780,7 +2780,7 @@ private: return TUnboxedValuePod(new TImpl(Pos_, args[0], alwaysWriteFractionalSeconds)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } class TImpl : public TBoxedValue { @@ -2812,7 +2812,7 @@ private: return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -3076,7 +3076,7 @@ private: TUnboxedValue Run(const IValueBuilder*, const TUnboxedValuePod* args) const final try { return TUnboxedValuePod(new TParse(args[0], Pos_)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } const TSourcePosition Pos_; @@ -3153,7 +3153,7 @@ private: } return result; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/file/file_udf.cpp b/yql/essentials/udfs/common/file/file_udf.cpp index ee09b2af20d..d499e85529e 100644 --- a/yql/essentials/udfs/common/file/file_udf.cpp +++ b/yql/essentials/udfs/common/file/file_udf.cpp @@ -379,11 +379,11 @@ namespace { TStreamMeta::TPtr metaPtr(new TStreamMeta(filePath)); auto pos = Pos_; auto terminateFunc = [pos](const TString& message) { - UdfTerminate((TStringBuilder() << pos << " " << message).data()); + UdfTerminate((TStringBuilder() << pos << " " << message).c_str()); }; return TUnboxedValuePod(new TListByLineBoxedValue<TUserType>(metaPtr, *valueBuilder, terminateFunc)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -437,7 +437,7 @@ namespace { items[IndexA_] = ValueBuilder_.NewString(attrs); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } return true; } @@ -534,7 +534,7 @@ namespace { TString filePath(args[0].AsStringRef()); return TUnboxedValuePod(new TList(IndexP_, IndexT_, IndexA_, *valueBuilder, Pos_, filePath)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/histogram/histogram_udf.cpp b/yql/essentials/udfs/common/histogram/histogram_udf.cpp index 1242c60927f..731b5956ed8 100644 --- a/yql/essentials/udfs/common/histogram/histogram_udf.cpp +++ b/yql/essentials/udfs/common/histogram/histogram_udf.cpp @@ -136,7 +136,7 @@ namespace { histogram->Get()->Add(args[0].Get<double>(), args[1].Get<double>()); return TUnboxedValuePod(histogram.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -187,7 +187,7 @@ namespace { resource->Get()->Add(args[1].Get<double>(), args[2].Get<double>()); return TUnboxedValuePod(args[0]); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -239,7 +239,7 @@ namespace { Y_PROTOBUF_SUPPRESS_NODISCARD proto.SerializeToString(&result); return valueBuilder->NewString(result); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -292,7 +292,7 @@ namespace { histogram->Get()->FromProto(proto); return TUnboxedValuePod(histogram.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -344,7 +344,7 @@ namespace { static_cast<THistogramResource*>(args[1].AsBoxed().Get())->Get()->Merge(proto, 1.0); return TUnboxedValuePod(args[1]); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -483,7 +483,7 @@ namespace { histogram->Get()->Add(args[0].Get<double>(), 1.0); return TUnboxedValuePod(histogram.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -519,7 +519,7 @@ namespace { histogram->Get()->FromProto(proto); return TUnboxedValuePod(histogram.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -553,7 +553,7 @@ namespace { histogram->Get()->Add(args[0].Get<double>(), 1.0); return TUnboxedValuePod(histogram.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -589,7 +589,7 @@ namespace { histogram->Get()->FromProto(proto); return TUnboxedValuePod(histogram.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -903,7 +903,7 @@ namespace { return GetResult(histogram, args); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/hyperloglog/hyperloglog_udf.cpp b/yql/essentials/udfs/common/hyperloglog/hyperloglog_udf.cpp index 744c25feac6..39d17f2ec44 100644 --- a/yql/essentials/udfs/common/hyperloglog/hyperloglog_udf.cpp +++ b/yql/essentials/udfs/common/hyperloglog/hyperloglog_udf.cpp @@ -149,7 +149,7 @@ namespace { hll->Get()->Update(args[0].Get<ui64>()); return TUnboxedValuePod(hll.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -196,7 +196,7 @@ namespace { resource->Get()->Update(args[1].Get<ui64>()); return TUnboxedValuePod(args[0]); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -244,7 +244,7 @@ namespace { static_cast<THyperLogLogResource*>(args[0].AsBoxed().Get())->Get()->Save(result); return valueBuilder->NewString(result.Str()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -292,7 +292,7 @@ namespace { THolder<THyperLogLogResource> hll(new THyperLogLogResource(THybridHyperLogLog::Load(input))); return TUnboxedValuePod(hll.Release()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -339,7 +339,7 @@ namespace { static_cast<THyperLogLogResource*>(args[1].AsBoxed().Get())->Get()->Merge(*left); return TUnboxedValuePod(args[1]); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/hyperscan/hyperscan_udf.cpp b/yql/essentials/udfs/common/hyperscan/hyperscan_udf.cpp index 45c64e73a70..c641407bc4c 100644 --- a/yql/essentials/udfs/common/hyperscan/hyperscan_udf.cpp +++ b/yql/essentials/udfs/common/hyperscan/hyperscan_udf.cpp @@ -181,7 +181,7 @@ namespace { } Scratch_ = MakeScratch(Database_); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -223,7 +223,7 @@ namespace { return Mode_ == THyperscanMatch::EMode::MULTI ? tuple : TUnboxedValue(TUnboxedValuePod(false)); } } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } private: @@ -249,7 +249,7 @@ namespace { const TUnboxedValuePod* args) const final try { return TUnboxedValuePod(new THyperscanCapture(args[0], Pos_)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } private: @@ -293,7 +293,7 @@ namespace { return TUnboxedValue(); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } TSourcePosition Pos_; @@ -315,7 +315,7 @@ namespace { const TUnboxedValuePod* args) const final try { return TUnboxedValuePod(new THyperscanReplace(args[0], Pos_)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } private: @@ -370,7 +370,7 @@ namespace { return TUnboxedValue(); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } TSourcePosition Pos_; diff --git a/yql/essentials/udfs/common/json2/as_json_node.h b/yql/essentials/udfs/common/json2/as_json_node.h index 12937f4351a..6060f03bea8 100644 --- a/yql/essentials/udfs/common/json2/as_json_node.h +++ b/yql/essentials/udfs/common/json2/as_json_node.h @@ -63,7 +63,7 @@ namespace NJson2Udf { } return Interpret(args[0], valueBuilder); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/json2/compile_path.h b/yql/essentials/udfs/common/json2/compile_path.h index 3d7eba01cb5..220bd4fbaf6 100644 --- a/yql/essentials/udfs/common/json2/compile_path.h +++ b/yql/essentials/udfs/common/json2/compile_path.h @@ -60,7 +60,7 @@ namespace NJson2Udf { return TUnboxedValuePod(new TJsonPathResource(jsonPath)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/json2/parse.h b/yql/essentials/udfs/common/json2/parse.h index 0020c164c2b..6df4bce9b0a 100644 --- a/yql/essentials/udfs/common/json2/parse.h +++ b/yql/essentials/udfs/common/json2/parse.h @@ -56,7 +56,7 @@ namespace NJson2Udf { const auto json = args[0].AsStringRef(); return TryParseJsonDom(json, valueBuilder); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/json2/serialize.h b/yql/essentials/udfs/common/json2/serialize.h index a7077cb6e6d..cda95e77f5a 100644 --- a/yql/essentials/udfs/common/json2/serialize.h +++ b/yql/essentials/udfs/common/json2/serialize.h @@ -67,7 +67,7 @@ namespace NJson2Udf { return valueBuilder->NewString(TStringBuf(binaryJson.Data(), binaryJson.Size())); } } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/json2/sql_exists.h b/yql/essentials/udfs/common/json2/sql_exists.h index 8a049b49d42..cb89f20ec21 100644 --- a/yql/essentials/udfs/common/json2/sql_exists.h +++ b/yql/essentials/udfs/common/json2/sql_exists.h @@ -105,7 +105,7 @@ namespace NJson2Udf { return TUnboxedValuePod(!result.GetNodes().empty()); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/json2/sql_query.h b/yql/essentials/udfs/common/json2/sql_query.h index cb3bafd3b0b..1c2d610f923 100644 --- a/yql/essentials/udfs/common/json2/sql_query.h +++ b/yql/essentials/udfs/common/json2/sql_query.h @@ -144,7 +144,7 @@ namespace NJson2Udf { return nodes[0].ConvertToUnboxedValue(valueBuilder); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/json2/sql_value.h b/yql/essentials/udfs/common/json2/sql_value.h index 8d3318a8c54..53b451c6275 100644 --- a/yql/essentials/udfs/common/json2/sql_value.h +++ b/yql/essentials/udfs/common/json2/sql_value.h @@ -231,7 +231,7 @@ namespace NJson2Udf { return BuildSuccessfulResult(valueBuilder, std::move(convertedValue)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/pire/pire_udf.cpp b/yql/essentials/udfs/common/pire/pire_udf.cpp index b8a05b5d6dc..de2a75955e3 100644 --- a/yql/essentials/udfs/common/pire/pire_udf.cpp +++ b/yql/essentials/udfs/common/pire/pire_udf.cpp @@ -106,7 +106,7 @@ namespace { if (Fsm_) try { *Fsm_ = *Fsm_ | TFsm(TString(part), options); } catch (const yexception&) { - UdfTerminate((TStringBuilder() << Pos_ << " Failed to glue up regexes, probably the finite state machine appeared to be too large").data()); + UdfTerminate((TStringBuilder() << Pos_ << " Failed to glue up regexes, probably the finite state machine appeared to be too large").c_str()); } else { Fsm_.Reset(new TFsm(TString(part), options)); } @@ -116,7 +116,7 @@ namespace { Fsm_.Reset(new TFsm(TString(regex), options)); } } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -159,7 +159,7 @@ namespace { return MultiMode_ ? tuple : TUnboxedValue(TUnboxedValuePod(false)); } } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } private: @@ -181,7 +181,7 @@ namespace { TUnboxedValue Run(const IValueBuilder*, const TUnboxedValuePod* args) const final try { return TUnboxedValuePod(new TPireCapture(args[0], Pos_)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } }; @@ -217,7 +217,7 @@ namespace { return TUnboxedValue(); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } TUniquePtr<TSlowCapturingFsm> Fsm_; @@ -235,7 +235,7 @@ namespace { TUnboxedValue Run(const IValueBuilder*, const TUnboxedValuePod* args) const final try { return TUnboxedValuePod(new TPireReplace(args[0], Pos_)); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } }; @@ -275,7 +275,7 @@ namespace { return TUnboxedValue(); } } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } TUniquePtr<TSlowCapturingFsm> Fsm_; diff --git a/yql/essentials/udfs/common/python/bindings/py_callable.cpp b/yql/essentials/udfs/common/python/bindings/py_callable.cpp index c60403bdca2..e9b25606ed0 100644 --- a/yql/essentials/udfs/common/python/bindings/py_callable.cpp +++ b/yql/essentials/udfs/common/python/bindings/py_callable.cpp @@ -188,7 +188,7 @@ private: TPyObjectPtr resultObj = PyObject_CallObject(Function_.Get(), pyArgs.Get()); if (!resultObj) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).c_str()); } auto returnType = Inspector_.GetReturnType(); @@ -198,7 +198,7 @@ private: return FromPyObject(CastCtx_, returnType, resultObj.Get()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Failed to cast arguments or result\n" << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Failed to cast arguments or result\n" << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/python/bindings/py_cast.cpp b/yql/essentials/udfs/common/python/bindings/py_cast.cpp index 1a90773cd45..51b68f897dc 100644 --- a/yql/essentials/udfs/common/python/bindings/py_cast.cpp +++ b/yql/essentials/udfs/common/python/bindings/py_cast.cpp @@ -474,7 +474,7 @@ TPyObjectPtr ToPyData(const TPyCastContext::TPtr& ctx, if (!pyObj) { UdfTerminate((TStringBuilder() << ctx->PyCtx->Pos << "Failed to convert to unicode with _yql_bytes_decode_mode='strict':\n" << - GetLastErrorAsString()).data() + GetLastErrorAsString()).c_str() ); } return pyObj; @@ -487,7 +487,7 @@ TPyObjectPtr ToPyData(const TPyCastContext::TPtr& ctx, PyTuple_SET_ITEM(pyArgs.Get(), 0, pyObj.Release()); pyObj = PyObject_CallObject(ctx->YsonConverterIn.Get(), pyArgs.Get()); if (!pyObj) { - UdfTerminate((TStringBuilder() << ctx->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << ctx->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).c_str()); } } @@ -554,7 +554,7 @@ NUdf::TUnboxedValue FromPyData( PyTuple_SET_ITEM(pyArgs.Get(), 0, input.Release()); input.ResetSteal(PyObject_CallObject(ctx->YsonConverterOut.Get(), pyArgs.Get())); if (!input) { - UdfTerminate((TStringBuilder() << ctx->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << ctx->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).c_str()); } return ctx->ValueBuilder->NewString(PyCast<NUdf::TStringRef>(input.Get())); } @@ -927,7 +927,7 @@ TPyObjectPtr ToPyArgs( sb << "Failed to export "; NUdf::TTypePrinter(*ctx->PyCtx->TypeInfoHelper, argType).Out(sb.Out); sb << " given as args[" << i << "]: "; - UdfTerminate((sb << ctx->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((sb << ctx->PyCtx->Pos << GetLastErrorAsString()).c_str()); } PyTuple_SET_ITEM(tuple.Get(), i, arg.Release()); } diff --git a/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_dict.cpp b/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_dict.cpp index b9d90e49f9f..1408f185a75 100644 --- a/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_dict.cpp +++ b/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_dict.cpp @@ -41,12 +41,12 @@ protected: } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return false; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool Next(NUdf::TUnboxedValue& value) override try { @@ -58,12 +58,12 @@ protected: } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return false; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool NextPair(NUdf::TUnboxedValue& key, NUdf::TUnboxedValue& payload) override { @@ -97,12 +97,12 @@ protected: } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return false; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool NextPair(NUdf::TUnboxedValue& key, NUdf::TUnboxedValue& pay) override try { @@ -115,12 +115,12 @@ protected: } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return false; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } private: @@ -143,12 +143,12 @@ protected: const TPyGilLocker lock; const auto has = PyObject_IsTrue(PyObject_.Get()); if (has < 0) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return bool(has); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } const TPyCastContext::TPtr CastCtx_; @@ -173,11 +173,11 @@ private: const TPyGilLocker lock; const auto len = PyMapping_Size(PyObject_.Get()); if (len < 0) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return ui64(len); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetKeysIterator() const override try { @@ -187,9 +187,9 @@ private: return NUdf::TUnboxedValuePod(new TIterator(CastCtx_, ItemType_, std::move(pyIter))); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetPayloadsIterator() const override try { @@ -199,9 +199,9 @@ private: return NUdf::TUnboxedValuePod(new TIterator(CastCtx_, PayType_, std::move(pyIter))); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetDictIterator() const override try { @@ -211,9 +211,9 @@ private: return NUdf::TUnboxedValuePod(new TPairIterator(CastCtx_, ItemType_, PayType_, std::move(pyIter))); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue Lookup(const NUdf::TUnboxedValuePod& key) const override try { @@ -229,9 +229,9 @@ private: return NUdf::TUnboxedValue(); } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool Contains(const NUdf::TUnboxedValuePod& key) const override try { @@ -246,9 +246,9 @@ private: return bool(has); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } private: @@ -272,11 +272,11 @@ private: const TPyGilLocker lock; const auto len = PyDict_Size(PyObject_.Get()); if (len < 0) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return ui64(len); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetKeysIterator() const override try { @@ -286,9 +286,9 @@ private: return NUdf::TUnboxedValuePod(new TIterator(CastCtx_, ItemType_, std::move(pyIter))); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetPayloadsIterator() const override try { @@ -298,9 +298,9 @@ private: return NUdf::TUnboxedValuePod(new TIterator(CastCtx_, PayType_, std::move(pyIter))); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetDictIterator() const override try { @@ -310,9 +310,9 @@ private: return NUdf::TUnboxedValuePod(new TPairIterator(CastCtx_, ItemType_, PayType_, std::move(pyIter))); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue Lookup(const NUdf::TUnboxedValuePod& key) const override try { @@ -324,9 +324,9 @@ private: return NUdf::TUnboxedValue(); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool Contains(const NUdf::TUnboxedValuePod& key) const override try { @@ -337,9 +337,9 @@ private: return bool(has); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } private: @@ -363,11 +363,11 @@ private: const TPyGilLocker lock; const auto len = PySet_Size(PyObject_.Get()); if (len < 0) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return ui64(len); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue Lookup(const NUdf::TUnboxedValuePod& key) const override { @@ -382,9 +382,9 @@ private: return bool(has); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetKeysIterator() const override try { @@ -392,9 +392,9 @@ private: if (TPyObjectPtr pyIter = PyObject_GetIter(PyObject_.Get())) { return NUdf::TUnboxedValuePod(new TIterator(CastCtx_, ItemType_, std::move(pyIter))); } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetPayloadsIterator() const override { @@ -439,11 +439,11 @@ private: const TPyGilLocker lock; const auto len = PySequence_Size(PyObject_.Get()); if (len < 0) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return ui64(len); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue Lookup(const NUdf::TUnboxedValuePod& key) const override { @@ -458,9 +458,9 @@ private: return bool(has); } } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetKeysIterator() const override try { @@ -468,9 +468,9 @@ private: if (TPyObjectPtr pyIter = PyObject_GetIter(PyObject_.Get())) { return NUdf::TUnboxedValuePod(new TIterator(CastCtx_, ItemType_, std::move(pyIter))); } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetPayloadsIterator() const override { @@ -561,7 +561,7 @@ private: value = FromPyObject(CastCtx_, ItemType_, PySequence_Fast_GET_ITEM(PySeq_.Get(), Index_++)); return true; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool NextPair(NUdf::TUnboxedValue& key, NUdf::TUnboxedValue& pay) override try { @@ -573,7 +573,7 @@ private: pay = FromPyObject(CastCtx_, ItemType_, PySequence_Fast_GET_ITEM(PySeq_.Get(), Index_++)); return true; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } private: @@ -613,10 +613,10 @@ private: if (const auto item = PySequence_Fast_GET_ITEM(PySeq_.Get(), index >= 0 ? index : Size_ + index)) { return FromPyObject(CastCtx_, ItemType_, item).Release().MakeOptional(); } else if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } return NUdf::TUnboxedValue(); } @@ -699,7 +699,7 @@ NUdf::TUnboxedValue FromPySequence( Y_ABORT("Invalid key type."); } } - UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).c_str()); } } // namespace NPython diff --git a/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_list.cpp b/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_list.cpp index fe3b8892e66..ef135f3ba20 100644 --- a/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_list.cpp +++ b/yql/essentials/udfs/common/python/bindings/py_lazy_mkql_list.cpp @@ -28,7 +28,7 @@ static ui64 CalculateIteratorLength(PyObject* iter, const TPyCastContext::TPtr& } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return length; @@ -41,7 +41,7 @@ static bool IsIteratorHasItems(PyObject* iter, const TPyCastContext::TPtr& castC } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return false; @@ -77,12 +77,12 @@ class TBaseLazyList: public NUdf::TBoxedValue } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return false; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool Next(NUdf::TUnboxedValue& value) override try { @@ -94,12 +94,12 @@ class TBaseLazyList: public NUdf::TBoxedValue } if (PyErr_Occurred()) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return false; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } private: @@ -129,7 +129,7 @@ private: return static_cast<const TDerived*>(this)->GetIteratorImpl(); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool HasFastListLength() const override { @@ -149,7 +149,7 @@ private: return *Length_; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool HasListItems() const override try { @@ -165,7 +165,7 @@ private: return hasItems; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } NUdf::TUnboxedValue GetListIterator() const override try { @@ -174,7 +174,7 @@ private: auto* self = const_cast<TListSelf*>(this); return NUdf::TUnboxedValuePod(new TIterator(self->CastCtx_, self->ItemType_, std::move(pyIter))); } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } const NUdf::TOpaqueListRepresentation* GetListRepresentation() const override { @@ -240,7 +240,7 @@ public: UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Cannot get iterator from object: " << PyObjectRepr(PyObject_.Get()) << ", error: " - << GetLastErrorAsString()).data()); + << GetLastErrorAsString()).c_str()); } private: @@ -261,7 +261,7 @@ private: return *Length_; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } bool HasListItems() const override try { @@ -280,7 +280,7 @@ private: return hasItems; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } }; @@ -303,7 +303,7 @@ public: if (IteratorDrained_) { UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Lazy list was build under python iterator. " - "Iterator was already used.").data()); + "Iterator was already used.").c_str()); } IteratorDrained_ = true; return PyObject_; @@ -343,7 +343,7 @@ public: TPyObjectPtr GetIteratorImpl() const { TPyObjectPtr generator = PyObject_CallObject(PyObject_.Get(), nullptr); if (!generator || !PyGen_Check(generator.Get())) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Expected generator as a result of function call").data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Expected generator as a result of function call").c_str()); } return PyObject_GetIter(generator.Get()); } diff --git a/yql/essentials/udfs/common/python/bindings/py_stream.cpp b/yql/essentials/udfs/common/python/bindings/py_stream.cpp index 5be78e442aa..24f7e0eb45d 100644 --- a/yql/essentials/udfs/common/python/bindings/py_stream.cpp +++ b/yql/essentials/udfs/common/python/bindings/py_stream.cpp @@ -215,7 +215,7 @@ private: PyIter_.Reset(); TPyObjectPtr result(PyObject_CallObject(PyGeneratorCallable_.Get(), PyGeneratorCallableArgs_.Get())); if (!result) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Failed to execute:\n" << GetLastErrorAsString()).c_str()); } if (PyGen_Check(result.Get())) { @@ -223,7 +223,7 @@ private: } else if (PyIter_Check(result.Get())) { iter = std::move(result); } else { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Expected iterator or generator, but got " << PyObjectRepr(result.Get())).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << "Expected iterator or generator, but got " << PyObjectRepr(result.Get())).c_str()); } } else { return NUdf::EFetchStatus::Yield; @@ -232,7 +232,7 @@ private: if (!iter) { iter.ResetSteal(PyObject_GetIter(iterable.Get())); if (!iter) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } } @@ -240,13 +240,13 @@ private: return NUdf::EFetchStatus::Yield; } - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return NUdf::EFetchStatus::Finish; } catch (const yexception& e) { - UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).data()); + UdfTerminate((TStringBuilder() << CastCtx_->PyCtx->Pos << e.what()).c_str()); } } @@ -287,7 +287,7 @@ NKikimr::NUdf::TUnboxedValue FromPyStream( if (PyGen_Check(value.Get())) { TPyObjectPtr iter(PyObject_GetIter(value.Get())); if (!iter) { - UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return NUdf::TUnboxedValuePod(new TStreamOverPyIter(castCtx, itemType, std::move(iter), nullptr, originalCallable, originalCallableClosure, originalCallableArgs)); @@ -308,11 +308,11 @@ NKikimr::NUdf::TUnboxedValue FromPyStream( if (PyCallable_Check(value.Get())) { TPyObjectPtr generator(PyObject_CallObject(value.Get(), nullptr)); if (!generator || !PyGen_Check(generator.Get())) { - UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << "Expected generator as a result of function call").data()); + UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << "Expected generator as a result of function call").c_str()); } TPyObjectPtr iter(PyObject_GetIter(generator.Get())); if (!iter) { - UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).c_str()); } TPyObjectPtr callableClosure; @@ -331,13 +331,13 @@ NKikimr::NUdf::TUnboxedValue FromPyStream( if (PySequence_Check(value.Get()) || PyObject_HasAttrString(value.Get(), "__iter__")) { TPyObjectPtr iter(PyObject_GetIter(value.Get())); if (!iter) { - UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << GetLastErrorAsString()).c_str()); } return NUdf::TUnboxedValuePod(new TStreamOverPyIter(castCtx, itemType, std::move(iter), originalCallable ? value : nullptr, nullptr, nullptr, nullptr)); } UdfTerminate((TStringBuilder() << castCtx->PyCtx->Pos << "Expected iterator, generator, generator factory, " - "or iterable object, but got " << PyObjectRepr(value.Get())).data()); + "or iterable object, but got " << PyObjectRepr(value.Get())).c_str()); } } // namespace NPython diff --git a/yql/essentials/udfs/common/python/python_udf/python_function_factory.h b/yql/essentials/udfs/common/python/python_udf/python_function_factory.h index 657fb1f442b..7d96f67a083 100644 --- a/yql/essentials/udfs/common/python/python_udf/python_function_factory.h +++ b/yql/essentials/udfs/common/python/python_udf/python_function_factory.h @@ -58,23 +58,23 @@ private: TPyGilLocker lock; TPyObjectPtr module = CompileModule(FunctionName_, source); if (!module) { - UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to compile module: " << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to compile module: " << GetLastErrorAsString()).c_str()); } TPyObjectPtr function(PyObject_GetAttrString(module.Get(), FunctionName_.data())); if (!function) { - UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to find entry point: " << GetLastErrorAsString()).data()); + UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to find entry point: " << GetLastErrorAsString()).c_str()); } if (!PyCallable_Check(function.Get())) { - UdfTerminate((TStringBuilder() << Ctx_->Pos << "Entry point is not a callable").data()); + UdfTerminate((TStringBuilder() << Ctx_->Pos << "Entry point is not a callable").c_str()); } try { SetupCallableSettings(castCtx, function.Get()); } catch (const yexception& e) { UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to setup callable settings: " - << e.what()).data()); + << e.what()).c_str()); } return FromPyCallable(castCtx, FunctionType_, function.Release()); } diff --git a/yql/essentials/udfs/common/re2/re2_udf.cpp b/yql/essentials/udfs/common/re2/re2_udf.cpp index baa3c6a3ec5..8e5079e6e42 100644 --- a/yql/essentials/udfs/common/re2/re2_udf.cpp +++ b/yql/essentials/udfs/common/re2/re2_udf.cpp @@ -209,7 +209,7 @@ namespace { } } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -248,7 +248,7 @@ namespace { const StringPiece rewrite(rewriteRef.data(), rewriteRef.size()); TString rewriteError; if (!Regexp_->CheckRewriteString(rewrite, &rewriteError)) { - UdfTerminate((TStringBuilder() << Pos_ << " [rewrite error] " << rewriteError).data()); + UdfTerminate((TStringBuilder() << Pos_ << " [rewrite error] " << rewriteError).c_str()); } std::string result(input); RE2::GlobalReplace(&result, *Regexp_, rewrite); @@ -289,7 +289,7 @@ namespace { Y_ABORT("Unexpected mode"); } } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } std::unique_ptr<RE2> Regexp_; @@ -392,7 +392,7 @@ namespace { if (hasEscape) { const std::string_view escapeRef(args[1].AsStringRef()); if (escapeRef.size() != 1U) { - UdfTerminate((TStringBuilder() << GetPos() << " Escape should be single character").data()); + UdfTerminate((TStringBuilder() << GetPos() << " Escape should be single character").c_str()); } escape = escapeRef.front(); } diff --git a/yql/essentials/udfs/common/stat/static/stat_udf.h b/yql/essentials/udfs/common/stat/static/stat_udf.h index 36a1bad7c4f..3ab6dbb20b4 100644 --- a/yql/essentials/udfs/common/stat/static/stat_udf.h +++ b/yql/essentials/udfs/common/stat/static/stat_udf.h @@ -19,7 +19,7 @@ namespace { const double delta = args[1].GetOrDefault<double>(0.01); const double K = args[2].GetOrDefault<double>(25.0); if (delta == 0 || K / delta < 1) { - UdfTerminate((TStringBuilder() << GetPos() << " Invalid combination of delta/K values").data()); + UdfTerminate((TStringBuilder() << GetPos() << " Invalid combination of delta/K values").c_str()); } return TUnboxedValuePod(new TDigestResource(delta, K, args[0].Get<double>(), true)); diff --git a/yql/essentials/udfs/common/streaming/streaming_udf.cpp b/yql/essentials/udfs/common/streaming/streaming_udf.cpp index dcae482b320..63fa55e9e80 100644 --- a/yql/essentials/udfs/common/streaming/streaming_udf.cpp +++ b/yql/essentials/udfs/common/streaming/streaming_udf.cpp @@ -279,7 +279,7 @@ namespace { ythrow yexception(); } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } @@ -564,7 +564,7 @@ namespace { return status; } catch (const std::exception& e) { - UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).data()); + UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str()); } } diff --git a/yql/essentials/udfs/common/url_base/lib/url_query.cpp b/yql/essentials/udfs/common/url_base/lib/url_query.cpp index f449be22681..885dc3b16e9 100644 --- a/yql/essentials/udfs/common/url_base/lib/url_query.cpp +++ b/yql/essentials/udfs/common/url_base/lib/url_query.cpp @@ -33,7 +33,7 @@ namespace NUrlUdf { StringSplitter(query).SplitByString(sep).Collect(&parts); if (parts.size() > maxFieldCnt) { UdfTerminate((TStringBuilder() << Pos_ << "Max number of fields (" << maxFieldCnt - << ") exceeded: got " << parts.size()).data()); + << ") exceeded: got " << parts.size()).c_str()); } std::vector<std::pair<TString, TString>> pairs; @@ -45,7 +45,7 @@ namespace NUrlUdf { if (nvPair.size() != 2) { if (strict) { UdfTerminate((TStringBuilder() << Pos_ << "Bad query field: \"" - << nvPair[0] << "\"").data()); + << nvPair[0] << "\"").c_str()); } if (keepBlankValues) { nvPair.emplace_back(""); diff --git a/yql/essentials/udfs/common/yson2/test/canondata/result.json b/yql/essentials/udfs/common/yson2/test/canondata/result.json index 32f8b40ce4d..efb3d3a0045 100644 --- a/yql/essentials/udfs/common/yson2/test/canondata/result.json +++ b/yql/essentials/udfs/common/yson2/test/canondata/result.json @@ -109,6 +109,11 @@ "uri": "file://test.test_ImplicitFromRes_/results.txt" } ], + "test.test[InvalidMapKey]": [ + { + "uri": "file://test.test_InvalidMapKey_/extracted" + } + ], "test.test[IsType]": [ { "uri": "file://test.test_IsType_/results.txt" @@ -139,6 +144,11 @@ "uri": "file://test.test_Lookup_/results.txt" } ], + "test.test[MapKeyEscape]": [ + { + "uri": "file://test.test_MapKeyEscape_/results.txt" + } + ], "test.test[NegativeArrayIndex]": [ { "uri": "file://test.test_NegativeArrayIndex_/results.txt" diff --git a/yql/essentials/udfs/common/yson2/test/canondata/test.test_InvalidMapKey_/extracted b/yql/essentials/udfs/common/yson2/test/canondata/test.test_InvalidMapKey_/extracted new file mode 100644 index 00000000000..b30b115217f --- /dev/null +++ b/yql/essentials/udfs/common/yson2/test/canondata/test.test_InvalidMapKey_/extracted @@ -0,0 +1,8 @@ +<tmp_path>/program.sql:<main>: Error: Execution + + <tmp_path>/program.sql:<main>:2:1: Error: Execution of node: Result + select ToBytes(Yson::SerializeJson(Yson::From({"\xff":1}))) + ^ + <tmp_path>/program.sql:<main>:2:22: Error: JSON writer: invalid UTF-8 + select ToBytes(Yson::SerializeJson(Yson::From({"\xff":1}))) + ^
\ No newline at end of file diff --git a/yql/essentials/udfs/common/yson2/test/canondata/test.test_MapKeyEscape_/results.txt b/yql/essentials/udfs/common/yson2/test/canondata/test.test_MapKeyEscape_/results.txt new file mode 100644 index 00000000000..3cdc772441e --- /dev/null +++ b/yql/essentials/udfs/common/yson2/test/canondata/test.test_MapKeyEscape_/results.txt @@ -0,0 +1,33 @@ +[ + { + "Write" = [ + { + "Type" = [ + "ListType"; + [ + "StructType"; + [ + [ + "column0"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + ]; + "Data" = [ + [ + [ + "{\":\\\"\":1}" + ] + ] + ] + } + ] + } +]
\ No newline at end of file diff --git a/yql/essentials/udfs/common/yson2/test/cases/InvalidMapKey.cfg b/yql/essentials/udfs/common/yson2/test/cases/InvalidMapKey.cfg new file mode 100644 index 00000000000..5dae597903c --- /dev/null +++ b/yql/essentials/udfs/common/yson2/test/cases/InvalidMapKey.cfg @@ -0,0 +1 @@ +xfail diff --git a/yql/essentials/udfs/common/yson2/test/cases/InvalidMapKey.sql b/yql/essentials/udfs/common/yson2/test/cases/InvalidMapKey.sql new file mode 100644 index 00000000000..e662a410ea7 --- /dev/null +++ b/yql/essentials/udfs/common/yson2/test/cases/InvalidMapKey.sql @@ -0,0 +1 @@ +select ToBytes(Yson::SerializeJson(Yson::From({"\xff":1}))) diff --git a/yql/essentials/udfs/common/yson2/test/cases/MapKeyEscape.sql b/yql/essentials/udfs/common/yson2/test/cases/MapKeyEscape.sql new file mode 100644 index 00000000000..1d4e0447c78 --- /dev/null +++ b/yql/essentials/udfs/common/yson2/test/cases/MapKeyEscape.sql @@ -0,0 +1 @@ +select ToBytes(Yson::SerializeJson(Yson::From({":\"":1}))) diff --git a/yql/essentials/udfs/common/yson2/yson2_udf.cpp b/yql/essentials/udfs/common/yson2/yson2_udf.cpp index 42f19d144e2..8fe6e17e366 100644 --- a/yql/essentials/udfs/common/yson2/yson2_udf.cpp +++ b/yql/essentials/udfs/common/yson2/yson2_udf.cpp @@ -331,7 +331,7 @@ template <TConverterPtr Converter = nullptr> TUnboxedValuePod YPathImpl(TUnboxedValuePod dict, const TUnboxedValuePod key, const IValueBuilder* valueBuilder, const TSourcePosition& pos) { const std::string_view path = key.AsStringRef(); if (path.size() < 2U || path.front() != '/' || path.back() == '/') { - UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(pos) << " Invalid YPath: '" << path << "'.").data()); + UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(pos) << " Invalid YPath: '" << path << "'.").c_str()); } for (const auto s : StringSplitter(path.substr(path[1U] == '/' ? 2U : 1U)).Split('/')) { @@ -676,7 +676,7 @@ SIMPLE_UDF_WITH_OPTIONAL_ARGS(TSerializeJson, TOptional<TJson>(TAutoMap<TNodeRes return valueBuilder->NewString(SerializeJsonDom(args[0], args[2].GetOrDefault(false), args[3].GetOrDefault(false), args[4].GetOrDefault(false))); } catch (const std::exception& e) { if (ParseOptions(args[1]).Strict) { - UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(GetPos()) << " " << e.what()).data()); + UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(GetPos()) << " " << e.what()).c_str()); } return {}; } @@ -1095,7 +1095,7 @@ TUnboxedValue TParse<TYson, false>::Run(const IValueBuilder* valueBuilder, const return TryParseYsonDom(args[0].AsStringRef(), valueBuilder); } catch (const std::exception& e) { if (StrictType_ || ParseOptions(args[1]).Strict) { - UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(Pos_) << " " << e.what()).data()); + UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(Pos_) << " " << e.what()).c_str()); } return TUnboxedValuePod(); } @@ -1105,7 +1105,7 @@ TUnboxedValue TParse<TJson, false>::Run(const IValueBuilder* valueBuilder, const return TryParseJsonDom(args[0].AsStringRef(), valueBuilder); } catch (const std::exception& e) { if (StrictType_ || ParseOptions(args[1]).Strict) { - UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(Pos_) << " " << e.what()).data()); + UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(Pos_) << " " << e.what()).c_str()); } return TUnboxedValuePod(); } @@ -1115,7 +1115,7 @@ TUnboxedValue TParse<TJson, true>::Run(const IValueBuilder* valueBuilder, const return TryParseJsonDom(args[0].AsStringRef(), valueBuilder, true); } catch (const std::exception& e) { if (StrictType_ || ParseOptions(args[1]).Strict) { - UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(Pos_) << " " << e.what()).data()); + UdfTerminate((::TStringBuilder() << valueBuilder->WithCalleePosition(Pos_) << " " << e.what()).c_str()); } return TUnboxedValuePod(); } diff --git a/yt/yt/client/api/rpc_proxy/client_impl.cpp b/yt/yt/client/api/rpc_proxy/client_impl.cpp index 8e05b3f4242..bf6685b7a02 100644 --- a/yt/yt/client/api/rpc_proxy/client_impl.cpp +++ b/yt/yt/client/api/rpc_proxy/client_impl.cpp @@ -2902,7 +2902,7 @@ TFuture<TSignedShuffleHandlePtr> TClient::StartShuffle( TFuture<IRowBatchReaderPtr> TClient::CreateShuffleReader( const TSignedShuffleHandlePtr& signedShuffleHandle, int partitionIndex, - std::optional<std::pair<int, int>> writerIndexRange, + std::optional<TIndexRange> writerIndexRange, const TShuffleReaderOptions& options) { auto proxy = CreateApiServiceProxy(); diff --git a/yt/yt/client/api/shuffle_client.h b/yt/yt/client/api/shuffle_client.h index afb6f26cf4f..a64009b8ec8 100644 --- a/yt/yt/client/api/shuffle_client.h +++ b/yt/yt/client/api/shuffle_client.h @@ -51,6 +51,8 @@ struct TShuffleWriterOptions struct IShuffleClient { + using TIndexRange = std::pair<int, int>; + virtual ~IShuffleClient() = default; virtual TFuture<TSignedShuffleHandlePtr> StartShuffle( @@ -62,7 +64,7 @@ struct IShuffleClient virtual TFuture<IRowBatchReaderPtr> CreateShuffleReader( const TSignedShuffleHandlePtr& shuffleHandle, int partitionIndex, - std::optional<std::pair<int, int>> writerIndexRange = {}, + std::optional<TIndexRange> writerIndexRange = {}, const TShuffleReaderOptions& options = {}) = 0; virtual TFuture<IRowBatchWriterPtr> CreateShuffleWriter( diff --git a/yt/yt/client/driver/shuffle_commands.cpp b/yt/yt/client/driver/shuffle_commands.cpp index 691870e399d..21cc875f9fa 100644 --- a/yt/yt/client/driver/shuffle_commands.cpp +++ b/yt/yt/client/driver/shuffle_commands.cpp @@ -91,7 +91,7 @@ void TReadShuffleDataCommand::DoExecute(ICommandContextPtr context) << TErrorAttribute("shuffle_handle", shuffleHandle); } - std::optional<std::pair<int, int>> writerIndexRange; + std::optional<IShuffleClient::TIndexRange> writerIndexRange; if (WriterIndexBegin.has_value()) { writerIndexRange = std::pair(*WriterIndexBegin, *WriterIndexEnd); } diff --git a/yt/yt/client/federated/client.cpp b/yt/yt/client/federated/client.cpp index da3cb8f0bea..917ca256c2f 100644 --- a/yt/yt/client/federated/client.cpp +++ b/yt/yt/client/federated/client.cpp @@ -505,7 +505,7 @@ public: UNIMPLEMENTED_METHOD(TFuture<void>, FinishDistributedWriteSession, (const TDistributedWriteSessionWithResults&, const TDistributedWriteSessionFinishOptions&)); UNIMPLEMENTED_METHOD(TFuture<ITableFragmentWriterPtr>, CreateTableFragmentWriter, (const TSignedWriteFragmentCookiePtr&, const TTableFragmentWriterOptions&)); UNIMPLEMENTED_METHOD(TFuture<TSignedShuffleHandlePtr>, StartShuffle, (const std::string& , int, NObjectClient::TTransactionId, const TStartShuffleOptions&)); - UNIMPLEMENTED_METHOD(TFuture<IRowBatchReaderPtr>, CreateShuffleReader, (const TSignedShuffleHandlePtr&, int, std::optional<std::pair<int, int>>, const TShuffleReaderOptions&)); + UNIMPLEMENTED_METHOD(TFuture<IRowBatchReaderPtr>, CreateShuffleReader, (const TSignedShuffleHandlePtr&, int, std::optional<TIndexRange>, const TShuffleReaderOptions&)); UNIMPLEMENTED_METHOD(TFuture<IRowBatchWriterPtr>, CreateShuffleWriter, (const TSignedShuffleHandlePtr&, const std::string&, std::optional<int>, const TShuffleWriterOptions&)); private: diff --git a/yt/yt/client/hedging/hedging.cpp b/yt/yt/client/hedging/hedging.cpp index 420326ad4c4..5350af8c4bb 100644 --- a/yt/yt/client/hedging/hedging.cpp +++ b/yt/yt/client/hedging/hedging.cpp @@ -239,7 +239,7 @@ public: UNSUPPORTED_METHOD(TFuture<TGetFlowViewResult>, GetFlowView, (const NYPath::TYPath&, const NYPath::TYPath&, const TGetFlowViewOptions&)); UNSUPPORTED_METHOD(TFuture<TFlowExecuteResult>, FlowExecute, (const NYPath::TYPath&, const TString&, const NYson::TYsonString&, const TFlowExecuteOptions&)); UNSUPPORTED_METHOD(TFuture<TSignedShuffleHandlePtr>, StartShuffle, (const std::string&, int, NObjectClient::TTransactionId, const TStartShuffleOptions&)); - UNSUPPORTED_METHOD(TFuture<IRowBatchReaderPtr>, CreateShuffleReader, (const TSignedShuffleHandlePtr&, int, std::optional<std::pair<int, int>>, const TShuffleReaderOptions&)); + UNSUPPORTED_METHOD(TFuture<IRowBatchReaderPtr>, CreateShuffleReader, (const TSignedShuffleHandlePtr&, int, std::optional<TIndexRange>, const TShuffleReaderOptions&)); UNSUPPORTED_METHOD(TFuture<IRowBatchWriterPtr>, CreateShuffleWriter, (const TSignedShuffleHandlePtr&, const std::string&, std::optional<int>, const TShuffleWriterOptions&)); private: diff --git a/yt/yt/client/security_client/access_control.h b/yt/yt/client/security_client/access_control.h index c24384b824f..f4e7abc0625 100644 --- a/yt/yt/client/security_client/access_control.h +++ b/yt/yt/client/security_client/access_control.h @@ -32,25 +32,27 @@ public: #define ACCESS_CONTROL_ENTRY(namespace, name) \ {(name), TAccessControlObjectDescriptor((namespace), (name))} -const std::vector<EAccessControlObjectNamespace> AccessControlObjectNamespaces = { +const inline std::vector<EAccessControlObjectNamespace> AccessControlObjectNamespaces = { EAccessControlObjectNamespace::AdminCommands }; -const THashMap<EAccessControlObject, TAccessControlObjectDescriptor> AccessControlObjects = { - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::DisableChunkLocations), - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::DestroyChunkLocations), - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::ResurrectChunkLocations), - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::BuildSnapshot), +const inline THashMap<EAccessControlObject, TAccessControlObjectDescriptor> AccessControlObjects = { ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::BuildMasterSnapshot), - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::GetMasterConsistentState), + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::BuildSnapshot), + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::CollectCoverage), + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::DestroyChunkLocations), + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::DisableChunkLocations), + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::DiscombobulateNonvotingPeers), ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::ExitReadOnly), + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::GetMasterConsistentState), ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::MasterExitReadOnly), - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::DiscombobulateNonvotingPeers), - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::SwitchLeader), ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::RequestRestart), - ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::CollectCoverage) + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::ResurrectChunkLocations), + ACCESS_CONTROL_ENTRY(EAccessControlObjectNamespace::AdminCommands, EAccessControlObject::SwitchLeader), }; +#undef ACCESS_CONTROL_ENTRY + //////////////////////////////////////////////////////////////////////////////// TAccessControlObjectDescriptor GetAccessControlObjectDescriptor(EAccessControlObject accessControlObjectName); diff --git a/yt/yt/client/signature/generator.cpp b/yt/yt/client/signature/generator.cpp index ba2de22d04a..799b64e620e 100644 --- a/yt/yt/client/signature/generator.cpp +++ b/yt/yt/client/signature/generator.cpp @@ -14,7 +14,7 @@ TSignaturePtr ISignatureGenerator::Sign(std::string payload) const { auto signature = New<TSignature>(); signature->Payload_ = std::move(payload); - DoSign(signature); + Resign(signature); return signature; } @@ -25,14 +25,14 @@ namespace { struct TDummySignatureGenerator : public ISignatureGenerator { - void DoSign(const TSignaturePtr& /*signature*/) const final + void Resign(const TSignaturePtr& /*signature*/) const final { } }; struct TAlwaysThrowingSignatureGenerator : public ISignatureGenerator { - void DoSign(const TSignaturePtr& /*signature*/) const final + void Resign(const TSignaturePtr& /*signature*/) const final { THROW_ERROR_EXCEPTION("Signature generation is unsupported"); } diff --git a/yt/yt/client/signature/generator.h b/yt/yt/client/signature/generator.h index 3772c841b3d..353c26b1bcb 100644 --- a/yt/yt/client/signature/generator.h +++ b/yt/yt/client/signature/generator.h @@ -13,10 +13,9 @@ struct ISignatureGenerator { [[nodiscard]] TSignaturePtr Sign(std::string payload) const; -private: //! Fills out the Signature_ and Header_ fields in a given TSignature //! based on its payload. - virtual void DoSign(const TSignaturePtr& signature) const = 0; + virtual void Resign(const TSignaturePtr& signature) const = 0; }; DEFINE_REFCOUNTED_TYPE(ISignatureGenerator) diff --git a/yt/yt/client/table_client/columnar_statistics.cpp b/yt/yt/client/table_client/columnar_statistics.cpp index 8ea80cd925d..0b8904c2277 100644 --- a/yt/yt/client/table_client/columnar_statistics.cpp +++ b/yt/yt/client/table_client/columnar_statistics.cpp @@ -70,13 +70,13 @@ TUnversionedOwningValue ApproximateMaxValue(TUnversionedValue value) } } -void UpdateLargeColumnarStatistics(TLargeColumnarStatistics& statistics, TUnversionedValue value) +void UpdateLargeColumnarStatistics(TLargeColumnarStatistics* statistics, TUnversionedValue value) { if (value.Type != EValueType::Null) { auto valueNoFlags = value; valueNoFlags.Flags = EValueFlags::None; auto fingerprint = TBitwiseUnversionedValueHash()(valueNoFlags); - statistics.ColumnHyperLogLogDigests[value.Id].Add(fingerprint); + statistics->ColumnHyperLogLogDigests[value.Id].Add(fingerprint); } } @@ -119,7 +119,7 @@ void UpdateColumnarStatistics( statistics->ColumnNonNullValueCounts[value.Id] += (value.Type != EValueType::Null); if (needsLargeStatistics) { - UpdateLargeColumnarStatistics(statistics->LargeStatistics, value); + UpdateLargeColumnarStatistics(&statistics->LargeStatistics, value); } } } @@ -373,7 +373,6 @@ void TColumnarStatistics::Update(TRange<TVersionedRow> rows) UpdateMinAndMax(this, minValues, maxValues); } - if (ChunkRowCount) { ChunkRowCount = *ChunkRowCount + rows.Size(); } @@ -398,6 +397,7 @@ TColumnarStatistics TColumnarStatistics::SelectByColumnNames(const TNameTablePtr } } } + result.TimestampTotalWeight = TimestampTotalWeight; result.LegacyChunkDataWeight = LegacyChunkDataWeight; diff --git a/yt/yt/client/unittests/mock/client.h b/yt/yt/client/unittests/mock/client.h index cd63cf4c589..92211f26ac6 100644 --- a/yt/yt/client/unittests/mock/client.h +++ b/yt/yt/client/unittests/mock/client.h @@ -32,8 +32,6 @@ class TMockClient : public IClient { public: - using TRange = std::pair<int, int>; - const NTabletClient::ITableMountCachePtr& GetTableMountCache() override; void SetTableMountCache(NTabletClient::ITableMountCachePtr value); @@ -904,7 +902,7 @@ public: MOCK_METHOD(TFuture<IRowBatchReaderPtr>, CreateShuffleReader, ( const TSignedShuffleHandlePtr& shuffleHandle, int partitionIndex, - std::optional<TRange> writerIndexRange, + std::optional<TIndexRange> writerIndexRange, const TShuffleReaderOptions& options), (override)); |