Compare commits

...

5 Commits

Author SHA1 Message Date
Oliver Kennedy caa59ac13d Schema generation 2016-10-11 22:54:38 -04:00
Oliver Kennedy b5995c89be export 2016-10-07 23:10:21 -04:00
Oliver Kennedy 404aca80e7 Debugging 2016-10-06 20:31:35 -04:00
Oliver Kennedy a4cd033a9a Standard tweaks to make dbgen happy with OSX 2016-10-06 19:23:46 -04:00
Oliver Kennedy b6efac9bd7 canonical makefile name 2016-10-06 19:15:58 -04:00
7 changed files with 164 additions and 9 deletions

4
MayBMS-tpch/uncertain-tpch/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.o
qgen
dbgen
*.tbl

View File

@ -91,7 +91,7 @@ WORKLOAD = TPCH
#
# add -EDTERABYTE if orderkey will execeed 32 bits (SF >= 300)
# and make the appropriate change in gen_schema() of runit.sh
CFLAGS = -O -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD)
CFLAGS = -g -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD)
LDFLAGS = -g
# The OBJ,EXE and LIB macros will need to be changed for compilation under
# Windows NT
@ -174,4 +174,4 @@ rnd$(OBJ): rnd.h
$(OBJ1): $(HDR1)
$(OBJ2): dss.h tpcd.h config.h rng64.h release.h
update_release:
update_release.sh ${VERSION} ${RELEASE} ${PATCH}
./update_release.sh ${VERSION} ${RELEASE} ${PATCH}

View File

@ -0,0 +1,139 @@
$files = {
cust: [ :c_acctbal, :c_address, :c_comment, :c_custkey, :c_mktsegment, :c_name, :c_nationkey, :c_phone ],
lineitem: [ :l_comment, :l_commitdate, :l_discount, :l_extendedprice, :l_linenumber, :l_linestatus, :l_orderkey, :l_partkey, :l_quantity, :l_receiptdate, :l_returnflag, :l_shipdate, :l_shipinstruct, :l_shipmode, :l_suppkey, :l_tax ],
nation: [ :n_nationkey, :n_name, :n_regionkey, :n_comment ],
orders: [ :o_clerk, :o_comment, :o_custkey, :o_orderdate, :o_orderkey, :o_orderpriority, :o_orderstatus, :o_shippriority, :o_totalprice ],
part: [ :p_brand, :p_comment, :p_container, :p_mfgr, :p_name, :p_partkey, :p_retailprice, :p_size, :p_type ],
psupp: [ :ps_availqty, :ps_comment, :ps_partkey, :ps_suppkey, :ps_supplycost ],
region: [ :r_comment, :r_name, :r_regionkey ],
supp: [ :s_acctbal, :s_address, :s_comment, :s_name, :s_nationkey, :s_phone, :s_suppkey ]
}
$types = {
:c_acctbal => "decimal",
:c_address => "varchar(40)",
:c_comment => "varchar(117)",
:c_custkey => "int",
:c_mktsegment => "char(10)",
:c_name => "varchar(25)",
:c_nationkey => "int",
:c_phone => "char(15)",
:l_comment => "char(44)",
:l_commitdate => "date",
:l_discount => "decimal",
:l_extendedprice => "decimal",
:l_linenumber => "int",
:l_linestatus => "char(1)",
:l_orderkey => "int",
:l_partkey => "int",
:l_quantity => "decimal",
:l_receiptdate => "date",
:l_returnflag => "char(1)",
:l_shipdate => "date",
:l_shipinstruct => "char(25)",
:l_shipmode => "char(10)",
:l_suppkey => "int",
:l_tax => "decimal",
:n_nationkey => "int",
:n_name => "char(25)",
:n_regionkey => "int",
:n_comment => "char(152)",
:o_clerk => "char(15)",
:o_comment => "varchar(79)",
:o_custkey => "int",
:o_orderdate => "date",
:o_orderkey => "int",
:o_orderpriority => "char(15)",
:o_orderstatus => "char(1)",
:o_shippriority => "int",
:o_totalprice => "decimal",
:p_brand => "char(10)",
:p_comment => "varchar(23)",
:p_container => "char(10)",
:p_mfgr => "char(25)",
:p_name => "varchar(55)",
:p_partkey => "int",
:p_retailprice => "decimal",
:p_size => "int",
:p_type => "varchar(25)",
:ps_availqty => "int",
:ps_comment => "varchar(199)",
:ps_partkey => "int",
:ps_suppkey => "int",
:ps_supplycost => "decimal",
:r_comment => "char(152)",
:r_name => "varchar(25)",
:r_regionkey => "int",
:s_acctbal => "decimal",
:s_address => "varchar(40)",
:s_comment => "varchar(101)",
:s_name => "char(25)",
:s_nationkey => "int",
:s_phone => "char(15)",
:s_suppkey => "int",
:tid => "int"
}
def init_data
# TUPLE_ID -> CONFLICT_GROUP -> WORLD -> FIELD -> VALUE
Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = Hash.new } } }
end
def load(data, table, field)
puts "Loading #{table}_#{field}.tbl"
File.open("input/#{table}_#{field}.tbl") do |f|
f.readlines.each do |l|
conflict_group, world, tuple_id, value = l.chomp.split(/\|/)
data[tuple_id.to_i][conflict_group.to_i][world.to_i][field] = value
end
end
end
def render(data)
puts "Rendering data..."
data.map do |tuple_id, conflict_groups|
conflict_groups = conflict_groups.values.to_a
world_ids = conflict_groups.map { |worlds| worlds.keys }
# compute the cartesian product of the resulting key sets
world_groups = [ [nil] ]
world_ids.each { |id_set| world_groups = world_groups.product(id_set) }
world_groups = world_groups.map { |x| x.flatten[1..-1] }
# render the corresponding tuple
world_groups.map do |per_group_world_ids|
conflict_groups.zip(per_group_world_ids).map { |worlds, world_id| worlds[world_id].to_a }.flatten(1)
end.map { |tuple| [tuple_id, tuple.to_h] }
end.flatten(1)
end
$files.each do |table, fields|
file "output/#{table}.tbl" do
data = init_data
fields.each { |field| load(data, table, field) }
File.open("output/#{table}.tbl", "w+") do |f|
f.puts "tid|#{fields.join("|")}"
render(data).each do |tid, tuple|
f.puts "#{tid}|#{fields.map {|f| tuple[f]}.join("|")}"
end
end
end
task table => "output/#{table}.tbl"
end
file "schema.sql" do
File.open("schema.sql", "w+") do |f|
$files.each do |table, fields|
f.puts("CREATE TABLE #{table}(#{([:tid]+fields).map {|field| "#{field} #{$types[field]}"}.join(", ")});")
end
end
end

View File

@ -74,7 +74,9 @@
#include <ctype.h>
#include <math.h>
#ifndef _POSIX_SOURCE
#ifndef __APPLE__
#include <malloc.h>
#endif
#endif /* POSIX_SOURCE */
#include <fcntl.h>
#include <sys/types.h>
@ -390,6 +392,7 @@ tbl_open(int tbl, char *mode)
struct stat fstats;
int retcode;
bzero(&fstats, sizeof(fstats));
if (*tdefs[tbl].name == PATH_SEP)
strcpy(fullpath, tdefs[tbl].name);

View File

@ -719,7 +719,7 @@ pr_cust(customer_t *c, int mode)
if (TUPLE_LEVEL) {
if ((long)i < threshold+1) {
add_placeholder(CUST, (long)c->custkey, 0);
return;
return 1;
}
threshold = -1;
}
@ -864,7 +864,7 @@ pr_order(order_t *o, int mode)
if (TUPLE_LEVEL) {
if ((long)i < threshold+1) {
add_placeholder(ORDER,(long)o->okey,0);
return;
return 1;
}
threshold = -1;
}
@ -1301,7 +1301,7 @@ pr_part(part_t *part, int mode)
if (TUPLE_LEVEL) {
if ((long)j <threshold+1) {
add_placeholder(PART,(long)part->partkey,0);
return;
return 1;
}
threshold = -1;
}
@ -1573,7 +1573,7 @@ pr_supp(supplier_t *supp, int mode)
if (TUPLE_LEVEL) {
if ((long)j <threshold+1) {
add_placeholder(SUPP,(long)supp->suppkey,0);
return;
return 1;
}
threshold = -1;
}
@ -1581,6 +1581,13 @@ pr_supp(supplier_t *supp, int mode)
if ((long)j > threshold) {
if (!COUNT_ONLY) {
printf("%ld\n",crt_cid);
printf("%c1\n",SEPARATOR);
printf("%c\n",SEPARATOR);
printf("%lld\n",supp->suppkey);
printf("%c\n",SEPARATOR);
printf("%lld\n",supp->suppkey);
printf("%d\n",supp_s_suppkey);
PR_STRT(supp_s_suppkey);
fprintf(supp_s_suppkey, "%ld%c1%c%lld%c%lld",crt_cid,SEPARATOR,SEPARATOR,supp->suppkey,SEPARATOR,
supp->suppkey);
@ -1699,7 +1706,7 @@ pr_nation(code_t *c, int mode)
if (TUPLE_LEVEL) {
if ((long)j <threshold+1) {
add_placeholder(NATION,(long)c->code,0);
return;
return 1;
}
threshold = -1;
}
@ -1779,7 +1786,7 @@ pr_region(code_t *c, int mode)
if (TUPLE_LEVEL) {
if ((long)j <threshold+1) {
add_placeholder(REGION,(long)c->code,0);
return;
return 1;
}
threshold = -1;
}

View File

@ -1,4 +1,4 @@
#ORIGINAL TPC-H distribution
/* #ORIGINAL TPC-H distribution */
#define VERSION 2
#define RELEASE 6
#define PATCH 0

View File

@ -41,7 +41,9 @@
*/
#include <stdio.h>
#ifndef _POSIX_SOURCE
#ifndef __APPLE__
#include <malloc.h>
#endif
#endif /* POSIX_SOURCE */
#if (defined(_POSIX_)||!defined(WIN32))
#include <unistd.h>