Commit a01d700a authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Update

git-svn-id: file:///svn/tokudb@521 c7de825b-a66e-492c-adef-691d508d4ae1
parent 48f0ad74
CFLAGS = -std=gnu89 -W -Wall -Wno-unused -g -fPIC -ldb
LFLAGS = -l CPPFLAGS =
BDB=/usr/local/BerkeleyDB.4.1
BDB_DUMP=$(BDB)/bin/db_dump
BDB_LOAD=$(BDB)/bin/db_load
BDB_DUMP=/usr/local/Berkeleydb.4.1/bin/db_dump
BDB_LOAD=/usr/local/Berkeleydb.4.1/bin/db_load
CPPFLAGS = -I$(BDB)/include
CFLAGS = -std=gnu89 -W -Wall -Wno-unused -g
LDFLAGS = -L$(BDB)/lib -ldb -lpthread -Wl,-rpath,$(BDB)/lib
# LDFLAGS = -L$(BDB)/lib -ldb -lpthread
STATIC_LDFLAGS = -static -L../lib -ldb -lz
UTILS= \
tokudb_gen \
tokudb_load \
tokudb_dump \
#End
STATIC_UTILS=$(patsubst %,%_static,$(UTILS))
.PHONY: all clean test test_gen test_gen_hex test_load test_dump
all: $(UTILS)
all: $(UTILS) $(STATIC_UTILS)
test: test_gen test_load test_dump
%: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS)
test_gen: test_gen_hex
%_static: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(STATIC_LDFLAGS)
BDB=/usr/local/BerkeleyDB.4.6
BDB_DUMP=$(BDB)/bin/db_dump
BDB_LOAD=$(BDB)/bin/db_load
test: test_gen test_load test_dump test_bdb_tokudb
test_gen: test_gen_hex
TEST_GEN_HEX_NUMKEYS=10000
TEST_GEN_HEX_LENGTHMIN=0
......@@ -35,7 +42,7 @@ test_gen_hex:
$(BDB_LOAD) $@.db.temp < $@.gen.temp
$(BDB_DUMP) $@.db.temp > $@.load_dump.temp
./tokudb_gen -Hf > $@.gen_sorted.temp
./tokudb_gen -hf $(TEST_GEN_HEX_FLAGS) -d "\t" -s "\n" | sort -k 1,1 | tr -d "\n" | tr "\t" "\n" >> $@.gen_sorted.temp
export LC_ALL=C;./tokudb_gen -hf $(TEST_GEN_HEX_FLAGS) -d "\t" -s "\n" | sort -k 1,1 | tr -d "\n" | tr "\t" "\n" >> $@.gen_sorted.temp
./tokudb_gen -Fh >> $@.gen_sorted.temp
if ! diff -q $@.load_dump.temp $@.gen_sorted.temp; then echo "Test Failed!"; exit 1; fi
rm $@.*.temp
......@@ -61,7 +68,16 @@ test_dump:
./tokudb_dump $@.bdb.temp > $@.dump.tokudb.temp
if ! diff -q $@.dump.bdb.temp $@.dump.tokudb.temp; then echo "Test Failed!"; exit 1; fi
test_bdb_tokudb:
rm -rf $@.*.temp
./tokudb_gen $(TEST_GEN_HEX_FLAGS) >$@.gen.temp
$(BDB_LOAD) $@.bdb.temp <$@.gen.temp
$(BDB_DUMP) $@.bdb.temp >$@.dump.bdb.temp
./tokudb_load_static $@.tdb.temp <$@.gen.temp
./tokudb_dump_static $@.tdb.temp >$@.dump.tdb.temp
if ! diff -q $@.dump.bdb.temp $@.dump.tdb.temp; then echo "$@ failed"; exit 1; fi
#if diff -q <(echo "foo") <(echo "foo") > /dev/null; then echo yes; else echo no; fi
clean:
rm -rf *.so *.o $(UTILS) *.temp
rm -rf *.so *.o $(UTILS) $(STATIC_UTILS) *.temp
void outputbyte(unsigned char ch, bool plaintext)
{
if (plaintext) {
if (ch != '\n' && isprint(ch)) {
switch (ch) {
case ('\\'): {
printf("\\\\");
break;
}
default:
{
printf("%c", ch);
break;
}
}
}
else {
printf(
"\\%c%c",
"0123456789abcdef"[(ch & 0xf0) >> 4],
"0123456789abcdef"[ch & 0x0f]
);
}
}
else {
printf(
"%c%c",
"0123456789abcdef"[(ch & 0xf0) >> 4],
"0123456789abcdef"[ch & 0x0f]
);
}
}
/*
The above code is too long, since printf isn't being used effectively.
*/
void outputbyte(unsigned char ch, bool plaintext)
{
if (plaintext) {
if (ch != '\n' && isprint(ch)) {
switch (ch) {
case ('\\'): {
printf("\\\\");
break;
}
default:
{
printf("%c", ch);
break;
}
}
}
else {
printf("%02x", ch);
}
}
else {
printf("%02x", ch);
}
}
/*
I don't understand the control flow for the plaintext case, since \n isn't a printable character.
Also using a switch for a two-way branch seems overkill.
Switch is quite dangerous because one can forget the break, and control falls through.
For one-liner conditionsals, there is no need to put in { }
*/
void outputbyte(unsigned char ch, bool plaintext)
{
if (plaintext) {
if (ch == '\\') printf("\\\\");
else if (isprint(ch)) printf("%c", ch);
else printf("%02x", ch);
} else {
printf("%02x", ch);
}
}
......@@ -266,7 +266,7 @@ int create_init_env()
REMOVE_BITS(flags, DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN);
SET_BITS(flags, DB_CREATE | DB_PRIVATE);
retval = dbenv->open(dbenv, g.homedir, flags, 0);
retval = dbenv->open(dbenv, g.homedir ? g.homedir : ".", flags, 0);
if (retval) {
ERROR(retval, "DB_ENV->open");
goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment