Introduce a new Batch struct for use with executing range commands.

A Batch is a minimal subset of the Engine interface which satisfies
the needs of MVCC and in general, the execution of Range/Raft commands.
The idea is to make the write-batch nature explicit, obviating the
need to carefully use WriteBatch inside MVCC code. Further, this lays
the groundwork for implementation of an API batch command, allowing
arbitrary combinations of KV API commands to be executed atomically.
This will be important for both large data tasks (e.g. imports), and
for the structured data API (e.g. many updates to associated indexes
on a table insert/update, collapsing a distributed txn which affects
only a single range into one Raft update without associated txn
record).

Also expanded interface for the RangeManager which provides accessors to
Store data objects so we don't need to senselessly keep copies of the same
pointers for all ranges.
Yeah, these things need to be completely localized to a single operation.
They're atomic so halfway-run ops don't leave garbage. They are also going
to be responsible for tracking counter updates for the range so we have
accurate size info.

On Wednesday, October 8, 2014, jiangmingyang <notifications@github.com>
wrote:

> In storage/range.go:
>
> > @@ -225,29 +219,16 @@ type Range struct {
> >  	respCache    *ResponseCache  // Provides idempotence for retries
> >  }
> >
> > -// NewRange initializes the range using the given metadata. The range will have
> > -// no knowledge of a possible store that contains it and thus all rebalancing
> > -// operations will fail. Use NewRangeFromStore() instead to create ranges
> > -// contained within a store.
> > -//
> > -// TODO(spencer): need to give range just a single instance of Range manager
> > -// to contain clock, mvcc, engine, allocator & gossip. This will reduce
> > -// completely unnecessary memory usage per range.
> > -func NewRange(meta *proto.RangeMetadata, clock *hlc.Clock, eng engine.Engine,
> > -	allocator *allocator, gossip *gossip.Gossip, rm RangeManager) *Range {
> > +// NewRange initializes the range using the given metadata.
> > +func NewRange(meta *proto.RangeMetadata, rm RangeManager) *Range {
> >  	r := &Range{
> >  		Meta:      meta,
>
> i c. You need to create a batch for mvcc each time..
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/cockroachdb/cockroach/pull/116/files#r18617020>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cockroach DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cockroach-db+unsubscribe@googlegroups.com
> <javascript:_e(%7B%7D,'cvml','cockroach-db%2Bunsubscribe@googlegroups.com');>
> .
> For more options, visit https://groups.google.com/d/optout.
>