我有以下格式的數據..增量MapReduce的在C#.NET
類型C_ID Assitor CollectionDate granulity計數器
A中的10 2012年8月8日00:00 15 0.9912378
B中的5 2012年8月8日00:00 15 0.1860929
C b 4 2012年8月8日00:00 15 0.5345317
d的C 1 2012年8月8日00:15 15 0.8656529
的E b 1 2012年8月8日00:15 15 0.3249502
A中的10 2012年8月8日00:15 15 0.3743117
B保持5 2012年8月8日00:30 15 0.2608622
C b 4 2012年8月8日00:30 15 0.0079308
d的C 1 2012年8月8日00:30 15 0.7094781
的E b 1 2012年8月8日00:45 15 0.6133461
A中的10 2012年8月8日00:45 15 0.3035875
B保持5 2012年8月8日00:45 15 0.6093015
C B 4 2012年8月8日01:00 15 0.4104008
d的C 1 2012年8月8日1點15 0.1687753
的E b 1 2012年8月8日1點15 0.6627076
A中的10 2012年8月8日1點15 15 0.1901386 .....
等..
我想要做的每小時的基礎上,該表增量的MapReduce ..上CollectionDate是表明,當記錄來了現場。但所有這些代碼我想在C#.NET
我已經做了mapReduce,但問題是我每15分鐘收到3條記錄,每小時收到12條記錄,在1小時後,這15條記錄將會減少..並且在接下來的1小時後,其餘記錄將在相同的基礎上減少。 。
我能得到幫助這個在C#.NET只有..我在上次20天深陷困境..
它的多餘csv文件..從我得到的記錄.. n插入到mongodb使用c#..在mongodb它看起來像這樣: {「_id」:a324b2f89d2e98fa21f,「Type」:A,「C_ID」: a「assitor」:10,「CollectionDate」:08-08-2012 00:00,「Granulity」:15,「Counter」:0.1901386} {「_id」:a324b2f89d2e98a216f,「Type」:B,「C_ID」 :a,「assitor」:10,「CollectionDate」:08-08-2012 00:00,「Granulity」:15,「Counter」:0.1233542} {「_id」:a324b2f89d2e98a3f2c,「Type」:A,「C_ID 「:b,」assitor「:12,」CollectionDate「:08-08-2012 00:15,」Granulity「:12,」Counter「:0.8134552} {」_id「:a324b2f89d2e98b4e2d,」Type「:B, C_ID「:b,」assitor「:12,」CollectionDate「:08-08-2012 00:15,」Granulity「:12,」Counter「:0。3218547}
OUTPUTFILE: { 「_id」:a8f3e231d456a675b23c, 「CollectionDate」:2012年8月8日00:00 「AvgCounter」:} { 「_id」:a8f3e232456a675a42cd, 「CollectionDate」:2012年8月8日01:00 「AvgCounter」:} { 「_id」:a8f3e231d46a67a0b4d2, 「CollectionDate」:2012年8月8日02:00 「AvgCounter」:}
意味着每小時彙總..
直到我有什麼完成...
private static void MapReduce(MongoDatabase db, String collName, BsonValue bsonValue, DateTime oldDateTime, DateTime newDateTime)
{
var collection = db.GetCollection<BsonDocument>(collName);
Console.WriteLine(TotalReduction++);
String map = @"function() {
var sample = this;
emit(sample.CollectionDate, {CID: sample.C_ID, count:1, CollectionTime: sample.CollectionDate});
}";
String reduce = @"function(key, values) {
var result = {CID: '', count:0};
values.forEach(function(value){
result.CID += value.CID;
result.count += value.count;
result.CollectionTime = value.CollectionTime;
});
return result;
}";
var options = new MapReduceOptionsBuilder();
IMongoQuery[] queries = { Query.EQ("CollectionTime", bsonValue) };
options.SetOutput(MapReduceOutput.Inline);
IMongoQuery query = Query.And(queries);
var results = collection.MapReduce(queries[0], map, reduce);
collection = db.GetCollection<BsonDocument>("MSS_REDUCE");
IEnumerable<BsonDocument> bdoc = results.GetResultsAs<BsonDocument>();
collection.InsertBatch<BsonDocument>(bdoc);
}
謝謝拉維Sharma
您已給我們一個平面文件架構。你的文檔在MongoDB中的外觀如何? –
它的多餘csv文件..我從哪裏得到的記錄.. n插入到mongodb使用c#..在mongodb它看起來像這樣: {「_id」:a324b2f89d2e98fa21f,「Type」:A,「C_ID 「:a,」assitor「:10,」CollectionDate「:08-08-2012 00:00,」Granulity「:15,」Counter「:0.1901386} {」_id「:a324b2f89d2e98fa21f,」Type「:B, 「C_ID」:b,「assitor」:12,「CollectionDate」:08-08-2012 00:15,「Granulity」:12,「Counter」:0.3485126} –
你的預期結果是什麼?你提到你在做什麼和問題是什麼,但不是你想要實現的目標... –