|
1 | 1 | package io.delta.sharing.java; |
2 | 2 |
|
3 | | -import io.delta.sharing.java.adaptor.DeltaSharingJSONProvider; |
| 3 | +import io.delta.sharing.java.adaptor.DeltaSharingJsonProvider; |
4 | 4 | import io.delta.sharing.spark.DeltaSharingProfileProvider; |
5 | 5 | import io.delta.sharing.spark.DeltaSharingRestClient; |
6 | | - |
7 | 6 | import java.io.IOException; |
8 | 7 | import java.nio.file.Files; |
9 | 8 | import java.nio.file.Path; |
|
12 | 11 | import java.util.HashMap; |
13 | 12 |
|
14 | 13 | /** |
15 | | - * Factory class for {@link DeltaSharing}. |
16 | | - * It provides different constructors that might be appropriate in different situations. |
| 14 | + * Factory class for {@link DeltaSharing}. It provides different constructors that might be |
| 15 | + * appropriate in different situations. |
17 | 16 | */ |
18 | 17 | public class DeltaSharingFactory { |
19 | 18 |
|
20 | | - /** |
21 | | - * Constructor |
22 | | - * @param profileProvider An instance of {@link DeltaSharingProfileProvider}. |
23 | | - * @param checkpointPath An path to a temporary checkpoint location. |
24 | | - * @return An instance of {@link DeltaSharing} client. |
25 | | - * @throws IOException Transitive due to the call to {@link Files#createTempDirectory(String, FileAttribute[])}. |
26 | | - */ |
27 | | - public static DeltaSharing create(DeltaSharingProfileProvider profileProvider, Path checkpointPath) throws IOException { |
28 | | - DeltaSharing instance = new DeltaSharing(); |
29 | | - instance.profileProvider = profileProvider; |
30 | | - instance.httpClient = new DeltaSharingRestClient(profileProvider, 120, 4, false); |
31 | | - instance.checkpointPath = checkpointPath; |
32 | | - instance.metadataMap = new HashMap<>(); |
33 | | - if (!Files.exists(checkpointPath)) { |
34 | | - Files.createDirectory(instance.checkpointPath); |
35 | | - } |
36 | | - instance.tempDir = Files.createTempDirectory(instance.checkpointPath, "delta_sharing"); |
37 | | - instance.tempDir.toFile().deleteOnExit(); |
38 | | - return instance; |
| 19 | + /** |
| 20 | + * Constructor. |
| 21 | + * |
| 22 | + * @param profileProvider An instance of {@link DeltaSharingProfileProvider}. |
| 23 | + * @param checkpointPath An path to a temporary checkpoint location. |
| 24 | + * @return An instance of {@link DeltaSharing} client. |
| 25 | + * @throws IOException Transitive due to the call to |
| 26 | + * {@link Files#createTempDirectory(String, FileAttribute[])}. |
| 27 | + */ |
| 28 | + public static DeltaSharing create(DeltaSharingProfileProvider profileProvider, |
| 29 | + Path checkpointPath) throws IOException { |
| 30 | + DeltaSharing instance = new DeltaSharing(); |
| 31 | + instance.profileProvider = profileProvider; |
| 32 | + instance.httpClient = new DeltaSharingRestClient(profileProvider, 120, 4, false); |
| 33 | + instance.checkpointPath = checkpointPath; |
| 34 | + instance.metadataMap = new HashMap<>(); |
| 35 | + if (!Files.exists(checkpointPath)) { |
| 36 | + Files.createDirectory(instance.checkpointPath); |
39 | 37 | } |
| 38 | + instance.tempDir = Files.createTempDirectory(instance.checkpointPath, "delta_sharing"); |
| 39 | + instance.tempDir.toFile().deleteOnExit(); |
| 40 | + return instance; |
| 41 | + } |
40 | 42 |
|
41 | | - /** |
42 | | - * Constructor |
43 | | - * @param providerConf A valid JSON document corresponding to {@link DeltaSharingProfileProvider}. |
44 | | - * @param checkpointLocation A string containing a path to be used as a checkpoint location. |
45 | | - * @return An instance of {@link DeltaSharing} client. |
46 | | - * @throws IOException Transitive due to the call to {@link Files#createDirectories(Path, FileAttribute[])}. |
47 | | - */ |
48 | | - public static DeltaSharing create(String providerConf, String checkpointLocation) throws IOException { |
49 | | - Path checkpointPath = Paths.get(checkpointLocation); |
50 | | - if(!Files.exists(checkpointPath)){ |
51 | | - Files.createDirectories(checkpointPath); |
52 | | - } |
53 | | - DeltaSharingProfileProvider profileProvider = new DeltaSharingJSONProvider(providerConf); |
54 | | - return create(profileProvider, checkpointPath); |
| 43 | + /** |
| 44 | + * Constructor. |
| 45 | + * |
| 46 | + * @param providerConf A valid JSON document corresponding to {@link DeltaSharingProfileProvider}. |
| 47 | + * @param checkpointLocation A string containing a path to be used as a checkpoint location. |
| 48 | + * @return An instance of {@link DeltaSharing} client. |
| 49 | + * @throws IOException Transitive due to the call to |
| 50 | + * {@link Files#createDirectories(Path, FileAttribute[])}. |
| 51 | + */ |
| 52 | + public static DeltaSharing create(String providerConf, String checkpointLocation) |
| 53 | + throws IOException { |
| 54 | + Path checkpointPath = Paths.get(checkpointLocation); |
| 55 | + if (!Files.exists(checkpointPath)) { |
| 56 | + Files.createDirectories(checkpointPath); |
55 | 57 | } |
| 58 | + DeltaSharingProfileProvider profileProvider = new DeltaSharingJsonProvider(providerConf); |
| 59 | + return create(profileProvider, checkpointPath); |
| 60 | + } |
56 | 61 | } |
0 commit comments