susumu.yata
null+****@clear*****
Mon Jun 22 13:47:49 JST 2015
susumu.yata 2015-06-22 13:47:49 +0900 (Mon, 22 Jun 2015) New Revision: 7243bb1eaa3dbf4e4f7ab659621c7a731be683c0 https://github.com/groonga/grngo/commit/7243bb1eaa3dbf4e4f7ab659621c7a731be683c0 Message: Rename TypeID to DataType and add data types. Constants for data types are added but not yet supported. GitHub: #5 Modified files: grngo.go grngo.h grngo_test.go Modified: grngo.go (+119 -132) =================================================================== --- grngo.go 2015-06-22 10:05:17 +0900 (aa3be82) +++ grngo.go 2015-06-22 13:47:49 +0900 (4411ff7) @@ -23,39 +23,72 @@ import ( // - Float: float64 // - Time: TODO // - WGS84/TokyoGeoPoint: GeoPoint -// - Text: []byte +// - (Short/Long)Text: []byte type GeoPoint struct{ Latitude, Longitude int32 } const NilID = uint32(C.GRN_ID_NIL) -type TypeID int +type DataType int const ( - VoidID = TypeID(iota) - BoolID - IntID - FloatID - GeoPointID - TextID + Void = DataType(C.GRN_DB_VOID) + Bool = DataType(C.GRN_DB_BOOL) + Int8 = DataType(C.GRN_DB_INT8) + Int16 = DataType(C.GRN_DB_INT16) + Int32 = DataType(C.GRN_DB_INT32) + Int64 = DataType(C.GRN_DB_INT64) + UInt8 = DataType(C.GRN_DB_UINT8) + UInt16 = DataType(C.GRN_DB_UINT16) + UInt32 = DataType(C.GRN_DB_UINT32) + UInt64 = DataType(C.GRN_DB_UINT64) + Float = DataType(C.GRN_DB_FLOAT) + Time = DataType(C.GRN_DB_TIME) + ShortText = DataType(C.GRN_DB_SHORT_TEXT) + Text = DataType(C.GRN_DB_TEXT) + LongText = DataType(C.GRN_DB_LONG_TEXT) + TokyoGeoPoint = DataType(C.GRN_DB_TOKYO_GEO_POINT) + WGS84GeoPoint = DataType(C.GRN_DB_WGS84_GEO_POINT) ) -func (id TypeID) String() string { - switch id { - case VoidID: +func (dataType DataType) String() string { + switch dataType { + case Void: return "Void" - case BoolID: + case Bool: return "Bool" - case IntID: - return "Int" - case FloatID: + case Int8: + return "Int8" + case Int16: + return "Int16" + case Int32: + return "Int32" + case Int64: + return "Int64" + case UInt8: + return "UInt8" + case UInt16: + return "UInt16" + case UInt32: + return "UInt32" + case UInt64: + return "UInt64" + case Float: return "Float" - case GeoPointID: - return "GeoPoint" - case TextID: + case Time: + return "Time" + case ShortText: + return "ShortText" + case Text: return "Text" + case LongText: + return "LongText" + case TokyoGeoPoint: + return "TokyoGeoPoint" + case WGS84GeoPoint: + return "WGS84GeoPoint" default: - return fmt.Sprintf("TypeID(%d)", id) + return fmt.Sprintf("DataType(%d)", dataType) } } @@ -367,16 +400,10 @@ func (db *DB) CreateTable(name string, options *TableOptions) (*Table, error) { } if options.KeyType != "" { switch options.KeyType { - case "Bool": - optionsMap["key_type"] = "Bool" - case "Int": - optionsMap["key_type"] = "Int64" - case "Float": - optionsMap["key_type"] = "Float" - case "GeoPoint": - optionsMap["key_type"] = "WGS84GeoPoint" - case "Text": - optionsMap["key_type"] = "ShortText" + case "Bool", "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16", + "UInt32", "UInt64", "Float", "Time", "ShortText", "TokyoGeoPoint", + "WGS84GeoPoint": + optionsMap["key_type"] = options.KeyType default: if _, err := db.FindTable(options.KeyType); err != nil { return nil, fmt.Errorf("unsupported key type: options = %+v", options) @@ -386,14 +413,9 @@ func (db *DB) CreateTable(name string, options *TableOptions) (*Table, error) { } if options.ValueType != "" { switch options.ValueType { - case "Bool": - optionsMap["value_type"] = "Bool" - case "Int": - optionsMap["value_type"] = "Int64" - case "Float": - optionsMap["value_type"] = "Float" - case "GeoPoint": - optionsMap["value_type"] = "WGS84GeoPoint" + case "Bool", "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16", + "UInt32", "UInt64", "Float", "Time", "TokyoGeoPoint", "WGS84GeoPoint": + optionsMap["value_type"] = options.ValueType default: if _, err := db.FindTable(options.ValueType); err != nil { return nil, fmt.Errorf("unsupported value type: options = %+v", @@ -441,28 +463,11 @@ func (db *DB) FindTable(name string) (*Table, error) { name) } // Check the key type. - var keyType TypeID - switch keyInfo.data_type { - case C.GRN_DB_VOID: - keyType = VoidID - case C.GRN_DB_BOOL: - keyType = BoolID - case C.GRN_DB_INT64: - keyType = IntID - case C.GRN_DB_FLOAT: - keyType = FloatID - case C.GRN_DB_WGS84_GEO_POINT: - keyType = GeoPointID - case C.GRN_DB_SHORT_TEXT: - keyType = TextID - default: - return nil, fmt.Errorf("unsupported key type: data_type = %d", - keyInfo.data_type) - } + keyType := DataType(keyInfo.data_type) // Find the destination table if the key is table reference. var keyTable *Table if keyInfo.ref_table != nil { - if keyType == VoidID { + if keyType == Void { return nil, fmt.Errorf("reference to void: name = <%s>", name) } cKeyTableName := C.grngo_table_get_name(db.ctx, keyInfo.ref_table) @@ -482,28 +487,11 @@ func (db *DB) FindTable(name string) (*Table, error) { name) } // Check the value type. - var valueType TypeID - switch valueInfo.data_type { - case C.GRN_DB_VOID: - valueType = VoidID - case C.GRN_DB_BOOL: - valueType = BoolID - case C.GRN_DB_INT64: - valueType = IntID - case C.GRN_DB_FLOAT: - valueType = FloatID - case C.GRN_DB_WGS84_GEO_POINT: - valueType = GeoPointID - case C.GRN_DB_SHORT_TEXT: - valueType = TextID - default: - return nil, fmt.Errorf("unsupported value type: data_type = %d", - valueInfo.data_type) - } + valueType := DataType(valueInfo.data_type) // Find the destination table if the value is table reference. var valueTable *Table if valueInfo.ref_table != nil { - if valueType == VoidID { + if valueType == Void { return nil, fmt.Errorf("reference to void: name = <%s>", name) } cValueTableName := C.grngo_table_get_name(db.ctx, valueInfo.ref_table) @@ -556,16 +544,16 @@ type Table struct { db *DB obj *C.grn_obj name string - keyType TypeID + keyType DataType keyTable *Table - valueType TypeID + valueType DataType valueTable *Table columns map[string]*Column } // newTable() creates a new Table object. -func newTable(db *DB, obj *C.grn_obj, name string, keyType TypeID, - keyTable *Table, valueType TypeID, valueTable *Table) *Table { +func newTable(db *DB, obj *C.grn_obj, name string, keyType DataType, + keyTable *Table, valueType DataType, valueTable *Table) *Table { var table Table table.db = db table.obj = obj @@ -580,7 +568,7 @@ func newTable(db *DB, obj *C.grn_obj, name string, keyType TypeID, // insertVoid() inserts an empty row. func (table *Table) insertVoid() (bool, uint32, error) { - if table.keyType != VoidID { + if table.keyType != Void { return false, NilID, fmt.Errorf("key type conflict") } rowInfo := C.grngo_table_insert_void(table.db.ctx, table.obj) @@ -592,7 +580,7 @@ func (table *Table) insertVoid() (bool, uint32, error) { // insertBool() inserts a row with Bool key. func (table *Table) insertBool(key bool) (bool, uint32, error) { - if table.keyType != BoolID { + if table.keyType != Bool { return false, NilID, fmt.Errorf("key type conflict") } grnKey := C.grn_bool(C.GRN_FALSE) @@ -608,7 +596,9 @@ func (table *Table) insertBool(key bool) (bool, uint32, error) { // insertInt() inserts a row with Int key. func (table *Table) insertInt(key int64) (bool, uint32, error) { - if table.keyType != IntID { + switch table.keyType { + case Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64: + default: return false, NilID, fmt.Errorf("key type conflict") } grnKey := C.int64_t(key) @@ -621,7 +611,7 @@ func (table *Table) insertInt(key int64) (bool, uint32, error) { // insertFloat() inserts a row with Float key. func (table *Table) insertFloat(key float64) (bool, uint32, error) { - if table.keyType != FloatID { + if table.keyType != Float { return false, NilID, fmt.Errorf("key type conflict") } grnKey := C.double(key) @@ -634,7 +624,9 @@ func (table *Table) insertFloat(key float64) (bool, uint32, error) { // insertGeoPoint() inserts a row with GeoPoint key. func (table *Table) insertGeoPoint(key GeoPoint) (bool, uint32, error) { - if table.keyType != GeoPointID { + switch table.keyType { + case TokyoGeoPoint, WGS84GeoPoint: + default: return false, NilID, fmt.Errorf("key type conflict") } grnKey := C.grn_geo_point{C.int(key.Latitude), C.int(key.Longitude)} @@ -647,7 +639,7 @@ func (table *Table) insertGeoPoint(key GeoPoint) (bool, uint32, error) { // insertText() inserts a row with Text key. func (table *Table) insertText(key []byte) (bool, uint32, error) { - if table.keyType != TextID { + if table.keyType != ShortText { return false, NilID, fmt.Errorf("key type conflict") } var grnKey C.grngo_text @@ -695,16 +687,10 @@ func (table *Table) CreateColumn(name string, valueType string, optionsMap["table"] = table.name optionsMap["name"] = name switch valueType { - case "Bool": - optionsMap["type"] = "Bool" - case "Int": - optionsMap["type"] = "Int64" - case "Float": - optionsMap["type"] = "Float" - case "GeoPoint": - optionsMap["type"] = "WGS84GeoPoint" - case "Text": - optionsMap["type"] = "LongText" + case "Bool", "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16", + "UInt32", "UInt64", "Float", "Time", "ShortText", "Text", "LongText", + "TokyoGeoPoint", "WGS84GeoPoint": + optionsMap["type"] = valueType default: if _, err := table.db.FindTable(valueType); err != nil { return nil, fmt.Errorf("unsupported value type: valueType = %s", valueType) @@ -766,12 +752,12 @@ func (table *Table) findColumn(name string) (*Column, error) { if obj == nil { return nil, fmt.Errorf("grn_obj_column() failed: table = %+v, name = <%s>", table, name) } - var valueType TypeID + var valueType DataType var valueTable *Table var isVector bool switch name { case "_id": - valueType = IntID + valueType = UInt32 case "_key": valueType = table.keyType valueTable = table.keyTable @@ -785,25 +771,11 @@ func (table *Table) findColumn(name string) (*Column, error) { name) } // Check the value type. - switch valueInfo.data_type { - case C.GRN_DB_BOOL: - valueType = BoolID - case C.GRN_DB_INT64: - valueType = IntID - case C.GRN_DB_FLOAT: - valueType = FloatID - case C.GRN_DB_WGS84_GEO_POINT: - valueType = GeoPointID - case C.GRN_DB_SHORT_TEXT, C.GRN_DB_LONG_TEXT: - valueType = TextID - default: - return nil, fmt.Errorf("unsupported value type: data_type = %d", - valueInfo.data_type) - } + valueType = DataType(valueInfo.data_type) isVector = valueInfo.dimension > 0 // Find the destination table if the value is table reference. if valueInfo.ref_table != nil { - if valueType == VoidID { + if valueType == Void { return nil, fmt.Errorf("reference to void: name = <%s>", name) } cValueTableName := C.grngo_table_get_name(table.db.ctx, valueInfo.ref_table) @@ -874,14 +846,14 @@ type Column struct { table *Table obj *C.grn_obj name string - valueType TypeID + valueType DataType isVector bool valueTable *Table } // newColumn() creates a new Column object. func newColumn(table *Table, obj *C.grn_obj, name string, - valueType TypeID, isVector bool, valueTable *Table) *Column { + valueType DataType, isVector bool, valueTable *Table) *Column { var column Column column.table = table column.obj = obj @@ -894,7 +866,7 @@ func newColumn(table *Table, obj *C.grn_obj, name string, // setBool() assigns a Bool value. func (column *Column) setBool(id uint32, value bool) error { - if (column.valueType != BoolID) || column.isVector { + if (column.valueType != Bool) || column.isVector { return fmt.Errorf("value type conflict") } var grnValue C.grn_bool = C.GRN_FALSE @@ -910,7 +882,12 @@ func (column *Column) setBool(id uint32, value bool) error { // setInt() assigns an Int value. func (column *Column) setInt(id uint32, value int64) error { - if (column.valueType != IntID) || column.isVector { + switch column.valueType { + case Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64: + default: + return fmt.Errorf("value type conflict") + } + if column.isVector { return fmt.Errorf("value type conflict") } grnValue := C.int64_t(value) @@ -923,7 +900,7 @@ func (column *Column) setInt(id uint32, value int64) error { // setFloat() assigns a Float value. func (column *Column) setFloat(id uint32, value float64) error { - if (column.valueType != FloatID) || column.isVector { + if (column.valueType != Float) || column.isVector { return fmt.Errorf("value type conflict") } grnValue := C.double(value) @@ -936,7 +913,12 @@ func (column *Column) setFloat(id uint32, value float64) error { // setGeoPoint() assigns a GeoPoint value. func (column *Column) setGeoPoint(id uint32, value GeoPoint) error { - if (column.valueType != GeoPointID) || column.isVector { + switch column.valueType { + case TokyoGeoPoint, WGS84GeoPoint: + default: + return fmt.Errorf("value type conflict") + } + if column.isVector { return fmt.Errorf("value type conflict") } grnValue := C.grn_geo_point{C.int(value.Latitude), C.int(value.Longitude)} @@ -949,7 +931,12 @@ func (column *Column) setGeoPoint(id uint32, value GeoPoint) error { // setText() assigns a Text value. func (column *Column) setText(id uint32, value []byte) error { - if (column.valueType != TextID) || column.isVector { + switch column.valueType { + case ShortText, Text, LongText: + default: + return fmt.Errorf("value type conflict") + } + if column.isVector { return fmt.Errorf("value type conflict") } var grnValue C.grngo_text @@ -1249,29 +1236,29 @@ func (column *Column) getTextVector(id uint32) (interface{}, error) { func (column *Column) GetValue(id uint32) (interface{}, error) { if !column.isVector { switch column.valueType { - case BoolID: + case Bool: return column.getBool(id) - case IntID: + case Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64: return column.getInt(id) - case FloatID: + case Float: return column.getFloat(id) - case GeoPointID: - return column.getGeoPoint(id) - case TextID: + case ShortText, Text, LongText: return column.getText(id) + case TokyoGeoPoint, WGS84GeoPoint: + return column.getGeoPoint(id) } } else { switch column.valueType { - case BoolID: + case Bool: return column.getBoolVector(id) - case IntID: + case Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64: return column.getIntVector(id) - case FloatID: + case Float: return column.getFloatVector(id) - case GeoPointID: - return column.getGeoPointVector(id) - case TextID: + case ShortText, Text, LongText: return column.getTextVector(id) + case TokyoGeoPoint, WGS84GeoPoint: + return column.getGeoPointVector(id) } } return nil, fmt.Errorf("undefined value type: valueType = %d", column.valueType) Modified: grngo.h (+1 -1) =================================================================== --- grngo.h 2015-06-22 10:05:17 +0900 (e260e9f) +++ grngo.h 2015-06-22 13:47:49 +0900 (726d6a1) @@ -22,7 +22,7 @@ typedef struct { grn_obj *grngo_find_table(grn_ctx *ctx, const char *name, int name_len); typedef struct { - grn_id data_type; // Data type (GRN_DB_VOID, GRN_DB_BOOL, etc.). + grn_builtin_type data_type; // Data type (GRN_DB_VOID, GRN_DB_BOOL, etc.). // If the type is table reference, the key type of the // referenced table is stored. int dimension; // Vector depth, 0 means the type is scalar. Modified: grngo_test.go (+65 -65) =================================================================== --- grngo_test.go 2015-06-22 10:05:17 +0900 (b05fc87) +++ grngo_test.go 2015-06-22 13:47:49 +0900 (7c9c3b9) @@ -139,7 +139,7 @@ func TestDBCreateTableWithBoolKey(t *testing.T) { } func TestDBCreateTableWithIntKey(t *testing.T) { - testDBCreateTableWithKey(t, "Int") + testDBCreateTableWithKey(t, "Int64") } func TestDBCreateTableWithFloatKey(t *testing.T) { @@ -147,11 +147,11 @@ func TestDBCreateTableWithFloatKey(t *testing.T) { } func TestDBCreateTableWithGeoPointKey(t *testing.T) { - testDBCreateTableWithKey(t, "GeoPoint") + testDBCreateTableWithKey(t, "WGS84GeoPoint") } func TestDBCreateTableWithTextKey(t *testing.T) { - testDBCreateTableWithKey(t, "Text") + testDBCreateTableWithKey(t, "ShortText") } func TestDBCreateTableWithBoolValue(t *testing.T) { @@ -159,7 +159,7 @@ func TestDBCreateTableWithBoolValue(t *testing.T) { } func TestDBCreateTableWithIntValue(t *testing.T) { - testDBCreateTableWithValue(t, "Int") + testDBCreateTableWithValue(t, "Int64") } func TestDBCreateTableWithFloatValue(t *testing.T) { @@ -167,7 +167,7 @@ func TestDBCreateTableWithFloatValue(t *testing.T) { } func TestDBCreateTableWithGeoPointValue(t *testing.T) { - testDBCreateTableWithValue(t, "GeoPoint") + testDBCreateTableWithValue(t, "WGS84GeoPoint") } func TestDBCreateTableWithBoolRefKey(t *testing.T) { @@ -175,7 +175,7 @@ func TestDBCreateTableWithBoolRefKey(t *testing.T) { } func TestDBCreateTableWithIntRefKey(t *testing.T) { - testDBCreateTableWithRefKey(t, "Int") + testDBCreateTableWithRefKey(t, "Int64") } func TestDBCreateTableWithFloatRefKey(t *testing.T) { @@ -183,11 +183,11 @@ func TestDBCreateTableWithFloatRefKey(t *testing.T) { } func TestDBCreateTableWithGeoPointRefKey(t *testing.T) { - testDBCreateTableWithRefKey(t, "GeoPoint") + testDBCreateTableWithRefKey(t, "WGS84GeoPoint") } func TestDBCreateTableWithTextRefKey(t *testing.T) { - testDBCreateTableWithRefKey(t, "Text") + testDBCreateTableWithRefKey(t, "ShortText") } func TestDBCreateTableWithBoolRefValue(t *testing.T) { @@ -195,7 +195,7 @@ func TestDBCreateTableWithBoolRefValue(t *testing.T) { } func TestDBCreateTableWithIntRefValue(t *testing.T) { - testDBCreateTableWithRefValue(t, "Int") + testDBCreateTableWithRefValue(t, "Int64") } func TestDBCreateTableWithFloatRefValue(t *testing.T) { @@ -203,22 +203,22 @@ func TestDBCreateTableWithFloatRefValue(t *testing.T) { } func TestDBCreateTableWithGeoPointRefValue(t *testing.T) { - testDBCreateTableWithRefValue(t, "GeoPoint") + testDBCreateTableWithRefValue(t, "WGS84GeoPoint") } func TestDBCreateTableWithTextRefValue(t *testing.T) { - testDBCreateTableWithRefValue(t, "Text") + testDBCreateTableWithRefValue(t, "ShortText") } func generateRandomKey(keyType string) interface{} { switch keyType { case "Bool": return (rand.Int() & 1) == 1 - case "Int": + case "Int64": return rand.Int63() case "Float": return rand.Float64() - case "GeoPoint": + case "WGS84GeoPoint": const ( MinLatitude = 73531000 MaxLatitude = 164006000 @@ -228,7 +228,7 @@ func generateRandomKey(keyType string) interface{} { latitude := MinLatitude + rand.Intn(MaxLatitude-MinLatitude+1) longitude := MinLongitude + rand.Intn(MaxLongitude-MinLongitude+1) return GeoPoint{int32(latitude), int32(longitude)} - case "Text": + case "ShortText": return []byte(strconv.Itoa(rand.Int())) default: return nil @@ -266,7 +266,7 @@ func TestTableInsertRowWithBoolKey(t *testing.T) { } func TestTableInsertRowWithIntKey(t *testing.T) { - testTableInsertRow(t, "Int") + testTableInsertRow(t, "Int64") } func TestTableInsertRowWithFloatKey(t *testing.T) { @@ -274,11 +274,11 @@ func TestTableInsertRowWithFloatKey(t *testing.T) { } func TestTableInsertRowWithGeoPointKey(t *testing.T) { - testTableInsertRow(t, "GeoPoint") + testTableInsertRow(t, "WGS84GeoPoint") } func TestTableInsertRowWithTextKey(t *testing.T) { - testTableInsertRow(t, "Text") + testTableInsertRow(t, "ShortText") } func testTableCreateScalarColumn(t *testing.T, valueType string) { @@ -374,7 +374,7 @@ func TestTableCreateColumnForBool(t *testing.T) { } func TestTableCreateColumnForInt(t *testing.T) { - testTableCreateScalarColumn(t, "Int") + testTableCreateScalarColumn(t, "Int64") } func TestTableCreateColumnForFloat(t *testing.T) { @@ -382,11 +382,11 @@ func TestTableCreateColumnForFloat(t *testing.T) { } func TestTableCreateColumnForGeoPoint(t *testing.T) { - testTableCreateScalarColumn(t, "GeoPoint") + testTableCreateScalarColumn(t, "WGS84GeoPoint") } func TestTableCreateColumnForText(t *testing.T) { - testTableCreateScalarColumn(t, "Text") + testTableCreateScalarColumn(t, "ShortText") } func TestTableCreateColumnForBoolVector(t *testing.T) { @@ -394,7 +394,7 @@ func TestTableCreateColumnForBoolVector(t *testing.T) { } func TestTableCreateColumnForIntVector(t *testing.T) { - testTableCreateVectorColumn(t, "Int") + testTableCreateVectorColumn(t, "Int64") } func TestTableCreateColumnForFloatVector(t *testing.T) { @@ -402,11 +402,11 @@ func TestTableCreateColumnForFloatVector(t *testing.T) { } func TestTableCreateColumnForGeoPointVector(t *testing.T) { - testTableCreateVectorColumn(t, "GeoPoint") + testTableCreateVectorColumn(t, "WGS84GeoPoint") } func TestTableCreateColumnForTextVector(t *testing.T) { - testTableCreateVectorColumn(t, "Text") + testTableCreateVectorColumn(t, "ShortText") } func TestTableCreateColumnForRefToBool(t *testing.T) { @@ -414,7 +414,7 @@ func TestTableCreateColumnForRefToBool(t *testing.T) { } func TestTableCreateColumnForRefToInt(t *testing.T) { - testTableCreateScalarRefColumn(t, "Int") + testTableCreateScalarRefColumn(t, "Int64") } func TestTableCreateColumnForRefToFloat(t *testing.T) { @@ -422,11 +422,11 @@ func TestTableCreateColumnForRefToFloat(t *testing.T) { } func TestTableCreateColumnForRefToGeoPoint(t *testing.T) { - testTableCreateScalarRefColumn(t, "GeoPoint") + testTableCreateScalarRefColumn(t, "WGS84GeoPoint") } func TestTableCreateColumnForRefToText(t *testing.T) { - testTableCreateScalarRefColumn(t, "Text") + testTableCreateScalarRefColumn(t, "ShortText") } func TestTableCreateColumnForRefToBoolVector(t *testing.T) { @@ -434,7 +434,7 @@ func TestTableCreateColumnForRefToBoolVector(t *testing.T) { } func TestTableCreateColumnForRefToIntVector(t *testing.T) { - testTableCreateVectorRefColumn(t, "Int") + testTableCreateVectorRefColumn(t, "Int64") } func TestTableCreateColumnForRefToFloatVector(t *testing.T) { @@ -442,22 +442,22 @@ func TestTableCreateColumnForRefToFloatVector(t *testing.T) { } func TestTableCreateColumnForRefToGeoPointVector(t *testing.T) { - testTableCreateVectorRefColumn(t, "GeoPoint") + testTableCreateVectorRefColumn(t, "WGS84GeoPoint") } func TestTableCreateColumnForRefToTextVector(t *testing.T) { - testTableCreateVectorRefColumn(t, "Text") + testTableCreateVectorRefColumn(t, "ShortText") } func generateRandomValue(valueType string) interface{} { switch valueType { case "Bool": return (rand.Int() & 1) == 1 - case "Int": + case "Int64": return rand.Int63() case "Float": return rand.Float64() - case "GeoPoint": + case "WGS84GeoPoint": const ( MinLatitude = 73531000 MaxLatitude = 164006000 @@ -467,7 +467,7 @@ func generateRandomValue(valueType string) interface{} { latitude := MinLatitude + rand.Intn(MaxLatitude-MinLatitude+1) longitude := MinLongitude + rand.Intn(MaxLongitude-MinLongitude+1) return GeoPoint{int32(latitude), int32(longitude)} - case "Text": + case "ShortText": return []byte(strconv.Itoa(rand.Int())) default: return nil @@ -483,7 +483,7 @@ func generateRandomVectorValue(valueType string) interface{} { value[i] = (rand.Int() & 1) == 1 } return value - case "Int": + case "Int64": value := make([]int64, size) for i := 0; i < size; i++ { value[i] = rand.Int63() @@ -495,7 +495,7 @@ func generateRandomVectorValue(valueType string) interface{} { value[i] = rand.Float64() } return value - case "GeoPoint": + case "WGS84GeoPoint": const ( MinLatitude = 73531000 MaxLatitude = 164006000 @@ -509,7 +509,7 @@ func generateRandomVectorValue(valueType string) interface{} { value[i] = GeoPoint{int32(latitude), int32(longitude)} } return value - case "Text": + case "ShortText": value := make([][]byte, size) for i := 0; i < size; i++ { value[i] = []byte(strconv.Itoa(rand.Int())) @@ -565,7 +565,7 @@ func TestColumnSetValueForBool(t *testing.T) { } func TestColumnSetValueForInt(t *testing.T) { - testColumnSetValueForScalar(t, "Int") + testColumnSetValueForScalar(t, "Int64") } func TestColumnSetValueForFloat(t *testing.T) { @@ -573,11 +573,11 @@ func TestColumnSetValueForFloat(t *testing.T) { } func TestColumnSetValueForGeoPoint(t *testing.T) { - testColumnSetValueForScalar(t, "GeoPoint") + testColumnSetValueForScalar(t, "WGS84GeoPoint") } func TestColumnSetValueForText(t *testing.T) { - testColumnSetValueForScalar(t, "Text") + testColumnSetValueForScalar(t, "ShortText") } func TestColumnSetValueForBoolVector(t *testing.T) { @@ -585,7 +585,7 @@ func TestColumnSetValueForBoolVector(t *testing.T) { } func TestColumnSetValueForIntVector(t *testing.T) { - testColumnSetValueForVector(t, "Int") + testColumnSetValueForVector(t, "Int64") } func TestColumnSetValueForFloatVector(t *testing.T) { @@ -593,11 +593,11 @@ func TestColumnSetValueForFloatVector(t *testing.T) { } func TestColumnSetValueForGeoPointVector(t *testing.T) { - testColumnSetValueForVector(t, "GeoPoint") + testColumnSetValueForVector(t, "WGS84GeoPoint") } func TestColumnSetValueForTextVector(t *testing.T) { - testColumnSetValueForVector(t, "Text") + testColumnSetValueForVector(t, "ShortText") } func testColumnGetValueForScalar(t *testing.T, valueType string) { @@ -656,7 +656,7 @@ func TestColumnGetValueForBool(t *testing.T) { } func TestColumnGetValueForInt(t *testing.T) { - testColumnGetValueForScalar(t, "Int") + testColumnGetValueForScalar(t, "Int64") } func TestColumnGetValueForFloat(t *testing.T) { @@ -664,11 +664,11 @@ func TestColumnGetValueForFloat(t *testing.T) { } func TestColumnGetValueForGeoPoint(t *testing.T) { - testColumnGetValueForScalar(t, "GeoPoint") + testColumnGetValueForScalar(t, "WGS84GeoPoint") } func TestColumnGetValueForText(t *testing.T) { - testColumnGetValueForScalar(t, "Text") + testColumnGetValueForScalar(t, "ShortText") } func TestColumnGetValueForBoolVector(t *testing.T) { @@ -676,7 +676,7 @@ func TestColumnGetValueForBoolVector(t *testing.T) { } func TestColumnGetValueForIntVector(t *testing.T) { - testColumnGetValueForVector(t, "Int") + testColumnGetValueForVector(t, "Int64") } func TestColumnGetValueForFloatVector(t *testing.T) { @@ -684,11 +684,11 @@ func TestColumnGetValueForFloatVector(t *testing.T) { } func TestColumnGetValueForGeoPointVector(t *testing.T) { - testColumnGetValueForVector(t, "GeoPoint") + testColumnGetValueForVector(t, "WGS84GeoPoint") } func TestColumnGetValueForTextVector(t *testing.T) { - testColumnGetValueForVector(t, "Text") + testColumnGetValueForVector(t, "ShortText") } var numTestRows = 100000 @@ -764,7 +764,7 @@ func BenchmarkColumnSetValueForBool(b *testing.B) { } func BenchmarkColumnSetValueForInt(b *testing.B) { - benchmarkColumnSetValueForScalar(b, "Int") + benchmarkColumnSetValueForScalar(b, "Int64") } func BenchmarkColumnSetValueForFloat(b *testing.B) { @@ -772,11 +772,11 @@ func BenchmarkColumnSetValueForFloat(b *testing.B) { } func BenchmarkColumnSetValueForGeoPoint(b *testing.B) { - benchmarkColumnSetValueForScalar(b, "GeoPoint") + benchmarkColumnSetValueForScalar(b, "WGS84GeoPoint") } func BenchmarkColumnSetValueForText(b *testing.B) { - benchmarkColumnSetValueForScalar(b, "Text") + benchmarkColumnSetValueForScalar(b, "ShortText") } func BenchmarkColumnSetValueForBoolVector(b *testing.B) { @@ -784,7 +784,7 @@ func BenchmarkColumnSetValueForBoolVector(b *testing.B) { } func BenchmarkColumnSetValueForIntVector(b *testing.B) { - benchmarkColumnSetValueForVector(b, "Int") + benchmarkColumnSetValueForVector(b, "Int64") } func BenchmarkColumnSetValueForFloatVector(b *testing.B) { @@ -792,11 +792,11 @@ func BenchmarkColumnSetValueForFloatVector(b *testing.B) { } func BenchmarkColumnSetValueForGeoPointVector(b *testing.B) { - benchmarkColumnSetValueForVector(b, "GeoPoint") + benchmarkColumnSetValueForVector(b, "WGS84GeoPoint") } func BenchmarkColumnSetValueForTextVector(b *testing.B) { - benchmarkColumnSetValueForVector(b, "Text") + benchmarkColumnSetValueForVector(b, "ShortText") } func benchmarkColumnGetValueForScalar(b *testing.B, valueType string) { @@ -858,7 +858,7 @@ func BenchmarkColumnGetValueForBool(b *testing.B) { } func BenchmarkColumnGetValueForInt(b *testing.B) { - benchmarkColumnGetValueForScalar(b, "Int") + benchmarkColumnGetValueForScalar(b, "Int64") } func BenchmarkColumnGetValueForFloat(b *testing.B) { @@ -866,11 +866,11 @@ func BenchmarkColumnGetValueForFloat(b *testing.B) { } func BenchmarkColumnGetValueForGeoPoint(b *testing.B) { - benchmarkColumnGetValueForScalar(b, "GeoPoint") + benchmarkColumnGetValueForScalar(b, "WGS84GeoPoint") } func BenchmarkColumnGetValueForText(b *testing.B) { - benchmarkColumnGetValueForScalar(b, "Text") + benchmarkColumnGetValueForScalar(b, "ShortText") } func BenchmarkColumnGetValueForBoolVector(b *testing.B) { @@ -878,7 +878,7 @@ func BenchmarkColumnGetValueForBoolVector(b *testing.B) { } func BenchmarkColumnGetValueForIntVector(b *testing.B) { - benchmarkColumnGetValueForVector(b, "Int") + benchmarkColumnGetValueForVector(b, "Int64") } func BenchmarkColumnGetValueForFloatVector(b *testing.B) { @@ -886,11 +886,11 @@ func BenchmarkColumnGetValueForFloatVector(b *testing.B) { } func BenchmarkColumnGetValueForGeoPointVector(b *testing.B) { - benchmarkColumnGetValueForVector(b, "GeoPoint") + benchmarkColumnGetValueForVector(b, "WGS84GeoPoint") } func BenchmarkColumnGetValueForTextVector(b *testing.B) { - benchmarkColumnGetValueForVector(b, "Text") + benchmarkColumnGetValueForVector(b, "ShortText") } func benchmarkDBSelectForScalar(b *testing.B, valueType string) { @@ -953,7 +953,7 @@ func BenchmarkDBSelectForBool(b *testing.B) { } func BenchmarkDBSelectForInt(b *testing.B) { - benchmarkDBSelectForScalar(b, "Int") + benchmarkDBSelectForScalar(b, "Int64") } func BenchmarkDBSelectForFloat(b *testing.B) { @@ -961,11 +961,11 @@ func BenchmarkDBSelectForFloat(b *testing.B) { } func BenchmarkDBSelectForGeoPoint(b *testing.B) { - benchmarkDBSelectForScalar(b, "GeoPoint") + benchmarkDBSelectForScalar(b, "WGS84GeoPoint") } func BenchmarkDBSelectForText(b *testing.B) { - benchmarkDBSelectForScalar(b, "Text") + benchmarkDBSelectForScalar(b, "ShortText") } func BenchmarkDBSelectForBoolVector(b *testing.B) { @@ -973,7 +973,7 @@ func BenchmarkDBSelectForBoolVector(b *testing.B) { } func BenchmarkDBSelectForIntVector(b *testing.B) { - benchmarkDBSelectForVector(b, "Int") + benchmarkDBSelectForVector(b, "Int64") } func BenchmarkDBSelectForFloatVector(b *testing.B) { @@ -981,9 +981,9 @@ func BenchmarkDBSelectForFloatVector(b *testing.B) { } func BenchmarkDBSelectForGeoPointVector(b *testing.B) { - benchmarkDBSelectForVector(b, "GeoPoint") + benchmarkDBSelectForVector(b, "WGS84GeoPoint") } func BenchmarkDBSelectForTextVector(b *testing.B) { - benchmarkDBSelectForVector(b, "Text") + benchmarkDBSelectForVector(b, "ShortText") } -------------- next part -------------- HTML����������������������������...Download