Skip to content

Commit bb6b381

Browse files
authored
Add FAQ for org.apache.hadoop.mapred.JobConf (#15)
1 parent 0b36e80 commit bb6b381

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ you can use `1.4.0` of `io.github.linghengqian:hive-server2-jdbc-driver-thin` or
102102
For the Docker Image of `apache/hive:4.0.1`,
103103
you can use `1.6.0` of `io.github.linghengqian:hive-server2-jdbc-driver-thin` or `io.github.linghengqian:hive-server2-jdbc-driver-uber`.
104104

105+
## FAQ
106+
107+
Refer to [FAQ](./doc/FAQ.md).
108+
105109
## Background
106110

107111
Refer to [Background](./doc/Background.md).

doc/FAQ.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# FAQ
2+
3+
## Where is the `org.apache.hadoop.mapred.JobConf` class?
4+
5+
For HiveServer2 JDBC Driver `org.apache.hive:hive-jdbc:4.0.1` or `org.apache.hive:hive-jdbc:4.0.1` with `classifier` as `standalone`,
6+
there is actually no additional dependency on `org.apache.hadoop:hadoop-mapreduce-client-core:3.3.6`.
7+
8+
In some cases, users may need to do this.
9+
10+
```java
11+
import org.apache.hadoop.hive.conf.HiveConf;
12+
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
13+
import org.apache.hadoop.hive.metastore.api.MetaException;
14+
public class ExampleTest {
15+
16+
void test() throws MetaException {
17+
HiveConf hiveConf = new HiveConf();
18+
hiveConf.set("hive.metastore.uris", "thrift://metastore:9083");
19+
HiveMetaStoreClient storeClient = new HiveMetaStoreClient(hiveConf);
20+
storeClient.close();
21+
}
22+
}
23+
```
24+
25+
Using `org.apache.hadoop.hive.conf.HiveConf` specifically requires a dependency on the `org.apache.hadoop.mapred.JobConf` class.
26+
This class belongs to `org.apache.hadoop:hadoop-mapreduce-client-core:3.3.6`.
27+
28+
When users need to use `org.apache.hadoop.hive.conf.HiveConf` directly in business code,
29+
they can additionally introduce the following dependencies.
30+
Since only the `org.apache.hadoop.mapred.JobConf` class is needed, excluding all sub-dependencies is no problem.
31+
32+
```xml
33+
<dependency>
34+
<groupId>org.apache.hadoop</groupId>
35+
<artifactId>hadoop-mapreduce-client-core</artifactId>
36+
<version>3.3.6</version>
37+
<exclusions>
38+
<exclusion>
39+
<groupId>*</groupId>
40+
<artifactId>*</artifactId>
41+
</exclusion>
42+
</exclusions>
43+
</dependency>
44+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2024 Qiheng He
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.github.linghengqian.hive.server2.jdbc.driver.thin;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
22+
import static org.junit.jupiter.api.Assertions.assertThrows;
23+
24+
public class ClassExistTest {
25+
26+
@Test
27+
void test() {
28+
assertDoesNotThrow(() -> {
29+
Class.forName("org.apache.hadoop.hive.conf.HiveConf");
30+
});
31+
assertThrows(ClassNotFoundException.class, () -> Class.forName("org.apache.hadoop.mapred.JobConf"));
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2024 Qiheng He
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.github.linghengqian.hive.server2.jdbc.driver.uber;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
22+
import static org.junit.jupiter.api.Assertions.assertThrows;
23+
24+
public class ClassExistTest {
25+
26+
@Test
27+
void test() {
28+
assertDoesNotThrow(() -> {
29+
Class.forName("org.apache.hadoop.hive.conf.HiveConf");
30+
});
31+
assertThrows(ClassNotFoundException.class, () -> Class.forName("org.apache.hadoop.mapred.JobConf"));
32+
}
33+
}

0 commit comments

Comments
 (0)