[Groonga-commit] groonga/grnxx at 722d0f7 [master] Gnx: implement LoadCMap().

Back to archive index

susumu.yata null+****@clear*****
Wed Apr 1 15:57:15 JST 2015


susumu.yata	2015-04-01 15:57:15 +0900 (Wed, 01 Apr 2015)

  New Revision: 722d0f795731eee0b8e162f0fafb274e305cb8b7
  https://github.com/groonga/grnxx/commit/722d0f795731eee0b8e162f0fafb274e305cb8b7

  Message:
    Gnx: implement LoadCMap().

  Modified files:
    go2/gnx/gnx.go
    go2/gnxTest.go

  Modified: go2/gnx/gnx.go (+9 -2)
===================================================================
--- go2/gnx/gnx.go    2015-04-01 15:48:00 +0900 (40b4150)
+++ go2/gnx/gnx.go    2015-04-01 15:57:15 +0900 (ddda9e0)
@@ -837,8 +837,15 @@ func (db *DB) loadC(
 
 func (db *DB) loadCMap(
 	tableName string, columnarRecordsMap map[string]interface{}) (int, error) {
-	// TODO
-	return 0, nil
+	columnNames := make([]string, len(columnarRecordsMap))
+	columnarRecords := make([]interface{}, len(columnarRecordsMap))
+	i := 0
+	for columnName, columnarValues := range columnarRecordsMap {
+		columnNames[i] = columnName
+		columnarRecords[i] = columnarValues
+		i++
+	}
+	return db.loadC(tableName, columnNames, columnarRecords)
 }
 
 func (db *DB) Load(

  Modified: go2/gnxTest.go (+24 -11)
===================================================================
--- go2/gnxTest.go    2015-04-01 15:48:00 +0900 (d4690fb)
+++ go2/gnxTest.go    2015-04-01 15:57:15 +0900 (37dd7db)
@@ -194,7 +194,7 @@ func testB() {
 		var columnarRecords []interface{}
 		// NOTE: In fact, the IDs are ignored.
 		columnarRecords = append(columnarRecords, []gnx.Int{5,6,7,8})
-		columnarRecords = append(columnarRecords, []gnx.Int{-10,-20,-30,-40})
+		columnarRecords = append(columnarRecords, []gnx.Int{-5,-6,-7,-8})
 		count, err := db.LoadC("Table", []string{"_id", "Value"}, columnarRecords)
 		if err != nil {
 			log.Println(err)
@@ -203,16 +203,29 @@ func testB() {
 		fmt.Println("count:", count)
 	}
 
-//	{
-//		columnarRecordsMap := make(map[string]interface{})
-//		columnarRecordsMap["Value"] = []gnx.Int{-100,-200,-300}
-//		count, err := db.LoadCMap("Table", columnarRecordsMap)
-//		if err != nil {
-//			log.Println(err)
-//			return
-//		}
-//		fmt.Println("count:", count)
-//	}
+	{
+		columnarRecordsMap := make(map[string]interface{})
+		columnarRecordsMap["Value"] = []gnx.Int{-10,-20,-30,-40}
+		count, err := db.LoadCMap("Table", columnarRecordsMap)
+		if err != nil {
+			log.Println(err)
+			return
+		}
+		fmt.Println("count:", count)
+	}
+
+	{
+		columnarRecordsMap := make(map[string]interface{})
+		// NOTE: In fact, the IDs are ignored.
+		columnarRecordsMap["_id"] = []gnx.Int{9,10,11,12}
+		columnarRecordsMap["Value"] = []gnx.Int{-50,-60,-70,-80}
+		count, err := db.LoadCMap("Table", columnarRecordsMap)
+		if err != nil {
+			log.Println(err)
+			return
+		}
+		fmt.Println("count:", count)
+	}
 
 	command := "select Table --limit -1"
 	for i := 0; i < 3; i++ {
-------------- next part --------------
HTML����������������������������...
Télécharger 



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