Skip to content

Latest commit

 

History

History
87 lines (65 loc) · 1.82 KB

Readme.org

File metadata and controls

87 lines (65 loc) · 1.82 KB

OrzClick

PHP client for Yandex ClickHouse, powered by PHP-CPP and clickhouse-cpp.

Supported data types

  • Array(T)
  • Date
  • DateTime
  • Decimal(P,S), Decimal32, Decimal64, Decimal128
  • Enum8, Enum16
  • FixedString(N)
  • Float32, Float64
  • IPv4, IPv6
  • Nullable(T)
  • String
  • Tuple
  • UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64

Limitations:

  • Tuple can not nested in Array, eg, Array(Tuple(Int8, Int8)) is not supported
  • UInt64 are returen as Int64, since PHP doesn’t support 64-bits unsigned integer

Building

Prerequisite

  • clang >= 10, with lld as default linker
  • php >= 7.4
  • cmake

Run

./build.sh

Then you have liborzclick.so in build directory.

Example

$options = (new OrzClick\ClientOptions())
         ->setHost('127.0.0.1')
         ->setCompressionMethod(1)
         ->TcpNoDelay(true);

$client = new OrzClick\Client($options);

// Execute statement
$client->execute('create table if not exists default.insert_demo (
   id  UInt32,
   arr Array(Int32)
) Engine = Memory' );

// Column definition
$columns = [
    'id'  => new OrzClick\ColumnUInt32(),
    'arr' => new OrzClick\ColumnArray(new OrzClick\ColumnInt32),
];

// KV data
for ($i = 0; $i < 10; $i++) {
    $data[]  = [
        'id' => $i,
        'arr' => [$i , $i + 1]
    ];
}
$client->insert('default.insert_demo', $columns, $data);

// Columnar Data
for ($i = 0; $i < 10; $i++) {
    $columnarData['id'][]  = $i;
    $columnarData['arr'][] = [$i, $i * 2];
}
$client->insertColumnar('default.insert_demo', $columns, $columnarData);

Benchmark (2020-10-06)

Select benchmark result (lower is better):

./bench/image/bench-select.png

Insert benchmark result (lower is better):

./bench/image/bench-insert.png