func (d *MapDatastore) Query(ctx context.Context, q dsq.Query) (dsq.Results, error) {
	re := make([]dsq.Entry, 0, len(d.values))
	for k, v := range d.values {
		e := dsq.Entry{Key: k.String(), Size: len(v)}
		if !q.KeysOnly {
			e.Value = v
		}
		re = append(re, e)
	}
	r := dsq.ResultsWithEntries(q, re)
	r = dsq.NaiveQueryApply(q, r)
	return r, nil
}
Query implements Datastore.Query
package datastore
import (
	"context"
	"log"
	dsq "github.com/ipfs/go-datastore/query"
)
type MapDatastore struct {
	values map[Key][]byte
}
func NewMapDatastore() (d *MapDatastore) {
	return &MapDatastore{
		values: make(map[Key][]byte),
	}
}
func (d *MapDatastore) Put(ctx context.Context, key Key, value []byte) (err error) {
	d.values[key] = value
	return nil
}
func (d *MapDatastore) Sync(ctx context.Context, prefix Key) error {
	return nil
}
func (d *MapDatastore) Get(ctx context.Context, key Key) (value []byte, err error) {
	val, found := d.values[key]
	if !found {
		return nil, ErrNotFound
	}
	return val, nil
}
func (d *MapDatastore) Has(ctx context.Context, key Key) (exists bool, err error) {
	_, found := d.values[key]
	return found, nil
}
func (d *MapDatastore) GetSize(ctx context.Context, key Key) (size int, err error) {
	if v, found := d.values[key]; found {
		return len(v), nil
	}
	return -1, ErrNotFound
}
func (d *MapDatastore) Delete(ctx context.Context, key Key) (err error) {
	delete(d.values, key)
	return nil
}