Quote:
Class Name - Allocated Objects Bytes Allocated Bytes Allocated Objects Allocated
char[] 39.94% 1587999016 38130259
java.lang.String 30.68% 1219811104 38119097
com.etcbase.cas.model.phonebook.PhoneBook 11.04% 438739600 4218650
java.lang.Long 5.86% 233131992 9713833
java.util.HashMap$Entry 3.45% 137127872 4285246
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer 2.29% 91122768 1265594
int[] 2.27% 90140104 67678
java.util.HashMap$Entry[] 0.92% 36772520 38601
com.etcbase.cas.model.lookup.PhoneBookType_$$_javassist_44 0.59% 23624384 421864
com.etcbase.sfc.model.lookup.ContactType_$$_javassist_101 0.59% 23624384 421864
com.etcbase.sfc.model.lookup.ValidityStatus_$$_javassist_105 0.59% 23624384 421864
byte[] 0.32% 12792760 34145
org.objectweb.asm.Item 0.16% 6351912 113427
version
<hibernate.search.version>3.4.0.Final</hibernate.search.version>
<lucene.version>3.3.0</lucene.version>
The table size which we want to index :5.6 GB
The fields for indexing are : (firstName,lastName,cityName,districtName)
Code:
package com.etcbase.cas.model.phonebook;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import com.etcbase.cas.model.lookup.PhoneBookType;
import com.etcbase.cas.util.LookupBridge;
import com.etcbase.sfc.model.common.SfcEntity;
import com.etcbase.sfc.model.lookup.ContactType;
import com.etcbase.sfc.model.lookup.ValidityStatus;
@Entity
@Indexed(index = "phoneBook")
@Analyzer(impl = StandardAnalyzer.class)
@XmlRootElement()
public class PhoneBook extends SfcEntity {
private static final long serialVersionUID = 2673638618514022474L;
private PhoneBookType phoneBookType;
private ContactType contactType;
private String phoneNumberText;
private String firstName;
private String lastName;
private String cityName;
private String originalCityName;
private String districtName;
private String originalDistrictName;
private String addressText;
private ValidityStatus validityStatus;
private PhoneBookQueue createdByPhoneBookQueue;
private PhoneBookQueue lastModifiedByPhoneBookQueue;
private PhoneBookQuery createByPhoneBookQuery;
private PhoneBookQuery lastModifiedByPhoneBookQuery;
private Date lastModifiedDateTime;
@ManyToOne(fetch = FetchType.LAZY)
@XmlTransient
public PhoneBookType getPhoneBookType() {
return phoneBookType;
}
@ManyToOne(fetch = FetchType.LAZY)
@XmlTransient
public ContactType getContactType() {
return contactType;
}
@Field(name = "phoneNumberText")
@Column(length = 20)
public String getPhoneNumberText() {
return phoneNumberText;
}
@Column(length = 80)
@Field(name = "firstName")
public String getFirstName() {
return firstName;
}
@Field(name = "lastName")
public String getLastName() {
return lastName;
}
@Column(length = 20)
@Field(name = "cityName")
public String getCityName() {
return cityName;
}
@Column(length = 40)
@Field(name = "districtName")a
public String getDistrictName() {
return districtName;
}
@XmlTransient
public String getAddressText() {
return addressText;
}
@ManyToOne(fetch = FetchType.LAZY)
@FieldBridge(impl = LookupBridge.class)
@Field(name = "validityStatus")
@XmlTransient
public ValidityStatus getValidityStatus() {
return validityStatus;
}
@ManyToOne(fetch = FetchType.LAZY)
@XmlTransient
public PhoneBookQueue getCreatedByPhoneBookQueue() {
return createdByPhoneBookQueue;
}
@ManyToOne(fetch = FetchType.LAZY)
@XmlTransient
public PhoneBookQueue getLastModifiedByPhoneBookQueue() {
return lastModifiedByPhoneBookQueue;
}
@Transient
public String getPhoneBookTypeEnumValue() {
return this.getPhoneBookType() == null ? null : this.getPhoneBookType().getEnumValue();
}
@Transient
public String getContactTypeEnumValue() {
return this.getContactType() == null ? null : this.getContactType().getEnumValue();
}
@ManyToOne(fetch = FetchType.LAZY)
@XmlTransient
public PhoneBookQuery getCreateByPhoneBookQuery() {
return createByPhoneBookQuery;
}
@ManyToOne(fetch = FetchType.LAZY)
@XmlTransient
public PhoneBookQuery getLastModifiedByPhoneBookQuery() {
return lastModifiedByPhoneBookQuery;
}
@XmlTransient
public String getOriginalCityName() {
return originalCityName;
}
@XmlTransient
public String getOriginalDistrictName() {
return originalDistrictName;
}
@Temporal(TemporalType.TIMESTAMP)
public Date getLastModifiedDateTime() {
return lastModifiedDateTime;
}
@Override
@Transient
@XmlTransient
public String getUid() {
return uid;
}
@Override
@Transient
@XmlTransient
public Long getId() {
return super.getId();
}
public void setPhoneBookType(PhoneBookType phoneBookType) {
this.phoneBookType = phoneBookType;
}
public void setContactType(ContactType contactType) {
this.contactType = contactType;
}
public void setPhoneNumberText(String phoneNumberText) {
this.phoneNumberText = phoneNumberText;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public void setDistrictName(String districtName) {
this.districtName = districtName;
}
public void setAddressText(String addressText) {
this.addressText = addressText;
}
public void setValidityStatus(ValidityStatus validityStatus) {
this.validityStatus = validityStatus;
}
public void setCreatedByPhoneBookQueue(PhoneBookQueue createdByPhoneBookQueue) {
this.createdByPhoneBookQueue = createdByPhoneBookQueue;
}
public void setLastModifiedByPhoneBookQueue(PhoneBookQueue lastModifiedByPhoneBookQueue) {
this.lastModifiedByPhoneBookQueue = lastModifiedByPhoneBookQueue;
}
public void setOriginalCityName(String originalCityName) {
this.originalCityName = originalCityName;
}
public void setOriginalDistrictName(String originalDistrictName) {
this.originalDistrictName = originalDistrictName;
}
public void setCreateByPhoneBookQuery(PhoneBookQuery createByPhoneBookQuery) {
this.createByPhoneBookQuery = createByPhoneBookQuery;
}
public void setLastModifiedByPhoneBookQuery(PhoneBookQuery lastModifiedByPhoneBookQuery) {
this.lastModifiedByPhoneBookQuery = lastModifiedByPhoneBookQuery;
}
public void setLastModifiedDateTime(Date lastModifiedDateTime) {
this.lastModifiedDateTime = lastModifiedDateTime;
}
}