help needed in map reduce code.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
hello .. i am trying to convert the UTC to GMT data format with MapReduce on desktop platform.i want to convert the time into datetime format.like this
2016-25-07 01:26:40
2016-25-07 01:26:40
2016-25-07 01:26:40
2016-25-07 01:26:40
2016-25-07 01:26:40
2016-25-07 04:13:20
2016-25-07 04:13:20
2016-25-07 04:13:20
2016-25-07 01:26:40
2016-25-07 01:26:40
2016-25-07 01:26:40
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
2016-25-07 07:00:00
i am getting wrong results from my code. can someone help me
>> read(outds)
ans =
Key Value
______ __________________
'date' [18598x1 datetime]
end
function Map(data, info, intermKVStore)
%datetime = data.RequestTime(~isnan(data.RequestTime));
dateformated=datetime(data.RequestTime/1000,'ConvertFrom','posixTime',...
'TimeZone','Asia/Hong_Kong','Format','dd-MMM-yyyy HH:mm:ss.SSS')
add(intermKVStore, 'datetime', dateformated);
end
function reduce(intermKey, intermValIter, outKVStore)
date = 0;
while hasnext(intermValIter)
date = date + getnext(intermValIter);
end
add(outKVStore,'date',date);
end
0 Kommentare
Antworten (1)
Guillaume
am 14 Okt. 2016
If your input is in UTC and you want the datetime objects to display time in your local timezone, you first need to construct the datetime object in UTC timezone then switch to your local one:
dateformated=datetime(data.RequestTime/1000,'ConvertFrom','posixTime',...
'TimeZone','UTC','Format','dd-MMM-yyyy HH:mm:ss.SSS'); %read data as Posix UTC
dateformated.Timezone = ''Asia/Hong_Kong'; %switch to new timezone. dateformated is adjusted accordingly
Note: Is your purpose really to add all the dates together? If so, why don't you first do it in the map function to reduce memory usage?
Siehe auch
Kategorien
Mehr zu MapReduce finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!