Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
15,429 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule "deps/bplus"] | ||
path = deps/bplus | ||
url = git://github.com/indutny/bplus.git | ||
Submodule bplus
deleted from
959350
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.o | ||
*.a | ||
*.dSYM/ | ||
test/* | ||
!test/*.cc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
script: | ||
- "make -j4 -B test" | ||
- "make SNAPPY=0 -j4 -B test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# | ||
# Configurable options | ||
# MODE = release | debug (default: debug) | ||
# SNAPPY = 0 | 1 (default: 1) | ||
# | ||
CSTDFLAG = --std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter | ||
CPPFLAGS += -fPIC -Iinclude -Ideps/snappy | ||
CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 | ||
CPPFLAGS += -D_XOPEN_SOURCE=500 -D_DARWIN_C_SOURCE | ||
LINKFLAGS += -lpthread | ||
|
||
ifeq ($(ARCH),i386) | ||
CPPFLAGS += -arch i386 | ||
endif | ||
|
||
ifeq ($(MODE),release) | ||
CPPFLAGS += -O3 | ||
DEFINES += -DNDEBUG | ||
else | ||
CFLAGS += -g | ||
endif | ||
|
||
# run make with SNAPPY=0 to turn it off | ||
ifneq ($(SNAPPY),0) | ||
DEFINES += -DBP_USE_SNAPPY=1 | ||
else | ||
DEFINES += -DBP_USE_SNAPPY=0 | ||
endif | ||
|
||
all: bplus.a | ||
|
||
OBJS = | ||
|
||
ifneq ($(SNAPPY),0) | ||
OBJS += deps/snappy/snappy-sinksource.o | ||
OBJS += deps/snappy/snappy.o | ||
OBJS += deps/snappy/snappy-c.o | ||
endif | ||
|
||
OBJS += src/threads.o | ||
OBJS += src/compressor.o | ||
OBJS += src/utils.o | ||
OBJS += src/writer.o | ||
OBJS += src/values.o | ||
OBJS += src/pages.o | ||
OBJS += src/bplus.o | ||
|
||
DEPS= | ||
DEPS += include/bplus.h | ||
DEPS += include/private/errors.h | ||
DEPS += include/private/threads.h | ||
DEPS += include/private/pages.h | ||
DEPS += include/private/values.h | ||
DEPS += include/private/tree.h | ||
DEPS += include/private/utils.h | ||
DEPS += include/private/compressor.h | ||
DEPS += include/private/writer.h | ||
|
||
bplus.a: $(OBJS) | ||
$(AR) rcs bplus.a $(OBJS) | ||
|
||
src/%.o: src/%.c $(DEPS) | ||
$(CC) $(CFLAGS) $(CSTDFLAG) $(CPPFLAGS) $(DEFINES) -c $< -o $@ | ||
|
||
deps/snappy/%.o: deps/snappy/%.cc | ||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ | ||
|
||
TESTS = | ||
TESTS += test/test-api | ||
TESTS += test/test-reopen | ||
TESTS += test/test-range | ||
TESTS += test/test-corruption | ||
TESTS += test/test-bulk | ||
TESTS += test/test-threaded-rw | ||
TESTS += test/bench-basic | ||
TESTS += test/bench-bulk | ||
TESTS += test/bench-multithread-get | ||
|
||
test: $(TESTS) | ||
@test/test-api | ||
@test/test-reopen | ||
@test/test-range | ||
@test/test-bulk | ||
@test/test-corruption | ||
@test/test-threaded-rw | ||
|
||
test/%: test/%.cc bplus.a | ||
$(CXX) $(CFLAGS) $(CPPFLAGS) $(LINKFLAGS) $< -o $@ bplus.a | ||
|
||
clean: | ||
@rm -f bplus.a | ||
@rm -f $(OBJS) $(TESTS) | ||
|
||
.PHONY: all test clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# BPlus - CoW B+ tree in C [![Build Status](https://secure.travis-ci.org/indutny/bplus.png)](http://travis-ci.org/indutny/bplus) | ||
|
||
|
||
## Compiling | ||
|
||
```bash | ||
git clone git://github.com/indutny/bplus.git | ||
cd bplus | ||
make MODE=release | ||
ls bplus.a # <- link your project with that file | ||
``` | ||
|
||
## Usage | ||
|
||
```C | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
#include "bplus.h" | ||
|
||
int main(void) { | ||
bp_db_t db; | ||
|
||
/* Open database */ | ||
bp_open(&db, "/tmp/1.bp"); | ||
|
||
/* Set some value */ | ||
bp_sets(&db, "key", "value"); | ||
|
||
/* Get some value */ | ||
bp_value_t value; | ||
bp_gets(&db, "key", &value); | ||
fprintf(stdout, "%s\n", value.value); | ||
free(value.value) | ||
|
||
/* Close database */ | ||
bp_close(&db); | ||
} | ||
``` | ||
See [include/bplus.h](https://github.com/indutny/bplus/blob/master/include/bplus.h) for more details. | ||
## Advanced build options | ||
```bash | ||
make MODE=debug # build with enabled assertions | ||
make SNAPPY=0 # build without snappy (no compression will be used) | ||
``` | ||
|
||
#### LICENSE | ||
|
||
This software is licensed under the MIT License. | ||
|
||
Copyright Fedor Indutny, 2012. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to permit | ||
persons to whom the Software is furnished to do so, subject to the | ||
following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
opensource@google.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Copyright 2011, Google Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* 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. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"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 COPYRIGHT | ||
OWNER OR CONTRIBUTORS 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. |
Oops, something went wrong.