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() ); } 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, IOContext.DEFAULT ); try { io.writeLong( timestamp.getTime() ); } finally { close( io ); } } } }
public static Date getTimestamp( Directory directory ) { synchronized ( directory ) { Date result = null; try { if ( directory.fileExists( TIMESTAMP_FILE ) ) { IndexInput ii = null; try { ii = directory.openInput( TIMESTAMP_FILE, IOContext.DEFAULT); result = new Date( ii.readLong() ); } finally { close( ii ); } } } catch ( IOException ex ) { } return result; } }
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 ); } } } }
/** * Unpack index data using specified Lucene Index writer * * @param is an input stream to unpack index data from * @param w a writer to save index data * @param ics a collection of index creators for updating unpacked documents. */ public static IndexDataReadResult unpackIndexData( final InputStream is, final Directory d, final IndexingContext context ) throws IOException { NexusIndexWriter w = new NexusIndexWriter( d, new NexusAnalyzer(), true ); try { IndexDataReader dr = new IndexDataReader( is ); return dr.readIndex( w, context ); } finally { IndexUtils.close( w ); } }
/** * Unpack index data using specified Lucene Index writer * * @param is an input stream to unpack index data from * @param w a writer to save index data * @param ics a collection of index creators for updating unpacked documents. */ public static IndexDataReadResult unpackIndexData( final InputStream is, final Directory d, final IndexingContext context ) throws IOException { NexusIndexWriter w = new NexusIndexWriter( d, new NexusAnalyzer(), true ); try { IndexDataReader dr = new IndexDataReader( is ); return dr.readIndex( w, context ); } finally { IndexUtils.close( w ); } }
/** * Unpack index data using specified Lucene Index writer * * @param is an input stream to unpack index data from * @param w a writer to save index data * @param ics a collection of index creators for updating unpacked documents. */ public static Date unpackIndexData( final InputStream is, final Directory d, final IndexingContext context ) throws IOException { NexusIndexWriter w = new NexusIndexWriter( d, new NexusAnalyzer(), true ); try { IndexDataReader dr = new IndexDataReader( is ); IndexDataReadResult result = dr.readIndex( w, context ); return result.getTimestamp(); } finally { IndexUtils.close( w ); } }