Skip to content

Commit 147329d

Browse files
committed
HIVE-27473: Rewrite MetaStoreClients to be composable
1 parent be59bd0 commit 147329d

File tree

13 files changed

+12923
-8575
lines changed

13 files changed

+12923
-8575
lines changed

ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMetaStoreClientWithLocalCache.java

Lines changed: 16 additions & 755 deletions
Large diffs are not rendered by default.

ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java

Lines changed: 20 additions & 2510 deletions
Large diffs are not rendered by default.

ql/src/java/org/apache/hadoop/hive/ql/metadata/TempTable.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,42 @@ public final class TempTable {
4444

4545
private static final String EXTERNAL_PARAM = "EXTERNAL";
4646

47-
TempTable(org.apache.hadoop.hive.metastore.api.Table t) {
47+
public TempTable(org.apache.hadoop.hive.metastore.api.Table t) {
4848
assert t != null;
4949
this.tTable = t;
5050
pTree = t.getPartitionKeysSize() > 0 ? new PartitionTree(tTable) : null;
5151
}
5252

53-
Partition addPartition(Partition p) throws AlreadyExistsException, MetaException {
53+
public Partition addPartition(Partition p) throws AlreadyExistsException, MetaException {
5454
String partName = makePartName(tTable.getPartitionKeys(), p.getValues());
5555
Partition partition = pTree.addPartition(p, partName, false);
5656
return partition == null ? pTree.getPartition(partName) : partition;
5757
}
5858

59-
boolean isExternal() {
59+
public boolean isExternal() {
6060
return tTable.getParameters() != null && "true".equals(tTable.getParameters().get(EXTERNAL_PARAM));
6161
}
6262

63-
Partition getPartition(String partName) throws MetaException {
63+
public Partition getPartition(String partName) throws MetaException {
6464
if (partName == null || partName.isEmpty()) {
6565
throw new MetaException("Partition name cannot be null or empty");
6666
}
6767
return pTree.getPartition(partName);
6868
}
6969

70-
Partition getPartition(List<String> partVals) throws MetaException {
70+
public Partition getPartition(List<String> partVals) throws MetaException {
7171
if (partVals == null) {
7272
throw new MetaException("Partition values cannot be null");
7373
}
7474
return pTree.getPartition(partVals);
7575
}
7676

77-
List<Partition> addPartitions(List<Partition> partitions, boolean ifNotExists)
77+
public List<Partition> addPartitions(List<Partition> partitions, boolean ifNotExists)
7878
throws MetaException, AlreadyExistsException {
7979
return pTree.addPartitions(partitions, ifNotExists);
8080
}
8181

82-
List<Partition> getPartitionsByNames(List<String> partNames) throws MetaException {
82+
public List<Partition> getPartitionsByNames(List<String> partNames) throws MetaException {
8383
if (partNames == null) {
8484
throw new MetaException("Partition names cannot be null");
8585
}
@@ -93,11 +93,11 @@ List<Partition> getPartitionsByNames(List<String> partNames) throws MetaExceptio
9393
return partitions;
9494
}
9595

96-
List<Partition> getPartitionsByPartitionVals(List<String> partialPartVals) throws MetaException {
96+
public List<Partition> getPartitionsByPartitionVals(List<String> partialPartVals) throws MetaException {
9797
return pTree.getPartitionsByPartitionVals(partialPartVals);
9898
}
9999

100-
Partition getPartitionWithAuthInfo(List<String> partionVals, String userName, List<String> groupNames)
100+
public Partition getPartitionWithAuthInfo(List<String> partionVals, String userName, List<String> groupNames)
101101
throws MetaException {
102102
Partition partition = getPartition(partionVals);
103103
if (partition == null) {
@@ -106,11 +106,11 @@ Partition getPartitionWithAuthInfo(List<String> partionVals, String userName, Li
106106
return checkPrivilegesForPartition(partition, userName, groupNames) ? partition : null;
107107
}
108108

109-
List<Partition> listPartitions() {
109+
public List<Partition> listPartitions() {
110110
return pTree.listPartitions();
111111
}
112112

113-
List<Partition> listPartitionsWithAuthInfo(String userName, List<String> groupNames) {
113+
public List<Partition> listPartitionsWithAuthInfo(String userName, List<String> groupNames) {
114114
List<Partition> partitions = listPartitions();
115115
List<Partition> result = new ArrayList<>();
116116
partitions.forEach(p -> {
@@ -121,7 +121,7 @@ List<Partition> listPartitionsWithAuthInfo(String userName, List<String> groupNa
121121
return result;
122122
}
123123

124-
List<Partition> listPartitionsByPartitionValsWithAuthInfo(List<String> partialVals, String userName,
124+
public List<Partition> listPartitionsByPartitionValsWithAuthInfo(List<String> partialVals, String userName,
125125
List<String> groupNames) throws MetaException {
126126
List<Partition> partitions = pTree.getPartitionsByPartitionVals(partialVals);
127127
List<Partition> result = new ArrayList<>();
@@ -159,11 +159,11 @@ private boolean checkPrivilegesForPartition(Partition partition, String userName
159159
return true;
160160
}
161161

162-
Partition dropPartition(List<String> partVals) throws MetaException, NoSuchObjectException {
162+
public Partition dropPartition(List<String> partVals) throws MetaException, NoSuchObjectException {
163163
return pTree.dropPartition(partVals);
164164
}
165165

166-
Partition dropPartition(String partitionName) throws MetaException, NoSuchObjectException {
166+
public Partition dropPartition(String partitionName) throws MetaException, NoSuchObjectException {
167167
Map<String, String> specFromName = makeSpecFromName(partitionName);
168168
if (specFromName.isEmpty()) {
169169
throw new NoSuchObjectException("Invalid partition name " + partitionName);
@@ -180,29 +180,29 @@ Partition dropPartition(String partitionName) throws MetaException, NoSuchObject
180180
return pTree.dropPartition(pVals);
181181
}
182182

183-
void alterPartition(Partition partition) throws MetaException, InvalidOperationException, NoSuchObjectException {
183+
public void alterPartition(Partition partition) throws MetaException, InvalidOperationException, NoSuchObjectException {
184184
pTree.alterPartition(partition.getValues(), partition, false);
185185
}
186186

187-
void alterPartitions(List<Partition> newParts)
187+
public void alterPartitions(List<Partition> newParts)
188188
throws MetaException, InvalidOperationException, NoSuchObjectException {
189189
pTree.alterPartitions(newParts);
190190
}
191191

192-
void renamePartition(List<String> partitionVals, Partition newPart)
192+
public void renamePartition(List<String> partitionVals, Partition newPart)
193193
throws MetaException, InvalidOperationException, NoSuchObjectException {
194194
pTree.renamePartition(partitionVals, newPart);
195195
}
196196

197-
int getNumPartitionsByFilter(String filter) throws MetaException {
197+
public int getNumPartitionsByFilter(String filter) throws MetaException {
198198
return pTree.getPartitionsByFilter(filter).size();
199199
}
200200

201-
List<Partition> listPartitionsByFilter(String filter) throws MetaException {
201+
public List<Partition> listPartitionsByFilter(String filter) throws MetaException {
202202
return pTree.getPartitionsByFilter(filter);
203203
}
204204

205-
GetPartitionsResponse getPartitionsWithSpecs(GetPartitionsRequest getPartitionsRequest) throws MetaException {
205+
public GetPartitionsResponse getPartitionsWithSpecs(GetPartitionsRequest getPartitionsRequest) throws MetaException {
206206
return pTree.getPartitionsWithSpecs(getPartitionsRequest);
207207
}
208208

0 commit comments

Comments
 (0)