27#include "iceberg/iceberg_export.h"
28#include "iceberg/result.h"
43 size_t code_point_count = 0;
44 size_t safe_point = 0;
46 for (
size_t i = 0; i < source.size(); ++i) {
48 if ((source[i] & 0xC0) != 0x80) {
50 if (code_point_count >
static_cast<size_t>(L)) {
57 if (safe_point != 0) {
59 source.resize(safe_point);
77 static Result<std::optional<std::string>> TruncateUTF8Max(
const std::string& source,
85 requires std::is_same_v<T, int32_t> || std::is_same_v<T, int64_t>
87 return v - (((v % W) + W) % W);
94 static Decimal TruncateDecimal(
const Decimal& decimal, int32_t width);
104 static Result<Literal> TruncateLiteral(
const Literal& literal, int32_t width);
117 static Result<std::optional<Literal>> TruncateLiteralMax(
const Literal& value,
129 static Result<Literal> TruncateLowerBound(
const PrimitiveType& type,
130 const Literal& value, int32_t width);
142 static Result<std::optional<Literal>> TruncateUpperBound(
const PrimitiveType& type,
Represents 128-bit fixed-point decimal numbers. The max decimal precision that can be safely represen...
Definition decimal.h:46
Literal is a literal value that is associated with a primitive type.
Definition literal.h:39
A data type that does not have child fields.
Definition type.h:78
Definition truncate_util.h:33
static T TruncateInteger(T v, int32_t W)
Truncate an integer v, either int32_t or int64_t, to v - (v % W).
Definition truncate_util.h:86
static std::string TruncateUTF8(std::string source, size_t L)
Truncate a UTF-8 string to a specified number of code points.
Definition truncate_util.h:42