@@ -152,10 +152,9 @@ public int getCompactedFilesCount() {
152152 }
153153
154154 @ Override
155- public void insertNewFiles (Collection <HStoreFile > sfs ) throws IOException {
155+ public void insertNewFiles (Collection <HStoreFile > sfs ) {
156156 CompactionOrFlushMergeCopy cmc = new CompactionOrFlushMergeCopy (true );
157- // Passing null does not cause NPE??
158- cmc .mergeResults (null , sfs );
157+ cmc .mergeResults (Collections .emptyList (), sfs );
159158 debugDumpState ("Added new files" );
160159 }
161160
@@ -321,11 +320,11 @@ public Collection<HStoreFile> getFilesForScan(byte[] startRow, boolean includeSt
321320 }
322321
323322 @ Override
324- public void addCompactionResults (
325- Collection <HStoreFile > compactedFiles , Collection < HStoreFile > results ) throws IOException {
323+ public void addCompactionResults (Collection < HStoreFile > compactedFiles ,
324+ Collection <HStoreFile > results ) {
326325 // See class comment for the assumptions we make here.
327- LOG .debug ("Attempting to merge compaction results: " + compactedFiles .size ()
328- + " files replaced by " + results .size ());
326+ LOG .debug ("Attempting to merge compaction results: " + compactedFiles .size () +
327+ " files replaced by " + results .size ());
329328 // In order to be able to fail in the middle of the operation, we'll operate on lazy
330329 // copies and apply the result at the end.
331330 CompactionOrFlushMergeCopy cmc = new CompactionOrFlushMergeCopy (false );
@@ -345,7 +344,7 @@ private void markCompactedAway(Collection<HStoreFile> compactedFiles) {
345344 }
346345
347346 @ Override
348- public void removeCompactedFiles (Collection <HStoreFile > compactedFiles ) throws IOException {
347+ public void removeCompactedFiles (Collection <HStoreFile > compactedFiles ) {
349348 // See class comment for the assumptions we make here.
350349 LOG .debug ("Attempting to delete compaction results: " + compactedFiles .size ());
351350 // In order to be able to fail in the middle of the operation, we'll operate on lazy
@@ -728,13 +727,15 @@ public CompactionOrFlushMergeCopy(boolean isFlush) {
728727 this .isFlush = isFlush ;
729728 }
730729
731- private void mergeResults (Collection <HStoreFile > compactedFiles , Collection < HStoreFile > results )
732- throws IOException {
730+ private void mergeResults (Collection <HStoreFile > compactedFiles ,
731+ Collection < HStoreFile > results ) {
733732 assert this .compactedFiles == null && this .results == null ;
734733 this .compactedFiles = compactedFiles ;
735734 this .results = results ;
736735 // Do logical processing.
737- if (!isFlush ) removeCompactedFiles ();
736+ if (!isFlush ) {
737+ removeCompactedFiles ();
738+ }
738739 TreeMap <byte [], HStoreFile > newStripes = processResults ();
739740 if (newStripes != null ) {
740741 processNewCandidateStripes (newStripes );
@@ -745,7 +746,7 @@ private void mergeResults(Collection<HStoreFile> compactedFiles, Collection<HSto
745746 updateMetadataMaps ();
746747 }
747748
748- private void deleteResults (Collection <HStoreFile > compactedFiles ) throws IOException {
749+ private void deleteResults (Collection <HStoreFile > compactedFiles ) {
749750 this .compactedFiles = compactedFiles ;
750751 // Create new state and update parent.
751752 State state = createNewState (true );
@@ -828,11 +829,11 @@ private final ArrayList<HStoreFile> getLevel0Copy() {
828829 }
829830
830831 /**
831- * Process new files, and add them either to the structure of existing stripes,
832- * or to the list of new candidate stripes.
832+ * Process new files, and add them either to the structure of existing stripes, or to the list
833+ * of new candidate stripes.
833834 * @return New candidate stripes.
834835 */
835- private TreeMap <byte [], HStoreFile > processResults () throws IOException {
836+ private TreeMap <byte [], HStoreFile > processResults () {
836837 TreeMap <byte [], HStoreFile > newStripes = null ;
837838 for (HStoreFile sf : this .results ) {
838839 byte [] startRow = startOf (sf ), endRow = endOf (sf );
@@ -859,8 +860,9 @@ private TreeMap<byte[], HStoreFile> processResults() throws IOException {
859860 }
860861 HStoreFile oldSf = newStripes .put (endRow , sf );
861862 if (oldSf != null ) {
862- throw new IOException ("Compactor has produced multiple files for the stripe ending in ["
863- + Bytes .toString (endRow ) + "], found " + sf .getPath () + " and " + oldSf .getPath ());
863+ throw new IllegalStateException (
864+ "Compactor has produced multiple files for the stripe ending in [" +
865+ Bytes .toString (endRow ) + "], found " + sf .getPath () + " and " + oldSf .getPath ());
864866 }
865867 }
866868 return newStripes ;
@@ -869,7 +871,7 @@ private TreeMap<byte[], HStoreFile> processResults() throws IOException {
869871 /**
870872 * Remove compacted files.
871873 */
872- private void removeCompactedFiles () throws IOException {
874+ private void removeCompactedFiles () {
873875 for (HStoreFile oldFile : this .compactedFiles ) {
874876 byte [] oldEndRow = endOf (oldFile );
875877 List <HStoreFile > source = null ;
@@ -878,13 +880,14 @@ private void removeCompactedFiles() throws IOException {
878880 } else {
879881 int stripeIndex = findStripeIndexByEndRow (oldEndRow );
880882 if (stripeIndex < 0 ) {
881- throw new IOException ("An allegedly compacted file [" + oldFile + "] does not belong"
882- + " to a known stripe (end row - [" + Bytes .toString (oldEndRow ) + "])" );
883+ throw new IllegalStateException (
884+ "An allegedly compacted file [" + oldFile + "] does not belong" +
885+ " to a known stripe (end row - [" + Bytes .toString (oldEndRow ) + "])" );
883886 }
884887 source = getStripeCopy (stripeIndex );
885888 }
886889 if (!source .remove (oldFile )) {
887- throw new IOException ("An allegedly compacted file [" + oldFile + " ] was not found" );
890+ LOG . warn ("An allegedly compacted file [{} ] was not found" , oldFile );
888891 }
889892 }
890893 }
@@ -894,16 +897,15 @@ private void removeCompactedFiles() throws IOException {
894897 * new candidate stripes/removes old stripes; produces new set of stripe end rows.
895898 * @param newStripes New stripes - files by end row.
896899 */
897- private void processNewCandidateStripes (
898- TreeMap <byte [], HStoreFile > newStripes ) throws IOException {
900+ private void processNewCandidateStripes (TreeMap <byte [], HStoreFile > newStripes ) {
899901 // Validate that the removed and added aggregate ranges still make for a full key space.
900902 boolean hasStripes = !this .stripeFiles .isEmpty ();
901903 this .stripeEndRows = new ArrayList <>(Arrays .asList (StripeStoreFileManager .this .state .stripeEndRows ));
902904 int removeFrom = 0 ;
903905 byte [] firstStartRow = startOf (newStripes .firstEntry ().getValue ());
904906 byte [] lastEndRow = newStripes .lastKey ();
905907 if (!hasStripes && (!isOpen (firstStartRow ) || !isOpen (lastEndRow ))) {
906- throw new IOException ("Newly created stripes do not cover the entire key space." );
908+ throw new IllegalStateException ("Newly created stripes do not cover the entire key space." );
907909 }
908910
909911 boolean canAddNewStripes = true ;
@@ -915,11 +917,15 @@ private void processNewCandidateStripes(
915917 removeFrom = 0 ;
916918 } else {
917919 removeFrom = findStripeIndexByEndRow (firstStartRow );
918- if (removeFrom < 0 ) throw new IOException ("Compaction is trying to add a bad range." );
920+ if (removeFrom < 0 ) {
921+ throw new IllegalStateException ("Compaction is trying to add a bad range." );
922+ }
919923 ++removeFrom ;
920924 }
921925 int removeTo = findStripeIndexByEndRow (lastEndRow );
922- if (removeTo < 0 ) throw new IOException ("Compaction is trying to add a bad range." );
926+ if (removeTo < 0 ) {
927+ throw new IllegalStateException ("Compaction is trying to add a bad range." );
928+ }
923929 // See if there are files in the stripes we are trying to replace.
924930 ArrayList <HStoreFile > conflictingFiles = new ArrayList <>();
925931 for (int removeIndex = removeTo ; removeIndex >= removeFrom ; --removeIndex ) {
@@ -961,7 +967,9 @@ private void processNewCandidateStripes(
961967 }
962968 }
963969
964- if (!canAddNewStripes ) return ; // Files were already put into L0.
970+ if (!canAddNewStripes ) {
971+ return ; // Files were already put into L0.
972+ }
965973
966974 // Now, insert new stripes. The total ranges match, so we can insert where we removed.
967975 byte [] previousEndRow = null ;
@@ -972,8 +980,8 @@ private void processNewCandidateStripes(
972980 assert !isOpen (previousEndRow );
973981 byte [] startRow = startOf (newStripe .getValue ());
974982 if (!rowEquals (previousEndRow , startRow )) {
975- throw new IOException ("The new stripes produced by "
976- + (isFlush ? "flush" : "compaction" ) + " are not contiguous" );
983+ throw new IllegalStateException ("The new stripes produced by " +
984+ (isFlush ? "flush" : "compaction" ) + " are not contiguous" );
977985 }
978986 }
979987 // Add the new stripe.
0 commit comments