本文整理汇总了Java中com.tinkerpop.pipes.transform.TransformFunctionPipe类的典型用法代码示例。如果您正苦于以下问题:Java TransformFunctionPipe类的具体用法?Java TransformFunctionPipe怎么用?Java TransformFunctionPipe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransformFunctionPipe类属于com.tinkerpop.pipes.transform包,在下文中一共展示了TransformFunctionPipe类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTagProjection
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private RelationProjection getTagProjection() {
Relation traitRelation = new TagRelation();
RelationProjection tagProjection = new RelationProjection("tags", Collections.singleton("name"),
traitRelation, Projection.Cardinality.MULTIPLE);
tagProjection.addPipe(new TransformFunctionPipe<>(
new PipeFunction<Collection<ProjectionResult>, Collection<ProjectionResult>>() {
@Override
public Collection<ProjectionResult> compute(Collection<ProjectionResult> results) {
for (ProjectionResult result : results) {
for (Map<String, Object> properties : result.getPropertyMaps()) {
properties.put("href", String.format("v1/entities/%s/tags/%s",
result.getStartingVertex().getProperty("id"), properties.get("name")));
}
}
return results;
}
}));
return tagProjection;
}
示例2: getDefaultRelationProjection
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private RelationProjection getDefaultRelationProjection() {
Relation genericRelation = new GenericRelation(this);
RelationProjection relationProjection = new RelationProjection(
"relations",
Arrays.asList("type", "id", "name"),
genericRelation, Projection.Cardinality.MULTIPLE);
relationProjection.addPipe(new TransformFunctionPipe<>(
new PipeFunction<Collection<ProjectionResult>, Collection<ProjectionResult>>() {
@Override
public Collection<ProjectionResult> compute(Collection<ProjectionResult> results) {
for (ProjectionResult result : results) {
for (Map<String, Object> properties : result.getPropertyMaps()) {
properties.put("href", String.format("v1/entities/%s", properties.get("id")));
}
}
return results;
}
}));
return relationProjection;
}
示例3: getHierarchyProjection
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getHierarchyProjection() {
final String projectionName = "hierarchy";
return new Projection(projectionName, Projection.Cardinality.SINGLE,
new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
@Override
public Collection<ProjectionResult> compute(VertexWrapper start) {
Map<String, Object> map = new TreeMap<>(new ResourceComparator());
TermPath termPath = new TermPath(start.getVertex().<String>getProperty(
Constants.ENTITY_TYPE_PROPERTY_KEY));
map.put("path", termPath.getPath());
map.put("short_name", termPath.getShortName());
map.put("taxonomy", termPath.getTaxonomyName());
return Collections.singleton(new ProjectionResult(projectionName, start,
Collections.singleton(map)));
}
}));
}
示例4: getTermProjection
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getTermProjection() {
return new Projection("term", Projection.Cardinality.SINGLE,
new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
@Override
public Collection<ProjectionResult> compute(VertexWrapper start) {
Map<String, Object> map = new TreeMap<>(new ResourceComparator());
StringBuilder sb = new StringBuilder();
sb.append("v1/taxonomies/");
String fullyQualifiedName = start.getVertex().getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
String[] paths = fullyQualifiedName.split("\\.");
// first path segment is the taxonomy
sb.append(paths[0]);
for (int i = 1; i < paths.length; ++i) {
String path = paths[i];
if (path != null && !path.isEmpty()) {
sb.append("/terms/");
sb.append(path);
}
}
map.put("href", sb.toString());
return Collections.singleton(new ProjectionResult("term", start,
Collections.singleton(map)));
}
}));
}
示例5: getSubTermProjection
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getSubTermProjection() {
//todo: combine with other term projections
final String termsProjectionName = "terms";
return new Projection(termsProjectionName, Projection.Cardinality.SINGLE,
new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
@Override
public Collection<ProjectionResult> compute(VertexWrapper start) {
Map<String, Object> map = new TreeMap<>(new ResourceComparator());
StringBuilder sb = new StringBuilder();
sb.append("v1/taxonomies/");
TermPath termPath = new TermPath(start.getVertex().<String>getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY));
String[] paths = termPath.getPathSegments();
sb.append(termPath.getTaxonomyName());
for (String path : paths) {
//todo: shouldn't need to check for null or empty after TermPath addition
if (path != null && !path.isEmpty()) {
sb.append("/terms/");
sb.append(path);
}
}
sb.append("/terms");
map.put("href", sb.toString());
return Collections.singleton(new ProjectionResult(termsProjectionName, start,
Collections.singleton(map)));
}
}));
}
示例6: getTermsProjection
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getTermsProjection() {
final String termsProjectionName = "terms";
return new Projection(termsProjectionName, Projection.Cardinality.SINGLE,
new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
private String baseHref = "v1/taxonomies/";
@Override
public Collection<ProjectionResult> compute(VertexWrapper v) {
Map<String, Object> map = new HashMap<>();
map.put("href", baseHref + v.getProperty("name") + "/terms");
return Collections.singleton(new ProjectionResult(termsProjectionName, v,
Collections.singleton(map)));
}
}));
}
示例7: EnricherPipeline
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public EnricherPipeline(EnricherConfig... configs) {
super();
// Create Graph objects from individual statements.
GroupByPipe<Statement, URI, Statement> groupByPipe = new GroupByPipe<Statement, URI, Statement>(
new StatementKeyFunction(),
new StatementValueFunction());
Pipeline<Statement, Graph> groupingPipeline = new Pipeline<Statement, Graph>();
groupingPipeline.addPipe(groupByPipe);
groupingPipeline.addPipe(new SideEffectCapPipe<Statement, Map<URI, List<Statement>>>(groupByPipe));
groupingPipeline.addPipe(new ScatterPipe<Map<URI, List<Statement>>, Entry<URI, List<Statement>>>());
groupingPipeline.addPipe(new TransformFunctionPipe<Entry<URI, List<Statement>>, NamedGraph>(new BuildNamedGraphPipeFunction()));
this.addPipe(groupingPipeline);
List<Pipe> enrichers = new ArrayList<Pipe>();
for (EnricherConfig config : configs) {
enrichers.add(EnricherFactory.getInstance(config));
}
// Send incoming data through all enricher instances.
CopySplitPipe<NamedGraph> enricherPipe = new CopySplitPipe<NamedGraph>(enrichers);
FairMergePipe<List<Statement>> mergerPipe = new FairMergePipe<List<Statement>>(enricherPipe.getPipes());
this.addPipe(enricherPipe);
this.addPipe(mergerPipe);
this.addPipe(new ScatterPipe<List<Statement>, Statement>());
}
示例8: transform
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
public <T> PipesPipeline<S, T> transform(final PipeFunction<E, T> function) {
return this.add(new TransformFunctionPipe(FluentUtility.prepareFunction(this.asMap, function)));
}
示例9: transform
import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
/**
* Add a TransformFunctionPipe to the end of the Pipeline.
* Given an input, the provided function is computed on the input and the output of that function is emitted.
*
* @param function the transformation function of the pipe
* @return the extended Pipeline
*/
public <T> GremlinPipeline<S, T> transform(final PipeFunction<E, T> function) {
return this.add(new TransformFunctionPipe(FluentUtility.prepareFunction(this.asMap, function)));
}