private boolean isDirectory(Path path) {
   try {
     return hdfsEnvironment.getFileSystem(path).isDirectory(path);
   } catch (IOException e) {
     throw new PrestoException(HIVE_FILESYSTEM_ERROR, "Failed checking path: " + path, e);
   }
 }
 private boolean useTemporaryDirectory(Path path) {
   try {
     // skip using temporary directory for S3
     return !(hdfsEnvironment.getFileSystem(path) instanceof PrestoS3FileSystem);
   } catch (IOException e) {
     throw new PrestoException(HIVE_FILESYSTEM_ERROR, "Failed checking path: " + path, e);
   }
 }
 private void createDirectories(Path path) {
   try {
     if (!hdfsEnvironment.getFileSystem(path).mkdirs(path)) {
       throw new IOException("mkdirs returned false");
     }
   } catch (IOException e) {
     throw new PrestoException(HIVE_FILESYSTEM_ERROR, "Failed to create directory: " + path, e);
   }
 }
 private void rename(Path source, Path target) {
   try {
     if (!hdfsEnvironment.getFileSystem(source).rename(source, target)) {
       throw new IOException("rename returned false");
     }
   } catch (IOException e) {
     throw new PrestoException(
         HIVE_FILESYSTEM_ERROR, format("Failed to rename %s to %s", source, target), e);
   }
 }
  @Override
  public RecordSink getRecordSink(
      ConnectorSession session, ConnectorOutputTableHandle tableHandle) {
    HiveOutputTableHandle handle =
        checkType(tableHandle, HiveOutputTableHandle.class, "tableHandle");

    Path target = new Path(handle.getTemporaryPath(), randomUUID().toString());
    JobConf conf = new JobConf(hdfsEnvironment.getConfiguration(target));

    return new HiveRecordSink(session, handle, target, conf);
  }