[Groonga-commit] groonga/groonga at 4541a0d [master] Support keeping last modified time per table/column

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jun 13 16:42:44 JST 2016


Kouhei Sutou	2016-06-13 16:42:44 +0900 (Mon, 13 Jun 2016)

  New Revision: 4541a0db4dd9cc7a0c922df42e361a3718e49231
  https://github.com/groonga/groonga/commit/4541a0db4dd9cc7a0c922df42e361a3718e49231

  Message:
    Support keeping last modified time per table/column
    
    New APIs:
    
      * grn_obj_touch()
      * grn_obj_get_last_modified()
      * grn_obj_is_dirty()

  Modified files:
    include/groonga/groonga.h
    include/groonga/obj.h
    include/groonga/time.h
    lib/db.c
    lib/grn_db.h

  Modified: include/groonga/groonga.h (+5 -0)
===================================================================
--- include/groonga/groonga.h    2016-06-13 16:32:29 +0900 (7ba7484)
+++ include/groonga/groonga.h    2016-06-13 16:42:44 +0900 (1343361)
@@ -1606,6 +1606,11 @@ struct _grn_table_scan_hit {
   unsigned int length;
 };
 
+typedef struct {
+  int64_t tv_sec;
+  int32_t tv_nsec;
+} grn_timeval;
+
 #ifdef __cplusplus
 }
 #endif

  Modified: include/groonga/obj.h (+4 -0)
===================================================================
--- include/groonga/obj.h    2016-06-13 16:32:29 +0900 (e811d87)
+++ include/groonga/obj.h    2016-06-13 16:42:44 +0900 (02747ea)
@@ -55,6 +55,10 @@ GRN_API grn_rc grn_obj_cast(grn_ctx *ctx,
 
 GRN_API grn_rc grn_obj_reindex(grn_ctx *ctx, grn_obj *obj);
 
+GRN_API void grn_obj_touch(grn_ctx *ctx, grn_obj *obj, grn_timeval *tv);
+GRN_API uint32_t grn_obj_get_last_modified(grn_ctx *ctx, grn_obj *obj);
+GRN_API grn_bool grn_obj_is_dirty(grn_ctx *ctx, grn_obj *obj);
+
 GRN_API const char *grn_obj_type_to_string(uint8_t type);
 
 #ifdef __cplusplus

  Modified: include/groonga/time.h (+0 -5)
===================================================================
--- include/groonga/time.h    2016-06-13 16:32:29 +0900 (3c88492)
+++ include/groonga/time.h    2016-06-13 16:42:44 +0900 (4437959)
@@ -24,11 +24,6 @@
 extern "C" {
 #endif
 
-typedef struct {
-  int64_t tv_sec;
-  int32_t tv_nsec;
-} grn_timeval;
-
 #define GRN_TIMEVAL_TO_MSEC(timeval)                    \
   (((timeval)->tv_sec * GRN_TIME_MSEC_PER_SEC) +        \
    ((timeval)->tv_nsec / GRN_TIME_NSEC_PER_MSEC))

  Modified: lib/db.c (+28 -11)
===================================================================
--- lib/db.c    2016-06-13 16:32:29 +0900 (352d36c)
+++ lib/db.c    2016-06-13 16:42:44 +0900 (0cd92d5)
@@ -658,35 +658,51 @@ grn_obj_io(grn_obj *obj)
 }
 
 uint32_t
-grn_db_get_last_modified(grn_ctx *ctx, grn_obj *db)
+grn_obj_get_last_modified(grn_ctx *ctx, grn_obj *obj)
 {
-  if (!db) {
+  if (!obj) {
     return 0;
   }
 
-  return grn_obj_io(db)->header->last_modified;
+  return grn_obj_io(obj)->header->last_modified;
 }
 
 grn_bool
-grn_db_is_dirty(grn_ctx *ctx, grn_obj *db)
+grn_obj_is_dirty(grn_ctx *ctx, grn_obj *obj)
 {
-  grn_obj *keys;
-
-  if (!db) {
+  if (!obj) {
     return GRN_FALSE;
   }
 
-  keys = ((grn_db *)db)->keys;
-  switch (keys->header.type) {
+  switch (obj->header.type) {
   case GRN_TABLE_PAT_KEY :
-    return grn_pat_is_dirty(ctx, (grn_pat *)keys);
+    return grn_pat_is_dirty(ctx, (grn_pat *)obj);
   case GRN_TABLE_DAT_KEY :
-    return grn_dat_is_dirty(ctx, (grn_dat *)keys);
+    return grn_dat_is_dirty(ctx, (grn_dat *)obj);
   default :
     return GRN_FALSE;
   }
 }
 
+uint32_t
+grn_db_get_last_modified(grn_ctx *ctx, grn_obj *db)
+{
+  return grn_obj_get_last_modified(ctx, db);
+}
+
+grn_bool
+grn_db_is_dirty(grn_ctx *ctx, grn_obj *db)
+{
+  grn_obj *keys;
+
+  if (!db) {
+    return GRN_FALSE;
+  }
+
+  keys = ((grn_db *)db)->keys;
+  return grn_obj_is_dirty(ctx, keys);
+}
+
 static grn_rc
 grn_db_dirty(grn_ctx *ctx, grn_obj *db)
 {
@@ -763,6 +779,7 @@ grn_obj_touch(grn_ctx *ctx, grn_obj *obj, grn_timeval *tv)
     case GRN_COLUMN_FIX_SIZE :
     case GRN_COLUMN_INDEX :
       if (!IS_TEMP(obj)) {
+        grn_obj_io(obj)->header->last_modified = tv->tv_sec;
         grn_obj_touch(ctx, DB_OBJ(obj)->db, tv);
       }
       break;

  Modified: lib/grn_db.h (+0 -2)
===================================================================
--- lib/grn_db.h    2016-06-13 16:32:29 +0900 (6748e37)
+++ lib/grn_db.h    2016-06-13 16:42:44 +0900 (0026905)
@@ -448,8 +448,6 @@ grn_obj *grn_obj_default_set_value_hook(grn_ctx *ctx,
                                         grn_obj **args,
                                         grn_user_data *user_data);
 
-void grn_obj_touch(grn_ctx *ctx, grn_obj *obj, grn_timeval *tv);
-
 grn_rc grn_pvector_fin(grn_ctx *ctx, grn_obj *obj);
 
 #ifdef __cplusplus
-------------- next part --------------
HTML����������������������������...
Download 



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