Skip to content

Commit 30fd9de

Browse files
authored
Brute Force Merging for HBase and CLI partition strategy converter (#1617)
1 parent 46a8f69 commit 30fd9de

3 files changed

Lines changed: 36 additions & 50 deletions

File tree

core/store/src/main/java/org/locationtech/geowave/core/store/index/IndexPluginOptions.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public int getNumPartitions() {
8888
return basicIndexOptions.getNumPartitions();
8989
}
9090

91-
public void setName(String indexName) {
91+
public void setName(final String indexName) {
9292
this.indexName = indexName;
9393
}
9494

@@ -160,5 +160,17 @@ public static String getIndexNamespace(final String name) {
160160

161161
public static enum PartitionStrategy {
162162
NONE, HASH, ROUND_ROBIN;
163+
164+
// converter that will be used later
165+
public static PartitionStrategy fromString(final String code) {
166+
167+
for (final PartitionStrategy output : PartitionStrategy.values()) {
168+
if (output.toString().equalsIgnoreCase(code)) {
169+
return output;
170+
}
171+
}
172+
173+
return null;
174+
}
163175
}
164176
}

core/store/src/main/java/org/locationtech/geowave/core/store/operations/remote/options/BasicIndexOptions.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
*/
99
package org.locationtech.geowave.core.store.operations.remote.options;
1010

11+
import java.util.Arrays;
1112
import org.locationtech.geowave.core.store.index.IndexPluginOptions.PartitionStrategy;
13+
import com.beust.jcommander.IStringConverter;
1214
import com.beust.jcommander.Parameter;
15+
import com.beust.jcommander.ParameterException;
1316

1417
public class BasicIndexOptions {
1518

@@ -20,7 +23,8 @@ public class BasicIndexOptions {
2023

2124
@Parameter(
2225
names = {"-ps", "--partitionStrategy"},
23-
description = "The partition strategy to use. Default will be none.")
26+
description = "The partition strategy to use. Default will be none.",
27+
converter = PartitionStrategyConverter.class)
2428
protected PartitionStrategy partitionStrategy = PartitionStrategy.NONE;
2529

2630
public int getNumPartitions() {
@@ -38,4 +42,22 @@ public PartitionStrategy getPartitionStrategy() {
3842
public void setPartitionStrategy(final PartitionStrategy partitionStrategy) {
3943
this.partitionStrategy = partitionStrategy;
4044
}
45+
46+
public static class PartitionStrategyConverter implements IStringConverter<PartitionStrategy> {
47+
48+
@Override
49+
public PartitionStrategy convert(final String value) {
50+
final PartitionStrategy convertedValue = PartitionStrategy.fromString(value);
51+
52+
if (convertedValue == null) {
53+
throw new ParameterException(
54+
"Value "
55+
+ value
56+
+ " can not be converted to PartitionStrategy. "
57+
+ "Available values are: "
58+
+ Arrays.toString(PartitionStrategy.values()));
59+
}
60+
return convertedValue;
61+
}
62+
}
4163
}

extensions/datastores/hbase/src/main/java/org/locationtech/geowave/datastore/hbase/operations/HBaseOperations.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -781,54 +781,6 @@ public boolean indexExists(final String indexName) throws IOException {
781781
}
782782
}
783783

784-
@Override
785-
public boolean mergeData(
786-
final Index index,
787-
final PersistentAdapterStore adapterStore,
788-
final InternalAdapterStore internalAdapterStore,
789-
final AdapterIndexMappingStore adapterIndexMappingStore,
790-
final Integer maxRangeDecomposition) {
791-
if (options.isServerSideLibraryEnabled()) {
792-
final TableName tableName = getTableName(index.getName());
793-
try (Admin admin = conn.getAdmin()) {
794-
admin.compact(tableName);
795-
// wait for table compaction to finish
796-
while (!admin.getCompactionState(tableName).equals(CompactionState.NONE)) {
797-
Thread.sleep(100);
798-
}
799-
} catch (final Exception e) {
800-
LOGGER.error("Cannot compact table '" + index.getName() + "'", e);
801-
return false;
802-
}
803-
} else {
804-
return DataStoreUtils.mergeData(
805-
this,
806-
maxRangeDecomposition,
807-
index,
808-
adapterStore,
809-
internalAdapterStore,
810-
adapterIndexMappingStore);
811-
}
812-
return true;
813-
}
814-
815-
@Override
816-
public boolean mergeStats(
817-
final DataStatisticsStore store,
818-
final InternalAdapterStore internalAdapterStore) {
819-
if (options.isServerSideLibraryEnabled()) {
820-
try (Admin admin = conn.getAdmin()) {
821-
admin.compact(getTableName(AbstractGeoWavePersistence.METADATA_TABLE));
822-
} catch (final IOException e) {
823-
LOGGER.error("Cannot compact table '" + AbstractGeoWavePersistence.METADATA_TABLE + "'", e);
824-
return false;
825-
}
826-
} else {
827-
828-
}
829-
return true;
830-
}
831-
832784
@Override
833785
public boolean ensureAuthorizations(final String clientUser, final String... authorizations) {
834786
return true;

0 commit comments

Comments
 (0)