Skip to content

Commit

Permalink
update the codes according to the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JiamingMai committed Sep 19, 2024
1 parent 7b95b19 commit 7c06a04
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.IOException;
import java.time.Instant;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;

Expand All @@ -29,29 +30,20 @@
public class AlluxioFileIterator
implements FileIterator
{
private final List<URIStatus> files;
private final Iterator<URIStatus> files;
private final String mountRoot;
private int index;

public AlluxioFileIterator(List<URIStatus> files, String mountRoot)
{
this.files = requireNonNull(files, "files is null");
this.files = requireNonNull(files.iterator(), "files is null");
this.mountRoot = requireNonNull(mountRoot, "mountRoot is null");
}

@Override
public boolean hasNext()
throws IOException
{
if (files.isEmpty() || index >= files.size()) {
return false;
}
if (files.get(index) != null) {
return true;
}
else {
return false;
}
return files.hasNext();
}

@Override
Expand All @@ -61,7 +53,7 @@ public FileEntry next()
if (!hasNext()) {
return null;
}
URIStatus fileStatus = files.get(index++);
URIStatus fileStatus = files.next();
Location location = convertToLocation(fileStatus, mountRoot);
return new FileEntry(
location,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class AlluxioFileSystem

public AlluxioFileSystem(FileSystem fileSystem)
{
this.fileSystem = fileSystem;
this.fileSystem = requireNonNull(fileSystem, "filesystem is null");
mountRoot = "/"; // default alluxio mount root
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static java.util.Objects.checkFromIndexSize;
import static java.util.Objects.requireNonNull;

public class AlluxioTrinoInputStream
public final class AlluxioTrinoInputStream
extends TrinoInputStream
{
private final Location location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,43 @@
import java.io.IOException;
import java.io.OutputStream;

public class AlluxioTrinoOutputStream
public final class AlluxioTrinoOutputStream
extends OutputStream
{
private final Location location;

private final OutputStream delegatedStream;
private final OutputStream delegate;

private volatile boolean closed;

public AlluxioTrinoOutputStream(Location location, OutputStream stream)
public AlluxioTrinoOutputStream(Location location, OutputStream delegate)
{
this.location = location;
delegatedStream = stream;
this.delegate = delegate;
}

@Override
public void write(int b)
throws IOException
{
ensureOpen();
delegatedStream.write(b);
delegate.write(b);
}

@Override
public void flush()
throws IOException
{
ensureOpen();
delegatedStream.flush();
delegate.flush();
}

@Override
public void close()
throws IOException
{
closed = true;
delegatedStream.close();
delegate.close();
}

private void ensureOpen()
Expand Down

0 comments on commit 7c06a04

Please sign in to comment.