// Hive-managed data sets
final OptionBuilder<DatasetRepository> managedBuilder =
new ManagedBuilder(conf);
Accessor.getDefault().registerDatasetRepository(
new URIPattern(URI.create("hive")), managedBuilder);
Accessor.getDefault().registerDatasetRepository(
new URIPattern(URI.create("hive://" + hiveAuthority + "/")),
managedBuilder);
// external data sets
final OptionBuilder<DatasetRepository> externalBuilder =
new ExternalBuilder(conf);
String hdfsAuthority;
try {
// Use a HDFS URI with no authority and the environment's configuration
// to find the default HDFS information
final URI hdfs = FileSystem.get(URI.create("hdfs:/"), conf).getUri();
hdfsAuthority = "&hdfs-host=" + hdfs.getHost() +
"&hdfs-port=" + hdfs.getPort();
} catch (IOException ex) {
logger.warn(
"Could not locate HDFS, hdfs-host and hdfs-port " +
"will not be set by default for Hive repositories.");
hdfsAuthority = "";
}
Accessor.getDefault().registerDatasetRepository(
new URIPattern(URI.create("hive://" + hiveAuthority +
"/*path?absolute=true" + hdfsAuthority)),
externalBuilder);
Accessor.getDefault().registerDatasetRepository(
new URIPattern(URI.create("hive:*path")), externalBuilder);
}