From 0679ed17a2ce8a55c2955cb2185032785d74498f Mon Sep 17 00:00:00 2001 From: travisturner Date: Fri, 3 Jan 2014 17:47:22 -0600 Subject: [PATCH] convert UUID to use "tux21b.org/v1/gocql/uuid" --- config/config.go | 6 +++--- core/etcd.go | 12 ++++++------ core/service.go | 10 +++++----- cruncher/cruncher_test.go | 2 +- db/topology.go | 2 +- deps.json | 5 ----- hold/hold.go | 2 +- hold/hold_test.go | 14 +++++++------- query/planner.go | 8 ++++---- query/planner_example.go | 1 - query/planner_test.go | 14 +++++++------- query/query.go | 10 +++++----- util/util_test.go | 14 +++++++------- 13 files changed, 47 insertions(+), 53 deletions(-) diff --git a/config/config.go b/config/config.go index b528b228a..daccb2b02 100644 --- a/config/config.go +++ b/config/config.go @@ -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 diff --git a/core/etcd.go b/core/etcd.go index 20edf39e3..d1387f3b3 100644 --- a/core/etcd.go +++ b/core/etcd.go @@ -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] { diff --git a/core/service.go b/core/service.go index b6c182046..133df3e1b 100644 --- a/core/service.go +++ b/core/service.go @@ -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) { diff --git a/cruncher/cruncher_test.go b/cruncher/cruncher_test.go index fd0d52598..3e6df2c72 100644 --- a/cruncher/cruncher_test.go +++ b/cruncher/cruncher_test.go @@ -2,7 +2,7 @@ package cruncher import ( "testing" - //"github.com/nu7hatch/gouuid" + "github.com/davecgh/go-spew/spew" . "github.com/smartystreets/goconvey/convey" ) diff --git a/db/topology.go b/db/topology.go index 08f0bbf47..10bf97273 100644 --- a/db/topology.go +++ b/db/topology.go @@ -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.") diff --git a/deps.json b/deps.json index a92ce3b19..caed4552e 100644 --- a/deps.json +++ b/deps.json @@ -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", diff --git a/hold/hold.go b/hold/hold.go index dd10c7070..87586f1aa 100644 --- a/hold/hold.go +++ b/hold/hold.go @@ -1,6 +1,6 @@ package hold -import "github.com/nu7hatch/gouuid" +import "tux21b.org/v1/gocql/uuid" type holdchan chan interface{} type gethold struct { diff --git a/hold/hold_test.go b/hold/hold_test.go index a57edcc8f..e8bfd4214 100644 --- a/hold/hold_test.go +++ b/hold/hold_test.go @@ -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") }) } diff --git a/query/planner.go b/query/planner.go index 9c4bceaf9..43177c3a0 100644 --- a/query/planner.go +++ b/query/planner.go @@ -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) diff --git a/query/planner_example.go b/query/planner_example.go index 4e80603de..02affe0a5 100644 --- a/query/planner_example.go +++ b/query/planner_example.go @@ -6,7 +6,6 @@ package query // "pilosa/query" // "pilosa/core" // "math/rand" -// "github.com/nu7hatch/gouuid" // "time" // "log" //) diff --git a/query/planner_test.go b/query/planner_test.go index 89481b56b..3bb714890 100644 --- a/query/planner_test.go +++ b/query/planner_test.go @@ -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) diff --git a/query/query.go b/query/query.go index 96f4ff38d..b9cb72aa6 100644 --- a/query/query.go +++ b/query/query.go @@ -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 } diff --git a/util/util_test.go b/util/util_test.go index 23a794ed3..246ac0116 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -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 } } }