Skip to content

Commit 12efca6

Browse files
committed
exposed max duplicates as a commandline option
1 parent cf53d9f commit 12efca6

3 files changed

Lines changed: 54 additions & 7 deletions

File tree

core/geotime/src/main/java/mil/nga/giat/geowave/core/geotime/ingest/SpatialTemporalDimensionalityTypeProvider.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ private static PrimaryIndex internalCreatePrimaryIndex(
114114
options.bias.getSpatialPrecision(),
115115
options.bias.getTemporalPrecision()
116116
},
117-
SFCType.HILBERT),
117+
SFCType.HILBERT,
118+
options.maxDuplicates),
118119
new BasicIndexModel(
119120
fields),
120121
new ByteArrayId(
@@ -146,6 +147,10 @@ private static class SpatialTemporalOptions implements
146147
"--pointTimestampOnly"
147148
}, required = false, description = "The index will only be good at handling points and timestamps and will not be optimized for handling lines/polys or time ranges. The default behavior is to handle any geometry and time ranges well.")
148149
protected boolean pointOnly = false;
150+
@Parameter(names = {
151+
"--maxDuplicates"
152+
}, required = false, description = "The max number of duplicates. The default is 8 (2^dimensions with range values), but if lines and polys are expected without time ranges 4 would be more appropriate, and if time ranges are expected with points, 2 would be more appropriate.")
153+
protected long maxDuplicates = -1;
149154
}
150155

151156
public static enum Bias {
@@ -265,6 +270,13 @@ public SpatialTemporalIndexBuilder setPeriodicity(
265270
options);
266271
}
267272

273+
public SpatialTemporalIndexBuilder setMaxDupicates(
274+
final long maxDuplicates ) {
275+
options.maxDuplicates = maxDuplicates;
276+
return new SpatialTemporalIndexBuilder(
277+
options);
278+
}
279+
268280
public PrimaryIndex createIndex() {
269281
return internalCreatePrimaryIndex(options);
270282
}

core/index/src/main/java/mil/nga/giat/geowave/core/index/sfc/tiered/TieredSFCIndexFactory.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ static public TieredSFCIndexStrategy createSingleTierStrategy(
9393
(byte) maxBitsOfPrecision));
9494
}
9595

96+
static public TieredSFCIndexStrategy createFullIncrementalTieredStrategy(
97+
final NumericDimensionDefinition[] baseDefinitions,
98+
final int[] maxBitsPerDimension,
99+
final SFCType sfcType ) {
100+
return createFullIncrementalTieredStrategy(
101+
baseDefinitions,
102+
maxBitsPerDimension,
103+
sfcType,
104+
null);
105+
}
106+
96107
/**
97108
*
98109
* @param baseDefinitions
@@ -101,13 +112,16 @@ static public TieredSFCIndexStrategy createSingleTierStrategy(
101112
* the max cardinality for the Index Strategy
102113
* @param sfcType
103114
* the type of space filling curve (e.g. Hilbert)
115+
* @param maxEstimatedDuplicatedIds
116+
* the max number of duplicate SFC IDs
104117
* @return an Index Strategy object with a tier for every incremental
105118
* cardinality between the lowest max bits of precision and 0
106119
*/
107120
static public TieredSFCIndexStrategy createFullIncrementalTieredStrategy(
108121
final NumericDimensionDefinition[] baseDefinitions,
109122
final int[] maxBitsPerDimension,
110-
final SFCType sfcType ) {
123+
final SFCType sfcType,
124+
Long maxEstimatedDuplicatedIds ) {
111125
if (maxBitsPerDimension.length == 0) {
112126
final ImmutableBiMap<Integer, Byte> emptyMap = ImmutableBiMap.of();
113127
return new TieredSFCIndexStrategy(
@@ -144,7 +158,13 @@ static public TieredSFCIndexStrategy createFullIncrementalTieredStrategy(
144158
sfcType);
145159

146160
}
147-
161+
if (maxEstimatedDuplicatedIds != null && maxEstimatedDuplicatedIds > 0) {
162+
return new TieredSFCIndexStrategy(
163+
baseDefinitions,
164+
spaceFillingCurves,
165+
sfcIndexToTier.build(),
166+
maxEstimatedDuplicatedIds);
167+
}
148168
return new TieredSFCIndexStrategy(
149169
baseDefinitions,
150170
spaceFillingCurves,

core/index/src/main/java/mil/nga/giat/geowave/core/index/sfc/tiered/TieredSFCIndexStrategy.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class TieredSFCIndexStrategy implements
4444
HierarchicalNumericIndexStrategy
4545
{
4646
private final static Logger LOGGER = Logger.getLogger(TieredSFCIndexStrategy.class);
47-
private final static int MAX_ESTIMATED_DUPLICATE_IDS_PER_DIMENSION = 2;
47+
private final static int DEFAULT_MAX_ESTIMATED_DUPLICATE_IDS_PER_DIMENSION = 2;
4848
protected static final int DEFAULT_MAX_RANGES = -1;
4949
private SpaceFillingCurve[] orderedSfcs;
5050
private ImmutableBiMap<Integer, Byte> orderedSfcIndexToTierId;
@@ -66,12 +66,27 @@ public TieredSFCIndexStrategy(
6666
final NumericDimensionDefinition[] baseDefinitions,
6767
final SpaceFillingCurve[] orderedSfcs,
6868
final ImmutableBiMap<Integer, Byte> orderedSfcIndexToTierId ) {
69+
this(
70+
baseDefinitions,
71+
orderedSfcs,
72+
orderedSfcIndexToTierId,
73+
(long) Math.pow(
74+
DEFAULT_MAX_ESTIMATED_DUPLICATE_IDS_PER_DIMENSION,
75+
baseDefinitions.length));
76+
}
77+
78+
/**
79+
* Constructor used to create a Tiered Index Strategy.
80+
*/
81+
public TieredSFCIndexStrategy(
82+
final NumericDimensionDefinition[] baseDefinitions,
83+
final SpaceFillingCurve[] orderedSfcs,
84+
final ImmutableBiMap<Integer, Byte> orderedSfcIndexToTierId,
85+
long maxEstimatedDuplicateIds ) {
6986
this.orderedSfcs = orderedSfcs;
7087
this.baseDefinitions = baseDefinitions;
7188
this.orderedSfcIndexToTierId = orderedSfcIndexToTierId;
72-
maxEstimatedDuplicateIds = (long) Math.pow(
73-
MAX_ESTIMATED_DUPLICATE_IDS_PER_DIMENSION,
74-
baseDefinitions.length);
89+
this.maxEstimatedDuplicateIds = maxEstimatedDuplicateIds;
7590
maxEstimatedDuplicateIdsBigInteger = BigInteger.valueOf(maxEstimatedDuplicateIds);
7691
}
7792

0 commit comments

Comments
 (0)