This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BaseConfiguration conf = new BaseConfiguration(); | |
conf.setProperty("graph.unique-instance-id", UUID.randomUUID().toString()); | |
conf.setProperty("schema.default", "none"); | |
conf.setProperty("gremlin.newInstance", "com.thinkaurelius.titan.core.TitanFactory"); | |
conf.setProperty("ids.block-size", 100); | |
conf.setProperty("storage.setup-wait", 60000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GraphTraversalSource traversal = titanGraph.traversal(); | |
long startSimilarQuery = System.currentTimeMillis(); | |
List<Vertex> similars = traversal.V() | |
.has(USER_LABEL, USER_ID_PROPERTY, userId) | |
.outE(SIMILAR_RELATIONSHIP) | |
.order() | |
.by(new Comparator<Edge>() { | |
@Override | |
public int compare(Edge o1, Edge o2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graph.tx().rollback(); | |
TitanManagement titanManagement = graph.openManagement(); | |
titanManagement.makeVertexLabel(USER_LABEL).make(); | |
titanManagement.makeEdgeLabel(LIKE_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make(); | |
titanManagement.makeEdgeLabel(DISLIKE_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make(); | |
titanManagement.makeEdgeLabel(BLOCK_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make(); | |
titanManagement.makeEdgeLabel(MATCH_RELATIONSHIP).multiplicity(Multiplicity.MULTI).make(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.angrytit; | |
import com.google.common.collect.Lists; | |
import com.opencsv.CSVReader; | |
import com.thinkaurelius.titan.core.TitanGraph; | |
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; | |
import org.apache.tinkerpop.gremlin.structure.Vertex; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public TitanGraph graph() { | |
BaseConfiguration conf = new BaseConfiguration(); | |
conf.setProperty("storage.batch-loading", true); | |
conf.setProperty("schema.default", "none"); | |
conf.setProperty("gremlin.graph", "com.thinkaurelius.titan.core.TitanFactory"); | |
conf.setProperty("ids.block-size", 1000000); | |
conf.setProperty("storage.setup-wait", 60000); |