[Groonga-commit] groonga/gcs [master] Add method to translate Amazon CloudSearch index field types to groonga builtin types

Back to archive index

null+****@clear***** null+****@clear*****
2012年 7月 6日 (金) 18:20:17 JST


SHIMODA Hiroshi	2012-07-06 18:20:17 +0900 (Fri, 06 Jul 2012)

  New Revision: f51eefcc2c7b5924b02e160ea5915589cd9162cf
  https://github.com/groonga/gcs/commit/f51eefcc2c7b5924b02e160ea5915589cd9162cf

  Log:
    Add method to translate Amazon CloudSearch index field types to groonga builtin types

  Modified files:
    lib/batch/translator.js
    lib/database.js
    test/batch-translator.test.js

  Modified: lib/batch/translator.js (+14 -0)
===================================================================
--- lib/batch/translator.js    2012-07-06 18:02:06 +0900 (810755e)
+++ lib/batch/translator.js    2012-07-06 18:20:17 +0900 (ed4c9ed)
@@ -1,4 +1,5 @@
 var Domain = require('../domain').Domain;
+var Database = require('../database').Database;
 
 function Translator(domain) {
   this.domain = new Domain(domain);
@@ -80,3 +81,16 @@ function commandsToString(commandSets) {
          }).join('\n');
 }
 exports.commandsToString = Translator.commandsToString = commandsToString;
+
+function translateIndexFieldType(type) {
+  switch (type) {
+    case 'text':
+      return Database.ShortText;
+    case 'uint':
+      return Database.UInt32;
+    default:
+      throw new Error('Unsupported index field type '+type);
+  }
+}
+exports.translateIndexFieldType =
+  Translator.translateIndexFieldType = translateIndexFieldType;

  Modified: lib/database.js (+3 -0)
===================================================================
--- lib/database.js    2012-07-06 18:02:06 +0900 (ca7ced6)
+++ lib/database.js    2012-07-06 18:20:17 +0900 (3b589cf)
@@ -6,6 +6,9 @@ var mkdirp = require('mkdirp');
 var ShortText =
       exports.ShortText =
       Database.ShortText = 'ShortText';
+var UInt32 =
+      exports.UInt32 =
+      Database.UInt32 = 'UInt32';
 
 var TABLE_HASH_KEY =
       exports.TABLE_HASH_KEY =

  Modified: test/batch-translator.test.js (+12 -0)
===================================================================
--- test/batch-translator.test.js    2012-07-06 18:02:06 +0900 (f4a55a1)
+++ test/batch-translator.test.js    2012-07-06 18:20:17 +0900 (4760b19)
@@ -205,4 +205,16 @@ suite('batch/translator/Translator (class methods)', function() {
       assert.equal(stringified, expected);
     });
   });
+
+  suite('translateIndexFieldType', function() {
+    test('text', function() {
+      assert.equal(Translator.translateIndexFieldType('text'),
+                   'ShortText');
+    });
+
+    test('uint', function() {
+      assert.equal(Translator.translateIndexFieldType('uint'),
+                   'UInt32');
+    });
+  });
 });
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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