flat

简介: flat

flat 字典是所有类型中性能最高的字典类型,它只能使用 UInt64 数值型 key 。顾名思义, flat 字典的数据在内存中使用数组结构保存,数组的初始大小为 1024 ,上限为 500 000 ,这意味着它最多只能保存 500 000 行数据。如果在创建字典时数据量超出其上限,那么字典会创建失败。如下所示是通过手动创建的 flat 字典配置文件。


/etc/clickhouse-server 目录下新建 test_flat_dictionary.xml 文件,写入如下内容:

<?xml version="1.0"?>
<dictionaries>
  <dictionary>
    <name>test_flat_dict</name>
    <source>
      <!-- 准备好的测试数据 -->
      <file>
        <path>/var/lib/clickhouse/dictionaries_lib/organization.csv</path>
        <format>CSV</format>
      </file>
    </source>
    <layout>
      <flat />
    </layout>
    <!-- 与测试数据的结构对应 -->
    <structure>
      <id>
        <name>id</name>
      </id>
      <attribute>
        <name>code</name>
        <type>String</type>
        <null_value></null_value>
      </attribute>
      <attribute>
        <name>name</name>
        <type>String</type>
        <null_value></null_value>
      </attribute>
    </structure>
    <lifetime>
      <min>300</min>
      <max>360</max>
    </lifetime>
  </dictionary>
</dictionaries>点击复制复制失败已复制


写入文件后无需重启ClickHouse 就会自动识别到这个文件,并建立字典。


在上述的配置中, source 数据源是 CSV 格式的文件, structure 数据结构与其对应。查验 system.dictionaries 系统表后,能够看到 flat 字典已经创建成功。

$ SELECT name, type, key, attribute.names, attribute.types FROM system.dictionaries;
┌─name───────────┬─type─┬─key────┬─attribute.names─┬─attribute.types─────┐
│ test_flat_dict │      │ UInt64 │ ['code','name'] │ ['String','String'] │
└────────────────┴──────┴────────┴─────────────────┴─────────────────────
目录
相关文章
|
6月前
193Echarts - 自定义系列(Custom Cartesian Polygon)
193Echarts - 自定义系列(Custom Cartesian Polygon)
24 0
|
6月前
200Echarts - 自定义系列(Use custom series to draw wind vectors)
200Echarts - 自定义系列(Use custom series to draw wind vectors)
15 0
|
9月前
ES6:flat()
ES6:flat()
40 0
|
11月前
使用flat()和flatMap来打平数组吧
# 引言 往往在开发中我们可能会遇到一些不平铺的,结构或是嵌套比较复杂的数组数据,那么我们面对这种数据的时候应该怎么优雅高效的处理他们的,今天让我们来学习一下使用flat()和flatMap来打平数组吧 # 使用flat()和flatMap来打平数组吧 今天我们来一起学习一下使用flat()和flatMap打平数组 在ES2019中,flat()方法用于创建并返回一个新数组,这个新数组包含于他调用flat()的数组相同的元素,只不过其中任何本身也是数组的元素会被打平填充到返回的数组中。例如: ``` [1,[2,3]].flat() //会变成[1,2,3] [1,[2,[3]]].
Only Tensors of floating point and complex dtype can require gradients问题解决方案
Only Tensors of floating point and complex dtype can require gradients问题解决方案
277 0
Only Tensors of floating point and complex dtype can require gradients问题解决方案
|
机器学习/深度学习 数据挖掘
|
机器学习/深度学习
Leetcode-Easy 887. Projection Area of 3D Shapes
Leetcode-Easy 887. Projection Area of 3D Shapes
107 0
Leetcode-Easy 887. Projection Area of 3D Shapes
Can not squeeze dim[1], expected a dimension of 1, got 21
Can not squeeze dim[1], expected a dimension of 1, got 21
431 0
|
Linux TensorFlow 算法框架/工具
Using side features: feature preprocessing
One of the great advantages of using a deep learning framework to build recommender models is the freedom to build rich, flexible feature representations.
132 0