EV-ClickHouse

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

`decode_datetime`, `decode_decimal`, `decode_enum`.

- Integers

    Int8..Int64 / UInt8..UInt64: native Perl IV/UV. Int128/UInt128/Int256/UInt256
    return decimal string representations on platforms with `__int128` (Int128/UInt128)
    or always for the 256-bit forms.

- Floats

    Float32/Float64 round-trip exactly within IEEE-754 limits. `NaN`/`+Inf`/
    `-Inf` are preserved.

- BFloat16

    Top 16 bits of a Float32. Encoded by truncation; decoded by zero-extension.
    Suitable for ML feature columns; not for accounting.

- Decimal32/64/128

    Decoded as IV (raw integer) or NV (scaled to N decimal digits if

lib/EV/ClickHouse.pm  view on Meta::CPAN

=over 4

=item Integers

Int8..Int64 / UInt8..UInt64: native Perl IV/UV. Int128/UInt128/Int256/UInt256
return decimal string representations on platforms with C<__int128> (Int128/UInt128)
or always for the 256-bit forms.

=item Floats

Float32/Float64 round-trip exactly within IEEE-754 limits. C<NaN>/C<+Inf>/
C<-Inf> are preserved.

=item BFloat16

Top 16 bits of a Float32. Encoded by truncation; decoded by zero-extension.
Suitable for ML feature columns; not for accounting.

=item Decimal32/64/128

Decoded as IV (raw integer) or NV (scaled to N decimal digits if

xs/types.c  view on Meta::CPAN

        return 0;  /* unsupported type — fall back to inline SQL */
    }
}

/* A plain number never reads as date text; stringifying it would only
 * allocate a PV in the caller's scalar. */
#define SV_PLAIN_NUM(sv) (!SvGMAGICAL(sv) && !SvPOK(sv) && !SvROK(sv) \
                          && (SvIOK(sv) || SvNOK(sv)))

/* The text SvPV would give a plain number (same rules as sv_2pv: IV
 * first, 0 for zeroes, Inf/NaN, %g at NV_DIG), written to buf instead of
 * cached in the caller's scalar. buf holds SV_NUM_TEXT_MAX bytes. */
#define SV_NUM_TEXT_MAX 64

#if defined(__SIZEOF_INT128__) && NVSIZE == 8 && NV_DIG == 15
#define HAVE_FAST_G15 1
/* The 15 significant digits %.15g prints for 1e-13 <= |v| < 1e21: the
 * exact binary value rounded half-even, as glibc does. v equals
 * q * 10^(e10 - 14) after rounding, q in [10^14, 10^15). 0 = out of range. */
static int g15_digits(double v, uint64_t *qp, int *e10p, int *negp) {
    static const uint64_t p5[28] = {

xs/types.c  view on Meta::CPAN

    NV nv;
    int n;
    if (SvIOK(sv)) {
        n = SvIsUV(sv) ? snprintf(buf, SV_NUM_TEXT_MAX, "%" UVuf, SvUVX(sv))
                       : snprintf(buf, SV_NUM_TEXT_MAX, "%" IVdf, SvIVX(sv));
    } else {
        nv = SvNVX(sv);
        if (nv == 0.0 && !Perl_isnan(nv))
            n = snprintf(buf, SV_NUM_TEXT_MAX, "0");
        else if (Perl_isnan(nv))
            n = snprintf(buf, SV_NUM_TEXT_MAX, "NaN");
        else if (Perl_isinf(nv))
            n = snprintf(buf, SV_NUM_TEXT_MAX, nv > 0 ? "Inf" : "-Inf");
        else {
#ifdef HAVE_FAST_G15
            n = fast_g15((double)nv, buf);
            if (!n)
#endif
            n = snprintf(buf, SV_NUM_TEXT_MAX, "%.*" NVgf, NV_DIG, nv);
        }
    }



( run in 1.347 second using v1.01-cache-2.11-cpan-60884a8df76 )