convert UUID to use "tux21b.org/v1/gocql/uuid"

This commit is contained in:
travisturner 2014-01-03 17:47:22 -06:00
parent cc1d292c7f
commit 0679ed17a2
13 changed files with 47 additions and 53 deletions

View file

@ -7,8 +7,8 @@ import (
"os"
"sync"
"github.com/nu7hatch/gouuid"
"launchpad.net/goyaml"
"tux21b.org/v1/gocql/uuid"
)
type Config struct {
@ -110,9 +110,9 @@ func (self *Config) GetString(key string) string {
func GetUUID(key string) *uuid.UUID {
value, ok := GetSafe(key)
if ok {
value_uuid, err := uuid.ParseHex(value.(string))
value_uuid, err := uuid.ParseUUID(value.(string))
if err == nil {
return value_uuid
return &value_uuid
}
}
return nil

View file

@ -12,7 +12,7 @@ import (
"github.com/coreos/go-etcd/etcd"
"github.com/davecgh/go-spew/spew"
"github.com/nu7hatch/gouuid"
"tux21b.org/v1/gocql/uuid"
)
type TopologyMapper struct {
@ -63,7 +63,7 @@ func (self *TopologyMapper) handlenode(node *etcd.Node) error {
var fragment_id util.SUUID
var slice *db.Slice
var slice_int int
var process_uuid *uuid.UUID
var process_uuid uuid.UUID
var process *db.Process
var err error
@ -107,11 +107,11 @@ func (self *TopologyMapper) handlenode(node *etcd.Node) error {
if bits[8] != "process" {
return errors.New("no process")
}
process_uuid, err = uuid.ParseHex(node.Value)
process_uuid, err = uuid.ParseUUID(node.Value)
if err != nil {
return err
}
process = db.NewProcess(process_uuid)
process = db.NewProcess(&process_uuid)
fragment.SetProcess(process)
if self.service.Id.String() == process_uuid.String() {
@ -262,11 +262,11 @@ func (self *ProcessMapper) handlenode(node *etcd.Node) error {
}
if len(bits) >= 2 {
id_string := bits[1]
id, err := uuid.ParseHex(id_string)
id, err := uuid.ParseUUID(id_string)
if err != nil {
return errors.New("Invalid UUID: " + id_string)
}
process = self.service.ProcessMap.GetOrAddProcess(id)
process = self.service.ProcessMap.GetOrAddProcess(&id)
}
if len(bits) >= 3 {
switch bits[2] {

View file

@ -12,7 +12,7 @@ import (
"github.com/coreos/go-etcd/etcd"
"github.com/davecgh/go-spew/spew"
"github.com/nu7hatch/gouuid"
"tux21b.org/v1/gocql/uuid"
)
type Service struct {
@ -47,22 +47,22 @@ func NewService() *Service {
}
func (service *Service) init_id() {
var id *uuid.UUID
var id uuid.UUID
var err error
id_string := config.GetString("id")
if id_string == "" {
log.Println("Service id not configured, generating...")
id, err = uuid.NewV4()
id = uuid.RandomUUID()
if err != nil {
log.Fatal("problem generating uuid")
}
} else {
id, err = uuid.ParseHex(id_string)
id, err = uuid.ParseUUID(id_string)
if err != nil {
log.Fatalf("Service id '%s' not valid", id_string)
}
}
service.Id = id
service.Id = &id
}
func (service *Service) GetSignals() (chan os.Signal, chan os.Signal) {

View file

@ -2,7 +2,7 @@ package cruncher
import (
"testing"
//"github.com/nu7hatch/gouuid"
"github.com/davecgh/go-spew/spew"
. "github.com/smartystreets/goconvey/convey"
)

View file

@ -7,8 +7,8 @@ import (
"pilosa/util"
"sync"
"github.com/nu7hatch/gouuid"
"github.com/stathat/consistent"
"tux21b.org/v1/gocql/uuid"
)
var FrameDoesNotExistError = errors.New("Frame does not exist.")

View file

@ -24,11 +24,6 @@
"version": "44eda643c1ae69e866e491b1c935c5b22e42350e",
"type": "git"
},
"gouuid": {
"repo": "github.com/nu7hatch/gouuid",
"version": "87bcc4729f2c5a08d2513ad10684c6bbd256380f",
"type": "git"
},
"goyaml": {
"repo": "launchpad.net/goyaml",
"version": "50",

View file

@ -1,6 +1,6 @@
package hold
import "github.com/nu7hatch/gouuid"
import "tux21b.org/v1/gocql/uuid"
type holdchan chan interface{}
type gethold struct {

View file

@ -4,24 +4,24 @@ import (
"testing"
"time"
"github.com/nu7hatch/gouuid"
. "github.com/smartystreets/goconvey/convey"
"tux21b.org/v1/gocql/uuid"
)
func TestHoldChan(t *testing.T) {
Convey("set then get", t, func() {
id, _ := uuid.NewV4()
Hold.Set(id, "derp")
derp := Hold.Get(id)
id := uuid.RandomUUID()
Hold.Set(&id, "derp")
derp := Hold.Get(&id)
So(derp, ShouldEqual, "derp")
})
Convey("get then set", t, func() {
id, _ := uuid.NewV4()
id := uuid.RandomUUID()
go func() {
time.Sleep(time.Second / 10)
Hold.Set(id, "derpsy")
Hold.Set(&id, "derpsy")
}()
derp := Hold.Get(id)
derp := Hold.Get(&id)
So(derp, ShouldEqual, "derpsy")
})
}

View file

@ -5,7 +5,7 @@ import (
"math/rand"
"pilosa/db"
"github.com/nu7hatch/gouuid"
"tux21b.org/v1/gocql/uuid"
)
// A single step in the query plan.
@ -147,10 +147,10 @@ func (qp *QueryPlanner) flatten(qt QueryTree, id *uuid.UUID, location *db.Locati
inputs := make([]QueryInput, len(composite.subqueries))
step := QueryStep{*id, composite.operation, inputs, composite.getLocation(qp.Database), location}
for index, subq := range composite.subqueries {
sub_id, _ := uuid.NewV4()
sub_id := uuid.RandomUUID()
// this is the "wait" step
step.inputs[index] = sub_id
subq_steps := qp.flatten(subq, sub_id, composite.getLocation(qp.Database))
step.inputs[index] = &sub_id
subq_steps := qp.flatten(subq, &sub_id, composite.getLocation(qp.Database))
plan = append(plan, *subq_steps...)
}
plan = append(plan, step)

View file

@ -6,7 +6,6 @@ package query
// "pilosa/query"
// "pilosa/core"
// "math/rand"
// "github.com/nu7hatch/gouuid"
// "time"
// "log"
//)

View file

@ -6,8 +6,8 @@ import (
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/nu7hatch/gouuid"
. "github.com/smartystreets/goconvey/convey"
"tux21b.org/v1/gocql/uuid"
)
func TestQueryPlanner(t *testing.T) {
@ -39,24 +39,24 @@ func TestQueryPlanner(t *testing.T) {
slice1 := database.GetOrCreateSlice(0)
fragment_id1 := util.Id()
fragment1 := database.GetOrCreateFragment(frame, slice1, fragment_id1)
process_id1, _ := uuid.NewV4()
process1 := db.NewProcess(process_id1)
process_id1 := uuid.RandomUUID()
process1 := db.NewProcess(&process_id1)
process1.SetHost("----192.1.1.0----")
fragment1.SetProcess(process1)
slice2 := database.GetOrCreateSlice(1)
fragment_id2 := util.Id()
fragment2 := database.GetOrCreateFragment(frame, slice2, fragment_id2)
process_id2, _ := uuid.NewV4()
process2 := db.NewProcess(process_id2)
process_id2 := uuid.RandomUUID()
process2 := db.NewProcess(&process_id2)
process2.SetHost("----192.1.1.1----")
fragment2.SetProcess(process2)
qplanner := QueryPlanner{Database: database}
destination := fragment1.GetLocation()
id, _ := uuid.NewV4()
qp := qplanner.Plan(&query, id, destination)
id := uuid.RandomUUID()
qp := qplanner.Plan(&query, &id, destination)
for i, qs := range *qp {
//spew.Dump(i, qs, qs.inputs)

View file

@ -5,7 +5,7 @@ import (
"pilosa/util"
"github.com/davecgh/go-spew/spew"
"github.com/nu7hatch/gouuid"
"tux21b.org/v1/gocql/uuid"
)
type QueryInput interface{}
@ -33,10 +33,10 @@ func QueryPlanForPQL(database *db.Database, pql string) *QueryPlan {
panic(err)
}
query_planner := QueryPlanner{Database: database}
id, _ := uuid.NewV4()
process_id, _ := uuid.NewV4()
id := uuid.RandomUUID()
process_id := uuid.RandomUUID()
fragment_id := util.SUUID(1)
destination := db.Location{process_id, fragment_id}
query_plan := query_planner.Plan(query, id, &destination)
destination := db.Location{&process_id, fragment_id}
query_plan := query_planner.Plan(query, &id, &destination)
return query_plan
}

View file

@ -3,8 +3,8 @@ package util
import (
"testing"
"github.com/nu7hatch/gouuid"
. "github.com/smartystreets/goconvey/convey"
"tux21b.org/v1/gocql/uuid"
)
/*
@ -18,8 +18,8 @@ var (
func init() {
for i, _ := range array {
muid[Id()] = i
id, _ := uuid.NewV4()
muuid[id] = i
id := uuid.RandomUUID()
muuid[&id] = i
}
}
@ -59,7 +59,7 @@ func BenchmarkId(b *testing.B) {
func BenchmarkUUID(b *testing.B) {
// run the Fib function b.N times
for n := 0; n < b.N; n++ {
uuid.NewV4()
uuid.RandomUUID()
}
}
@ -73,10 +73,10 @@ func BenchmarkLookupId(b *testing.B) {
}
}
func BenchmarkLookupUUID(b *testing.B) {
x, _ := uuid.NewV4()
x := uuid.RandomUUID()
for i := 0; i < b.N; i++ {
if a, found := muuid[x]; found {
muuid[x] = a + 1
if a, found := muuid[&x]; found {
muuid[&x] = a + 1
}
}
}