8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/MARQ/MADB.rb', line 8
def self.save(dataset)
prefix = Object::CustomDS.path(dataset)
codes = File.open(prefix + '.codes').collect{|l| l.chomp.downcase}
DBcache.save(dataset + '_codes', codes)
experiments = File.open(prefix + '.experiments').collect{|l| l.chomp}
orders = File.open(prefix + '.orders').collect{|l| values = l.chomp.split(/\t/).collect{|v| v == "NA" ? nil : v.to_i };}
data = {}
codes.each_with_index{|code,i|
data[code.to_sym] = orders[i]
}
case
when codes.length < 65535
type = "SMALLINT UNSIGNED"
when codes.length < 16777215
type = "MEDIUMIN UNSIGNED"
else
type = "INT UNSIGNED"
end
puts "Saving #{ dataset }"
DBcache.save(dataset + '_experiments', experiments)
DBcache.save(dataset, data, [type] * orders.first.length)
return unless Object::CustomDS::has_cross_platform?(dataset)
dataset = dataset + '_cross_platform'
prefix = Object::CustomDS.path(dataset)
codes = File.open(prefix + '.codes').collect{|l| l.chomp.downcase}
DBcache.save(dataset + '_codes', codes)
experiments = File.open(prefix + '.experiments').collect{|l| l.chomp}
orders = File.open(prefix + '.orders').collect{|l| values = l.chomp.split(/\t/).collect{|v| v == "NA" ? nil : v.to_i };}
data = {}
codes.each_with_index{|code,i|
data[code.to_sym] = orders[i]
}
case
when codes.length < 65535
type = "SMALLINT UNSIGNED"
when codes.length < 16777215
type = "MEDIUMIN UNSIGNED"
else
type = "INT UNSIGNED"
end
puts "Saving #{ dataset }"
DBcache.save(dataset + '_experiments', experiments)
DBcache.save(dataset, data, [type] * orders.first.length)
nil
end
|