forked from hibernate/hibernate-search
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PartitionUnit.java
102 lines (85 loc) · 2.4 KB
/
PartitionUnit.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.jsr352.internal.util;
/**
* Information about a target partition which can not be stored in the partition
* 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
*/
public class PartitionUnit {
private Class<?> entityClazz;
private Object lowerBound;
private Object upperBound;
private long rowsToIndex;
public PartitionUnit() {
}
public PartitionUnit(Class<?> entityClazz, long rowsToIndex) {
this.entityClazz = entityClazz;
this.rowsToIndex = rowsToIndex;
}
public PartitionUnit(Class<?> entityClazz,
long rowsToIndex,
Object lowerBound,
Object upperBound) {
this.entityClazz = entityClazz;
this.rowsToIndex = rowsToIndex;
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}
public Class<?> getEntityClazz() {
return entityClazz;
}
public String getEntityName() {
return entityClazz.toString();
}
public long getRowsToIndex() {
return rowsToIndex;
}
public Object getLowerBound() {
return lowerBound;
}
public Object getUpperBound() {
return upperBound;
}
public boolean isFirstPartition() {
boolean isFirst = false;
if ( lowerBound == null && upperBound != null ) {
isFirst = true;
}
return isFirst;
}
public boolean isLastPartition() {
boolean isLast = false;
if ( lowerBound != null && upperBound == null ) {
isLast = true;
}
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;
}
public void setRowsToIndex(long rowsToIndex) {
this.rowsToIndex = rowsToIndex;
}
@Override
public String toString() {
return "PartitionUnit [entityClazz=" + entityClazz + ", lowerBound="
+ lowerBound + ", upperBound=" + upperBound + ", rowsToIndex="
+ rowsToIndex + "]";
}
}