本文整理了Java中org.apache.tinkerpop.gremlin.structure.Graph.variables()
方法的一些代码示例,展示了Graph.variables()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.variables()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Graph
类名称:Graph
方法名:variables
[英]A collection of global Variables associated with the graph. Variables are used for storing metadata about the graph.
[中]与图形关联的全局变量的集合。变量用于存储有关图形的元数据。
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = FEATURE_VARIABLES)
public void testGraphVariablesSet() throws Exception {
try {
graph.variables().set(key, val);
fail(String.format("Setting an annotation with these arguments [key: %s value: %s] should throw an exception", key, val));
} catch (Exception ex) {
validateException(expectedException, ex);
}
}
}
代码示例来源:origin: apache/tinkerpop
/**
* A {@link org.apache.tinkerpop.gremlin.structure.Graph} that does not support {@link org.apache.tinkerpop.gremlin.structure.Graph.Features.VariableFeatures#FEATURE_VARIABLES} must call
* {@link org.apache.tinkerpop.gremlin.structure.Graph.Exceptions#variablesNotSupported()}.
*/
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = FEATURE_VARIABLES, supported = false)
public void shouldSupportMemoryIfAGraphAcceptsMemory() throws Exception {
try {
graph.variables();
fail(String.format(INVALID_FEATURE_SPECIFICATION, Graph.Features.VariableFeatures.class.getSimpleName(), FEATURE_VARIABLES));
} catch (Exception e) {
validateException(Graph.Exceptions.variablesNotSupported(), e);
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_STRING_VALUES)
public void shouldHoldVariableNone() {
final Graph.Variables variables = graph.variables();
final Map<String, Object> mapOfAnnotations = variables.asMap();
assertNotNull(mapOfAnnotations);
assertEquals(0, mapOfAnnotations.size());
try {
mapOfAnnotations.put("something", "can't do this");
fail("Should not be able to mutate the Map returned from Graph.variables.getAnnotations()");
} catch (UnsupportedOperationException ignored) {
}
}
代码示例来源:origin: apache/tinkerpop
/**
* In this case, the feature requirement for sideEffects is checked, because it means that at least one aspect of
* sideEffects is supported so we need to test other features to make sure they work properly.
*/
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
public void shouldEnableFeatureOnGraphIfNotEnabled() throws Exception {
assumeThat(graph.features().supports(Graph.Features.VariableFeatures.class, featureName), is(false));
try {
final Graph.Variables variables = graph.variables();
variables.set("aKey", value);
fail(String.format(INVALID_FEATURE_SPECIFICATION, Graph.Features.VariableFeatures.class.getSimpleName(), featureName));
} catch (Exception e) {
validateException(Graph.Variables.Exceptions.dataTypeOfVariableValueNotSupported(value), e);
}
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_STRING_VALUES)
public void shouldHoldVariableString() {
final Graph.Variables variables = graph.variables();
variables.set("test1", "1");
variables.set("test2", "2");
variables.set("test3", "3");
tryCommit(graph, graph -> {
final Map<String, Object> m = variables.asMap();
assertEquals("1", m.get("test1"));
assertEquals("2", m.get("test2"));
assertEquals("3", m.get("test3"));
});
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_LONG_VALUES)
public void shouldHoldVariableLong() {
final Graph.Variables variables = graph.variables();
variables.set("test1", 1l);
variables.set("test2", 2l);
variables.set("test3", 3l);
tryCommit(graph, graph -> {
final Map<String, Object> m = variables.asMap();
assertEquals(1l, m.get("test1"));
assertEquals(2l, m.get("test2"));
assertEquals(3l, m.get("test3"));
});
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_INTEGER_VALUES)
public void shouldHoldVariableInteger() {
final Graph.Variables variables = graph.variables();
variables.set("test1", 1);
variables.set("test2", 2);
variables.set("test3", 3);
tryCommit(graph, graph -> {
final Map<String, Object> m = variables.asMap();
assertEquals(1, m.get("test1"));
assertEquals(2, m.get("test2"));
assertEquals(3, m.get("test3"));
});
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_STRING_VALUES)
public void testVariables() {
final Graph.Variables variables = graph.variables();
variables.set("xo", "test1");
variables.set("yo", "test2");
variables.set("zo", "test3");
tryCommit(graph, graph -> assertEquals(StringFactory.graphVariablesString(variables), variables.toString()));
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_STRING_VALUES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_INTEGER_VALUES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_LONG_VALUES)
public void shouldHoldVariableMixed() {
final Graph.Variables variables = graph.variables();
variables.set("test1", "1");
variables.set("test2", 2);
variables.set("test3", 3l);
tryCommit(graph, graph -> {
final Map<String, Object> m = variables.asMap();
assertEquals("1", m.get("test1"));
assertEquals(2, m.get("test2"));
assertEquals(3l, m.get("test3"));
});
}
}
代码示例来源:origin: apache/tinkerpop
public void shouldSetValueOnGraph() throws Exception {
assumeThat(graph.features().supports(Graph.Features.VariableFeatures.class, featureName), is(true));
final Graph.Variables variables = graph.variables();
variables.set("aKey", value);
代码示例来源:origin: dstl/baleen
private void loadGraphMetadata(JCas jCas, Graph graph, Optional<Vertex> document) {
if (!document.isPresent()) {
Variables variables = graph.variables();
getGraphMetadata(jCas)
.entrySet()
.stream()
.forEach(e -> variables.set(e.getKey(), e.getValue()));
}
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-graph
private void loadGraphMetadata(JCas jCas, Graph graph, Optional<Vertex> document) {
if (!document.isPresent()) {
Variables variables = graph.variables();
getGraphMetadata(jCas)
.entrySet()
.stream()
.forEach(e -> variables.set(e.getKey(), e.getValue()));
}
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-graph
private void loadDocumentContent(JCas jCas, Graph graph, Optional<Vertex> document) {
if (document.isPresent()) {
document.get().property(FIELD_CONTENT, coerce(jCas.getDocumentText()));
} else {
graph.variables().set(FIELD_CONTENT, jCas.getDocumentText());
}
}
代码示例来源:origin: dstl/baleen
private void loadDocumentContent(JCas jCas, Graph graph, Optional<Vertex> document) {
if (document.isPresent()) {
document.get().property(FIELD_CONTENT, coerce(jCas.getDocumentText()));
} else {
graph.variables().set(FIELD_CONTENT, jCas.getDocumentText());
}
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
/**
* A {@link org.apache.tinkerpop.gremlin.structure.Graph} that does not support {@link org.apache.tinkerpop.gremlin.structure.Graph.Features.VariableFeatures#FEATURE_VARIABLES} must call
* {@link org.apache.tinkerpop.gremlin.structure.Graph.Exceptions#variablesNotSupported()}.
*/
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = FEATURE_VARIABLES, supported = false)
public void shouldSupportMemoryIfAGraphAcceptsMemory() throws Exception {
try {
graph.variables();
fail(String.format(INVALID_FEATURE_SPECIFICATION, Graph.Features.VariableFeatures.class.getSimpleName(), FEATURE_VARIABLES));
} catch (Exception e) {
validateException(Graph.Exceptions.variablesNotSupported(), e);
}
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = FEATURE_VARIABLES)
public void testGraphVariablesSet() throws Exception {
try {
graph.variables().set(key, val);
fail(String.format("Setting an annotation with these arguments [key: %s value: %s] should throw an exception", key, val));
} catch (Exception ex) {
validateException(expectedException, ex);
}
}
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_STRING_VALUES)
public void shouldHoldVariableNone() {
final Graph.Variables variables = graph.variables();
final Map<String, Object> mapOfAnnotations = variables.asMap();
assertNotNull(mapOfAnnotations);
assertEquals(0, mapOfAnnotations.size());
try {
mapOfAnnotations.put("something", "can't do this");
fail("Should not be able to mutate the Map returned from Graph.variables.getAnnotations()");
} catch (UnsupportedOperationException ignored) {
}
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
@Test
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_VARIABLES)
@FeatureRequirement(featureClass = Graph.Features.VariableFeatures.class, feature = Graph.Features.VariableFeatures.FEATURE_STRING_VALUES)
public void testVariables() {
final Graph.Variables variables = graph.variables();
variables.set("xo", "test1");
variables.set("yo", "test2");
variables.set("zo", "test3");
tryCommit(graph, graph -> assertEquals(StringFactory.graphVariablesString(variables), variables.toString()));
}
}
代码示例来源:origin: dstl/baleen
@Test
public void testDocumentGraphMetadataHasContentFromJCas() throws UIMAException {
DocumentGraphOptions options = DocumentGraphOptions.builder().withContent(true).build();
DocumentGraphFactory factory = createfactory(options);
JCas jCas = JCasFactory.createJCas();
JCasTestGraphUtil.populateJcas(jCas);
Graph graph = factory.create(jCas);
Variables variables = graph.variables();
assertEquals(JCasTestGraphUtil.CONTENT, variables.get(FIELD_CONTENT).orElse(""));
}
代码示例来源:origin: dstl/baleen
@Test
public void testDocumentGraphCreatesMetadataFromJCas() throws UIMAException {
DocumentGraphOptions options = DocumentGraphOptions.builder().withMeta(true).build();
DocumentGraphFactory factory = createfactory(options);
JCas jCas = JCasFactory.createJCas();
JCasTestGraphUtil.populateJcas(jCas);
Graph graph = factory.create(jCas);
assertMetadata(jCas, graph.variables().asMap());
}
内容来源于网络,如有侵权,请联系作者删除!