Secondary Indices

  EOSIO has the ability to sort tables by up to 16 indices.  A table's struct cannot be modified when it has data in it. \

1、添加第二列索引 member 和 getter。

  The secondary index needs to be numeric field, so a uint64_t was chosen for the age variable

  

2、Add secondary index to `addresses` table configuration

typedef eosio::multi_index<"people"_n, person,
indexed_by<"byage"_n, const_mem_fun<person, uint64_t, &person::get_secondary_1>>
> address_index;

  1) indexed_by 是一个 struct.

  2) first parameter set name of index as "byage"

  3) the second type parameter as a function call operator should extract a const value as an index key.

3、compile & deploy

eosio-cpp -o addressbook.wasm addressbook.cpp --abigen

cleos set contract addressbook /home/ubuntu/contracts/addressbook

4、Test

cleos push action addressbook upsert '["alice", "alice", "liddell", 9, "123 drink me way", "wonderland", "amsterdam"]' -p alice@active

cleos push action addressbook upsert '["bob", "bob", "is a guy", 49, "doesnt exist", "somewhere", "someplace"]' -p bob@active

  查看一下插入结果,注意--upper 10 是指定上限,即只查看索引值小于10的row.

cleos get table addressbook addressbook people --upper  \
--key-type i64 \
--index

  上面命令会看到结果

  

参考:https://developers.eos.io/eosio-home/docs/secondary-indices

Secondary Indices的更多相关文章

  1. Berkeley 四种产品如何选择?

    Berkeley 四种产品如何选择? 四种产品综览 Berkeley 可供选择的四款产品: DS: 简单的.支持单写单读的数据存储:支持高并发,多进程同时读操作:不支持锁,这就意味着当程序在进行更新和 ...

  2. ABAP程序执行效率和优化 ABAP Performance Examples

    一.             SQL Interface1.         Select ... Where vs. Select + Check用Select … Where语句效率比Select ...

  3. Awesome Hadoop

    A curated list of amazingly awesome Hadoop and Hadoop ecosystem resources. Inspired by Awesome PHP,  ...

  4. EOS踩坑记

    [EOS踩坑记] 1.每个account只能更新自己的contract,即使两个account的秘钥相同,也不允许. 如下,使用alice的权限来更新james的contract.会返回 Missin ...

  5. BerkeleyDB java的简单使用

    关于BerkeleyDB的有点和优点,列在以下 JE offers the following major features: Large database support. JE databases ...

  6. MySQL、HBase、ES的特点和区别

    MySQL:关系型数据库,主要面向OLTP,支持事务,支持二级索引,支持sql,支持主从.Group Replication架构模型(本文全部以Innodb为例,不涉及别的存储引擎). HBase:基 ...

  7. [AlwaysOn Availability Groups]排查:Primary上的修改无法在Secondary体现

    排查:Primary上的修改无法在Secondary体现 客户端进程在primary上修改成功,但是在Secondary上却无法看到修改结果.这个case假设你的可用性组有同步的健康问题.很多情况下这 ...

  8. Visual Studio 2015 Pre Secondary Installer 在哪里

    安装vs2015 pre后,会自动打开Secondary Installer, 用于Cross Platform的移动开发框架,包括Cordova插件.若安装失败,启动程序位置: "D:\P ...

  9. Secondary NameNode:的作用?

    前言 最近刚接触Hadoop, 一直没有弄明白NameNode和Secondary NameNode的区别和关系.很多人都认为,Secondary NameNode是NameNode的备份,是为了防止 ...

随机推荐

  1. java-Set集合、HashSet集合、LinkedHashSet集合和TreeSet集合

    1.Set集合,无索引,不可以重复,无序(存取不一致) public class Demo { public static void main(String[] args) { //demo1(); ...

  2. Greenplum(4.3.73)集群安装手册

    1. 概述 本文档仅限于指导Greenplum 4.3.7.3(对应安装包greenplum-db-4.3.7.3-build-2-RHEL5-x86_64.bin)版本在CentOS6.5 系统进行 ...

  3. iOS兼容性(不断完善)

    1.iOs不支持iframe,不支持flash,如果移动端要嵌入视频,请用html5 的video标签.

  4. a small notepad++ plugin to support doxygen 1key generate

    Precondition: doxygen in c:\ folder testdoxygen.bat --- path %path%;C:\Doxygen;C:\Doxygen\graphviz\b ...

  5. Linux内核分析第三次作业

    实验:mykernel时间片轮转多道程序内核 进入实验楼实验,在终端中分别输入以下命令 cd LinuxKernel/linux-3.9.4 rm -rf mykernel patch -p1 < ...

  6. C# 流总结

    前言 本篇文章简单总结了在C#编程中经常会用到的一些流.比如说FileStream.MemoryStream. BufferedStream. NetWorkStream. StreamReader/ ...

  7. C 栈实现队列节点的管理

    栈预先存储节点,队列的malloc/free均有栈模拟,从而保证不频繁的开辟/是否节点内存. #include "com_is_buf.h" #include "com_ ...

  8. linux中telnet后退出连接窗口的方法?

    linux中telnet后退出连接窗口 [root@a cron]# telnet www.baidu.com 80Trying 115.239.211.112...Connected to www. ...

  9. 双心一键获取winsxs的写入权限,解决VC运行库安装error1935错误

    @Echo offtitle 双心一键获取winsxs的写入权限,解决VC运行库安装error1935等错误set path=%path%;%~dp0setlocal EnableDelayedExp ...

  10. Bootstrap 插件收集

    Bootstrap-Mutilselect  将下拉选项扩展支持多选以及多种选择方式 http://davidstutz.de/bootstrap-multiselect/ Bootstrap Sel ...