*/
public static <E> View<E> viewForUri(Dataset<E> dataset, URI uri) {
Preconditions.checkArgument(dataset instanceof FileSystemDataset,
"Not a file system dataset: " + dataset);
DatasetDescriptor descriptor = dataset.getDescriptor();
String s1 = descriptor.getLocation().getScheme();
String s2 = uri.getScheme();
Preconditions.checkArgument((s1 == null || s2 == null) || s1.equals(s2),
"%s is not contained in %s", uri, descriptor.getLocation());
URI location = URI.create(descriptor.getLocation().getPath());
URI relative = location.relativize(URI.create(uri.getPath()));
if (relative.toString().isEmpty()) {
// no partitions are selected
return dataset;
}
Preconditions.checkArgument(!relative.getPath().startsWith("/"),
"%s is not contained in %s", uri, location);
Preconditions.checkArgument(descriptor.isPartitioned(),
"Dataset is not partitioned");
Schema schema = descriptor.getSchema();
PartitionStrategy strategy = descriptor.getPartitionStrategy();
RefinableView<E> view = dataset;
Iterator<String> parts = PATH_SPLITTER.split(relative.toString()).iterator();
for (FieldPartitioner fp : strategy.getFieldPartitioners()) {
if (!parts.hasNext()) {