Small integers

Motivation

As of March 2025, Voedger does not support 2-byte and 1-byte integers. This limitation causes unnecessary storage and processing overhead, particularly for data types that don't require the full range of 4-byte integers.

Introduction

This document outlines the implementation of two smaller integer data types in Voedger: smallint (2 bytes) and tinyint (1 byte). Adding these types will optimize storage utilization and processing efficiency for appropriate use cases.

smallint

A 2-byte signed integer type with range from -32,768 to 32,767.

smallint is declared in ISO/IEC 9075 standard and is widely supported by popular SQL database systems:

tinyint

A 1-byte signed integer type with range from -128 to 127

While not declared in the ISO/IEC 9075 standard, tinyint is implemented by several major SQL database systems:

Functional design

Example of a view with smallint and tinyint columns:

VIEW MeasurementAggr (

    -- Partion key

    ID smallint,
    Period smallint,
    Cluster smallint,

    -- Clustering key

    Year smallint,
    Month tinyint,
    Day tinyint,
    Hour tinyint,
    Minute tinyint,
    Second tinyint,

    -- Value

    Cnt smallint,           -- Number of measurements
    Sum double precision,   -- Sum of measurements
    Min double precision,   -- Minimal measurement
    Max double precision    -- Maximum measurement

    PRIMARY KEY ((ID, Period, Cluster), Year, Month, Day, Hour, Minute, Second)
)

Technical design

  • ~cmp.AppDef~✅: Support new data types

  • ~cmp.Parser~✅: Support new data types

  • ~cmp.istructs~✅: Add new members to IRowReader and IRowWriter interfaces

  • ~cmp.istructsmem~✅: Implement new members of IRowReader and IRowWriter interfaces

Test plan

  • ~it.SmallIntegers~

Addressed issues

Footnotes

Last updated

Was this helpful?