Index: impl/memory/datastore_index.go |
diff --git a/impl/memory/datastore_index.go b/impl/memory/datastore_index.go |
index f4db119e6bd8af872caa037749419d62181a2e38..e61ce89d770c411f89df47ca34d3aa25719bad6e 100644 |
--- a/impl/memory/datastore_index.go |
+++ b/impl/memory/datastore_index.go |
@@ -60,27 +60,36 @@ func (s serializedPvals) Less(i, j int) bool { return bytes.Compare(s[i], s[j]) |
// the ancestor entries for this key. |
type serializedIndexablePmap map[string]serializedPvals |
+func serializeRow(vals []ds.Property) serializedPvals { |
iannucci
2015/09/10 03:56:58
This was a convenient refactoring. It'll become mo
|
+ dups := map[string]struct{}{} |
+ ret := make(serializedPvals, 0, len(vals)) |
+ for _, v := range vals { |
+ if v.IndexSetting() == ds.NoIndex { |
+ continue |
+ } |
+ data := serialize.ToBytes(v.ForIndex()) |
+ dataS := string(data) |
+ if _, ok := dups[dataS]; ok { |
+ continue |
+ } |
+ dups[dataS] = struct{}{} |
+ ret = append(ret, data) |
+ } |
+ return ret |
+} |
+ |
func partiallySerialize(k ds.Key, pm ds.PropertyMap) (ret serializedIndexablePmap) { |
ret = make(serializedIndexablePmap, len(pm)+2) |
+ if k == nil { |
+ impossible(fmt.Errorf("key to partiallySerialize is nil")) |
+ } |
ret["__key__"] = [][]byte{serialize.ToBytes(ds.MkProperty(k))} |
for k != nil { |
ret["__ancestor__"] = append(ret["__ancestor__"], serialize.ToBytes(ds.MkProperty(k))) |
k = k.Parent() |
} |
for k, vals := range pm { |
- dups := stringSet{} |
- newVals := make(serializedPvals, 0, len(vals)) |
- for _, v := range vals { |
- if v.IndexSetting() == ds.NoIndex { |
- continue |
- } |
- data := serialize.ToBytes(v) |
- dataS := string(data) |
- if !dups.add(dataS) { |
- continue |
- } |
- newVals = append(newVals, data) |
- } |
+ newVals := serializeRow(vals) |
if len(newVals) > 0 { |
ret[k] = newVals |
} |