diff --git a/kv/server/raw_api.go b/kv/server/raw_api.go new file mode 100644 index 00000000..025cb246 --- /dev/null +++ b/kv/server/raw_api.go @@ -0,0 +1,36 @@ +package server + +import ( + "context" + "github.com/pingcap-incubator/tinykv/proto/pkg/kvrpcpb" +) + +// The functions below are Server's Raw API. (implements TinyKvServer). +// Some helper methods can be found in sever.go in the current directory + +// RawGet return the corresponding Get response based on RawGetRequest's CF and Key fields +func (server *Server) RawGet(_ context.Context, req *kvrpcpb.RawGetRequest) (*kvrpcpb.RawGetResponse, error) { + // Your Code Here (1). + return nil, nil +} + +// RawPut puts the target data into storage and returns the corresponding response +func (server *Server) RawPut(_ context.Context, req *kvrpcpb.RawPutRequest) (*kvrpcpb.RawPutResponse, error) { + // Your Code Here (1). + // Hint: Consider using Storage.Modify to store data to be modified + return nil, nil +} + +// RawDelete delete the target data from storage and returns the corresponding response +func (server *Server) RawDelete(_ context.Context, req *kvrpcpb.RawDeleteRequest) (*kvrpcpb.RawDeleteResponse, error) { + // Your Code Here (1). + // Hint: Consider using Storage.Modify to store data to be deleted + return nil, nil +} + +// RawScan scan the data starting from the start key up to limit. and return the corresponding result +func (server *Server) RawScan(_ context.Context, req *kvrpcpb.RawScanRequest) (*kvrpcpb.RawScanResponse, error) { + // Your Code Here (1). + // Hint: Consider using reader.IterCF + return nil, nil +} diff --git a/kv/server/server.go b/kv/server/server.go index b21036cf..94df306e 100644 --- a/kv/server/server.go +++ b/kv/server/server.go @@ -35,27 +35,6 @@ func NewServer(storage storage.Storage) *Server { // The below functions are Server's gRPC API (implements TinyKvServer). -// Raw API. -func (server *Server) RawGet(_ context.Context, req *kvrpcpb.RawGetRequest) (*kvrpcpb.RawGetResponse, error) { - // Your Code Here (1). - return nil, nil -} - -func (server *Server) RawPut(_ context.Context, req *kvrpcpb.RawPutRequest) (*kvrpcpb.RawPutResponse, error) { - // Your Code Here (1). - return nil, nil -} - -func (server *Server) RawDelete(_ context.Context, req *kvrpcpb.RawDeleteRequest) (*kvrpcpb.RawDeleteResponse, error) { - // Your Code Here (1). - return nil, nil -} - -func (server *Server) RawScan(_ context.Context, req *kvrpcpb.RawScanRequest) (*kvrpcpb.RawScanResponse, error) { - // Your Code Here (1). - return nil, nil -} - // Raft commands (tinykv <-> tinykv) // Only used for RaftStorage, so trivially forward it. func (server *Server) Raft(stream tinykvpb.TinyKv_RaftServer) error {