Elasticsearch压缩索引——lucene倒排索引本质是列存储+使用嵌套文档可以大幅度提高压缩率
注意:由于是重复数据,词法不具有通用性!文章价值不大!
摘自:https://segmentfault.com/a/1190000002695169
Doc Values 会压缩存储重复的内容。 给定这样一个简单的 mapping
mappings = {
'testdata': {
'_source': {'enabled': False},
'_all': {'enabled': False},
'properties': {
'name': {
'type': 'string',
'index': 'no',
'store': False,
'dynamic': 'strict',
'fielddata': {'format': 'doc_values'}
}
}
}
}
插入100万行随机的重复值
words = ['hello', 'world', 'there', 'here']
def read_test_data_in_batches():
batch = []
for i in range(10000 * 100):
if i % 50000 == 0:
print(i)
if len(batch) > 10000:
yield batch
batch = []
batch.append({
'_index': 'wentao-test-doc-values',
'_type': 'testdata',
'_source': {'name': random.choice(words)}
})
print(i)
yield batch
磁盘占用是
size: 28.5Mi (28.5Mi)
docs: 1,000,000 (1,000,000)
把每个word搞长一些,同样是插入100万行
words = ['hello' * 100, 'world' * 100, 'there' * 100, 'here' * 100]
def read_test_data_in_batches():
batch = []
for i in range(10000 * 100):
if i % 50000 == 0:
print(i)
if len(batch) > 10000:
yield batch
batch = []
batch.append({
'_index': 'wentao-test-doc-values',
'_type': 'testdata',
'_source': {'name': random.choice(words)}
})
print(i)
yield batch
磁盘占用不升反降
size: 14.4Mi (14.4Mi)
docs: 1,000,000 (1,000,000)
这说明了lucene在底层用列式存储这些字符串的时候是做了压缩的。这个要是在某个商业列式数据库里,就这么点优化都是要大书特书的dictionary encoding优化云云。
Nested Document
实验表明把一堆小文档打包成一个大文档的nested document可以压缩存储空间。把前面的mapping改成这样:
mappings = {
'testdata': {
'_source': {'enabled': False},
'_all': {'enabled': False},
'properties': {
'children': {
'type': 'nested',
'properties': {
'name': {
'type': 'string',
'index': 'no',
'store': False,
'dynamic': 'strict',
'fielddata': {'format': 'doc_values'}
}
}
}
}
}
}
还是插入100万行,但是每一千行打包成一个大文档
words = ['hello', 'world', 'there', 'here']
def read_test_data_in_batches():
batch = []
for i in range(10000 * 100):
if i % 50000 == 0:
print(i)
if len(batch) > 1000:
yield [{
'_index': 'wentao-test-doc-values2',
'_type': 'testdata',
'_source': {'children': batch}
}]
batch = []
batch.append({'name': random.choice(words)})
print(i)
yield [{
'_index': 'wentao-test-doc-values2',
'_type': 'testdata',
'_source': {'children': batch}
}]
磁盘占用是
size: 2.47Mi (2.47Mi)
docs: 1,001,000 (1,001,000)
文档数没有变小,但是磁盘空间仅仅占用了2.47M。这个应该受益于lucene内部对于嵌套文档的存储优化。
Elasticsearch压缩索引——lucene倒排索引本质是列存储+使用嵌套文档可以大幅度提高压缩率的更多相关文章
- ElasticSearch入门 第四篇:使用C#添加和更新文档
这是ElasticSearch 2.4 版本系列的第四篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...
- 读《深入理解Elasticsearch》点滴-对象类型、嵌套文档、父子关系
一.对象类型 1.mapping定义文件 "title":{ "type":"text" }, "edition":{ ...
- amazon redshift 分析型数据库特点——本质还是列存储
Amazon Redshift 是一种快速且完全托管的 PB 级数据仓库,使您可以使用现有的商业智能工具经济高效地轻松分析您的所有数据.从最低 0.25 USD 每小时 (不承担任何义务) 直到每年每 ...
- 时间序列数据库选型——本质是列存储,B-tree索引,抑或是搜索引擎中的倒排索引
时间序列数据库最多,使用也最广泛.一般人们谈论时间序列数据库的时候指代的就是这一类存储.按照底层技术不同可以划分为三类. 直接基于文件的简单存储:RRD Tool,Graphite Whisper.这 ...
- Druid.io索引过程分析——时间窗,列存储,LSM树,充分利用内存,concise压缩
Druid底层不保存原始数据,而是借鉴了Apache Lucene.Apache Solr以及ElasticSearch等检索引擎的基本做法,对数据按列建立索引,最终转化为Segment,用于存储.查 ...
- OpenTSDB介绍——基于Hbase的分布式的,可伸缩的时间序列数据库,而Hbase本质是列存储
原文链接:http://www.jianshu.com/p/0bafd0168647 OpenTSDB介绍 1.1.OpenTSDB是什么?主要用途是什么? 官方文档这样描述:OpenTSDB is ...
- ELK学习笔记之ElasticSearch的索引详解
0x00 ElasticSearch的索引和MySQL的索引方式对比 Elasticsearch是通过Lucene的倒排索引技术实现比关系型数据库更快的过滤.特别是它对多条件的过滤支持非常好,比如年龄 ...
- elasticsearch——海量文档高性能索引系统
elasticsearch elasticsearch是一个高性能高扩展性的索引系统,底层基于apache lucene. 可结合kibana工具进行可视化. 概念: index 索引: 类似SQL中 ...
- 〈二〉ElasticSearch的认识:索引、类型、文档
目录 上节回顾 本节前言 索引index 创建索引 查看索引 查看单个索引 查看所有索引 删除索引 修改索引 修改副本分片数量 关闭索引 索引别名 增加索引别名: 查看索引别名: 删除索引别名: 补充 ...
随机推荐
- git 解决push报错:[rejected] master -> master (fetch first) error: failed to push some refs to
今天对代码进行了修改优化,然后往往远程push,但push后报错了 git操作 git add . git commit -m"fix" git push origin maste ...
- Mycat教程---数据库的分库分表
mycat介绍 介绍在官方网站上有比较详细的介绍,在这里复制粘贴没什么意思,大家到官网上看 官网链接 前置条件 本教程是在window环境下运行的,实际生产推荐在Linux上运行. 必备条件(自行安装 ...
- [Python] Send emails to the recepients specified in Message["CC"]
Recently, I'm working on a small program which needs to send emails to specific accounts. When I wan ...
- s5_day8作业
# 1 整理今天装饰器代码(每人手写一份,注意,是手写,交到小组长手里,明天我检查),准备明天默写 # 2 编写日志装饰器,实现功能如:一旦函数f1执行,则将消息2017-07-21 11:12:11 ...
- JavaScript判断对象 是什么类型的.
// 这种方法不起作用 if (x == undefined) { // 作某些操作 } // 这个方法同样不起作用- if (typeof(x) == undefined) { // 作某些 ...
- 用VS2013编译FFMPEG232
http://blog.csdn.net/finewind/article/details/38854517 如果只是拿来使用,网上有现成的SDK.但我是想深入研究FFMPEG代码,又不熟悉Linux ...
- centos、linux关机与重启命令详解
Linux centos关机与重启命令详解与实战 Linux centos重启命令: 1.reboot 2.shutdown -r now 立刻重启(root用户使用) 3.shutdown -r 1 ...
- jquery在线引用
转载:http://www.cnblogs.com/lzx-1024/p/7716615.html jquery-3.1.1(最新)官网jquery压缩版引用地址:<script src=&qu ...
- install tabix/bgzip
bgzip – Block compression/decompression utility tabix – Generic indexer for TAB-delimited genome pos ...
- 编程练习赛11B 物品价值(装压dp)
题意:每个物品有m(m<=10)种属性和一个价格,你有n种物品从中任意选择一些物品,让每种属性恰好有奇数个物品拥有,输出满足条件的最大价值和 题解:一看就是明显的01背包问题,但是价格乘以个数的 ...