-
Notifications
You must be signed in to change notification settings - Fork 2
tpch: extra careful loading of dbgen data #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ local mem_size = 10 * 1024^3 | |
|
|
||
| local function config(portN, memSz) | ||
| box.cfg{ listen = tonumber(portN), memtx_memory = tonumber(memSz) } | ||
| local fiber = require('fiber') | ||
| fiber.set_max_slice(60 * 60) -- "1 hour should be enough for everybody" | ||
| end | ||
|
|
||
| local function show_usage() | ||
|
|
@@ -165,13 +167,18 @@ local tables = { | |
| 'region', 'nation', 'part', 'supplier', | ||
| 'partsupp', 'customer', 'orders', 'lineitem' | ||
| } | ||
|
|
||
| for _, tblname in ipairs(tables) do | ||
| local f = assert(io.open(string.format("tpch-dbgen/%s.tbl", tblname), 'rb')) | ||
| print (tblname) | ||
| box.begin() | ||
| local sql_table = tblname:upper() | ||
| local lines = 0 | ||
| print ('Loading: ', tblname) | ||
|
|
||
| while true do | ||
| local line = f:read('*line') | ||
| if not line then break end | ||
| lines = lines + 1 | ||
|
|
||
| local t = {} | ||
| for s in string.gmatch(line, '[^|]+') do | ||
|
|
@@ -193,9 +200,26 @@ for _, tblname in ipairs(tables) do | |
| end | ||
| local tuple = box.tuple.new(t) | ||
|
|
||
| box.space[tblname:upper()]:insert(tuple) | ||
| local rc, msg = pcall(box.space[sql_table].insert, box.space[sql_table], tuple) | ||
| if not rc then | ||
| print(('database %s failed to insert tuple %s: %s'): | ||
| format(sql_table, require'json'.encode(tuple), msg)) | ||
| end | ||
| end | ||
| f:close() | ||
| box.commit() | ||
| -- sanity check - assume we have successfully inserted all tuples | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we throw here an error if not all tuples were inserted successfully? Also, is there a way to add tests to TPCH? |
||
| local check_lines = box.execute(('select count(*) from %s'):format(sql_table)) | ||
| if not check_lines then | ||
| error(('database %s is not existing'):format(sql_table)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message looks rather strange. Can we change it to |
||
| end | ||
| local count = check_lines.rows[1][1] | ||
| if count ~= lines then | ||
| error(('database %s contains %d rows, but expected %d'): | ||
| format(sql_table, count, lines)) | ||
| else | ||
| print(('.... %d rows loaded'):format(lines)) | ||
| end | ||
| end | ||
|
|
||
| box.snapshot() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two lines seem rather strange to me, since something is wrong with the indentation, and it seems strange to me to move the method to the next line. It might be worth changing it to something like: