Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local log = require('log')
- local xlog = require('xlog')
- local yaml = require('yaml')
- local fiber = require('fiber')
- local function find_space_id(snap, name)
- for lsn, record in xlog.pairs(snap) do
- if record.BODY.space_id > 512 then
- break
- end
- if record.BODY.space_id == 280 then
- if record.BODY.tuple[3] == name then
- return record.BODY.tuple[1]
- end
- end
- end
- error(('Failed to find space with name "%s"'):format(name))
- end
- local status_number = 100000
- local function load_space(snap, name, callback)
- local id = find_space_id(snap, name)
- local sp = box.space[name]
- if sp == nil then
- error(('Failed to find space "%s"'):format(name))
- end
- for lsn, record in xlog.pairs(snap) do
- if record.BODY.space_id == id then
- sp:insert(record.BODY.tuple)
- end
- if lsn % status_number == 0 then
- fiber.sleep(0)
- log.info("Scanned %0.1fM tuples", lsn / (status_number*10))
- end
- end
- return true
- end
- box.cfg{ memtx_memory = 1 * 1024 * 1024 * 1024 }
- box.once('offering', function()
- local sp = box.schema.create_space('product_offering')
- sp:create_index('primary', { parts = {1, 'string'} })
- load_space('product_offering.snapshot', 'product_offering')
- end)
- os.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement