本文整理了Java中org.kitesdk.data.URIBuilder
类的一些代码示例,展示了URIBuilder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URIBuilder
类的具体详情如下:
包路径:org.kitesdk.data.URIBuilder
类名称:URIBuilder
[英]Builds dataset and view URIs
[中]构建数据集和视图URI
代码示例来源:origin: apache/nifi
@Override
public ValidationResult validate(String subject, String uri, ValidationContext context) {
String message = "not set";
boolean isValid = true;
if (uri.trim().isEmpty()) {
isValid = false;
} else {
final boolean elPresent = context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(uri);
if (!elPresent) {
try {
new URIBuilder(URI.create(uri)).build();
} catch (RuntimeException e) {
message = e.getMessage();
isValid = false;
}
}
}
return new ValidationResult.Builder()
.subject(subject)
.input(uri)
.explanation("Dataset URI is invalid: " + message)
.valid(isValid)
.build();
}
};
代码示例来源:origin: kite-sdk/kite
@Override
public URI getUri() {
URIBuilder builder = new URIBuilder(dataset.getUri());
for (Map.Entry<String, String> entry : constraints.toQueryMap().entrySet()) {
builder.with(entry.getKey(), entry.getValue());
}
return builder.build();
}
代码示例来源:origin: kite-sdk/kite
@Test
public void testEmptyConstraints() {
Assert.assertEquals("Empty constraints should produce dataset URI",
URI.create("dataset:file:/datasets/test"),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty)
.build());
}
}
代码示例来源:origin: kite-sdk/kite
/**
* Builds a dataset URI from the given repository URI string, namespace, and
* dataset name.
*
* @param repoUri a repository URI string
* @param namespace a String namespace
* @param dataset a String dataset name
* @return a dataset URI for the namespace and dataset name in the repository
*
* @since 0.17.0
*/
public static URI build(String repoUri, String namespace, String dataset) {
return build(URI.create(repoUri), namespace, dataset);
}
代码示例来源:origin: kite-sdk/kite
@Override
public void run() {
new URIBuilder("repo:file:/datasets", "ns", null).build();
代码示例来源:origin: kite-sdk/kite
@Override
public void run() {
Datasets.list(new URIBuilder(repoUri, "ns", "test")
.with("field", 34)
.build());
}
});
代码示例来源:origin: kite-sdk/kite
@Test
public void testAddExistsConstraints() {
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?id="),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty.with("id"))
.build());
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?id=×tamp="),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty.with("id").with("timestamp"))
.build());
}
代码示例来源:origin: kite-sdk/kite
@Test
public void signalReadyOnUnboundedDataset() {
final FileSystemDataset<Record> ds = new FileSystemDataset.Builder<Record>()
.namespace("ns")
.name("users")
.configuration(getConfiguration())
.descriptor(
new DatasetDescriptor.Builder().schema(USER_SCHEMA).format(format)
.location(testDirectory).build())
.type(Record.class)
.uri(URIBuilder.build(URI.create("repo:" + testDirectory.toUri()), "ns", "name"))
.build();
Assert.assertFalse("Unbounded dataset has not been signaled", ds.isReady());
ds.signalReady();
Assert.assertTrue("Unbounded dataset has been signaled and should be ready", ds.isReady());
}
代码示例来源:origin: apache/flume
DEFAULT_NAMESPACE);
this.datasetUri = new URIBuilder(repositoryURI, namespace, datasetName)
.build();
代码示例来源:origin: kite-sdk/kite
@Test
public void testBuildViewUri() {
URI uri = new URIBuilder("repo:file:/tmp/data", "ns", "test-ds")
.with("username", "bob").with("lastName", "Smith").build();
Assert.assertEquals(URI.create("view:file:/tmp/data/ns/test-ds?username=bob&lastName=Smith"), uri);
}
代码示例来源:origin: kite-sdk/kite
@Test
public void testAddRangeConstraints() {
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?color=[green,)"),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty.from("color", "green"))
.build());
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?color=(,green]"),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty.to("color", "green"))
.build());
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?timestamp=[0,1405720705333)&color=(green,red]"),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty
.from("timestamp", 0l).toBefore("timestamp", 1405720705333L)
.fromAfter("color", "green").to("color", "red"))
.build());
}
代码示例来源:origin: kite-sdk/kite
@Test
public void testReadySignalUpdatesModifiedTime() {
final FileSystemDataset<Record> ds = new FileSystemDataset.Builder<Record>()
.namespace("ns")
.name("users")
.configuration(getConfiguration())
.descriptor(
new DatasetDescriptor.Builder().schema(USER_SCHEMA).format(format)
.location(testDirectory).build())
.type(Record.class)
.uri(URIBuilder.build(URI.create("repo:" + testDirectory.toUri()), "ns", "name"))
.build();
Assert.assertFalse("Dataset should not be ready before being signaled",
ds.isReady());
// the modified time depends on the filesystem, and may only be granular to the second
// signal and check until the modified time is after the current time, or until
// enough time has past that the signal should have been distinguishable
long signaledTime = 0;
long currentTime = System.currentTimeMillis();
while(currentTime >= signaledTime && (System.currentTimeMillis() - currentTime) <= 2000) {
ds.signalReady();
signaledTime = ds.getLastModified();
}
Assert.assertTrue("Dataset should have been signaled as ready", ds.isReady());
Assert.assertTrue("Signal should update the modified time",
signaledTime > currentTime);
Assert.assertFalse("Only the dataset should have been signaled",
((Signalable)ds.with("username", "bob")).isReady());
}
代码示例来源:origin: kite-sdk/kite
/**
* Builds a dataset URI from the given repository URI, namespace, and dataset
* name.
*
* @param repoUri a repository URI
* @param namespace a String namespace
* @param dataset a String dataset name
* @return a dataset URI for the namespace and dataset name in the repository
*
* @since 0.17.0
*/
public static URI build(URI repoUri, String namespace, String dataset) {
return new URIBuilder(repoUri, namespace, dataset).build();
}
代码示例来源:origin: kite-sdk/kite
@Test
public void testRepoUriHasQueryString() {
URI uri = new URIBuilder("repo:file:/tmp/data?repoParam=x", "ns", "test-ds")
.with("username", "bob")
.build();
Assert.assertEquals(URI.create("view:file:/tmp/data/ns/test-ds?repoParam=x&username=bob"), uri);
}
}
代码示例来源:origin: kite-sdk/kite
@Test
public void testAddEqualityConstraints() {
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?id=" + ID),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty.with("id", new Utf8(ID)))
.build());
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?id=a,b"),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty.with("id", new Utf8("a"), new Utf8("b")))
.build());
Assert.assertEquals("Should add equality constraints",
URI.create("view:file:/datasets/test?id=" + ID + "×tamp=1405720705333"),
new URIBuilder("dataset:file:/datasets/test")
.constraints(
empty.with("id", new Utf8(ID)).with("timestamp", 1405720705333L))
.build());
Assert.assertEquals("Should add encoded equality constraints",
URI.create("view:file:/datasets/test?id=a%2Fb"),
new URIBuilder("dataset:file:/datasets/test")
.constraints(empty.with("id", new Utf8("a/b")))
.build());
}
代码示例来源:origin: kite-sdk/kite
@Override
public void run() {
new URIBuilder("dataset:file:/datasets/test-name", "ns", "test-name-2")
.build();
}
});
代码示例来源:origin: kite-sdk/kite
@Test
public void testDatasetUriAddEquals() {
Assert.assertEquals("Should produce an equivalent dataset URI",
URI.create("view:file:/datasets/test-name?prop=value"),
new URIBuilder("dataset:file:/datasets/test-name")
.with("prop", "value")
.build());
Assert.assertEquals("Should produce an equivalent dataset URI",
URI.create("view:file:/datasets/test-name?prop=value&num=34"),
new URIBuilder("dataset:file:/datasets/test-name")
.with("prop", "value")
.with("num", 34)
.build());
}
代码示例来源:origin: kite-sdk/kite
@Override
public void run() {
new URIBuilder((URI) null).build();
}
});
代码示例来源:origin: kite-sdk/kite
@Test
public void testRepoUriAndNameAddEquals() {
Assert.assertEquals("Should construct the correct dataset URI",
URI.create("view:file:/datasets/ns/test-name?prop=value"),
new URIBuilder("repo:file:/datasets", "ns", "test-name")
.with("prop", "value")
.build());
// order should be preserved
Assert.assertEquals("Should construct the correct dataset URI",
URI.create("view:file:/datasets/ns/test-name?prop=value&num=34"),
new URIBuilder("repo:file:/datasets", "ns", "test-name")
.with("prop", "value")
.with("num", 34)
.build());
}
代码示例来源:origin: kite-sdk/kite
@Override
public void run() {
new URIBuilder("view:file:/datasets/test-name?n=34", "ns", "test-name-2")
.build();
}
});
内容来源于网络,如有侵权,请联系作者删除!