/** * {@inheritDoc} * <p> * Flushes the underlying index output. */ public void flush() throws IOException { out.flush(); }
/** * {@inheritDoc} * <p> * Flushes the underlying index output. */ public void flush() throws IOException { out.flush(); }
@Override public void flush() throws IOException { delegate.flush(); }
/** * {@inheritDoc} * <p/> * Flushes the underlying index output. */ public void flush() throws IOException { out.flush(); }
public void flush() throws IOException { main.flush(); }
public void flush() throws IOException { indexOutput.flush(); }
@Override public void flush() throws IOException { delegate.flush(); }
@Override public void flush() throws IOException { this.delegate.flush(); }
public void flush() throws IOException { localCacheIndexOutput.flush(); }
public void flush() throws IOException { main.flush(); }
public void flush() throws IOException { actualOutput().flush(); }
public static void updateTimestamp( Directory directory, Date timestamp ) throws IOException { synchronized ( directory ) { Date currentTimestamp = getTimestamp( directory ); if ( timestamp != null && ( currentTimestamp == null || !currentTimestamp.equals( timestamp ) ) ) { deleteTimestamp( directory ); IndexOutput io = directory.createOutput( TIMESTAMP_FILE, IOContext.DEFAULT); try { io.writeLong( timestamp.getTime() ); io.flush(); } finally { close( io ); } } } }
public static void updateTimestamp( Directory directory, Date timestamp ) throws IOException { synchronized ( directory ) { Date currentTimestamp = getTimestamp( directory ); if ( timestamp != null && ( currentTimestamp == null || !currentTimestamp.equals( timestamp ) ) ) { deleteTimestamp( directory ); IndexOutput io = directory.createOutput( TIMESTAMP_FILE ); try { io.writeLong( timestamp.getTime() ); io.flush(); } finally { close( io ); } } } }
/** * Starts but does not complete the commit of this file (= * writing of the final checksum at the end). After this * is called must call {@link #finishCommit} and the * {@link #close} to complete the commit. */ public void prepareCommit() throws IOException { final long checksum = getChecksum(); // Intentionally write a mismatched checksum. This is // because we want to 1) test, as best we can, that we // are able to write a long to the file, but 2) not // actually "commit" the file yet. This (prepare // commit) is phase 1 of a two-phase commit. final long pos = main.getFilePointer(); main.writeLong(checksum-1); main.flush(); main.seek(pos); }
/** * Starts but does not complete the commit of this file (= * writing of the final checksum at the end). After this * is called must call {@link #finishCommit} and the * {@link #close} to complete the commit. */ public void prepareCommit() throws IOException { final long checksum = getChecksum(); // Intentionally write a mismatched checksum. This is // because we want to 1) test, as best we can, that we // are able to write a long to the file, but 2) not // actually "commit" the file yet. This (prepare // commit) is phase 1 of a two-phase commit. final long pos = main.getFilePointer(); main.writeLong(checksum-1); main.flush(); main.seek(pos); }
@Test public void readNonStreamingWhenMultipleBlobsExist() throws Exception { boolean oldVal = BufferedOakDirectory.isEnableWritingSingleBlobIndexFile(); BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(false); try (Directory multiBlobDir = createDir(builder, true)) { IndexOutput multiBlobIndexOutput = multiBlobDir.createOutput("foo", IOContext.DEFAULT); multiBlobIndexOutput.writeBytes(randomBytes(100), 0, 100); multiBlobIndexOutput.flush(); } // Enable feature... reader shouldn't care about the flag. // Repo state needs to be used for that BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(true); try (Directory multiBlobDir = createDir(builder, true)) { OakIndexInput multiBlobIndexInput = (OakIndexInput)multiBlobDir.openInput("foo", IOContext.DEFAULT); assertTrue("OakBufferedIndexFile must be used", multiBlobIndexInput.file instanceof OakBufferedIndexFile); } BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(oldVal); }
@Test public void readStreamingWithSingleBlob() throws Exception { boolean oldVal = BufferedOakDirectory.isEnableWritingSingleBlobIndexFile(); BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(true); try (Directory multiBlobDir = createDir(builder, true)) { IndexOutput multiBlobIndexOutput = multiBlobDir.createOutput("foo", IOContext.DEFAULT); multiBlobIndexOutput.writeBytes(randomBytes(100), 0, 100); multiBlobIndexOutput.flush(); } // Enable feature... reader shouldn't care about the flag. // Repo state needs to be used for that BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(false); try (Directory multiBlobDir = createDir(builder, true)) { OakIndexInput multiBlobIndexInput = (OakIndexInput)multiBlobDir.openInput("foo", IOContext.DEFAULT); assertTrue("OakStreamingIndexFile must be used", multiBlobIndexInput.file instanceof OakStreamingIndexFile); } BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(oldVal); }
@Test public void testWritingAndReadingAFile() throws IOException { IndexOutput output = directory.createOutput("testing.test"); output.writeInt(12345); output.flush(); output.close(); IndexInput input = directory.openInput("testing.test"); assertEquals(12345, input.readInt()); input.close(); String[] listAll = directory.listAll(); assertEquals(1, listAll.length); assertEquals("testing.test", listAll[0]); assertEquals(4, directory.fileLength("testing.test")); IndexInput input1 = directory.openInput("testing.test"); IndexInput input2 = (IndexInput) input1.clone(); assertEquals(12345, input2.readInt()); input2.close(); assertEquals(12345, input1.readInt()); input1.close(); assertFalse(directory.fileExists("testing.test.other")); assertTrue(directory.fileExists("testing.test")); directory.deleteFile("testing.test"); assertFalse(directory.fileExists("testing.test")); }