Add to indexes
This commit is contained in:
parent
dd9031de32
commit
24ad8870cf
|
@ -36,13 +36,15 @@ import java.util.Date;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
/** Don't change this without careful consideration. You will break existing hashes! */
|
|
||||||
private static final HashFunction HASH_FUNCTION = Hashing.murmur3_128(0);
|
|
||||||
/** Don't make this public 'cause nobody better be able to modify it! */
|
|
||||||
private static final byte[] DELIMITER_BYTES = "|".getBytes(Charsets.UTF_8);
|
|
||||||
|
|
||||||
static final int MAX_SP_NAME = 100;
|
static final int MAX_SP_NAME = 100;
|
||||||
|
/**
|
||||||
|
* Don't change this without careful consideration. You will break existing hashes!
|
||||||
|
*/
|
||||||
|
private static final HashFunction HASH_FUNCTION = Hashing.murmur3_128(0);
|
||||||
|
/**
|
||||||
|
* Don't make this public 'cause nobody better be able to modify it!
|
||||||
|
*/
|
||||||
|
private static final byte[] DELIMITER_BYTES = "|".getBytes(Charsets.UTF_8);
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
// TODO: make this nullable=false and a primitive (written may 2017)
|
// TODO: make this nullable=false and a primitive (written may 2017)
|
||||||
|
@ -71,6 +73,13 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date myUpdated;
|
private Date myUpdated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclasses may override
|
||||||
|
*/
|
||||||
|
protected void clearHashes() {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract Long getId();
|
protected abstract Long getId();
|
||||||
|
|
||||||
public String getParamName() {
|
public String getParamName() {
|
||||||
|
@ -82,13 +91,6 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
myParamName = theName;
|
myParamName = theName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Subclasses may override
|
|
||||||
*/
|
|
||||||
protected void clearHashes() {
|
|
||||||
// nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceTable getResource() {
|
public ResourceTable getResource() {
|
||||||
return myResource;
|
return myResource;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +129,10 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
|
|
||||||
public abstract IQueryParameterType toQueryParameterType();
|
public abstract IQueryParameterType toQueryParameterType();
|
||||||
|
|
||||||
|
public static long calculateHashIdentity(String theResourceType, String theParamName) {
|
||||||
|
return hash(theResourceType, theParamName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a fast and consistent hashing algorithm to a set of strings
|
* Applies a fast and consistent hashing algorithm to a set of strings
|
||||||
*/
|
*/
|
||||||
|
@ -148,5 +154,4 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
return hashCode.asLong();
|
return hashCode.asLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,20 +41,22 @@ public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchP
|
||||||
public static final int MAX_LENGTH = 100;
|
public static final int MAX_LENGTH = 100;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Column(name = "SP_LATITUDE")
|
||||||
|
@Field
|
||||||
|
public double myLatitude;
|
||||||
|
@Column(name = "SP_LONGITUDE")
|
||||||
|
@Field
|
||||||
|
public double myLongitude;
|
||||||
@Id
|
@Id
|
||||||
@SequenceGenerator(name = "SEQ_SPIDX_COORDS", sequenceName = "SEQ_SPIDX_COORDS")
|
@SequenceGenerator(name = "SEQ_SPIDX_COORDS", sequenceName = "SEQ_SPIDX_COORDS")
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SPIDX_COORDS")
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SPIDX_COORDS")
|
||||||
@Column(name = "SP_ID")
|
@Column(name = "SP_ID")
|
||||||
private Long myId;
|
private Long myId;
|
||||||
|
/**
|
||||||
@Column(name = "SP_LATITUDE")
|
* @since 3.5.0 - At some point this should be made not-null
|
||||||
@Field
|
*/
|
||||||
public double myLatitude;
|
@Column(name = "HASH_IDENTITY", nullable = true)
|
||||||
|
private Long myHashIdentity;
|
||||||
@Column(name = "SP_LONGITUDE")
|
|
||||||
@Field
|
|
||||||
public double myLongitude;
|
|
||||||
|
|
||||||
public ResourceIndexedSearchParamCoords() {
|
public ResourceIndexedSearchParamCoords() {
|
||||||
}
|
}
|
||||||
|
@ -65,6 +67,20 @@ public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchP
|
||||||
setLongitude(theLongitude);
|
setLongitude(theLongitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void calculateHashes() {
|
||||||
|
if (myHashIdentity == null) {
|
||||||
|
String resourceType = getResourceType();
|
||||||
|
String paramName = getParamName();
|
||||||
|
setHashIdentity(calculateHashIdentity(resourceType, paramName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void clearHashes() {
|
||||||
|
myHashIdentity = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object theObj) {
|
public boolean equals(Object theObj) {
|
||||||
if (this == theObj) {
|
if (this == theObj) {
|
||||||
|
@ -90,19 +106,22 @@ public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchP
|
||||||
return myId;
|
return myId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IQueryParameterType toQueryParameterType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLatitude() {
|
public double getLatitude() {
|
||||||
return myLatitude;
|
return myLatitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLatitude(double theLatitude) {
|
||||||
|
myLatitude = theLatitude;
|
||||||
|
}
|
||||||
|
|
||||||
public double getLongitude() {
|
public double getLongitude() {
|
||||||
return myLongitude;
|
return myLongitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLongitude(double theLongitude) {
|
||||||
|
myLongitude = theLongitude;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
HashCodeBuilder b = new HashCodeBuilder();
|
HashCodeBuilder b = new HashCodeBuilder();
|
||||||
|
@ -113,12 +132,13 @@ public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchP
|
||||||
return b.toHashCode();
|
return b.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLatitude(double theLatitude) {
|
public void setHashIdentity(Long theHashIdentity) {
|
||||||
myLatitude = theLatitude;
|
myHashIdentity = theHashIdentity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLongitude(double theLongitude) {
|
@Override
|
||||||
myLongitude = theLongitude;
|
public IQueryParameterType toQueryParameterType() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,10 +44,6 @@ import java.util.Date;
|
||||||
public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchParam {
|
public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchParam {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Transient
|
|
||||||
private transient String myOriginalValue;
|
|
||||||
|
|
||||||
@Column(name = "SP_VALUE_HIGH", nullable = true)
|
@Column(name = "SP_VALUE_HIGH", nullable = true)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@Field
|
@Field
|
||||||
|
@ -56,11 +52,18 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@Field
|
@Field
|
||||||
public Date myValueLow;
|
public Date myValueLow;
|
||||||
|
@Transient
|
||||||
|
private transient String myOriginalValue;
|
||||||
@Id
|
@Id
|
||||||
@SequenceGenerator(name = "SEQ_SPIDX_DATE", sequenceName = "SEQ_SPIDX_DATE")
|
@SequenceGenerator(name = "SEQ_SPIDX_DATE", sequenceName = "SEQ_SPIDX_DATE")
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SPIDX_DATE")
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SPIDX_DATE")
|
||||||
@Column(name = "SP_ID")
|
@Column(name = "SP_ID")
|
||||||
private Long myId;
|
private Long myId;
|
||||||
|
/**
|
||||||
|
* @since 3.5.0 - At some point this should be made not-null
|
||||||
|
*/
|
||||||
|
@Column(name = "HASH_IDENTITY", nullable = true)
|
||||||
|
private Long myHashIdentity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -79,6 +82,20 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
myOriginalValue = theOriginalValue;
|
myOriginalValue = theOriginalValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void calculateHashes() {
|
||||||
|
if (myHashIdentity == null) {
|
||||||
|
String resourceType = getResourceType();
|
||||||
|
String paramName = getParamName();
|
||||||
|
setHashIdentity(calculateHashIdentity(resourceType, paramName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void clearHashes() {
|
||||||
|
myHashIdentity = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object theObj) {
|
public boolean equals(Object theObj) {
|
||||||
if (this == theObj) {
|
if (this == theObj) {
|
||||||
|
@ -100,6 +117,11 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
return b.isEquals();
|
return b.isEquals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Long getId() {
|
||||||
|
return myId;
|
||||||
|
}
|
||||||
|
|
||||||
protected Long getTimeFromDate(Date date) {
|
protected Long getTimeFromDate(Date date) {
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
return date.getTime();
|
return date.getTime();
|
||||||
|
@ -107,11 +129,6 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Long getId() {
|
|
||||||
return myId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getValueHigh() {
|
public Date getValueHigh() {
|
||||||
return myValueHigh;
|
return myValueHigh;
|
||||||
}
|
}
|
||||||
|
@ -138,6 +155,10 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
return b.toHashCode();
|
return b.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHashIdentity(Long theHashIdentity) {
|
||||||
|
myHashIdentity = theHashIdentity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType toQueryParameterType() {
|
public IQueryParameterType toQueryParameterType() {
|
||||||
DateTimeType value = new DateTimeType(myOriginalValue);
|
DateTimeType value = new DateTimeType(myOriginalValue);
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.hibernate.search.annotations.NumericField;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
//@formatter:off
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "HFJ_SPIDX_NUMBER", indexes = {
|
@Table(name = "HFJ_SPIDX_NUMBER", indexes = {
|
||||||
|
@ -42,7 +41,6 @@ import java.math.BigDecimal;
|
||||||
@Index(name = "IDX_SP_NUMBER_UPDATED", columnList = "SP_UPDATED"),
|
@Index(name = "IDX_SP_NUMBER_UPDATED", columnList = "SP_UPDATED"),
|
||||||
@Index(name = "IDX_SP_NUMBER_RESID", columnList = "RES_ID")
|
@Index(name = "IDX_SP_NUMBER_RESID", columnList = "RES_ID")
|
||||||
})
|
})
|
||||||
//@formatter:on
|
|
||||||
public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchParam {
|
public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchParam {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -56,6 +54,11 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SPIDX_NUMBER")
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SPIDX_NUMBER")
|
||||||
@Column(name = "SP_ID")
|
@Column(name = "SP_ID")
|
||||||
private Long myId;
|
private Long myId;
|
||||||
|
/**
|
||||||
|
* @since 3.5.0 - At some point this should be made not-null
|
||||||
|
*/
|
||||||
|
@Column(name = "HASH_IDENTITY", nullable = true)
|
||||||
|
private Long myHashIdentity;
|
||||||
|
|
||||||
public ResourceIndexedSearchParamNumber() {
|
public ResourceIndexedSearchParamNumber() {
|
||||||
}
|
}
|
||||||
|
@ -65,6 +68,20 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
|
||||||
setValue(theValue);
|
setValue(theValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void calculateHashes() {
|
||||||
|
if (myHashIdentity == null) {
|
||||||
|
String resourceType = getResourceType();
|
||||||
|
String paramName = getParamName();
|
||||||
|
setHashIdentity(calculateHashIdentity(resourceType, paramName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void clearHashes() {
|
||||||
|
myHashIdentity = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object theObj) {
|
public boolean equals(Object theObj) {
|
||||||
if (this == theObj) {
|
if (this == theObj) {
|
||||||
|
@ -108,6 +125,10 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
|
||||||
return b.toHashCode();
|
return b.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHashIdentity(Long theHashIdentity) {
|
||||||
|
myHashIdentity = theHashIdentity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType toQueryParameterType() {
|
public IQueryParameterType toQueryParameterType() {
|
||||||
return new NumberParam(myValue.toPlainString());
|
return new NumberParam(myValue.toPlainString());
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class ResourceIndexedSearchParamQuantity extends BaseResourceIndexedSearc
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ResourceIndexedSearchParamQuantity(String theParamName, BigDecimal theValue, String theSystem, String theUnits) {
|
public ResourceIndexedSearchParamQuantity(String theParamName, BigDecimal theValue, String theSystem, String theUnits) {
|
||||||
setParamName(theParamName);
|
setParamName(theParamName);
|
||||||
setSystem(theSystem);
|
setSystem(theSystem);
|
||||||
|
|
|
@ -192,11 +192,6 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
|
||||||
return myHashExact;
|
return myHashExact;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceIndexedSearchParam setDaoConfig(DaoConfig theDaoConfig) {
|
|
||||||
myDaoConfig = theDaoConfig;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHashExact(Long theHashExact) {
|
public void setHashExact(Long theHashExact) {
|
||||||
myHashExact = theHashExact;
|
myHashExact = theHashExact;
|
||||||
}
|
}
|
||||||
|
@ -247,6 +242,11 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
|
||||||
return b.toHashCode();
|
return b.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseResourceIndexedSearchParam setDaoConfig(DaoConfig theDaoConfig) {
|
||||||
|
myDaoConfig = theDaoConfig;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType toQueryParameterType() {
|
public IQueryParameterType toQueryParameterType() {
|
||||||
return new StringParam(getValueExact());
|
return new StringParam(getValueExact());
|
||||||
|
|
|
@ -238,10 +238,6 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
|
||||||
return hash(theResourceType, theParamName, trim(theSystem));
|
return hash(theResourceType, theParamName, trim(theSystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long calculateHashIdentity(String theResourceType, String theParamName) {
|
|
||||||
return hash(theResourceType, theParamName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long calculateHashSystemAndValue(String theResourceType, String theParamName, String theSystem, String theValue) {
|
public static long calculateHashSystemAndValue(String theResourceType, String theParamName, String theSystem, String theValue) {
|
||||||
return hash(theResourceType, theParamName, defaultString(trim(theSystem)), trim(theValue));
|
return hash(theResourceType, theParamName, defaultString(trim(theSystem)), trim(theValue));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue