[Groonga-commit] groonga/groonga at 985e0e2 [master] grn_string: add offsets

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 28 11:40:43 JST 2018


Kouhei Sutou	2018-05-28 11:40:43 +0900 (Mon, 28 May 2018)

  New Revision: 985e0e261965a141f6d41c1c7bea4ee7f714dd8a
  https://github.com/groonga/groonga/commit/985e0e261965a141f6d41c1c7bea4ee7f714dd8a

  Message:
    grn_string: add offsets

  Modified files:
    include/groonga/string.h
    lib/grn_string.h
    lib/string.c

  Modified: include/groonga/string.h (+4 -0)
===================================================================
--- include/groonga/string.h    2018-05-28 10:33:42 +0900 (609d95097)
+++ include/groonga/string.h    2018-05-28 11:40:43 +0900 (f004b6cd2)
@@ -98,6 +98,10 @@ GRN_API const unsigned char *grn_string_get_types(grn_ctx *ctx, grn_obj *string)
 GRN_API grn_rc grn_string_set_types(grn_ctx *ctx,
                                     grn_obj *string,
                                     unsigned char *types);
+GRN_API const uint64_t *grn_string_get_offsets(grn_ctx *ctx, grn_obj *string);
+GRN_API grn_rc grn_string_set_offsets(grn_ctx *ctx,
+                                      grn_obj *string,
+                                      uint64_t *offsets);
 GRN_API grn_encoding grn_string_get_encoding(grn_ctx *ctx, grn_obj *string);
 GRN_API grn_obj *grn_string_get_table(grn_ctx *ctx, grn_obj *string);
 

  Modified: lib/grn_string.h (+1 -0)
===================================================================
--- lib/grn_string.h    2018-05-28 10:33:42 +0900 (c7e7bad06)
+++ lib/grn_string.h    2018-05-28 11:40:43 +0900 (4864a6ea2)
@@ -37,6 +37,7 @@ typedef struct {
   unsigned int n_characters;
   short *checks;
   unsigned char *ctypes;
+  uint64_t *offsets;
   grn_encoding encoding;
   int flags;
   grn_obj *lexicon;

  Modified: lib/string.c (+33 -1)
===================================================================
--- lib/string.c    2018-05-28 10:33:42 +0900 (b63f5813c)
+++ lib/string.c    2018-05-28 11:40:43 +0900 (f746ecfbc)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2009-2012 Brazil
+  Copyright(C) 2009-2018 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -224,6 +224,7 @@ grn_string_open_(grn_ctx *ctx,
   string->n_characters = 0;
   string->checks = NULL;
   string->ctypes = NULL;
+  string->offsets = NULL;
   string->encoding = encoding;
   string->flags = flags;
   string->lexicon = NULL;
@@ -414,6 +415,36 @@ grn_string_set_types(grn_ctx *ctx, grn_obj *string, unsigned char *types)
   GRN_API_RETURN(rc);
 }
 
+const uint64_t *
+grn_string_get_offsets(grn_ctx *ctx, grn_obj *string)
+{
+  uint64_t *offsets = NULL;
+  grn_string *string_ = (grn_string *)string;
+  GRN_API_ENTER;
+  if (string_) {
+    offsets = string_->offsets;
+  } else {
+    offsets = NULL;
+  }
+  GRN_API_RETURN(offsets);
+}
+
+grn_rc
+grn_string_set_offsets(grn_ctx *ctx, grn_obj *string, uint64_t *offsets)
+{
+  grn_rc rc;
+  grn_string *string_ = (grn_string *)string;
+  GRN_API_ENTER;
+  if (string_) {
+    if (string_->offsets) { GRN_FREE(string_->offsets); }
+    string_->offsets = offsets;
+    rc = GRN_SUCCESS;
+  } else {
+    rc = GRN_INVALID_ARGUMENT;
+  }
+  GRN_API_RETURN(rc);
+}
+
 grn_encoding
 grn_string_get_encoding(grn_ctx *ctx, grn_obj *string)
 {
@@ -500,6 +531,7 @@ grn_string_close(grn_ctx *ctx, grn_obj *string)
     if (string_->normalized) { GRN_FREE(string_->normalized); }
     if (string_->ctypes) { GRN_FREE(string_->ctypes); }
     if (string_->checks) { GRN_FREE(string_->checks); }
+    if (string_->offsets) { GRN_FREE(string_->offsets); }
     GRN_FREE(string);
     rc = GRN_SUCCESS;
   } else {
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180528/42a36cb9/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index