Skip to main content

Posts

Java8 Features - Date and Time API enhancements

Date and Time API - JSR 310 - Need for the enhancement Anybody who has worked with Java date, calendar and time prior to java8 has had to google at least a few times before their code worked fine. that was how tedious or non-intuitive the entire code surrouding the date and time model was.  Secondly, the objects related to date time were all mutable, causing issues in multithreaded functionalities. (classic example use of SimpleDateFormat.parse()). Third, missing common operations like finding time in TZ x knowing current time in TZ y, month, day, year operations on date etc. Updates in java8 Completely new model of date and time based on the calendar system defined in ISO-8601 . java.time.* package  Two types of times: human time (LocalDate, LocalTime, LocalDateTime, ZonedDateTime,Period) continuous time / unix timestamp (Instant, duration) One can implement their own calendar system by extending the ChronoLocalDate. Sample code Ease of doing dat...
Recent posts

AWS Developer Associate certification

Almost a month since i completed my AWS DA certification. Got 94% overall score. This post is about my preparation time and resources. I spent almost 4-5 hours  on weekdays for 1 calendar month to learn about AWS. I did not have any background of AWS before this. I researched on which resources to use to learn and prepare for the certification. Undoubtedly, acloudguru comes up as the most popular study guide followed by whizlabs for the timed exam preparation. I bought the course on acloudguru and whizlabs. I setup my AWS free tier account. And at the end of each lesson i did the labs on my aws account and read the FAQ about that lesson from the AWS website. My approach to preparation was as much hands-on as possible. I found the course material for developer associate on acloudguru an OK resource. Something that will help you focus on what topics to cover rather than something that helps you understand the AWS ocean. The quizzes are nowhere close to the exam. Real exam has ...

Java 8 Tutorial for Lambda

For those of you who are searching internet for good resource on Lambda, you must read the oracle tutorial.  Java 8 Lambda Quickstart I think this is one of the best tutorial with some simple examples that help you understand when and how to use Lambdas.

Mistakes in my first MapRed prog

Took the Big Data University course for MapReduce.  Following issues in the lab exercise sampleData folder is located on the hadoop fs and not local. test.jar located in the local fs using MapReduce Model V1 for the programming. 1. when providing the input file location, used /sampleData/ XXX.dat instead of sampleData/XXX.dat This resulted in Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://yyy:8020/sampleData/XXX.dat hadoop jar test.jar com.pk.hadoop.MapReduce.Samp sampleData/XXX.dat sampleData/XXX.dat.out 2. Error: java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.Text, received org.apache.hadoop.io.LongWritable Every time the code executed, it was throwing the above error. Problem was that i forgot to declare the mapper and reducer classes for the job. And therefore the job was trying to use its default mappings and failing

overhead of String comparision over int

refer to the last 2 successful submissions on my codechef site for the permut problem https://www.codechef.com/problems/PERMUT2 As you can see, the only difference is use of int[] in place of string[] and hence comparing the int[] with each other as opposed to string[] with each other. one with int[] is ~40% faster than with String[]

To use lambda or not

For a problem as simple as repeat division on each of the N numbers from console, you might be tempted to use single line of code by making use of lambda expressions. ( like below ) reader.lines().limit(numOfTCs).mapToInt(parseInt(x)).foreach(buffer.append(y/divisor)); But, the choice will cost you performance and readability!! At times, its the more verbose but easier to understand piece of code that wins over the newer methods of coding. Lesson: Just because you can code in Java8 syntax, you need not overuse it.