private int persistHydrant ( FireHydrant indexToPersist , SegmentIdWithShardSpec identifier ) { synchronized ( indexToPersist ) { if ( indexToPersist . hasSwapped ( ) ) { log . info ( "Segment[%s], Hydrant[%s] already swapped. Ignoring request to persist." , identifier , indexToPersist ) ; return 0 ; } log . info ( "Segment[%s], persisting Hydrant[%s]" , identifier , indexToPersist ) ; try { int numRows = indexToPersist . getIndex ( ) . size ( ) ; final File persistedFile ; final File persistDir = createPersistDirIfNeeded ( identifier ) ; final IndexSpec indexSpec = tuningConfig . getIndexSpec ( ) ; persistedFile = indexMerger . persist ( indexToPersist . getIndex ( ) , identifier . getInterval ( ) , new File ( persistDir , String . valueOf ( indexToPersist . getCount ( ) ) ) , indexSpec , tuningConfig . getSegmentWriteOutMediumFactory ( ) ) ; indexToPersist . swapSegment ( new QueryableIndexSegment ( indexIO . loadIndex ( persistedFile ) , indexToPersist . getSegmentId ( ) ) ) ; return numRows ; } catch ( IOException e ) { log . makeAlert ( "dataSource[%s] -- incremental persist failed" , schema . getDataSource ( ) ) . addData ( "segment" , identifier . toString ( ) ) . addData ( "count" , indexToPersist . getCount ( ) ) . emit ( ) ; throw new RuntimeException ( e ) ; } } }
Persists the given hydrant and returns the number of rows persisted . Must only be called in the single - threaded persistExecutor .