/**
   * Returns a boolean indicating if the given thrift caching operation would perform an update on
   * an already existing cache directive.
   */
  public static boolean isUpdateOp(THdfsCachingOp op, Map<String, String> params)
      throws ImpalaRuntimeException {

    Long directiveId = Long.parseLong(params.get(CACHE_DIR_ID_PROP_NAME));
    CacheDirectiveEntry entry = getDirective(directiveId);
    Preconditions.checkNotNull(entry);

    // Verify cache pool
    if (!op.getCache_pool_name().equals(entry.getInfo().getPool())) {
      return false;
    }

    // Check cache replication factor
    if ((op.isSetReplication() && op.getReplication() != entry.getInfo().getReplication())
        || (!op.isSetReplication()
            && entry.getInfo().getReplication()
                != JniCatalogConstants.HDFS_DEFAULT_CACHE_REPLICATION_FACTOR)) {
      return true;
    }
    return false;
  }
 /** Helper method for frequent lookup of replication factor in the thrift caching structure. */
 public static short getReplicationOrDefault(THdfsCachingOp op) {
   return op.isSetReplication()
       ? op.getReplication()
       : JniCatalogConstants.HDFS_DEFAULT_CACHE_REPLICATION_FACTOR;
 }