org.unlaxer.jaddress.gremlin.GremlinIndexer Maven / Gradle / Ivy
package org.unlaxer.jaddress.gremlin;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
import org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph.Features;
import org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexPropertyFeatures;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.unlaxer.jaddress.entity.standard.郵便番号;
import org.unlaxer.jaddress.entity.standard.階層要素;
import org.unlaxer.jaddress.parser.AddressElement;
import org.unlaxer.jaddress.parser.AddressParser;
import org.unlaxer.jaddress.parser.AddressParserImpl;
import org.unlaxer.jaddress.parser.BlockHierarchyResolver.BlockPatternResolverResult;
import org.unlaxer.jaddress.parser.BuildingHierarchyResolver.BuildingHierarchyResolverResult;
import org.unlaxer.jaddress.parser.BuildingHierarchyResolver2.BuildingHierarchyResolverResult2;
import org.unlaxer.jaddress.parser.DataAccessContext;
import org.unlaxer.jaddress.parser.DataAccessContextImpl;
public class GremlinIndexer {
public static void main(String[] args) throws Exception {
// load();
test();
}
private static void test() {
try (DriverRemoteConnection conn = DriverRemoteConnection.using("localhost", 8182, "g");
GraphTraversalSource g = AnonymousTraversalSource.traversal().withRemote(conn);) {
GremlinUtil gremlinUtil = new GremlinUtil(g);
// propertyArrayTest(g);
// searchBuildings(gremlinUtil);
searchBuildings2(gremlinUtil);
// searchBlockPattern(gremlinUtil);
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(0);
}
}
private static void load() {
DataAccessContext dataAccessContext = new DataAccessContextImpl();
AddressParser addressParser = new AddressParserImpl();
try (DriverRemoteConnection conn = DriverRemoteConnection.using("localhost", 8182, "g");
GraphTraversalSource g = AnonymousTraversalSource.traversal().withRemote(conn);) {
GremlinUtil gremlinUtil = new GremlinUtil(g);
gremlinUtil.truncate();
DataLoader2 dataLoader2 = new DataLoader2();
dataLoader2.load(g , dataAccessContext , addressParser);
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(0);
}
}
private static void propertyArrayTest(GraphTraversalSource g) {
Features features =g.getGraph().features();
VertexPropertyFeatures f = features.vertex().properties();
System.out.println(f.supportsIntegerArrayValues());
addTest(g, "a1", 1);
addTest(g, "a1", 2);
addTest(g, "a2", 3);
g.V().propertyMap().toStream().forEach(c -> {
c.entrySet().stream().forEach(e -> {
System.out.println(e.getKey() + ":" + e.getValue());
});
});
}
private static void addTest(GraphTraversalSource g, String label, Integer value) {
GraphTraversal g0 = g.V().hasLabel(label)//
.has("element", "a")//
// .has("value", value)//
;
Vertex v1;
if (g0.hasNext()) {
Object val = g.V(1).values("value").toList();
System.out.println(val);
v1 = g0.next();
List © 2015 - 2025 Weber Informatics LLC | Privacy Policy