English 中文(简体)
Map/Reduce over shard data with RavenDB
原标题:Map/Reduce over sharded data with RavenDB
  • 时间:2012-01-13 22:24:30
  •  标签:
  • ravendb

当数据在两个节点之间hard缩时,我难以绘制地图,从而减少了样本。 I m 储存与申请错误有关的文件,贴上两个地方的拉文银行节点,错误文件认为:

第1号文件例,共有6份

errors/1/6
{
  "UniqueId": "c62c7e30-8ec7-45af-88e4-da023d796727",
  "ApplicationName": "MyAppName"
}

第2号文件例,共有7份

errors/2/6  --Error stored on shard node 2
{
  "UniqueId": "7e0b0f87-9d75-4e70-9fa0-d64a18bc88dc",
  "ApplicationName": "MyAppName"
}

当我提出这个问题时:

public class ApplicationNames : AbstractIndexCreationTask<ErrorDocument, Application>
{
    public ApplicationNames()
    {
         Map = errors => from error in errors
                        select new { error.ApplicationName, Count = 1 };

        Reduce = results => from error in results
                            group error by new { error.ApplicationName, error.Count } into g
                            select new { g.Key.ApplicationName, Count = g.Sum(x=> x.Count) };
    }
}

I m 得出2个结果;1个有6个,2个有7个。 我预计,每hard的两种结果将合并成一个结果,即13个。 不知道我是否做过错,或者说这不算它想做什么。 我在上观看了这个例子,以制定艰苦战略。

问题回答

Grant, RavenDB currently doesn t handle reduce over multiple nodes. You can do that yourself using:

session.Query<Application, ApplicationNames>()
   .ToList()
   .Select(new ApplicationNames().Reduce)
   .ToList();




相关问题
RavenDB: Grammatical and phonetical analysis?

I m a little confused about the level of integration between Lucene.NET and RavenDB. Lucene supports grammatical and phonetical analysis of texts (like word stemming, Metaphone) to allow searches ...

RavenDB: Id Generation For Sub-Documents

I m trying migrating an existing web application to use RavenDB. I currently have pages in my web application which allow you to view Categories, SubCategories and Resources based on an id in the ...

Updating documents in RavenDB

If you add, delete or rename a property on a persisted entity, what s the easiest way to update the documents in RavenDB?

Lucene Boolean Query on Not ANalyzed Fields

Using RavenDB to do a query on Lucene Index. This query parses okay: X:[[a]] AND Y:[[b]] AND Z:[[c]] However this query gives me a parse exception: X:[[a]] AND Y:[[b]] AND Z:[[c]] AND P:[[d]] "...

.Net Finalizer Order / Semantics in Esent and Ravendb

Help me understand. I ve read that "The time and order of execution of finalizers cannot be predicted or pre-determined" Correct? However looking at RavenDB source code TransactionStorage.cs I see ...

热门标签