forked from DataCentricAlliance/aerodrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaerospike_index.go
47 lines (41 loc) · 930 Bytes
/
aerospike_index.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"github.com/aerospike/aerospike-client-go"
)
type AeroIndex struct {
namespace string
set string
name string
Key string `json: "key"`
Type string `json: "type"`
}
func (storage *AerospikeStorage) CreateIndex(query AeroIndex) bool {
var (
err error
index_type aerospike.IndexType
)
switch query.Type {
case "STRING":
index_type = aerospike.STRING
break
case "NUMERIC":
index_type = aerospike.NUMERIC
break
default:
panic(fmt.Sprintf("Unknown Index type %s", query.Type))
}
if _, err = storage.Client.CreateIndex(nil, query.namespace, query.set, query.name, query.Key, index_type); err != nil {
panic(err)
}
return true
}
func (storage *AerospikeStorage) DropIndex(query AeroIndex) bool {
var (
err error
)
if err = storage.Client.DropIndex(nil, query.namespace, query.set, query.name); err != nil {
panic(err)
}
return true
}