This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

merge from 0.5.6

  • Loading branch information...
davies committed Feb 23, 2012
1 parent a8f8e81 commit 516ee63b0a55df4f92c19e552b70fe625e24ae7d
Showing with 5,704 additions and 2,072 deletions.
  1. +4 −1 ChangeLog
  2. +8 −13 INSTALL
  3. +0 −39 LICENSE
  4. +4 −3 Makefile.am
  5. +4 −1 README
  6. +101 −0 ae_epoll.c
  7. +91 −0 ae_kqueue.c
  8. +72 −0 ae_select.c
  9. +353 −458 beansdb.c
  10. +25 −77 beansdb.h
  11. +482 −0 bitcask.c
  12. +42 −0 bitcask.h
  13. +141 −0 clock_gettime_stub.c
  14. +236 −0 codec.c
  15. +24 −0 codec.h
  16. +5 −93 configure.ac
  17. +85 −0 crc32.c
  18. +158 −0 diskmgr.c
  19. +30 −0 diskmgr.h
  20. +16 −1 fnv1a.h
  21. +258 −0 hint.c
  22. +35 −0 hint.h
  23. +322 −409 hstore.c
  24. +8 −8 hstore.h
  25. +279 −523 htree.c
  26. +30 −8 htree.h
  27. +0 −36 item.c
  28. +14 −19 python/dbclient.py
  29. +1 −1 python/httpd.py
  30. +7 −7 python/proxy.py
  31. +1 −4 python/sync.py
  32. +826 −0 quicklz.c
  33. +94 −0 quicklz.h
  34. +445 −0 record.c
  35. +53 −0 record.h
  36. +27 −0 test/Makefile
  37. +296 −0 test/beansdb.go
  38. +176 −0 test/bitcask.go
  39. +296 −0 test/bitcask_test.go
  40. +37 −0 test/codec.go
  41. +44 −0 test/codec_test.go
  42. +22 −0 test/fnv1a.h
  43. +93 −0 test/htree.go
  44. +110 −0 test/htree_test.go
  45. +44 −0 test/main.go
  46. +5 −0 test/test.sh
  47. +43 −0 test/test_htree.c
  48. +124 −0 test/test_record.c
  49. +21 −0 test/test_store.c
  50. +112 −371 thread.c
View
@@ -1,2 +1,5 @@
-2009-12-15 0.3.0
+2011-11-24 0.5.6
+ * support multi directories as Home, manage disk spaces auto.
+
+2009-12-25 0.3.0
* First public release.
View
21 INSTALL
@@ -1,23 +1,18 @@
Dependencies
============
-Before deploying Beansdb, make sure that following packages installed:
-
-TokyoCabinet 1.4 or later
--------------------------
-http://1978th.net/tokyocabinet/
-
-libevent 1.3e or later
--------------------------
-http://monkey.org/~provos/libevent/
+beansdb require epoll on Linux, or kqueue on *BSD/Mac OS.
Installation
============
$svn co svn checkout http://beansdb.googlecode.com/svn/trunk/ beansdb-trunk
$cd beansdb-trunk
+$./autogen.sh
+
or
-$wget
-$tar xvzf beansdb-X.Y.Z.tar.gz
-$cd beansdb-X.Y.Z
+
+$wget http://
+$tar xvzf memcachedb-X.Y.Z.tar.gz
+$cd memcachedb-X.Y.Z
$./configure
$make
@@ -32,7 +27,7 @@ Running Examples:
1. run as a single daemon
- beansdb -p 7900 -H /data/beansdb -v
+ beansdb -p 7900 -H /data/beansdb -T 0 -v
2. test it
View
39 LICENSE
@@ -29,12 +29,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-This product includes software developed by Mikio Hirabayashi.
-
-[Tokyo Cabinet]
-
-http://1978th.net/tokyocabinet/
-
This product includes software developed by Steve Chu.
[memcachedb]
@@ -105,36 +99,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-This product includes software developed by Niels Provos.
-
-[ libevent ]
-
-Copyright 2000-2003 Niels Provos <provos@citi.umich.edu>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
- must display the following acknowledgement:
- This product includes software developed by Niels Provos.
-4. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -1,8 +1,9 @@
bin_PROGRAMS = beansdb
-beansdb_SOURCES = beansdb.c item.c fnv1a.h beansdb.h thread.c htree.h htree.c stats.c hstore.h hstore.c
+beansdb_SOURCES = beansdb.c item.c fnv1a.h beansdb.h thread.c htree.h htree.c hint.h hint.c record.h record.c codec.h codec.c bitcask.h bitcask.c hstore.h hstore.c quicklz.h quicklz.c diskmgr.h diskmgr.c
+beansdb_CPPFLAGS = -DNDEBUG
-SUBDIRS = doc tools
-EXTRA_DIST = python CREDITS AUTHORS LICENSE
+SUBDIRS = doc
+EXTRA_DIST = python crc32.c clock_gettime_stub.c ae_epoll.c ae_kqueue.c ae_select.c CREDITS AUTHORS LICENSE
dist-hook:
rm -rf $(distdir)/*/.svn/
View
5 README
@@ -25,10 +25,13 @@ Features
Supported memcache commands
***************************
-get, gets
+get
set(with version support)
+append
+incr
delete
stats
+flush_all
Private commands
****************
View
@@ -0,0 +1,101 @@
+/* Linux epoll(2) based ae.c module
+ * Copyright (C) 2009-2010 Salvatore Sanfilippo - antirez@gmail.com
+ * Released under the BSD license. See the COPYING file for more info. */
+
+#include <sys/epoll.h>
+#include <errno.h>
+
+typedef struct aeApiState {
+ int epfd;
+ struct epoll_event events[AE_SETSIZE];
+} aeApiState;
+
+static int aeApiCreate(EventLoop *eventLoop) {
+ aeApiState *state = malloc(sizeof(aeApiState));
+
+ if (!state) return -1;
+ state->epfd = epoll_create(1024); /* 1024 is just an hint for the kernel */
+ if (state->epfd == -1) return -1;
+ eventLoop->apidata = state;
+ return 0;
+}
+
+static void aeApiFree(EventLoop *eventLoop) {
+ aeApiState *state = eventLoop->apidata;
+
+ close(state->epfd);
+ free(state);
+}
+
+static int aeApiAddEvent(EventLoop *eventLoop, int fd, int mask) {
+ aeApiState *state = eventLoop->apidata;
+ struct epoll_event ee;
+ ee.events = EPOLLONESHOT;
+ if (mask & AE_READABLE) ee.events |= EPOLLIN;
+ if (mask & AE_WRITABLE) ee.events |= EPOLLOUT;
+ ee.data.u64 = 0; /* avoid valgrind warning */
+ ee.data.fd = fd;
+ if (epoll_ctl(state->epfd, EPOLL_CTL_ADD,fd,&ee) == -1 && errno != EEXIST) {
+ fprintf(stderr, "epoll_ctl(%d,%d) failed: %d\n", EPOLL_CTL_ADD,fd,errno);
+ return -1;
+ }
+ return 0;
+}
+
+static int aeApiUpdateEvent(EventLoop *eventLoop, int fd, int mask) {
+ aeApiState *state = eventLoop->apidata;
+ struct epoll_event ee;
+ ee.events = EPOLLONESHOT;
+ if (mask & AE_READABLE) ee.events |= EPOLLIN;
+ if (mask & AE_WRITABLE) ee.events |= EPOLLOUT;
+ ee.data.u64 = 0; /* avoid valgrind warning */
+ ee.data.fd = fd;
+ if (epoll_ctl(state->epfd, EPOLL_CTL_MOD,fd,&ee) == -1) {
+ fprintf(stderr, "epoll_ctl(%d,%d) failed: %d\n", EPOLL_CTL_ADD,fd,errno);
+ return -1;
+ }
+ return 0;
+}
+
+static int aeApiDelEvent(EventLoop *eventLoop, int fd) {
+ aeApiState *state = eventLoop->apidata;
+ struct epoll_event ee;
+
+ ee.events = 0;
+ ee.data.u64 = 0; /* avoid valgrind warning */
+ ee.data.fd = fd;
+ /* Note, Kernel < 2.6.9 requires a non null event pointer even for
+ * EPOLL_CTL_DEL. */
+ if ( epoll_ctl(state->epfd,EPOLL_CTL_DEL,fd,&ee) == -1
+ && errno != ENOENT && errno != EBADF) {
+ fprintf(stderr, "epoll_ctl(%d,%d) failed: %d\n", EPOLL_CTL_DEL,fd,errno);
+ return -1;
+ }
+ return 0;
+}
+
+int aeApiPoll(EventLoop *eventLoop, struct timeval *tvp) {
+ aeApiState *state = eventLoop->apidata;
+ int retval, numevents = 0;
+
+ retval = epoll_wait(state->epfd,state->events,AE_SETSIZE,
+ tvp ? (tvp->tv_sec*1000 + tvp->tv_usec/1000) : -1);
+ if (retval > 0) {
+ int j;
+
+ numevents = retval;
+ for (j = 0; j < numevents; j++) {
+ int mask = 0;
+ struct epoll_event *e = state->events+j;
+
+ if (e->events & EPOLLIN) mask |= AE_READABLE;
+ if (e->events & EPOLLOUT) mask |= AE_WRITABLE;
+ eventLoop->fired[j] = e->data.fd;
+ }
+ }
+ return numevents;
+}
+
+static char *aeApiName(void) {
+ return "epoll";
+}
View
@@ -0,0 +1,91 @@
+/* Kqueue(2)-based ae.c module
+ * Copyright (C) 2009 Harish Mallipeddi - harish.mallipeddi@gmail.com
+ * Released under the BSD license. See the COPYING file for more info. */
+
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/time.h>
+
+typedef struct aeApiState {
+ int kqfd;
+ struct kevent events[AE_SETSIZE];
+} aeApiState;
+
+static int aeApiCreate(EventLoop *eventLoop) {
+ aeApiState *state = malloc(sizeof(aeApiState));
+
+ if (!state) return -1;
+ state->kqfd = kqueue();
+ if (state->kqfd == -1) return -1;
+ eventLoop->apidata = state;
+
+ return 0;
+}
+
+static void aeApiFree(EventLoop *eventLoop) {
+ aeApiState *state = eventLoop->apidata;
+
+ close(state->kqfd);
+ free(state);
+}
+
+static int aeApiAddEvent(EventLoop *eventLoop, int fd, int mask) {
+ aeApiState *state = eventLoop->apidata;
+ struct kevent ke;
+
+ if (mask & AE_READABLE) {
+ EV_SET(&ke, fd, EVFILT_READ, EV_ADD, 0, 0, NULL);
+ if (kevent(state->kqfd, &ke, 1, NULL, 0, NULL) == -1) return -1;
+ }
+ if (mask & AE_WRITABLE) {
+ EV_SET(&ke, fd, EVFILT_WRITE, EV_ADD, 0, 0, NULL);
+ if (kevent(state->kqfd, &ke, 1, NULL, 0, NULL) == -1) return -1;
+ }
+ return 0;
+}
+
+static int aeApiUpdateEvent(EventLoop *eventLoop, int fd, int mask) {
+ return aeApiAddEvent(eventLoop, fd, mask);
+}
+
+static int aeApiDelEvent(EventLoop *eventLoop, int fd) {
+ aeApiState *state = eventLoop->apidata;
+ struct kevent ke;
+
+ EV_SET(&ke, fd, EVFILT_READ | EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
+ kevent(state->kqfd, &ke, 1, NULL, 0, NULL);
+ return 0;
+}
+
+static int aeApiPoll(EventLoop *eventLoop, struct timeval *tvp) {
+ aeApiState *state = eventLoop->apidata;
+ int retval, numevents = 0;
+
+ if (tvp != NULL) {
+ struct timespec timeout;
+ timeout.tv_sec = tvp->tv_sec;
+ timeout.tv_nsec = tvp->tv_usec * 1000;
+ retval = kevent(state->kqfd, NULL, 0, state->events, AE_SETSIZE, &timeout);
+ } else {
+ retval = kevent(state->kqfd, NULL, 0, state->events, AE_SETSIZE, NULL);
+ }
+
+ if (retval > 0) {
+ int j;
+
+ numevents = retval;
+ for(j = 0; j < numevents; j++) {
+ int mask = 0;
+ struct kevent *e = state->events+j;
+
+ if (e->filter == EVFILT_READ) mask |= AE_READABLE;
+ if (e->filter == EVFILT_WRITE) mask |= AE_WRITABLE;
+ eventLoop->fired[j] = e->ident;
+ }
+ }
+ return numevents;
+}
+
+static char *aeApiName(void) {
+ return "kqueue";
+}
View
@@ -0,0 +1,72 @@
+/* Select()-based ae.c module
+ * Copyright (C) 2009-2010 Salvatore Sanfilippo - antirez@gmail.com
+ * Released under the BSD license. See the COPYING file for more info. */
+
+#include <string.h>
+
+typedef struct aeApiState {
+ fd_set rfds, wfds;
+ /* We need to have a copy of the fd sets as it's not safe to reuse
+ * FD sets after select(). */
+ fd_set _rfds, _wfds;
+} aeApiState;
+
+static int aeApiCreate(EventLoop *eventLoop) {
+ aeApiState *state = malloc(sizeof(aeApiState));
+
+ if (!state) return -1;
+ FD_ZERO(&state->rfds);
+ FD_ZERO(&state->wfds);
+ eventLoop->apidata = state;
+ return 0;
+}
+
+static void aeApiFree(EventLoop *eventLoop) {
+ free(eventLoop->apidata);
+}
+
+static int aeApiAddEvent(EventLoop *eventLoop, int fd, int mask) {
+ aeApiState *state = eventLoop->apidata;
+
+ if (mask & AE_READABLE) FD_SET(fd,&state->rfds);
+ if (mask & AE_WRITABLE) FD_SET(fd,&state->wfds);
+ return 0;
+}
+
+static void aeApiDelEvent(EventLoop *eventLoop, int fd, int mask) {
+ aeApiState *state = eventLoop->apidata;
+
+ if (mask & AE_READABLE) FD_CLR(fd,&state->rfds);
+ if (mask & AE_WRITABLE) FD_CLR(fd,&state->wfds);
+}
+
+static int aeApiPoll(EventLoop *eventLoop, struct timeval *tvp) {
+ aeApiState *state = eventLoop->apidata;
+ int retval, j, numevents = 0;
+
+ memcpy(&state->_rfds,&state->rfds,sizeof(fd_set));
+ memcpy(&state->_wfds,&state->wfds,sizeof(fd_set));
+
+ retval = select(eventLoop->maxfd+1,
+ &state->_rfds,&state->_wfds,NULL,tvp);
+ if (retval > 0) {
+ for (j = 0; j <= eventLoop->maxfd; j++) {
+ int mask = 0;
+ aeFileEvent *fe = &eventLoop->events[j];
+
+ if (fe->mask == AE_NONE) continue;
+ if (fe->mask & AE_READABLE && FD_ISSET(j,&state->_rfds))
+ mask |= AE_READABLE;
+ if (fe->mask & AE_WRITABLE && FD_ISSET(j,&state->_wfds))
+ mask |= AE_WRITABLE;
+ eventLoop->fired[numevents].fd = j;
+ eventLoop->fired[numevents].mask = mask;
+ numevents++;
+ }
+ }
+ return numevents;
+}
+
+static char *aeApiName(void) {
+ return "select";
+}
Oops, something went wrong.

0 comments on commit 516ee63

Please sign in to comment.