Commit 6a9710a9 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Compress (but don't uncompress right)

git-svn-id: file:///svn/tokudb.1131@5901 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0098cfa0
...@@ -36,7 +36,7 @@ FORMAT=-Wmissing-format-attribute ...@@ -36,7 +36,7 @@ FORMAT=-Wmissing-format-attribute
endif endif
CFLAGS = -Wall -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn $(FORMAT) $(OPTFLAGS) -g3 -ggdb3 $(GCOV_FLAGS) $(PROF_FLAGS) -Werror $(FPICFLAGS) $(SHADOW) $(VISIBILITY) CFLAGS = -Wall -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn $(FORMAT) $(OPTFLAGS) -g3 -ggdb3 $(GCOV_FLAGS) $(PROF_FLAGS) -Werror $(FPICFLAGS) $(SHADOW) $(VISIBILITY)
LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS) LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS) -lz
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500 CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500
# Add -Wconversion # Add -Wconversion
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <zlib.h>
static const int brtnode_header_overhead = (8+ // magic "tokunode" or "tokuleaf" static const int brtnode_header_overhead = (8+ // magic "tokunode" or "tokuleaf"
4+ // nodesize 4+ // nodesize
...@@ -199,14 +199,35 @@ void toku_serialize_brtnode_to (int fd, DISKOFF off, BRTNODE node) { ...@@ -199,14 +199,35 @@ void toku_serialize_brtnode_to (int fd, DISKOFF off, BRTNODE node) {
} }
#endif #endif
if (!node->ever_been_written) char *MALLOC_N(node->nodesize, compressed_buf);
memset(w.buf+w.ndone, 0, (size_t)(node->nodesize-w.ndone)); // fill with zeros // The first part of the data is uncompressed
int first_part = (4+ // toku
4+ // leaf or node
4+ // version
8);// lsn
memcpy(compressed_buf, buf, first_part);
uLongf compressed_len=node->nodesize-first_part-4;
{
int r = compress(((Bytef*)compressed_buf)+first_part+4, &compressed_len,
((Bytef*)buf)+first_part, calculated_size-first_part);
assert(r==Z_OK);
}
toku_free(compressed_buf);
*((int32_t*)(compressed_buf+first_part)) = htonl(compressed_len);
int compressed_n_to_write;
if (!node->ever_been_written) {
memset(compressed_buf+first_part+4+compressed_len, 0, (size_t)(node->nodesize-first_part-4-compressed_len)); // fill with zeros
compressed_n_to_write = node->nodesize;
} else {
compressed_n_to_write = first_part+4+compressed_len;
}
//write_now: printf("%s:%d Writing %d bytes\n", __FILE__, __LINE__, w.ndone); //write_now: printf("%s:%d Writing %d bytes\n", __FILE__, __LINE__, w.ndone);
{ {
// If the node has never been written, then write the whole buffer, including the zeros // If the node has never been written, then write the whole buffer, including the zeros
//size_t n_to_write = node->nodesize; //size_t n_to_write = node->nodesize;
ssize_t r=pwrite(fd, w.buf, n_to_write, off); ssize_t r=pwrite(fd, compressed_buf, compressed_n_to_write, off);
if (r<0) printf("r=%ld errno=%d\n", (long)r, errno); if (r<0) printf("r=%ld errno=%d\n", (long)r, errno);
assert(r==(ssize_t)n_to_write); assert(r==(ssize_t)n_to_write);
} }
......
...@@ -33,7 +33,7 @@ FORMAT=-Wmissing-format-attribute ...@@ -33,7 +33,7 @@ FORMAT=-Wmissing-format-attribute
endif endif
CFLAGS = -Wall -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn $(FORMAT) $(OPTFLAGS) -g3 -ggdb3 $(GCOV_FLAGS) $(PROF_FLAGS) -Werror $(FPICFLAGS) $(SHADOW) $(VISIBILITY) CFLAGS = -Wall -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn $(FORMAT) $(OPTFLAGS) -g3 -ggdb3 $(GCOV_FLAGS) $(PROF_FLAGS) -Werror $(FPICFLAGS) $(SHADOW) $(VISIBILITY)
LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS) -lpthread LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS) -lpthread -lz
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I.. CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I..
# Add -Wconversion # Add -Wconversion
...@@ -69,7 +69,6 @@ REGRESSION_TESTS = \ ...@@ -69,7 +69,6 @@ REGRESSION_TESTS = \
cachetable-fd-test \ cachetable-fd-test \
cachetable-flush-test \ cachetable-flush-test \
cachetable-count-pinned-test \ cachetable-count-pinned-test \
cachetable-checkpoint-test \
fifo-test \ fifo-test \
list-test \ list-test \
keyrange \ keyrange \
......
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