Skip to content

Commit

Permalink
hibernate#126 fix boundary setting error
Browse files Browse the repository at this point in the history
  • Loading branch information
mincong-h committed Aug 7, 2016
1 parent 750b7f6 commit 967db61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
Expand Up @@ -200,7 +200,10 @@ private ScrollableResults buildScroll(StatelessSession ss,
criteria.add( Restrictions.ge( idName, checkpointID ) );
}

if ( unit.isFirstPartition() ) {
if ( unit.isUniquePartition() ) {
// no bounds if the partition unit is unique
}
else if ( unit.isFirstPartition() ) {
criteria.add( Restrictions.lt( idName, unit.getUpperBound() ) );
}
else if ( unit.isLastPartition() ) {
Expand Down
Expand Up @@ -8,7 +8,10 @@

/**
* Information about a target partition which can not be stored in the partition
* properties as String values.
* properties as String values. In particular, the boundary properties help us
* to identify the lower boundary and upper boundary of a given partition, with
* which the two ends of the scrollable results can be defined and be applied
* to {@link org.hibernate.search.jsr352.internal.steps.lucene.ItemReader#open}.
*
* @author Mincong Huang
*/
Expand All @@ -34,7 +37,8 @@ public PartitionUnit(Class<?> entityClazz,
Object upperBound) {
this.entityClazz = entityClazz;
this.rowsToIndex = rowsToIndex;
setBoundary( lowerBound, upperBound );
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}

public Class<?> getEntityClazz() {
Expand Down Expand Up @@ -73,6 +77,14 @@ public boolean isLastPartition() {
return isLast;
}

public boolean isUniquePartition() {
boolean isUnique = false;
if ( lowerBound == null && upperBound == null ) {
isUnique = true;
}
return isUnique;
}

public void setEntityClazz(Class<?> entityClazz) {
this.entityClazz = entityClazz;
}
Expand All @@ -81,24 +93,6 @@ public void setRowsToIndex(long rowsToIndex) {
this.rowsToIndex = rowsToIndex;
}

/**
* Boundary helps us to identify the lower boundary and upper boundary of a
* given partition, with which the two ends of the scrollable results can be
* defined and later applied to
* {@link org.hibernate.search.jsr352.internal.steps.lucene.ItemReader#open}
*
* @param lowerBound
* @param upperBound
*/
public void setBoundary(Object lowerBound, Object upperBound) {
if ( lowerBound == null && upperBound == null ) {
throw new NullPointerException( "lowerBound and upperBound cannot "
+ "be null at the same time." );
}
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}

@Override
public String toString() {
return "PartitionUnit [entityClazz=" + entityClazz + ", lowerBound="
Expand Down
Expand Up @@ -105,7 +105,6 @@ public void testMassIndexer() throws InterruptedException {
.jobOperator( jobOperator )
.isJavaSE( true )
.entityManagerFactory( emf )
.rowsPerPartition( 2 )
.start();
JobExecution jobExecution = jobOperator.getJobExecution( executionId );
jobExecution = keepTestAlive( jobExecution );
Expand Down

0 comments on commit 967db61

Please sign in to comment.