From: <ma...@us...> - 2006-04-19 17:20:02
|
Revision: 1371 Author: markwkm Date: 2006-04-19 10:19:50 -0700 (Wed, 19 Apr 2006) ViewCVS: http://svn.sourceforge.net/osdldbt/?rev=1371&view=rev Log Message: ----------- Updated the load scripts to be able to handle tablespaces and to background each table and index created. Had to renamed to the order table datafile from order.data to orders.data. Also had to create an autoconf rule for vacuumdb. Modified Paths: -------------- trunk/dbt4/configure.ac trunk/dbt4/scripts/pgsql/build_db.sh.in trunk/dbt4/scripts/pgsql/load_db.sh.in trunk/dbt4/src/org/osdl/dbt4/DataGenerator.java Modified: trunk/dbt4/configure.ac =================================================================== --- trunk/dbt4/configure.ac 2006-04-18 23:13:21 UTC (rev 1370) +++ trunk/dbt4/configure.ac 2006-04-19 17:19:50 UTC (rev 1371) @@ -68,6 +68,14 @@ AC_MSG_ERROR([*** psql is required]) fi + dnl check for vacuumdb + AC_PATH_PROGS(VACUUMDB, vacuumdb, , + [$PATH:$pgsql_path/bin:/bin:/usr/bin:/usr/local/bin] + ) + if test -z "$VACUUMDB" ; then + AC_MSG_ERROR([*** vacuumdb is required]) + fi + AC_CONFIG_FILES([scripts/pgsql/build_db.sh], [chmod +x scripts/pgsql/build_db.sh]) AC_CONFIG_FILES([scripts/pgsql/create_db.sh], Modified: trunk/dbt4/scripts/pgsql/build_db.sh.in =================================================================== --- trunk/dbt4/scripts/pgsql/build_db.sh.in 2006-04-18 23:13:21 UTC (rev 1370) +++ trunk/dbt4/scripts/pgsql/build_db.sh.in 2006-04-19 17:19:50 UTC (rev 1371) @@ -13,8 +13,11 @@ GENERATE_DATAFILE=0 REBUILD_DB=0 -while getopts "d:e:gp:r:t" OPT; do +while getopts "bd:e:gp:rt" OPT; do case ${OPT} in + b) + BACKGROUND_FLAG="-b" + ;; d) DATADIR=${OPTARG} ;; @@ -51,7 +54,7 @@ ${SHELL} @abs_srcdir@/create_db.sh || exit 1 @abs_srcdir@/create_tables.sh ${TABLESPACES_FLAG} || exit 1 -${SHELL} @abs_srcdir@/load_db.sh -d ${DATADIR} ${TABLESPACES_FLAG} || exit 1 +${SHELL} @abs_srcdir@/load_db.sh -d ${DATADIR} ${TABLESPACES_FLAG} ${BACKGROUND_FLAG} || exit 1 # Referential integrity is not required, Appendix H. #@PSQL@ -d ${DBNAME} -f @abs_srcdir@/create_foreign_keys.sql || exit 1 Modified: trunk/dbt4/scripts/pgsql/load_db.sh.in =================================================================== --- trunk/dbt4/scripts/pgsql/load_db.sh.in 2006-04-18 23:13:21 UTC (rev 1370) +++ trunk/dbt4/scripts/pgsql/load_db.sh.in 2006-04-19 17:19:50 UTC (rev 1371) @@ -4,92 +4,64 @@ # This file is released under the terms of the Artistic License. # Please see the file LICENSE, included in this package, for details. # -# Copyright (C) 2005 Mark Wong & Open Source Development Lab, Inc. +# Copyright (C) 2005-2006 Mark Wong & Open Source Development Lab, Inc. # DIR=`dirname $0` . ${DIR}/pgsql_profile || exit 1 -while getopts "d:t" OPT; do - case ${OPT} in - d) - DATADIR=${OPTARG} - ;; - t) - TABLESPACES_FLAG="-t" - ;; - esac +while getopts "bd:t" OPT; do + case ${OPT} in + b) + BACKGROUND=yes + ;; + d) + DATADIR=${OPTARG} + ;; + t) + TABLESPACES_FLAG="-t" + ;; + esac done -# Verify datafiles exist in the specified directory. -if [ ! -f ${DATADIR}/item.data ]; then - echo "Data file item.data does not exist." - exit 1 -fi -if [ ! -f ${DATADIR}/stock.data ]; then - echo "Data file stock.data does not exist." - exit 1 -fi -if [ ! -f @abs_top_srcdir@/scripts/@database_to_use@/country.data ]; then - echo "Data file country.data does not exist." - exit 1 -fi -if [ ! -f ${DATADIR}/author.data ]; then - echo "Data file author.data does not exist." - exit 1 -fi -if [ ! -f ${DATADIR}/customer.data ]; then - echo "Data file customer.data does not exist." - exit 1 -fi -if [ ! -f ${DATADIR}/order.data ]; then - echo "Data file order.data does not exist." - exit 1 -fi -if [ ! -f ${DATADIR}/order_line.data ]; then - echo "Data file order_line.data does not exist." - exit 1 -fi -if [ ! -f ${DATADIR}/address.data ]; then - echo "Data file address.data does not exist." - exit 1 -fi +# Load tables +# This background stuff is honestly kinda ugly. IMO the right way to do this is +# to utilize make -j +load_table() { + table=${1} + if [ x${2} == x ]; then + file=${table}.data + else + file=${2}.data + fi -@PSQL@ -e -d ${DBNAME} -c " -COPY item FROM '${DATADIR}/item.data' WITH NULL AS ''; -" || exit 1 + local sql="COPY $table FROM '${DATADIR}/$file' WITH NULL AS '';" + local cmd="@PSQL@ -e -d ${DBNAME} -c " + if [ x${BACKGROUND} == xyes ]; then + echo "Loading $table table in the background..." + ${cmd} "${sql} VACUUM ANALYZE $table;" || exit 1 & + else + echo "Loading $table table..." + ${cmd} "${sql}" || exit 1 + fi +} -@PSQL@ -e -d ${DBNAME} -c " -COPY stock FROM '${DATADIR}/stock.data' WITH NULL AS ''; -" || exit 1 +load_table address +load_table author +load_table customer +load_table item +load_table orders +load_table order_line +load_table stock -@PSQL@ -e -d ${DBNAME} -c " -COPY country -FROM '@abs_top_srcdir@/scripts/@database_to_use@/country.data' WITH NULL AS ''; -" || exit 1 +wait -@PSQL@ -e -d ${DBNAME} -c " -COPY author FROM '${DATADIR}/author.data' WITH NULL AS ''; -" || exit 1 - -@PSQL@ -e -d ${DBNAME} -c " -COPY customer FROM '${DATADIR}/customer.data' WITH NULL AS ''; -" || exit 1 - -@PSQL@ -e -d ${DBNAME} -c " -COPY orders FROM '${DATADIR}/order.data' WITH NULL AS ''; -" || exit 1 - -@PSQL@ -e -d ${DBNAME} -c " -COPY order_line FROM '${DATADIR}/order_line.data' WITH NULL AS ''; -" || exit 1 - -@PSQL@ -e -d ${DBNAME} -c " -COPY address FROM '${DATADIR}/address.data' WITH NULL AS ''; -" || exit 1 - @abs_srcdir@/create_indexes.sh ${TABLESPACES_FLAG} || exit 1 @PSQL@ -e -d ${DBNAME} -f ${DATADIR}/sequence.sql +if [ x{$BACKGROUND} == xno ]; then + @VACUUMDB@ -z -f -d ${DBNAME} || exit 1 +fi + exit 0 Modified: trunk/dbt4/src/org/osdl/dbt4/DataGenerator.java =================================================================== --- trunk/dbt4/src/org/osdl/dbt4/DataGenerator.java 2006-04-18 23:13:21 UTC (rev 1370) +++ trunk/dbt4/src/org/osdl/dbt4/DataGenerator.java 2006-04-19 17:19:50 UTC (rev 1371) @@ -555,7 +555,7 @@ dg[1] = new DataGenerator(format, directory, "author"); dg[2] = new DataGenerator(format, directory, "customer"); dg[3] = new DataGenerator(format, directory, "item"); - dg[4] = new DataGenerator(format, directory, "order"); + dg[4] = new DataGenerator(format, directory, "orders"); dg[5] = new DataGenerator(format, directory, "stock"); for (int i = 0; i < dg.length; i++) { dg[i].run(); @@ -625,7 +625,7 @@ generateCustomerData(); } else if (table.equals("item")) { generateItemData(); - } else if (table.equals("order")) { + } else if (table.equals("orders")) { generateOrderData(); } else if (table.equals("stock")) { generateStockData(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |