44
44
45
45
public class TableImpl implements Table {
46
46
47
- //////////////////////////////
48
- // Static Methods / Members //
49
- //////////////////////////////
50
-
51
47
private static final Logger logger = LoggerFactory .getLogger (TableImpl .class );
52
48
53
49
public static Table forPath (Engine engine , String path ) {
@@ -64,60 +60,34 @@ public static Table forPath(Engine engine, String path) {
64
60
* @return an instance of {@link Table} representing the Delta table at the given path
65
61
*/
66
62
public static Table forPath (Engine engine , String path , Clock clock ) {
67
- return forPathWithTableId (engine , path , Optional .empty (), clock );
68
- }
69
-
70
- public static Table forPathWithTableId (Engine engine , String path , TableIdentifier tableId ) {
71
- return forPathWithTableId (engine , path , Optional .of (tableId ), System ::currentTimeMillis );
72
- }
73
-
74
- public static Table forPathWithTableId (
75
- Engine engine , String path , Optional <TableIdentifier > tableIdOpt , Clock clock ) {
63
+ String resolvedPath ;
76
64
try {
77
- final String resolvedPath =
65
+ resolvedPath =
78
66
wrapEngineExceptionThrowsIO (
79
67
() -> engine .getFileSystemClient ().resolvePath (path ), "Resolving path %s" , path );
80
- return new TableImpl (resolvedPath , tableIdOpt , clock );
81
68
} catch (IOException io ) {
82
69
throw new UncheckedIOException (io );
83
70
}
71
+ return new TableImpl (resolvedPath , clock );
84
72
}
85
73
86
- ////////////////////////////////
87
- // Instance Methods / Members //
88
- ////////////////////////////////
89
-
74
+ private final SnapshotManager snapshotManager ;
90
75
private final String tablePath ;
91
- private final Optional <TableIdentifier > tableIdOpt ;
92
76
private final Clock clock ;
93
77
94
- private final Path dataPath ;
95
- private final Path logPath ;
96
- private final SnapshotManager snapshotManager ;
97
-
98
- private TableImpl (String tablePath , Optional <TableIdentifier > tableIdOpt , Clock clock ) {
78
+ public TableImpl (String tablePath , Clock clock ) {
99
79
this .tablePath = tablePath ;
100
- this .tableIdOpt = tableIdOpt ;
101
- this .clock = clock ;
102
- this .dataPath = new Path (tablePath );
103
- this .logPath = new Path (dataPath , "_delta_log" );
80
+ final Path dataPath = new Path (tablePath );
81
+ final Path logPath = new Path (dataPath , "_delta_log" );
104
82
this .snapshotManager = new SnapshotManager (logPath , dataPath );
83
+ this .clock = clock ;
105
84
}
106
85
107
- /////////////////
108
- // Public APIs //
109
- /////////////////
110
-
111
86
@ Override
112
87
public String getPath (Engine engine ) {
113
88
return tablePath ;
114
89
}
115
90
116
- @ Override
117
- public Optional <TableIdentifier > getTableIdentifier () {
118
- return tableIdOpt ;
119
- }
120
-
121
91
@ Override
122
92
public Snapshot getLatestSnapshot (Engine engine ) throws TableNotFoundException {
123
93
return snapshotManager .buildLatestSnapshot (engine );
@@ -199,7 +169,8 @@ public CloseableIterator<ColumnarBatch> getChanges(
199
169
for (int rowId = 0 ; rowId < protocolVector .getSize (); rowId ++) {
200
170
if (!protocolVector .isNullAt (rowId )) {
201
171
Protocol protocol = Protocol .fromColumnVector (protocolVector , rowId );
202
- TableFeatures .validateReadSupportedTable (protocol , tablePath , Optional .empty ());
172
+ TableFeatures .validateReadSupportedTable (
173
+ protocol , getDataPath ().toString (), Optional .empty ());
203
174
}
204
175
}
205
176
if (shouldDropProtocolColumn ) {
@@ -210,6 +181,14 @@ public CloseableIterator<ColumnarBatch> getChanges(
210
181
});
211
182
}
212
183
184
+ protected Path getDataPath () {
185
+ return new Path (tablePath );
186
+ }
187
+
188
+ protected Path getLogPath () {
189
+ return new Path (tablePath , "_delta_log" );
190
+ }
191
+
213
192
/**
214
193
* Returns the latest version that was committed before or at {@code millisSinceEpochUTC}. If no
215
194
* version exists, throws a {@link KernelException}
@@ -290,22 +269,6 @@ public long getVersionAtOrAfterTimestamp(Engine engine, long millisSinceEpochUTC
290
269
}
291
270
}
292
271
293
- ////////////////////
294
- // Protected APIs //
295
- ////////////////////
296
-
297
- protected Path getDataPath () {
298
- return dataPath ;
299
- }
300
-
301
- protected Path getLogPath () {
302
- return logPath ;
303
- }
304
-
305
- ////////////////////////////
306
- // Private Helper Methods //
307
- ////////////////////////////
308
-
309
272
/**
310
273
* Returns the raw delta actions for each version between startVersion and endVersion. Only reads
311
274
* the actions requested in actionSet from the JSON log files.
0 commit comments