forked from gchq/sleeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreinitialiseTable.sh
More file actions
executable file
·58 lines (49 loc) · 2.39 KB
/
reinitialiseTable.sh
File metadata and controls
executable file
·58 lines (49 loc) · 2.39 KB
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
#!/usr/bin/env bash
# Copyright 2022-2025 Crown Copyright
#
# Licensed 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.
set -e
unset CDPATH
#####################
# Initial variables #
#####################
if [[ -z $1 || -z $2 ]]; then
echo "Usage: $0 <instance-id> <table name> <optional-delete-partitions-true-or-false> <optional-split-points-file-location> <optional-split-points-file-base64-encoded-true-or-false>"
exit 1
fi
INSTANCE_ID=$1
TABLE_NAME=$2
SCRIPTS_DIR=$(cd "$(dirname "$0")" && cd "../" && pwd)
TEMPLATE_DIR=${SCRIPTS_DIR}/templates
JAR_DIR=${SCRIPTS_DIR}/jars
VERSION=$(cat "${TEMPLATE_DIR}/version.txt")
ARROW_FLAGS="--add-opens java.base/java.nio=ALL-UNNAMED"
if [[ -z $3 ]]; then
java -cp "${JAR_DIR}/clients-${VERSION}-utility.jar" $ARROW_FLAGS sleeper.clients.table.ReinitialiseTable "${INSTANCE_ID}" "${TABLE_NAME}"
else
DELETE_PARTITIONS=$3
echo "Optional parameter for <delete-partitions> recognised and set to" "${DELETE_PARTITIONS}"
if [[ -n $4 ]]; then
SPLIT_POINT_FILE_LOCATION=$4
echo "Optional parameter for <split-point-file-location> recognised and set to" "${SPLIT_POINT_FILE_LOCATION}"
if [[ -n $5 ]]; then
SPLIT_POINTS_FILE_ENCODED=$5
echo "Optional parameter for <split-points-file-base64-encoded> recognised and set to" "${SPLIT_POINTS_FILE_ENCODED}"
java -cp "${JAR_DIR}/clients-${VERSION}-utility.jar" $ARROW_FLAGS sleeper.clients.table.partition.ReinitialiseTableFromSplitPoints "${INSTANCE_ID}" "${TABLE_NAME}" "${SPLIT_POINT_FILE_LOCATION}" "${SPLIT_POINTS_FILE_ENCODED}"
else
java -cp "${JAR_DIR}/clients-${VERSION}-utility.jar" $ARROW_FLAGS sleeper.clients.table.partition.ReinitialiseTableFromSplitPoints "${INSTANCE_ID}" "${TABLE_NAME}" "${SPLIT_POINT_FILE_LOCATION}"
fi
else
java -cp "${JAR_DIR}/clients-${VERSION}-utility.jar" $ARROW_FLAGS sleeper.clients.table.ReinitialiseTable "${INSTANCE_ID}" "${TABLE_NAME}" "${DELETE_PARTITIONS}"
fi
fi