[Groonga-commit] groonga/gcs [master] Do reindexing by IndexField

Back to archive index

null+****@clear***** null+****@clear*****
2012年 7月 12日 (木) 19:13:07 JST


SHIMODA Hiroshi	2012-07-12 19:13:07 +0900 (Thu, 12 Jul 2012)

  New Revision: 157674b0bf94a9e874142bf582f75cdb9bf0e050
  https://github.com/groonga/gcs/commit/157674b0bf94a9e874142bf582f75cdb9bf0e050

  Log:
    Do reindexing by IndexField

  Modified files:
    lib/database/domain.js
    lib/database/index-field.js

  Modified: lib/database/domain.js (+3 -38)
===================================================================
--- lib/database/domain.js    2012-07-12 19:09:28 +0900 (9eaab16)
+++ lib/database/domain.js    2012-07-12 19:13:07 +0900 (ab5d07b)
@@ -145,44 +145,9 @@ Domain.prototype = {
     });
   },
   reindexSync: function() {
-    var indexFields = this.indexFields;
-    indexFields.forEach(function(field) {
-      var fieldName = field.name;
-      var fieldType = field.type;
-      if (fieldType == 'uint' || fieldType == 'literal') {
-        this.context.commandSync('column_remove', {
-          table: field.alterTableName,
-          name: field.indexColumnName
-        });
-        this.context.commandSync('table_remove', {
-          name: field.alterTableName
-        });
-        this.context.commandSync('table_create', {
-          name: field.alterTableName,
-          flags: nroonga.TABLE_HASH_KEY,
-          key_type: field.alterTableKeyType
-        });
-        this.context.commandSync('column_create', {
-          table: field.alterTableName,
-          name: field.indexColumnName,
-          flags: nroonga.INDEX_COLUMN_DEFAULT_FLAGS,
-          type: this.tableName,
-          source: field.columnName
-        });
-      } else {
-        this.context.commandSync('column_remove', {
-          table: this.termsTableName,
-          name: field.indexColumnName
-        });
-        this.context.commandSync('column_create', {
-          table: this.termsTableName,
-          name: field.indexColumnName,
-          flags: nroonga.INDEX_COLUMN_DEFAULT_FLAGS,
-          type: this.tableName,
-          source: field.columnName
-        });
-      }
-    }, this);
+    this.indexFields.forEach(function(field) {
+      field.reindexSync();
+    });
   }
 };
 

  Modified: lib/database/index-field.js (+37 -0)
===================================================================
--- lib/database/index-field.js    2012-07-12 19:09:28 +0900 (6e13a25)
+++ lib/database/index-field.js    2012-07-12 19:13:07 +0900 (58729f9)
@@ -180,6 +180,43 @@ IndexField.prototype = {
       table: this.domain.tableName,
       name: this.columnName
     });
+  },
+  reindexSync: function() {
+    var name = this.name;
+    var type = this.type;
+    if (type == 'uint' || fieldType == 'literal') {
+      this.context.commandSync('column_remove', {
+        table: this.alterTableName,
+        name: this.indexColumnName
+      });
+      this.context.commandSync('table_remove', {
+        name: this.alterTableName
+      });
+      this.context.commandSync('table_create', {
+        name: this.alterTableName,
+        flags: nroonga.TABLE_HASH_KEY,
+        key_type: this.alterTableKeyType
+      });
+      this.context.commandSync('column_create', {
+        table: this.alterTableName,
+        name: this.indexColumnName,
+        flags: nroonga.INDEX_COLUMN_DEFAULT_FLAGS,
+        type: this.domain.tableName,
+        source: this.columnName
+      });
+    } else {
+      this.context.commandSync('column_remove', {
+        table: this.domain.termsTableName,
+        name: this.indexColumnName
+      });
+      this.context.commandSync('column_create', {
+        table: this.domain.termsTableName,
+        name: this.indexColumnName,
+        flags: nroonga.INDEX_COLUMN_DEFAULT_FLAGS,
+        type: this.tableName,
+        source: this.columnName
+      });
+    }
   }
 };
 
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
下载 



Groonga-commit メーリングリストの案内
Back to archive index