@Test public void typical() throws URISyntaxException { S3LocationResolver resolver = new S3LocationResolver(s3, "bucket", "prefix"); URI uri = resolver.resolveLocation("tableName", false); assertThat(uri, is(new URI("s3: }
@Override public URI resolveLocation(String location, boolean create) { List<String> elements = new ArrayList<>(); if (StringUtils.isNotBlank(prefix)) { elements.add(prefix); } elements.add(location); String path = elements.stream().collect(joining("/")); if (create) { ByteArrayInputStream content = new ByteArrayInputStream(new byte[0]); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(0); s3.putObject(bucket, path + "/", content, metadata); } try { return new URI("s3", bucket, "/" + path, null); } catch (URISyntaxException e) { throw new MetaStoreException( String.format("Could not construct location URI for: bucket='%s', prefix='%s', location='%s'", bucket, prefix, location), e); } }
S3LocationResolver implements LocationResolver { @Override public URI resolveLocation(String location, boolean create) { List<String> elements = new ArrayList<>(); if (StringUtils.isNotBlank(prefix)) { elements.add(prefix); } elements.add(location); String path = elements.stream().collect(joining("/")); if (create) { ByteArrayInputStream content = new ByteArrayInputStream(new byte[0]); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(0); s3.putObject(bucket, path + "/", content, metadata); } try { return new URI("s3", bucket, "/" + path, null); } catch (URISyntaxException e) { throw new MetaStoreException( String.format("Could not construct location URI for: bucket='%s', prefix='%s', location='%s'", bucket, prefix, location), e); } } }
S3LocationResolver implements LocationResolver { @Override public URI resolveLocation(String location, boolean create) { List<String> elements = new ArrayList<>(); if (StringUtils.isNotBlank(prefix)) { elements.add(prefix); } elements.add(location); String path = elements.stream().collect(joining("/")); if (create) { ByteArrayInputStream content = new ByteArrayInputStream(new byte[0]); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(0); s3.putObject(bucket, path + "/", content, metadata); } try { return new URI("s3", bucket, "/" + path, null); } catch (URISyntaxException e) { throw new MetaStoreException( String.format("Could not construct location URI for: bucket='%s', prefix='%s', location='%s'", bucket, prefix, location), e); } }  }
S3LocationResolver implements LocationResolver { @Override public URI resolveLocation(String location, boolean create) { List<String> elements = new ArrayList<>(); if (StringUtils.isNotBlank(prefix)) { elements.add(prefix); } elements.add(location); String path = elements.stream().collect(joining("/")); if (create) { ByteArrayInputStream content = new ByteArrayInputStream(new byte[0]); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(0); s3.putObject(bucket, path + "/", content, metadata); } try { return new URI("s3", bucket, "/" + path, null); } catch (URISyntaxException e) { throw new MetaStoreException( String.format("Could not construct location URI for: bucket='%s', prefix='%s', location='%s'", bucket, prefix, location), e); } }  @Override URI resolveLocation(String location, boolean create); }
S3LocationResolver implements LocationResolver { @Override public URI resolveLocation(String location, boolean create) { List<String> elements = new ArrayList<>(); if (StringUtils.isNotBlank(prefix)) { elements.add(prefix); } elements.add(location); String path = elements.stream().collect(joining("/")); if (create) { ByteArrayInputStream content = new ByteArrayInputStream(new byte[0]); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(0); s3.putObject(bucket, path + "/", content, metadata); } try { return new URI("s3", bucket, "/" + path, null); } catch (URISyntaxException e) { throw new MetaStoreException( String.format("Could not construct location URI for: bucket='%s', prefix='%s', location='%s'", bucket, prefix, location), e); } }  @Override URI resolveLocation(String location, boolean create);  }