Category Archives: Uncategorized

Lucene An SPI class of type org.apache.lucene.codecs.Codec with name does not exist

if you are getting this error

An SPI class of type org.apache.lucene.codecs.Codec with name ‘Lucene54’ does not exist

Add Folders

If maven based project then add META-IN/services folders in src/main/resource

else just create META-IN/services folders inside classpath

And File

1- org.apache.lucene.codecs.Codec inside META-INF/services/

with following text inside

org.apache.lucene.codecs.lucene54.Lucene54Codec

It works. The key thing is to remember the version no of lucene jar should match org.apache.lucene.codecs.lucene54.Lucene54Codec text.  I m using lucene 5.4 so lucene54.Lucene54Code.

 

Thanks

 

Learn Recursion – Advantages of Tail Recursion (Day 3)

The tail recursive functions considered better than non tail recursive functions as tail-recursion can be optimized by compiler. The idea used by compilers to optimize tail-recursive functions is simple, since the recursive call is the last statement, there is nothing left to do in the current function, so saving the current function’s stack frame is of no use.

Recursion and Stack Frame

Stack : Variable

Global or Static Variables are stored here.

 

etc/profile

JAVA_HOME=/usr/local/thesis/jvm/jdk_1_8_66/jdk1.8.0_66
PATH=$PATH:$JAVA_HOME/bin
HADOOP_INSTALL=/usr/local/thesis/hadoop/hadoop-2.7.0

# — HADOOP ENVIRONMENT VARIABLES START — #

export HADOOP_HOME=/usr/local/thesis/hadoop/hadoop-2.7.0
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native

# — HADOOP ENVIRONMENT VARIABLES END — #

PATH=$PATH:$HADOOP_INSTALL/bin

export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS=”-Djava.library.path=$HADOOP_HOME/lib”

export SCALA_HOME=/usr/local/thesis/scala/scala-2.11.7
export PATH=$SCALA_HOME/bin:$PATH

export SPARK_HOME=/usr/local/thesis/spark/spark-1.5.2-bin-hadoop2.6
export PATH=$SPARK_HOME/bin:$PATH

export JAVA_HOME
export JRE_HOME
export PATH
export HADOOP_INSTALL

Clone , Shallow and Deep Copy

 

 

The default Object.clone() is indeed a shallow copy. However, it’s designed to throw a CloneNotSupportedException unless your object implements Cloneable.

And when you implement Cloneable, you should override clone() to make it do a deep copy, by calling clone() on all fields that are themselves cloneable.

Hadoop System Environment Variables

JAVA_HOME=/usr/local/java/jdk1.8.0_66
PATH=$PATH:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.8.0_66
PATH=$PATH:$JRE_HOME/bin
HADOOP_INSTALL=/usr/local/hadoop

# — HADOOP ENVIRONMENT VARIABLES START — #

export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS=”-Djava.library.path=$HADOOP_HOME/lib”
export HADOOP_OPTS=$HADOOP_OPTS -Djava.library.path=/usr/local/hadoop/lib/native
# — HADOOP ENVIRONMENT VARIABLES END — #

PATH=$PATH:$HADOOP_INSTALL/bin
export JAVA_HOME
export JRE_HOME
export PATH
export HADOOP_INSTALL

export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS=”-Djava.library.path=$HADOOP_HOME/lib”
export HADOOP_OPTS=”$HADOOP_OPTS -Djava.library.path=/usr/local/hadoop/lib/native”
export JAVA_HOME

# Add following hostname and their ip in host table
10.12.32.110    HadoopMaster
10.12.32.109    HadoopSlave1

Boxing , Unboxing

Converting from a primitive type to its corresponding reference type is boxing conversion and vice versa is unboxing conversion.

Examples are,

  • From primitive boolean to type Boolean
  • From primitive int to type Integer
	int i = 10;
	Integer iObj = new Integer(100);

	iObj = i;//boxing conversion
	i = iObj;//unboxing conversion