File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -83,11 +83,16 @@ static void truncateTable(Table table) throws IOException {
8383 if (table == null ) {
8484 return ;
8585 }
86- try (TableIterator <Object , ? extends KeyValue <Object , Object >>
87- tableIterator = table .iterator ()) {
88- while (tableIterator .hasNext ()) {
89- KeyValue <Object , Object > entry = tableIterator .next ();
90- table .delete (entry .getKey ());
86+ try (TableIterator <Object , ? extends KeyValue <Object , Object >> iterator = table .iterator ()) {
87+ if (iterator .hasNext ()) {
88+ Object firstKey = iterator .next ().getKey ();
89+ Object lastKey = null ;
90+ while (iterator .hasNext ()) {
91+ lastKey = iterator .next ().getKey ();
92+ }
93+ if (lastKey != null ) {
94+ table .deleteRange (firstKey , lastKey ); // Efficient bulk deletion
95+ }
9196 }
9297 }
9398 }
You can’t perform that action at this time.
0 commit comments