Xinglong Wang created HUDI-6133:
-----------------------------------

             Summary: Refactor deleteInstant in TimelineService to reduce 
deletion operation if state is not COMPLETED
                 Key: HUDI-6133
                 URL: https://issues.apache.org/jira/browse/HUDI-6133
             Project: Apache Hudi
          Issue Type: Improvement
            Reporter: Xinglong Wang


Look at the code below, if the state of instant is not `COMPLETED`, it calls 
`store.deleteInstant` twice:

 
{code:java}
public HoodieInstantChangeResult deleteInstant(String db, String tb, 
THoodieInstant instant) throws MetaserverStorageException, 
NoSuchObjectException {
  Long tableId = MetaserverTableUtils.getTableId(store, db, tb);
  HoodieInstantChangeResult result = new HoodieInstantChangeResult();
  if (store.instantExists(tableId, instant)) {
    switch (instant.getState()) {
      case COMPLETED:
        store.deleteInstantAllMeta(tableId, instant.getTimestamp());
        break;
      default:
        store.deleteInstant(tableId, instant);
    }
    store.deleteInstant(tableId, instant);
  } else {
    LOG.info("Instant " + instant + " has been already deleted");
  }
  result.setSuccess(true);
  return result;
} {code}
So I want to eliminate one deletion operation. 

By the way, it needs to add `IF NOT EXISTS` in DDL, if you want to run unit 
tests `TestRelationalDBBasedStore` on MySQL more than once.
 
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to