Posts

Index MySQL datadase table in Solr

Prerequisites Download the following jars. 1. MySQL jar 2. Solr Data Import Handler jar Data Configuration File Create a data-config.xml file in conf folder & add following content to it. <dataConfig>     <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://<host>:<port>/<database name>" user="<user>" password="<password>" batchSize="1" />     <document name="userdoc">         <entity name="userentity" query="select ID, FIRST_NAME, LAST_NAME from users">             <field column="id" name="ID"/>             <field column="first_name" name="FIRST_NAME" />             <field column="last_name" name="L...

Change MYSQL Database Directory Path in Linux

Step 1: Stop MYSQL sudo service mysqld stop Step 2: Copy MYSQL data to new path sudo cp -R [old path] [new path] Note: By default we have /var/lib/mysql as [old path] Step 3 : Change user to mysql for new data directory sudo chown -R mysql:mysql [new path] Step 4 : Apply proper security context sudo chcon -R -t mysqld_db_t [new path] Step 5 : Edit /etc/my.cnf [mysqld] datadir=[new path] socket=[new path]/mysql.sock [mysql] socket=[new path]/mysql.sock

Deep Copy

In Deep copy all the fields are deeply copied from source object to destination object. If the source object is containing any field that holds a reference to another object then for the destination object a new copy will be created i.e. source and destination objects field will point to different memory location. Java code for Deep Copy package deep; class JobDescription {     private String designation;     public JobDescription(String designation) {         this.designation = designation;     }     public String getDesignation() {         return designation;     }     public void setDesignation(String designation) {         this.designation = designation;     }     @Override     public String toString() { ...

Shallow Copy

In Shallow copy all the fields are just copied from source object to destination object. If the source object is containing any field that holds a reference to another object then only the reference will be copied i.e. source and destination objects field(that particular field) will point to same memory location. Java code for Shallow Copy package shallow; class JobDescription {     private String designation;     public JobDescription(String designation) {         this.designation = designation;     }     public String getDesignation() {         return designation;     }     public void setDesignation(String designation) {         this.designation = designation;     }     @Override     public String toString() {...

Match Rating Algorithm (Phonetic Match)

It's an algorithm for indexing of words by their pronunciation. Algotithm Encoding rules 1. Delete all vowels unless the vowel begins the word 2. Remove the second consonant of any double consonants present 3. Reduce codex to 6 letters by joining the first 3 and last 3 letters only Comparison rules 1. If the length difference between the encoded strings is 3 or greater, then no similarity comparison is done. 2. Obtain the minimum rating value by calculating the length sum of the encoded strings and using below given Minimum Rating Table 3. Process the encoded strings from left to right and remove any identical characters found from both strings respectively. 4. Process the unmatched characters from right to left and remove any identical characters found from both names respectively. 5. Subtract the number of unmatched characters from 6 in the longer string. This is the similarity rating. 6. If the similarit...

Serializable

Serializable is a marker interface which is used to activate serialization on a class. Java Code package demo; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; class Vehicle implements Serializable {     private static final long serialVersionUID = 1L;     private String modelName;     private int noOFWheels;     private String color;     public String getModelName() {         return modelName;     }     public void setModelName(String modelName) {         this.modelName = modelName;     }     public int getNoOFWheels() {...

Marker Interface

Marker interface is one which don't contain any methods and also it is specially recognized by JVM to provide some specific kind of functionality. Some of the Marker interfaces in java: 1. Serializable 2. Cloneable 3. EventListener