Permalink
Browse files

Merge branch 'master' of github.com:ayende/ravendb

  • Loading branch information...
fitzchak committed Apr 16, 2012
2 parents 9d220f1 + 3780a65 commit 5763d2b8236efe58c62b98941e2b2b0a44227eba
@@ -141,29 +141,34 @@ public IEnumerable<MappedResultInfo> GetMappedResultsReduceKeysAfter(string inde
if (Api.TrySeek(session, MappedResults, SeekGrbit.SeekLE) == false)
return Enumerable.Empty<MappedResultInfo>();
- var optimizer = new OptimizedIndexReader(Session, MappedResults, take);
+ var results = new Dictionary<string, MappedResultInfo>();
while (
- optimizer.Count < take &&
+ results.Count < take &&
Api.RetrieveColumnAsString(session, MappedResults, tableColumnsCache.MappedResultsColumns["view"], Encoding.Unicode, RetrieveColumnGrbit.RetrieveFromIndex) == indexName)
{
-
- optimizer.Add();
-
- // the index is view ascending and etag descending
+ var mappedResultInfo = new MappedResultInfo
+ {
+ ReduceKey =
+ Api.RetrieveColumnAsString(session, MappedResults, tableColumnsCache.MappedResultsColumns["reduce_key"]),
+ Etag = new Guid(Api.RetrieveColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["etag"])),
+ Timestamp =
+ Api.RetrieveColumnAsDateTime(session, MappedResults, tableColumnsCache.MappedResultsColumns["timestamp"]).
+ Value,
+ Data = loadData
+ ? Api.RetrieveColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["data"]).
+ ToJObject()
+ : null,
+ };
+
+ results[mappedResultInfo.ReduceKey] = mappedResultInfo;
+
+ // the index is view ascending and etag descending
// that means that we are going backward to go up
if (Api.TryMovePrevious(session, MappedResults) == false)
break;
}
- return optimizer.Select(() => new MappedResultInfo
- {
- ReduceKey = Api.RetrieveColumnAsString(session, MappedResults, tableColumnsCache.MappedResultsColumns["reduce_key"]),
- Etag = new Guid(Api.RetrieveColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["etag"])),
- Timestamp = Api.RetrieveColumnAsDateTime(session, MappedResults, tableColumnsCache.MappedResultsColumns["timestamp"]).Value,
- Data = loadData
- ? Api.RetrieveColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["data"]).ToJObject()
- : null,
- });
+ return results.Values;
}
}
}
@@ -92,7 +92,7 @@ public void DeleteMappedResultsForView(string view)
public IEnumerable<MappedResultInfo> GetMappedResultsReduceKeysAfter(string indexName, Guid lastReducedEtag, bool loadData, int take)
{
- return storage.MappedResults["ByViewAndEtagDesc"]
+ var mappedResultInfos = storage.MappedResults["ByViewAndEtagDesc"]
// the index is sorted view ascending and then etag descending
// we index before this index, then backward toward the last one.
.SkipBefore(new RavenJObject { { "view", indexName }, {"etag", lastReducedEtag.ToByteArray()}})
@@ -112,7 +112,18 @@ public IEnumerable<MappedResultInfo> GetMappedResultsReduceKeysAfter(string inde
mappedResultInfo.Data = readResult.Data().ToJObject();
}
return mappedResultInfo;
- }).Take(take);
+ });
+
+ var results = new Dictionary<string, MappedResultInfo>();
+
+ foreach (var mappedResultInfo in mappedResultInfos)
+ {
+ results[mappedResultInfo.ReduceKey] = mappedResultInfo;
+ if (results.Count == take)
+ break;
+ }
+
+ return results.Values;
}
}
}
Oops, something went wrong.

0 comments on commit 5763d2b

Please sign in to comment.