支持insert和批量insert,待研究怎么设置
一、建表
(1)默认表名为usertable- CREATE TABLE usertable (
- YCSB_KEY VARCHAR(255) PRIMARY KEY,
- FIELD0 TEXT, FIELD1 TEXT,
- FIELD2 TEXT, FIELD3 TEXT,
- FIELD4 TEXT, FIELD5 TEXT,
- FIELD6 TEXT, FIELD7 TEXT,
- FIELD8 TEXT, FIELD9 TEXT,<br> FIELD10 VARCHAR(100) #YCSB的默认字段长度是100
复制代码 关键要点:
- 主键字段需要命名为YCSB_KEY
- 其他字段需要以FIELD作为前缀,并从1开始计数
- 添加与您在YCSB核心属性中指定的相同数量的字段,默认为10。
- 字段的类型并不那么重要,只要它们可以接受你在YCSB核心属性中指定的长度的字符串,默认值是100;
- prepare测试时会优先判断是否存在usertable表,存在则执行truncate清空表数据,若不存在则新建usertable表;
(2)如果自己另起了表名,如student,则运行时增加 -p table=student即可,此时运行脚本就会读取student的表- ./bin/ycsb load jdbc -s -P workloads/workloadd -cp /syw_test/ycsb-0.17.0/jdbc-binding/lib/mysql-connector-java-5.1.46.jar<br> -p recordcount=1000 -p threads=5 -p operationcount=1000 -p table=usertable2
复制代码 二、JDBC连接的重要默认值
- #直接从源码中可查内容
- private static final String TABLE_NAME = "USERTABLE";
- private static final int FIELD_LENGTH = 32;
- private static final String FIELD_PREFIX = "FIELD";
- private static final String KEY_PREFIX = "user";
- private static final String KEY_FIELD = "YCSB_KEY";
- private static final int NUM_FIELDS = 3;
复制代码 三、配置参数(db.properties)
若是MySQL,则从jdbc-binding--->conf--->则可看到配置文件- db.driver=com.mysql.jdbc.Driver # The JDBC driver class to use.
- db.url=jdbc:mysql://127.0.0.1:3306/ycsb # The Database connection URL.
- db.user=admin # User name for the connection.
- db.passwd=admin # Password for the connection.
- db.batchsize=1000 # The batch size for doing batched inserts. Defaults to 0. Set to >0 to use batching.
- jdbc.fetchsize=10 # The JDBC fetch size hinted to the driver.
- jdbc.autocommit=true # The JDBC connection auto-commit property for the driver.
- jdbc.batchupdateapi=false # Use addBatch()/executeBatch() JDBC methods instead of executeUpdate() for writes (default: false)
- db.batchsize=1000 # The number of rows to be batched before commit (or executeBatch() when jdbc.batchupdateapi=true)
复制代码 四、workload支持的配置参数详解
- Fieldcount:记录中字段的数量(默认值:10)
- Fieldlength:每个字段的大小(默认:100)
- Minfieldlength:每个字段的最小大小(默认值:1)
- Readallfields:应该读取所有字段(true)或只读取一个字段(false)(默认值:true)
- Writeallfields:应该更新和读取/修改/写入更新所有字段(true)或只是一个(false)(默认:false)
- Readproportion:应该读取的操作的比例(默认:0.95)
- Updateproportion:操作的更新比例(默认值:0.05)
- Insertproportion:应该插入的操作的比例(默认:0)
- Scanproportion:应该扫描的操作的比例(默认值:0)
- Readmodifywriteproportion:读取记录、修改记录、写回记录的操作比例(默认:0)
- Requestdistribution:应该使用什么分布来选择要操作的记录-uniform(均匀分布), zipfian, hotspot, sequential, exponential or latest(数据越新访问概率越高)(默认:uniform)
- Minscanlength:扫描的最小范围(默认值:1)
- Maxscanlength:扫描的最大范围(默认:1000)
- Scanlengthdistribution:对于扫描,应该使用什么分布来选择要扫描的记录数量,对于每次扫描,在1和maxscanlength之间(默认:uniform)
- insertstart:用于并行加载和运行,为这个YCSB实例定义起始记录(默认值:0)
- insertcount:对于并行加载和运行,定义这个YCSB实例的记录数量(默认:recordcount)
- 零填充:用于生成与字符串排序顺序兼容的记录序列,以0填充记录号。控制用于填充的0的数量。(默认值:1)
- 例如,对于第5行,如果zeropadding=1,则得到' user5 '键,如果zeropading=8,则得到' user00000005 '键。为了看到它的影响,零加法需要大于记录数中的位数。
- Insertorder:记录是按键顺序插入(" ordered "),还是按散列顺序插入(" hashed ")(默认值:hashed)
- Fieldnameprefix:字段名的前缀,较短的可能会减少所需的存储大小(默认:" field ")<br>core_workload_insertion_retry_limit:插入失败重试次数,默认 0<br><em id="__mceDel">core_workload_insertion_retry_interval:重试间隔(秒),默认 3</em>
复制代码 五、相关SQL语法
insert
- INSERT IGNORE INTO table ([columns]) VALUES(...)
- INSERT IGNORE INTO table ([columns]) VALUES (?, ?, ?...), (?, ?, ?), ...
复制代码 read
- SELECT * FROM %s %s WHERE YCSB_KEY = ?
- SELECT * FROM %s %s WHERE YCSB_KEY IN (.....)
复制代码 scan
- SELECT * FROM %s %s WHERE YCSB_KEY >= ? LIMIT ?
复制代码 update
- update tablename set Field[x]=? where YCSB_KEY = ?
复制代码 delete
- DELETE FROM %s WHERE YCSB_KEY = ?
- DELETE FROM %s WHERE YCSB_KEY IN (....)
复制代码
[/td][/tr][/table]
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |