Skip to content

Commit

Permalink
Remove unnecessary FileDescriptor sync
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 255380796
  • Loading branch information
ojw28 committed Jul 9, 2019
1 parent d57a858 commit cdf70ed
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public final class CacheDataSink implements DataSink {
private final long fragmentSize;
private final int bufferSize;

private boolean syncFileDescriptor;
private DataSpec dataSpec;
private long dataSpecFragmentSize;
private File file;
Expand Down Expand Up @@ -108,18 +107,6 @@ public CacheDataSink(Cache cache, long fragmentSize, int bufferSize) {
this.cache = Assertions.checkNotNull(cache);
this.fragmentSize = fragmentSize == C.LENGTH_UNSET ? Long.MAX_VALUE : fragmentSize;
this.bufferSize = bufferSize;
syncFileDescriptor = true;
}

/**
* Sets whether file descriptors are synced when closing output streams.
*
* <p>This method is experimental, and will be renamed or removed in a future release.
*
* @param syncFileDescriptor Whether file descriptors are synced when closing output streams.
*/
public void experimental_setSyncFileDescriptor(boolean syncFileDescriptor) {
this.syncFileDescriptor = syncFileDescriptor;
}

@Override
Expand Down Expand Up @@ -208,9 +195,6 @@ private void closeCurrentOutputStream() throws IOException {
boolean success = false;
try {
outputStream.flush();
if (syncFileDescriptor) {
underlyingFileOutputStream.getFD().sync();
}
success = true;
} finally {
Util.closeQuietly(outputStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public final class CacheDataSinkFactory implements DataSink.Factory {
private final long fragmentSize;
private final int bufferSize;

private boolean syncFileDescriptor;

/** @see CacheDataSink#CacheDataSink(Cache, long) */
public CacheDataSinkFactory(Cache cache, long fragmentSize) {
this(cache, fragmentSize, CacheDataSink.DEFAULT_BUFFER_SIZE);
Expand All @@ -40,20 +38,8 @@ public CacheDataSinkFactory(Cache cache, long fragmentSize, int bufferSize) {
this.bufferSize = bufferSize;
}

/**
* See {@link CacheDataSink#experimental_setSyncFileDescriptor(boolean)}.
*
* <p>This method is experimental, and will be renamed or removed in a future release.
*/
public CacheDataSinkFactory experimental_setSyncFileDescriptor(boolean syncFileDescriptor) {
this.syncFileDescriptor = syncFileDescriptor;
return this;
}

@Override
public DataSink createDataSink() {
CacheDataSink dataSink = new CacheDataSink(cache, fragmentSize, bufferSize);
dataSink.experimental_setSyncFileDescriptor(syncFileDescriptor);
return dataSink;
return new CacheDataSink(cache, fragmentSize, bufferSize);
}
}

0 comments on commit cdf70ed

Please sign in to comment.