Skip to content

Commit

Permalink
Merge pull request #41 from mezis/update-ruby
Browse files Browse the repository at this point in the history
Support Ruby 2.2
  • Loading branch information
mezis committed Jan 5, 2015
2 parents 023666c + d077bcd commit 8a09bfd
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.5
2.2.0
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ rvm:
- "1.9.3"
- "2.0.0"
- "2.1.5"
- "2.2.0"
# increment to force build: 001
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GEM
thor (= 0.18.1)
diff-lcs (1.2.5)
docile (1.1.5)
eventmachine (1.0.3)
eventmachine (1.0.4)
ffi (1.9.6)
formatador (0.2.5)
guard (2.8.2)
Expand Down
7 changes: 6 additions & 1 deletion ext/blurrily/blurrily.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
*/

#define PACKED_STRUCT __attribute__ ((__packed__))
#ifndef __BLURRILY_H__
#define __BLURRILY_H__ 1

#define BR_PACKED_STRUCT __attribute__ ((__packed__))
#define UNUSED(_IDENT) _IDENT __attribute__ ((unused))

#ifdef DEBUG
#define LOG(...) fprintf(stderr, __VA_ARGS__)
#else
#define LOG(...)
#endif

#endif
6 changes: 3 additions & 3 deletions ext/blurrily/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/******************************************************************************/

/* one trigram entry -- client reference and sorting weight */
struct PACKED_STRUCT trigram_entry_t
struct BR_PACKED_STRUCT trigram_entry_t
{
uint32_t reference;
uint32_t weight;
Expand All @@ -44,7 +44,7 @@ typedef struct trigram_entry_t trigram_entry_t;
/* collection of entries for a given trigram */
/* <entries> points to an array of <buckets> entries */
/* of which <used> are filled */
struct PACKED_STRUCT trigram_entries_t
struct BR_PACKED_STRUCT trigram_entries_t
{
uint32_t buckets;
uint32_t used;
Expand All @@ -59,7 +59,7 @@ typedef struct trigram_entries_t trigram_entries_t;

/* hash map of all possible trigrams to collection of entries */
/* there are 28^3 = 19,683 possible trigrams */
struct PACKED_STRUCT trigram_map_t
struct BR_PACKED_STRUCT trigram_map_t
{
char magic[6]; /* the string "trigra" */
uint8_t big_endian;
Expand Down
6 changes: 5 additions & 1 deletion ext/blurrily/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
Trigram map creation, persistence, and qurying.
*/
#ifndef __STORAGE_H__
#define __STORAGE_H__

#include <inttypes.h>
#include "tokeniser.h"
#include "blurrily.h"

struct trigram_map_t;
typedef struct trigram_map_t* trigram_map;

struct PACKED_STRUCT trigram_match_t {
struct BR_PACKED_STRUCT trigram_match_t {
uint32_t reference;
uint32_t matches;
uint32_t weight;
Expand Down Expand Up @@ -113,3 +116,4 @@ int blurrily_storage_find(trigram_map haystack, const char* needle, uint16_t lim
*/
int blurrily_storage_stats(trigram_map haystack, trigram_stat_t* stats);

#endif
5 changes: 5 additions & 0 deletions ext/blurrily/tokeniser.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
Each trigram is represented by a 16-bit integer.
*/
#ifndef __TOKENISER_H__
#define __TOKENISER_H__

#include <inttypes.h>

#define TRIGRAM_BASE 28
Expand All @@ -39,3 +42,5 @@ int blurrily_tokeniser_parse_string(const char* input, trigram_t* output);
Returns positive on success, negative on failure.
*/
int blurrily_tokeniser_trigram(trigram_t input, char* output);

#endif

0 comments on commit 8a09bfd

Please sign in to comment.