Random Thoughts on Coding

Whatever comes to mind at the moment.

Whats New in Java 8 - Date API Part II

This post is continues our review of the Date API that came with the release of Java 8. We are going to continue our concentration on classes that make working with dates/times very easy. Working with date objects in previous releases of Java was very challenging with respect to adding time or getting the difference between dates. Hopefully after looking at the classes we present here, your opinion of working with dates and times in Java will change. Specifically, we are going to take a look at the following classes:

  • Other classes to represent dates/times ZonedDateTime and OffsetDateTime
  • Getting the current snapshot in time with Instant
  • Using the Clock class to get system time but specify different time zones
  • Represent arbitrary number of days with the Period class
  • Represent arbitrary amount of hours with the Duration class

Blog Migrated to Octopress

After a long period of good intentions with no action, I finally moved the codingjunkie.net blog from Wordpress to Octopress. I have nothing bad to say about Wordpress, it’s been a great tool for me. It’s just that over time I’ve found myself wanting a simpler blogging platform. Aside from liking the overall looks of Ocotpress, the big draw for me was the decreased load time from serving up static HTML pages. Once I sat down and decided to pull the plug, it was really pretty simple. It all boiled down to just a few steps:

  1. Export my posts into the Wordpress XML format.
  2. Run exitwp on the exported XML.
  3. Some basic regex work to fix image tags.
  4. Configure the permalinks to match the form I already use.
  5. Spend 5 minutes reconfiguring my blog on the WebFaction control panel.
  6. Deploy the converted posts using rsync.

Overall, it went much easier than I had anticipated. Only time will tell if switching to the new platform will help me write better content!

What’s New in Java 8 - Date API

With the final release of Java 8 around the corner, one of the new features I’m excited about is the new Date API, a result of the work on JSR 310. While Lambda expressions are certainly the big draw of Java 8, having a better way to work with dates is a decidedly welcome addition. This is a quick post (part 1 of 2 or 3) showing some highlights of the new Date functionality, this time mostly around the LocalDate class.

MapReduce Algorithms - Understanding Data Joins Part II

It’s been awhile since I last posted, and like last time I took a big break, I was taking some classes on Coursera. This time it was Functional Programming Principals in Scala and Principles of Reactive Programming. I found both of them to be great courses and would recommend taking either one if you have the time. In this post we resume our series on implementing the algorithms found in Data-Intensive Text Processing with MapReduce, this time covering map-side joins. As we can guess from the name, map-side joins join data exclusively during the mapping phase and completely skip the reducing phase. In the last post on data joins we covered reduce side joins. Reduce-side joins are easy to implement, but have the drawback that all data is sent across the network to the reducers. Map-side joins offer substantial gains in performance since we are avoiding the cost of sending data across the network. However, unlike reduce-side joins, map-side joins require very specific criteria be met. Today we will discuss the requirements for map-side joins and how we can implement them.

Fine-Grained Concurrency With the Guava Striped Class

This post is going to cover how to use the Striped class from Guava to achieve finer-grained concurrency. The ConcurrentHashMap uses a striped locked approach to increase concurrency and the Striped class extends this principal by giving us the ability to have striped Locks, ReadWriteLocks and Semaphores. When accessing an object or data-structure such as an Array or HashMap typically we would synchronize on the entire object or data-structure, but is this always necessary? In several cases the answer is yes, but there may be times where we don’t that level of course-grained locking and can improve the performance of the application by using a finer-grained approach.