From 59234b9eb221764f808227ec00201b9c8b9eebee Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Fri, 17 Jan 2014 19:27:51 -0600 Subject: [PATCH] added batch enpoint --- core/batch.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 core/batch.go diff --git a/core/batch.go b/core/batch.go new file mode 100644 index 000000000..445ec64a1 --- /dev/null +++ b/core/batch.go @@ -0,0 +1,50 @@ +package core + +import ( + "encoding/gob" + "pilosa/db" + . "pilosa/util" + + "tux21b.org/v1/gocql/uuid" +) + +type BatchRequest struct { + Id *uuid.UUID + Source *uuid.UUID + Fragment_id SUUID + Bitmap_id uint64 + Compressed_bitmap string +} + +type BatchResponse struct { + Id *uuid.UUID +} + +func (self BatchResponse) ResultId() *uuid.UUID { + return self.Id +} +func (self BatchResponse) ResultData() interface{} { + return self.Id +} + +func init() { + gob.Register(BatchRequest{}) + gob.Register(BatchResponse{}) +} + +func (self *Service) Batch(database_name, frame, compressed_bitmap string, bitmap_id uint64, slice int) error { + //determine the fragment_id from database/frame/slice + database := self.Cluster.GetOrCreateDatabase(database_name) + oslice := database.GetOrCreateSlice(slice) + //need to find processid and fragment id for that slice + + fragment, _ := database.GetFragmentForBitmap(oslice, &db.Bitmap{bitmap_id, frame}) + id := uuid.RandomUUID() + batch := db.Message{Data: BatchRequest{Id: &id, Source: self.Id, Fragment_id: fragment.GetId(), Bitmap_id: bitmap_id, Compressed_bitmap: compressed_bitmap}} + dest_id := fragment.GetProcess().Id() + self.Transport.Send(&batch, &dest_id) + + _, err := self.Hold.Get(&id, 60) + return err + +}