jmark99 closed pull request #575: Add splits to table at time of table creation
#573
URL: https://github.com/apache/accumulo/pull/575
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/core/src/main/java/org/apache/accumulo/core/client/admin/InitialTableState.java
b/core/src/main/java/org/apache/accumulo/core/client/admin/InitialTableState.java
new file mode 100644
index 00..eb12bc9038
--- /dev/null
+++
b/core/src/main/java/org/apache/accumulo/core/client/admin/InitialTableState.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.client.admin;
+
+/**
+ * Creation mode for table creation.
+ *
+ * @since 2.0.0
+ */
+public enum InitialTableState {
+ /*
+ * Set if table is to be created in OFFLINE mode.
+ */
+ OFFLINE,
+ /*
+ * Used if table is to be created in ONLINE mode.
+ */
+ ONLINE
+}
diff --git
a/core/src/main/java/org/apache/accumulo/core/client/admin/NewTableConfiguration.java
b/core/src/main/java/org/apache/accumulo/core/client/admin/NewTableConfiguration.java
index 9c97f54b0d..01b2fdddc7 100644
---
a/core/src/main/java/org/apache/accumulo/core/client/admin/NewTableConfiguration.java
+++
b/core/src/main/java/org/apache/accumulo/core/client/admin/NewTableConfiguration.java
@@ -20,6 +20,7 @@
import static java.util.Objects.requireNonNull;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
@@ -27,7 +28,7 @@
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
-import java.util.stream.Collectors;
+import java.util.SortedSet;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.IteratorSetting;
@@ -44,6 +45,8 @@
import org.apache.accumulo.core.util.LocalityGroupUtil;
import org.apache.hadoop.io.Text;
+import com.google.common.collect.ImmutableSortedSet;
+
/**
* This object stores table creation parameters. Currently includes: {@link
TimeType}, whether to
* include default iterators, and user-specified initial properties
@@ -55,13 +58,17 @@
private static final TimeType DEFAULT_TIME_TYPE = TimeType.MILLIS;
private TimeType timeType = DEFAULT_TIME_TYPE;
+ private static final InitialTableState DEFAULT_CREATION_MODE =
InitialTableState.ONLINE;
+ private InitialTableState initialTableState = DEFAULT_CREATION_MODE;
+
private boolean limitVersion = true;
private Map properties = Collections.emptyMap();
private Map samplerProps = Collections.emptyMap();
private Map summarizerProps = Collections.emptyMap();
private Map localityProps = Collections.emptyMap();
- private Map iteratorProps = new HashMap<>();
+ private final Map iteratorProps = new HashMap<>();
+ private SortedSet splitProps = Collections.emptySortedSet();
private void checkDisjoint(Map props, Map
derivedProps,
String kind) {
@@ -103,6 +110,29 @@ public NewTableConfiguration withoutDefaultIterators() {
return this;
}
+ /**
+ * Create the new table in an offline state.
+ *
+ * @return this
+ *
+ * @since 2.0.0
+ */
+ public NewTableConfiguration createOffline() {
+this.initialTableState = InitialTableState.OFFLINE;
+return this;
+ }
+
+ /**
+ * Return value indicating whether table is to be created in offline or
online mode.
+ *
+ * @return 1 if true; 0 otherwise.
+ *
+ * @since 2.0.0
+ */
+ public InitialTableState getInitialTableState() {
+return initialTableState;
+ }
+
/**
* Sets additional properties to be applied to tables created with this
configuration. Additional
* calls to this method replace properties set by previous calls.
@@ -142,6 +172,17 @@ public NewTableConfiguration
setProperties(Map props) {
return Collections.unmodifiableMap(propertyMap);
}
+ /**
+ * Return Collection of split values.
+ *
+ * @return Collection containing splits associated with this