Wednesday, March 30, 2016

Adding Missing Data points to Collections in Java

If you are from the .NET world, there are high chances that you have used LINQ in the .NET world. I was working on some JAVA project where there was some data which had missing datapoints.

This data in question was read from a DB, and was a big stored procedure. Making any more changes to it for filling in missing values was out of question, as it required nested loops which is better dealt in your programming language as it makes the program clean and more readable, plus its up the reader/consumer how he wants to prune/treat the data.
So here is a small snippet of code for filling missing data in a collection.

List<Timestamp> completeSeries= Utils.generateTimestampSequence(startTimestamp, endTimestamp); -> {
boolean found =
anyMatch(x-> (x.getTimestamp().equals(w) ));
interestingDataCollectionWithMissingPoints.add(new InterestingDataClass(w, 0, 0, 0));
} );
//Now the interestingDataCollectionWithMissingPoints contains all the missing data points
Here, I had a certain data collection which was missing some data for a per minute time intervals. And I needed the complete data for all the point in times for the given time period (startTimeStamp and endTimeStamp).
So the little code snippet above does the trick. Java had no such feature prior to 1.5 version. Of course move to newer Java compiler version  to use this nifty feature.


Troubleshooting Packet Drops in SolarFlare Onload 10G PCI Card

If you see lots of packet drops in your onload accelerated application even after going the troubleshooting discussion we did over here ,...