private <T extends Element> void createUniqueKeyIndex(final KeyIndexableGraph kig, final String key, Class<T> elementClass) { Parameter[] params = NO_PARAMS; // supported index parameters depend on underlying graph implementation: if (kig instanceof OrientBaseGraph) { params = new Parameter[] { new Parameter("type", "unique") }; } createKeyIndex(kig, key, elementClass, params); }
private static Map<String, String> generateParameterMap(final Parameter<Object, Object>... indexParameters) { final Map<String, String> map = new HashMap<String, String>(); for (final Parameter<Object, Object> parameter : indexParameters) { map.put(parameter.getKey().toString(), parameter.getValue().toString()); } return map; }
private static Map<String, String> generateParameterMap(final Parameter<Object, Object>... indexParameters) { final Map<String, String> map = new HashMap<String, String>(); for (final Parameter<Object, Object> parameter : indexParameters) { map.put(parameter.getKey().toString(), parameter.getValue().toString()); } return map; }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Object call(final OrientBaseGraph g) { OrientVertexType v = g.getVertexBaseType(); if(!v.existsProperty(NODE_ID)) { // TODO fix schema detection hack later v.createProperty(NODE_ID, OType.INTEGER); g.createKeyIndex(NODE_ID, Vertex.class, new Parameter("type", "UNIQUE_HASH_INDEX"), new Parameter( "keytype", "INTEGER")); v.createEdgeProperty(Direction.OUT, SIMILAR, OType.LINKBAG); v.createEdgeProperty(Direction.IN, SIMILAR, OType.LINKBAG); OrientEdgeType similar = g.createEdgeType(SIMILAR); similar.createProperty("out", OType.LINK, v); similar.createProperty("in", OType.LINK, v); g.createKeyIndex(COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"), new Parameter("keytype", "INTEGER")); g.createKeyIndex(NODE_COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"), new Parameter("keytype", "INTEGER")); } return null; } });
private static Map<String, String> generateParameterMap(final Parameter<Object, Object>... indexParameters) { final Map<String, String> map = new HashMap<String, String>(); for (final Parameter<Object, Object> parameter : indexParameters) { map.put(parameter.getKey().toString(), parameter.getValue().toString()); } return map; }
public BrainGraph(final KeyIndexableGraph baseGraph) { IdGraph.IdFactory f = new ExtendoIdFactory(); graph = new IdGraph<KeyIndexableGraph>(baseGraph); graph.setVertexIdFactory(f); graph.setEdgeIdFactory(f); framedGraph = createFramedGraph(graph); searchIndex = graph.getIndex("search", Vertex.class); if (null == searchIndex) { try { Class.forName("org.neo4j.index.impl.lucene.LowerCaseKeywordAnalyzer"); LOGGER.info("creating fulltext search index"); searchIndex = graph.createIndex("search", Vertex.class, new Parameter("analyzer", LowerCaseKeywordAnalyzer.class.getName())); } catch (ClassNotFoundException e) { LOGGER.warning("fulltext search not available"); } } if (!graph.getIndexedKeys(Vertex.class).contains(Extendo.ALIAS)) { LOGGER.info("creating key index for 'alias' property"); graph.createKeyIndex(Extendo.ALIAS, Vertex.class); } }
public boolean equals(Object object) { if (object.getClass().equals(Parameter.class)) { final Object otherKey = ((Parameter) object).getKey(); final Object otherValue = ((Parameter) object).getValue(); if (otherKey == null) { if (key != null) return false; } else { if (!otherKey.equals(key)) return false; } if (otherValue == null) { if (value != null) return false; } else { if (!otherValue.equals(value)) return false; } return true; } return false; }
public GraphContext(File diskCache) { File lucene = new File(diskCache, "graphsearch"); FileUtils.deleteQuietly(lucene); File berkley = new File(diskCache, "graph"); FileUtils.deleteQuietly(berkley); Configuration conf = new BaseConfiguration(); conf.setProperty("storage.directory", berkley.getAbsolutePath()); conf.setProperty("storage.backend", "berkeleyje"); conf.setProperty("storage.index.search.backend", "lucene"); conf.setProperty("storage.index.search.directory", lucene.getAbsolutePath()); graph = TitanFactory.open(conf); graph.createKeyIndex("qualifiedName", Vertex.class, new Parameter<String, String>("type", "UNIQUE")); batch = new BatchGraph<TitanGraph>(graph, 1000L); FramedGraphFactory factory = new FramedGraphFactory( new TypedGraphModuleBuilder() .withClass(JavaClassFacet.class) .withClass(org.jboss.windup.graph.model.resource.File.class) .withClass(XmlFacet.class) .withClass(Meta.class) .withClass(JBossModuleMeta.class) .build() ); framed = factory.create(graph); }
if (p.getKey().equals("type")) indexType = p.getValue().toString().toUpperCase(Locale.ENGLISH); else if (p.getKey().equals("keytype")) keyType = OType.valueOf(p.getValue().toString().toUpperCase(Locale.ENGLISH)); else if (p.getKey().equals("class")) className = p.getValue().toString(); else if (p.getKey().equals("collate")) collate = p.getValue().toString(); else if (p.getKey().toString().startsWith("metadata.")) { if (metadata == null) metadata = new ODocument(); metadata.field(p.getKey().toString().substring("metadata.".length()), p.getValue());
public GraphContext(File diskCache) { File lucene = new File(diskCache, "graphsearch"); FileUtils.deleteQuietly(lucene); File berkley = new File(diskCache, "graph"); FileUtils.deleteQuietly(berkley); Configuration conf = new BaseConfiguration(); conf.setProperty("storage.directory", berkley.getAbsolutePath()); conf.setProperty("storage.backend", "berkeleyje"); conf.setProperty("storage.index.search.backend", "lucene"); conf.setProperty("storage.index.search.directory", lucene.getAbsolutePath()); graph = TitanFactory.open(conf); graph.createKeyIndex("qualifiedName", Vertex.class, new Parameter<String, String>("type", "UNIQUE")); batch = new BatchGraph<TitanGraph>(graph, 1000L); FramedGraphFactory factory = new FramedGraphFactory( new TypedGraphModuleBuilder() .withClass(JavaClassFacet.class) .withClass(org.jboss.windup.graph.model.resource.File.class) .withClass(XmlFacet.class) .withClass(Meta.class) .withClass(JBossModuleMeta.class) .build() ); framed = factory.create(graph); }
config.createProperty("createDate", OType.DATETIME); config.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("configId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Config")); role.createProperty("createDate", OType.DATETIME); role.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("roleId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Role")); user.createProperty("createDate", OType.DATETIME); user.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("userId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "User")); graph.createKeyIndex("email", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "User")); client.createProperty("createDate", OType.DATETIME); client.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("clientId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Client")); event.createProperty("data", OType.EMBEDDEDMAP); event.createProperty("createDate", OType.DATETIME); graph.createKeyIndex("eventId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Event")); rule.createProperty("createDate", OType.DATETIME); rule.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("ruleClass", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Rule")); menuItem.createProperty("createDate", OType.DATETIME); menuItem.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("menuItemId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "MenuItem"));