From 401f07f6cf09de904c9e291111ed49a42949c08d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 25 Mar 2012 00:30:22 -0700 Subject: [PATCH] mysqlindexer: implement Get, Set, Delete Change-Id: I5670bfc9ac91044be663f248c034ae20c11562bb --- pkg/mysqlindexer/mysqlindexer.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/mysqlindexer/mysqlindexer.go b/pkg/mysqlindexer/mysqlindexer.go index 88d2ad4ac..be373f83e 100644 --- a/pkg/mysqlindexer/mysqlindexer.go +++ b/pkg/mysqlindexer/mysqlindexer.go @@ -47,15 +47,18 @@ func (ms *myIndexStorage) CommitBatch(b index.BatchMutation) error { } func (ms *myIndexStorage) Get(key string) (value string, err error) { - panic("TODO(bradfitz): implement") + err = ms.db.QueryRow("SELECT v FROM rows WHERE k=?", key).Scan(&value) + return } func (ms *myIndexStorage) Set(key, value string) error { - return errors.New("TODO(bradfitz): implement") + _, err := ms.db.Exec("INSERT INTO rows (k, v) VALUES (?, ?)", key, value) + return err } func (ms *myIndexStorage) Delete(key string) error { - return errors.New("TODO(bradfitz): implement") + _, err := ms.db.Exec("DELETE FROM rows WHERE k=?", key) + return err } func (ms *myIndexStorage) Find(key string) index.Iterator {