-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rtyler/patch-2
Patch 2
- Loading branch information
Showing
38 changed files
with
820 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
core/src/main/scala/io/delta/storage/CloseableIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (2020) The Delta Lake Project Authors. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package io.delta.storage; | ||
|
||
import java.io.Closeable; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* An iterator that may contain resources which should be released after use. Users of | ||
* CloseableIterator are responsible to to close the iterator if they are done with it. | ||
*/ | ||
public interface CloseableIterator<T> extends Iterator<T>, Closeable {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (2020) The Delta Lake Project Authors. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package io.delta.storage; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileStatus; | ||
import org.apache.hadoop.fs.Path; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.nio.file.FileAlreadyExistsException; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* General interface for all critical file system operations required to read and write the | ||
* Delta logs. The correctness is predicated on the atomicity and durability guarantees of | ||
* the implementation of this interface. Specifically, | ||
* | ||
* 1. Atomic visibility of files: If isPartialWriteVisible is false, any file written through | ||
* this store must be made visible atomically. In other words, this should not generate partial | ||
* files. | ||
* | ||
* 2. Mutual exclusion: Only one writer must be able to create (or rename) a file at the final | ||
* destination. | ||
* | ||
* 3. Consistent listing: Once a file has been written in a directory, all future listings for | ||
* that directory must return that file. | ||
* | ||
* All subclasses of this interface is required to have a constructor that takes Configuration | ||
* as a single parameter. This constructor is used to dynamically create the LogStore. | ||
*/ | ||
public abstract class LogStore { | ||
|
||
private Configuration initHadoopConf; | ||
|
||
public LogStore(Configuration initHadoopConf) { | ||
this.initHadoopConf = initHadoopConf; | ||
} | ||
|
||
/** | ||
* Hadoop configuration that should only be used during initialization of LogStore. Each method | ||
* should use their `haddopConf` parameter rather than this (potentially outdated) hadoop | ||
* configuration. | ||
*/ | ||
public Configuration initHadoopConf() { return initHadoopConf; } | ||
|
||
/** | ||
* Load the given file and return an `Iterator` of lines, with line breaks removed from each line. | ||
* Callers of this function are responsible to close the iterator if they are done with it. | ||
*/ | ||
public abstract CloseableIterator<String> read(Path path, Configuration hadoopConf); | ||
|
||
/** | ||
* Write the given `actions` to the given `path` with or without overwrite as indicated. | ||
* Implementation must throw [[java.nio.file.FileAlreadyExistsException]] exception if the file | ||
* already exists and overwrite = false. Furthermore, if isPartialWriteVisible returns false, | ||
* implementation must ensure that the entire file is made visible atomically, that is, | ||
* it should not generate partial files. | ||
*/ | ||
public abstract void write( | ||
Path path, | ||
Iterator<String> actions, | ||
Boolean overwrite, | ||
Configuration hadoopConf) throws FileAlreadyExistsException; | ||
|
||
/** | ||
* List the paths in the same directory that are lexicographically greater or equal to | ||
* (UTF-8 sorting) the given `path`. The result should also be sorted by the file name. | ||
*/ | ||
public abstract Iterator<FileStatus> listFrom( | ||
Path path, | ||
Configuration hadoopConf) throws FileNotFoundException; | ||
|
||
/** | ||
* Resolve the fully qualified path for the given `path`. | ||
*/ | ||
public abstract Path resolvePathOnPhysicalStorage(Path path, Configuration hadoopConf); | ||
|
||
/** | ||
* Whether a partial write is visible for the underlying file system of `path`. | ||
*/ | ||
public abstract Boolean isPartialWriteVisible(Path path, Configuration hadoopConf); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.