Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

embed snappy and sparkey into Ruby extension#7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
wjordan wants to merge1 commit intoemnl:master
base:master
Choose a base branch
Loading
fromwjordan:embed
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ test/version_tmp
tmp

Makefile
extconf.h
mkmf.log

.DS_Store
6 changes: 6 additions & 0 deletions.gitmodules
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
[submodule "ext/gnista/sparkey"]
path = ext/gnista/sparkey
url = https://github.com/spotify/sparkey.git
[submodule "ext/gnista/snappy"]
path = ext/gnista/snappy
url = https://github.com/google/snappy
7 changes: 3 additions & 4 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,9 +4,7 @@ Gnista is a wrapper for the database/hashstore [Sparkey](http://github.com/spoti

## Setup

You will need Sparkey, obviously. It's really easy to install. Head over to [http://github.com/spotify/sparkey](http://github.com/spotify/sparkey) and install it, I'll wait..

Now, add this line to your application's Gemfile:
Add this line to your application's Gemfile:

gem 'gnista'

Expand DownExpand Up@@ -88,7 +86,8 @@ Both ```Logreader```and ```Hash``` mixin [Enumerable](http://ruby-doc.org/core-2

__Step-by-step:__

1. Fork it
1. Fork it
1. Fetch submodules (`git submodule update`)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Write some code
4. Build and test
Expand Down
63 changes: 61 additions & 2 deletionsext/gnista/extconf.rb
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,66 @@
extension_name = 'gnista'
dir_config(extension_name)

have_library('sparkey') or raise "Sparkey is missing"
have_header('sparkey/sparkey.h') or raise "sparkey.h could not be found"
$CFLAGS << ' -std=c99'
$INCFLAGS << ' -I$(srcdir)/sparkey/src'
$INCFLAGS << ' -I$(srcdir)/snappy'
$VPATH ||= []
$VPATH << '$(srcdir)/sparkey/src'
$VPATH << '$(srcdir)/snappy'
gnista_srcs = %w[
gnista.c
]

sparkey_srcs = %w[
buf.c
hashalgorithms.c
hashiter.c
hashwriter.c
logreader.c
returncodes.c
util.c
endiantools.c
hashheader.c
hashreader.c
logheader.c
logwriter.c
MurmurHash3.c
]

snappy_srcs = %w[
snappy.cc
snappy-c.cc
snappy-sinksource.cc
]

$srcs = gnista_srcs + sparkey_srcs + snappy_srcs

# Create macro definitions used by Snappy sources.
%w[
byteswap.h
stddef.h
stdint.h
sys/endian.h
sys/mman.h
sys/resource.h
sys/time.h
sys/uio.h
unistd.h
windows.h
].each { |header| have_header header }

if have_func 'mmap', 'sys/mman.h'
$defs << '-DHAVE_FUNC_MMAP'
end
if have_func 'sysconf', 'unistd.h'
$defs << '-DHAVE_FUNC_SYSCONF'
end
if try_compile('int main(void) { return __builtin_expect(0, 1); }')
$defs << '-DHAVE_BUILTIN_EXPECT'
end
if try_compile('int main(void) { return __builtin_ctzll(0); }')
$defs << '-DHAVE_BUILTIN_CTZ'
end

create_header
create_makefile(extension_name)
2 changes: 1 addition & 1 deletionext/gnista/gnista.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
#include <ruby.h>
#include <sparkey/sparkey.h>
#include <sparkey.h>

typedef uint8_t bool;
#define true 1
Expand Down
1 change: 1 addition & 0 deletionsext/gnista/snappy
Open in desktop
Submodulesnappy added at 4f7bd2
94 changes: 94 additions & 0 deletionsext/gnista/snappy-stubs-public.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Author: sesse@google.com (Steinar H. Gunderson)
//
// 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.
//
// Various type stubs for the open-source version of Snappy.
//
// This file cannot include config.h, as it is included from snappy.h,
// which is a public header. Instead, snappy-stubs-public.h is generated by
// from snappy-stubs-public.h.in at configure time.

#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_

#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif // HAVE_STDDEF_H

#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif // HAVE_STDDEF_H

#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif // HAVE_SYS_UIO_H

#define SNAPPY_MAJOR 1
#define SNAPPY_MINOR 1
#define SNAPPY_PATCHLEVEL 7
#define SNAPPY_VERSION \
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)

#include <string>

namespace snappy {

#ifdef HAVE_STDINT_H
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#else
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
#endif // HAVE_STDINT_H

typedef std::string string;

#ifndef HAVE_SYS_UIO_H
// Windows does not have an iovec type, yet the concept is universally useful.
// It is simple to define it ourselves, so we put it inside our own namespace.
struct iovec {
void* iov_base;
size_t iov_len;
};
#endif // !HAVE_SYS_UIO_H

} // namespace snappy

#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
1 change: 1 addition & 0 deletionsext/gnista/sparkey
Open in desktop
Submodulesparkey added at e3f71b
4 changes: 3 additions & 1 deletiongnista.gemspec
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,9 @@ Gem::Specification.new do |spec|
spec.files = %w[README.md LICENSE.txt HISTORY.md Rakefile
ext/gnista/extconf.rb ext/gnista/gnista.c
test/test_gnista.rb test/test_commands.rb
lib/gnista.rb lib/gnista/version.rb]
lib/gnista.rb lib/gnista/version.rb] +
# Add all files from all included submodules.
`git submodule --quiet foreach 'git ls-files | sed "s|^|$path/|"'`.split("\n")

spec.test_files = ['test/test_gnista.rb', 'test/test_commands.rb']
spec.require_paths = ["ext", "lib"]
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp