Monday, 26 January 2015

How To Write A Hello World Program in Scala

How To Write A Hello World Program in Scala




Since the Scala plugin is installed, we can create a Scala Project from the “File->New” menu option. If the option Scala Project does not show up, select the “Other” option, then scroll down to “Scala Wizards” and select “Scala Project”.
Create a new package inside the “source” folder. Right click on the new package and select “New->Scala Object”. Provide a name of the Object and click Finish. A Scala object is created inside the package and we can write code inside the object. Let us put a simple main function printing the text “Hello World”. The code snippet is shown below:

 object HelloWorld {
  def main(args: Array[String]){
    println("Hello World!")
  }
}




Doing a right click and selecting “Run As -> Scala Application” will run the program. It will print the text in the console as shown below:

 
Hello World!


Saturday, 27 December 2014

How To Set-Up Development Environment For Scala

How To Set-Up Development Environment For Scala

   

Update Eclipse for Scala Support



The simplest way to get started is to download a pre-configured version of Eclipse by going to the download page. But if Eclipse is already installed, we can add the Scala plugin using software update site.
For the Eclipse versions Eclipse 4.4 (Luna) and Eclipse 4.5 (Mars), Scala 2.11.7 version can be downloaded using the following update site:
For this version of Scala we can use JDK 6, JDK 7, or JDK 8.

Update Eclipse Heap Size to Run Scala


After the Scala plugin installations are done successfully, check the Eclipse’s eclipse.ini file for the heap size value. It needs to be changed to 1024 MB or more.
A sample from the eclipse.ini file is shown below, highlighting the heap size value:

-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms40m
-Xmx1024m

Friday, 28 November 2014

How To Enter The World Of Scala Spark Streaming - Beginners Introduction

How To Enter The World Of Scala, Spark and Streaming - Beginners Introduction




Apache spark can be used as a solution for ingesting data and transforming data. Spark fits well with the other components of Big Data ecosystem. Spark lets you quickly write applications in Java, Scala, or Python. This helps developers to create and run their applications on their familiar programming languages. Spark runs on top of the Hadoop Distributed File System (HDFS). Spark does in memory computations as much as it can which results in increased speed in data processing over Hadoop MapReduce. 

 Scala

Scala is a pure-bred object-oriented language. Conceptually, every value is an object and every operation is a method-call. Scala is also a full-blown functional language. It has a general preference of immutability over mutation. Scala allows a gradual, easy migration to a more functional style. You can start to use it as a “Java without semicolons”. Over time, you can progress to gradually eliminate mutable state in your applications, phasing in safe functional composition patterns instead. Scala runs on the JVM. Java and Scala classes can be freely mixed, no matter whether they reside in different projects or in the same. They can even mutually refer to each other. The Scala compiler contains a subset of a Java compiler to make sense of such recursive dependencies.

Spark

Apache Spark is a fast and general engine for large-scale data processing. Spark runs programs up to 100x faster than Hadoop MapReduce in memory, or 10x faster on disk. Though Spark is written in Scala, Spark applications can be quickly written in Java, Scala and Python. Spark combines SQL, streaming, and complex analytics. Spark powers a stack of high-level tools including Spark SQL, MLlib for machine learning, GraphX, and Spark Streaming. You can combine these libraries seamlessly in the same application. Spark runs on Hadoop, Mesos, standalone, or in the cloud. It can access diverse data sources including HDFS, Cassandra, HBase, and S3. Since its release, Spark has been rapidly adopted by enterprises across a wide range of industries. Many internet powerhouses have deployed Spark at massive scale, collectively processing multiple petabytes of data on clusters of over 8,000 nodes. It has quickly become the largest open source community in big data.

Spark Streaming

Spark Streaming is an extension of the core Spark API that enables scalable, high-throughput, fault-tolerant stream processing of live data streams. Data can be ingested from many sources like Kafka, Flume, Twitter, ZeroMQ, Kinesis or TCP sockets and can be processed using complex algorithms expressed with high-level functions like map, reduce, join and window. Finally, processed data can be pushed out to file systems, databases, and live dashboards. In fact, we can apply Spark’s machine learning and graph processing algorithms on data streams.



Wednesday, 29 October 2014

How To Maximize Enjoyment While Eating

How To Maximize Enjoyment While Eating


Follow these simple steps and your life will be changed:
  1. Pick the food you love most among the foods served to you
  2. Take a small bit of the food
  3. Put it inside your mouth but do not chew
  4. Keep it intact for not less than 15 seconds
  5. Bite the food for once but do not chew
  6. Keep the food still inside your mouth for not less than 15 seconds
  7. Chew the food slowly and enjoy the taste
  8. Make the food dissolve in your mouth slowly
  9. When your mouth is empty wait for some time
  10. Repeat the previous steps