mirror of https://github.com/apache/lucene.git
LUCENE-5621: remove IndexOutput.flush
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1588739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6902200e65
commit
ec0a9f1f13
|
@ -83,6 +83,9 @@ API Changes
|
||||||
IndexOutput.getFilePointer instead) and IndexOutput.setLength.
|
IndexOutput.getFilePointer instead) and IndexOutput.setLength.
|
||||||
(Mike McCandless)
|
(Mike McCandless)
|
||||||
|
|
||||||
|
* LUCENE-5621: Deprecate IndexOutput.flush: this is not used by Lucene.
|
||||||
|
(Robert Muir)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
|
|
||||||
* LUCENE-5603: hunspell stemmer more efficiently strips prefixes
|
* LUCENE-5603: hunspell stemmer more efficiently strips prefixes
|
||||||
|
|
|
@ -383,7 +383,6 @@ public final class DirectPostingsFormat extends PostingsFormat {
|
||||||
|
|
||||||
final byte[] payloads;
|
final byte[] payloads;
|
||||||
if (hasPayloads) {
|
if (hasPayloads) {
|
||||||
ros.flush();
|
|
||||||
payloads = new byte[(int) ros.getFilePointer()];
|
payloads = new byte[(int) ros.getFilePointer()];
|
||||||
ros.writeTo(payloads, 0);
|
ros.writeTo(payloads, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -100,8 +100,8 @@ public abstract class BufferedIndexOutput extends IndexOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** Forces any buffered output to be written. */
|
||||||
public void flush() throws IOException {
|
protected void flush() throws IOException {
|
||||||
crc.update(buffer, 0, bufferPosition);
|
crc.update(buffer, 0, bufferPosition);
|
||||||
flushBuffer(buffer, bufferPosition);
|
flushBuffer(buffer, bufferPosition);
|
||||||
bufferStart += bufferPosition;
|
bufferStart += bufferPosition;
|
||||||
|
|
|
@ -298,11 +298,6 @@ final class CompoundFileWriter implements Closeable{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException {
|
|
||||||
delegate.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (!closed) {
|
if (!closed) {
|
||||||
|
|
|
@ -31,9 +31,6 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public abstract class IndexOutput extends DataOutput implements Closeable {
|
public abstract class IndexOutput extends DataOutput implements Closeable {
|
||||||
|
|
||||||
/** Forces any buffered output to be written. */
|
|
||||||
public abstract void flush() throws IOException;
|
|
||||||
|
|
||||||
/** Closes this stream to further operations. */
|
/** Closes this stream to further operations. */
|
||||||
@Override
|
@Override
|
||||||
public abstract void close() throws IOException;
|
public abstract void close() throws IOException;
|
||||||
|
|
|
@ -154,8 +154,8 @@ public class RAMOutputStream extends IndexOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** Forces any buffered output to be written. */
|
||||||
public void flush() throws IOException {
|
protected void flush() throws IOException {
|
||||||
setFileLength();
|
setFileLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,15 +51,6 @@ final class RateLimitedIndexOutput extends BufferedIndexOutput {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException {
|
|
||||||
try {
|
|
||||||
super.flush();
|
|
||||||
} finally {
|
|
||||||
delegate.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -59,9 +59,10 @@ public class TestMockDirectoryWrapper extends LuceneTestCase {
|
||||||
final byte[] bytes = new byte[] { 1, 2};
|
final byte[] bytes = new byte[] { 1, 2};
|
||||||
IndexOutput out = dir.createOutput("foo", IOContext.DEFAULT);
|
IndexOutput out = dir.createOutput("foo", IOContext.DEFAULT);
|
||||||
out.writeBytes(bytes, bytes.length); // first write should succeed
|
out.writeBytes(bytes, bytes.length); // first write should succeed
|
||||||
// flush() to ensure the written bytes are not buffered and counted
|
// close() to ensure the written bytes are not buffered and counted
|
||||||
// against the directory size
|
// against the directory size
|
||||||
out.flush();
|
out.close();
|
||||||
|
out = dir.createOutput("bar", IOContext.DEFAULT);
|
||||||
try {
|
try {
|
||||||
out.writeBytes(bytes, bytes.length);
|
out.writeBytes(bytes, bytes.length);
|
||||||
fail("should have failed on disk full");
|
fail("should have failed on disk full");
|
||||||
|
@ -76,9 +77,10 @@ public class TestMockDirectoryWrapper extends LuceneTestCase {
|
||||||
dir.setMaxSizeInBytes(3);
|
dir.setMaxSizeInBytes(3);
|
||||||
out = dir.createOutput("foo", IOContext.DEFAULT);
|
out = dir.createOutput("foo", IOContext.DEFAULT);
|
||||||
out.copyBytes(new ByteArrayDataInput(bytes), bytes.length); // first copy should succeed
|
out.copyBytes(new ByteArrayDataInput(bytes), bytes.length); // first copy should succeed
|
||||||
// flush() to ensure the written bytes are not buffered and counted
|
// close() to ensure the written bytes are not buffered and counted
|
||||||
// against the directory size
|
// against the directory size
|
||||||
out.flush();
|
out.close();
|
||||||
|
out = dir.createOutput("bar", IOContext.DEFAULT);
|
||||||
try {
|
try {
|
||||||
out.copyBytes(new ByteArrayDataInput(bytes), bytes.length);
|
out.copyBytes(new ByteArrayDataInput(bytes), bytes.length);
|
||||||
fail("should have failed on disk full");
|
fail("should have failed on disk full");
|
||||||
|
|
|
@ -164,7 +164,6 @@ public class SlowRAMDirectory extends RAMDirectory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void close() throws IOException { io.close(); }
|
@Override public void close() throws IOException { io.close(); }
|
||||||
@Override public void flush() throws IOException { io.flush(); }
|
|
||||||
@Override public long getFilePointer() { return io.getFilePointer(); }
|
@Override public long getFilePointer() { return io.getFilePointer(); }
|
||||||
@Override public long getChecksum() throws IOException { return io.getChecksum(); }
|
@Override public long getChecksum() throws IOException { return io.getChecksum(); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,11 +198,6 @@ public class NativeUnixDirectory extends FSDirectory {
|
||||||
// FileChannel provides an API?
|
// FileChannel provides an API?
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() {
|
|
||||||
// TODO -- I don't think this method is necessary?
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dump() throws IOException {
|
private void dump() throws IOException {
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
final long limit = filePos + buffer.limit();
|
final long limit = filePos + buffer.limit();
|
||||||
|
|
|
@ -983,15 +983,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
|
||||||
io.writeBytes(b, offset, len);
|
io.writeBytes(b, offset, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException {
|
|
||||||
try {
|
|
||||||
super.flush();
|
|
||||||
} finally {
|
|
||||||
io.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -105,12 +105,6 @@ public class MockIndexOutputWrapper extends IndexOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException {
|
|
||||||
dir.maybeThrowDeterministicException();
|
|
||||||
delegate.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeByte(byte b) throws IOException {
|
public void writeByte(byte b) throws IOException {
|
||||||
singleByte[0] = b;
|
singleByte[0] = b;
|
||||||
|
|
|
@ -68,12 +68,6 @@ public class ThrottledIndexOutput extends IndexOutput {
|
||||||
this.minBytesWritten = minBytesWritten;
|
this.minBytesWritten = minBytesWritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException {
|
|
||||||
sleep(flushDelayMillis);
|
|
||||||
delegate.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -46,11 +46,6 @@ public class CachedIndexOutput extends ReusedBufferedIndexOutput {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flushInternal() throws IOException {
|
|
||||||
dest.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeInternal() throws IOException {
|
public void closeInternal() throws IOException {
|
||||||
dest.close();
|
dest.close();
|
||||||
|
@ -91,7 +86,7 @@ public class CachedIndexOutput extends ReusedBufferedIndexOutput {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getChecksum() throws IOException {
|
public long getChecksum() throws IOException {
|
||||||
flush();
|
flushBufferToCache();
|
||||||
return dest.getChecksum();
|
return dest.getChecksum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public abstract class ReusedBufferedIndexOutput extends IndexOutput {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write the buffered bytes to cache */
|
/** Write the buffered bytes to cache */
|
||||||
private void flushBufferToCache() throws IOException {
|
protected void flushBufferToCache() throws IOException {
|
||||||
writeInternal(buffer, 0, bufferLength);
|
writeInternal(buffer, 0, bufferLength);
|
||||||
|
|
||||||
bufferStart += bufferLength;
|
bufferStart += bufferLength;
|
||||||
|
@ -72,14 +72,6 @@ public abstract class ReusedBufferedIndexOutput extends IndexOutput {
|
||||||
bufferPosition = 0;
|
bufferPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void flushInternal() throws IOException;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException {
|
|
||||||
flushBufferToCache();
|
|
||||||
flushInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void closeInternal() throws IOException;
|
protected abstract void closeInternal() throws IOException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,11 +34,6 @@ public class NullIndexOutput extends IndexOutput {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getFilePointer() {
|
public long getFilePointer() {
|
||||||
return pos;
|
return pos;
|
||||||
|
|
|
@ -92,7 +92,6 @@ public class HdfsDirectoryTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
IndexOutput output = directory.createOutput("testing.test", new IOContext());
|
IndexOutput output = directory.createOutput("testing.test", new IOContext());
|
||||||
output.writeInt(12345);
|
output.writeInt(12345);
|
||||||
output.flush();
|
|
||||||
output.close();
|
output.close();
|
||||||
|
|
||||||
IndexInput input = directory.openInput("testing.test", new IOContext());
|
IndexInput input = directory.openInput("testing.test", new IOContext());
|
||||||
|
|
Loading…
Reference in New Issue