Thursday, December 24, 2009

Impact of NOSQL movement on the datastore vendors

Term #NOSQL (Not Only SQL) props up frequently these days, sometimes rivalling the traditional SQL-based datastores and on a few occasions augmenting it.
Both of these categories of datastores (databases) are no doubt quite different from each other, have different philosophies behind their implementation and most importantly, have different vendors.

Why don't the conventional SQL-based vendors grasp this opportunity and acquire another paradigm support under their belt? Although Oracle, a RDBMS vendor speaks up of supporting map-reduce model (a feature that is associated with NOSQL solutions), it however does not gives explicit constructs of endorsing the feature.

On the other hand, the NOSQL counterparts are emerging one after the other, solutions made in different languages, with slight variations. It seems like these NOSQL advocates turned vendors are trying to make the most of a hole found in the datastore market, and why shouldn't they capitalize on this silver opportunity? RDBMS vendors have left no room for the different DBMS paradigms to grow, and some of them have evolved into immense beasts.

It will be interesting to see how the different vendors, new and established ones will react to the new demands posed by the NOSQL movement. Only time will determine the leading marketshare holder for this new trend in data storage.

Sunday, December 20, 2009

Sherlock Holmes on MSN

As you may already know about the upcoming Sherlock Holmes movie, casting the Iron Man (Robert Downey Jr.) as the detective himself and Jude Law as Dr. Watson, I'm pretty much excited about this adaption of my favorite literary character and the man of scientific methods - Sherlock Holmes.

The title of this blog also bear a reference of the residence of Mr. Holmes (221b Baker Street), a place I wish to visit some day. In fact, I've fancied myself to be like this great detective during my childhood and most part of my premature adulthood, my MSN Messenger's nick has been 'Sherlock Holmes' for more than 6 years, I've developed a role playing game named 'Sherlock Holmes in FAST', I am also the moderator of a group discussing topics relating to 'The Science of Deduction' and it goes on and on. I think my love is obvious.

Today I visited the promotion site for the much awaited movie hosted by MSN Arabia and was taken to a crashed page upon filling the registration form with incorrect DOB.

Click on the picture to see the enlarged error. You will see the
HarryPotter.reg.btnSubmit_Click method being used to handle the requests coming from a Sherlock Holmes page. This shows that CCP (Cut-Copy-Paste) is also a trend in Microsoft :-)

Can't tell why I posted this little blunder from MS. Maybe it has something to do with my affection with Holmes, or the negative emotions towards Microsoft, or maybe I just can't bear that Harry Potter's handler is receiving requests from a Sherlock Holmes page :P

(Disclaimer: I am not finished with posts related to Sherlock Holmes.)

Wednesday, December 16, 2009

Retrieving Time Zone's DST information in Java

I have worked extensively with times. By time, I mean the software representation of time and the mapping of various concepts surrounding this tangible entity.

Handling of Time Zone, Daylight Saving Time (DST) is a pretty important use case in most softwares. All programming languages have libraries specifically designed to manipulate time easily. However, the implementation of these APIs isn't standardized and therefore developers have to go through a learning curve in order to use these APIs effectively and correctly. But the fact is that most of the developers take the concept for granted and are contend to directly use the libraries without learning the concepts properly.

Web is full of these resources and help can be found for learning the concepts and correctly utilizing the APIs in different languages.
There's one small use case in Java for which I couldn't find any assistance and that simply is: retrieving DST details for a particular Time Zone in Java.

The java.util.TimeZone does contain DST information, however it is not exposed in a direct manner in any of the TimeZone related classes. Internally, TimeZone calculates DST in SimpleTimeZone class (an implementation of TimeZone), which is accessed within TimeZone via ZoneInfo class' static methods.

Look here for the DST related private members of java.util.SimpleTimeZone.

Fortunately, these fields are visible through the toString() method of this class. Have a look at the source.

For convenience I'm providing a simple listing to extract out the DST information of a particular TimeZone:

  * DST details for the time zone i.e. when DST is applied and when it ends.
  * @return
public static String getDSTDetails(TimeZone timeZone) {

if (timeZone.getDSTSavings() > 0) {
/* Java's TimeZone related classes compute the start and end date of DST application but
    * do not expose it. The only way is to decipher the toString method which fortunately
    * prints enough information for us to deduce our required data.
Pattern pattern = Pattern.compile("startMonth=(\\d+),startDay=(\\d+),.+endMonth=(\\d+),endDay=(\\d+),");
Matcher m = pattern.matcher(timeZone.toString());
if (m.find()) {
Calendar startCal = Calendar.getInstance();
Calendar endCal = Calendar.getInstance();

startCal.set(Calendar.MONTH, Integer.valueOf(;
startCal.set(Calendar.DAY_OF_MONTH, Integer.valueOf(;

endCal.set(Calendar.MONTH, Integer.valueOf(;
endCal.set(Calendar.DAY_OF_MONTH, Integer.valueOf(;

final SimpleDateFormat monthFormatter = new SimpleDateFormat("MMMM");

return new MessageFormat("Daylight savings starts at day {0} of {1}, ends at day {2} of {3}")
.format(new Serializable[] {
startCal.get(Calendar.DAY_OF_MONTH), monthFormatter.format(startCal.getTime()),
endCal.get(Calendar.DAY_OF_MONTH), monthFormatter.format(endCal.getTime())

return "NA";

Complete source code is also available as a Github gist.

Feel free to contact me for queries regarding time handling in Java (and on a side note, Teradata).