NavigableSet Interface

We use set in Java when we don’t want to store duplicate entries. There are two implementation of Set. HashSet and TreeSet.

HashSet stores its elements in a hash table which means it uses hashCode() method of the objects to retrieve and store more efficiently. The main benefit of having HashSet is that adding and searching of a element have constant time. HashSet is very commonly used implementation of Set.

Click Here

Recursion in Java

A Recursion is when the method calls itself to solve a problem. The recursive solution is constructed with a base case and a recursive case. In every recursive solution, we need to have these two components. If we miss base case in our recursive solution, the method will run in never ending loop and will throw StackOverFlowError.

Click Here

Properties File Formats for Java

The most common syntax is where a property file contains key/value pairs in the following format. If you define the log4j.properties file, you might define following way which is the default way of doing it.

Click Here

Creating a JanusGraph Using Gremlin Console

JanusGraph is new community project under the Linux foundation. It is forked from TitanDB code. JanusGraph incorporates support for the property graph model with Apache TinkerPop (the open source graph computing framework) and its Gremlin graph traversal language.

Click Here

Starting Gremlin Console With JanusGraph in Linux

Gremlin is the graph database query language that is used to interact with JanusGraph. One method of putting Gremlin code in JanusGraph is to use Gremlin Console that is being provided by the JanusGraph which comes with JanusGraph plugin. The Gremlin console is a very useful interactive environment for directly writing Gremlin query…

Click Here

Testing Void Method Using Mockito

Mockito is industry wide mocking framework for unit test. It gives an ability to a developer to write his/her code without depending on other developer’s code. Testing void method is hard because it doesn’t return any value. In this blog, I will show, how we can test our void method using Mockito.

Click Here

Testing Mapping with Embedded Elasticsearch Server

Running instance of Elasticsearch cluster server won’t available for unit test. On the other hand, unit test shouldn’t depend on the external running instance. If you want to test the real Elasticsearch behavior in unit test, you can use embedded Elasticsearch server instance. Embedded Elasticsearch server is a small instance of Elasticsearch cluster and it works exactly…

Click Here

Mapping in Elasticsearch

Mapping is the process of defining how a document and fields it contains are stored and indexed. Mapping is very useful to define for following cases:

  1. Which string fields should be treated as full text fields?
  2. Which fields contain numbers, dates or geolocations?
  3. Whether the values of all fields in the document should be indexed into the catch-all _all field?
  4. Format of date values?
  5. Custom rules to control the mapping for dynamically added fields?

Click Here

Deleting Containers and Images from Docker

If you want to delete specific image or container from docker registry, it is very easy to delete just by writing following command.

for container: docker rm [container name]
for image: docker rmi [image id/name]

What about if you want to delete all the images and containers from your docker?…

Click Here

Connecting to Elasticsearch Cluster Using Java API

We can use Elasticsearch Client to connect to elasitcsearch. There are Transport Client and Node Client to connect to Elasticsearch cluster. Node is very lowever level client and knows the cluster very well. However, the TransportClient connects remotely to an Elasticsearch cluster using the transport module. It does not join the cluster…

Click Here

Easy Way to Write toString() Method

It starts get boring to write toString() method especially if you want to include a lot of instance variables. If you are using eclipse, you can generate toString() method code by clicking Source > Generate toString()…. Method looks ugly to be honest…

Click Here

Reading and Writing text files using java – part 1

Manipulating text file is the main skill that needs to be in a Java programmer. Manipulating means reading text file and writing into the another text file. Text file means just plain text file. You can create text file in your notepad/wordpad in windows. If you have mac, you can use textedit. You can also use Notepad++ or Sublime Text to create text file which both are compatible for windows and mac. There are many ways to read and write text file depending on the JDK that you are using…

Click Here

How to setup SQuirrel SQL Client for PostgreSQL/Greenplum?

SQuirreL SQL Client is a popular open source graphical application written in java that allows users to browse tables and issue all kinds of SQL commands. SQuirrel can be used in variety of OS like Java application since it is written in java…

Click Here

Installing PgAdmin

pgAdmin is the popular open source (free) administrative tool to interact with PostgreSQL database. PgAdmin can be used on Linux, Solaris, Mac OSX and windows platforms to manage the PostgreSQL database that is 7.3 and above…

Click Here

How to setup the Squirrel to Connect to DB2?

SQuirreL SQL Client is a popular open source graphical application written in java that allows users to browse tables and issue all kinds of SQL commands. SQuirrel can be used in variety of OS like Java application since it is written in java. The newer and recent version i.e. 3.6 supports Java 1.6 or higher…

Click Here