• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OrientEdgeType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.tinkerpop.blueprints.impls.orient.OrientEdgeType的典型用法代码示例。如果您正苦于以下问题:Java OrientEdgeType类的具体用法?Java OrientEdgeType怎么用?Java OrientEdgeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OrientEdgeType类属于com.tinkerpop.blueprints.impls.orient包,在下文中一共展示了OrientEdgeType类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addEdgeType

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
private static void addEdgeType(OrientBaseGraph graph, Class<?> clasz) {

			if (clasz.isAnnotationPresent(DatabaseEdge.class)) {

				//DatabaseEdge classAnotation = clasz.getAnnotation(DatabaseEdge.class);

				OrientEdgeType oClass = graph.getEdgeType(clasz.getSimpleName());

				OrientEdgeType oClassParent = graph.getEdgeType(clasz.getSuperclass().getSimpleName());
				if (clasz.getSuperclass().getSimpleName().equals(Object.class.getSimpleName())) {
					oClassParent = graph.getEdgeBaseType();
				}

				if (oClass == null) {
					logger.warn("Add Edge @" + clasz.getSimpleName() + " child of @" + oClassParent);
					graph.createEdgeType(clasz.getSimpleName(), oClassParent.getName());
				} else {
					if (logger.isDebugEnabled())
						logger.debug("Edge @" + clasz.getSimpleName() + " exist, child of @" + oClassParent);
				}

			}

		}
 
开发者ID:e-baloo,项目名称:it-keeps,代码行数:25,代码来源:DatabaseFactory.java


示例2: setUp

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
@Override
public void setUp() {
  OGlobalConfiguration.USE_WAL.setValue(true);

  super.setUp();
  final OrientVertexType v1 = graph.createVertexType("V1");
  final OrientVertexType v2 = graph.createVertexType("V2");

  final OrientEdgeType edgeType = graph.createEdgeType("Friend");
  edgeType.createProperty("in", OType.LINK, v2);
  edgeType.createProperty("out", OType.LINK, v1);

  // ASSURE NOT DUPLICATES
  edgeType.createIndex("out_in", OClass.INDEX_TYPE.UNIQUE, "in", "out");

  graph.addVertex("class:V2").setProperty("name", "Luca");
  graph.commit();
}
 
开发者ID:orientechnologies,项目名称:orientdb-etl,代码行数:19,代码来源:OEdgeTransformerTest.java


示例3: addCustomEdgeIndex

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
@Override
public void addCustomEdgeIndex(String label, String indexPostfix, String... fields) {
	OrientGraphNoTx noTx = factory.getNoTx();
	try {
		OrientEdgeType e = noTx.getEdgeType(label);
		if (e == null) {
			throw new RuntimeException("Could not find edge type {" + label + "}. Create edge type before creating indices.");
		}

		for (String key : fields) {
			if (e.getProperty(key) == null) {
				OType type = OType.STRING;
				if (key.equals("out") || key.equals("in")) {
					type = OType.LINK;
				}
				e.createProperty(key, type);
			}
		}
		String name = "e." + label + "_" + indexPostfix;
		name = name.toLowerCase();
		if (fields.length != 0 && e.getClassIndex(name) == null) {
			e.createIndex(name, OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, fields);
		}

	} finally {
		noTx.shutdown();
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:29,代码来源:OrientDBDatabase.java


示例4: edgeLookup

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
@Override
public List<Object> edgeLookup(String edgeLabel, String indexPostfix, Object key) {
	OrientBaseGraph orientBaseGraph = unwrapCurrentGraph();
	List<Object> ids = new ArrayList<>();

	// Load the edge type in order to access the indices of the edge
	OrientEdgeType edgeType = orientBaseGraph.getEdgeType(edgeLabel);
	if (edgeType != null) {
		// Fetch the required index
		OIndex<?> index = edgeType.getClassIndex("e." + edgeLabel.toLowerCase() + "_" + indexPostfix);
		if (index != null) {
			// Iterate over the sb-tree index entries
			OIndexCursor cursor = index.iterateEntriesMajor(new OCompositeKey(key), true, false);
			while (cursor.hasNext()) {
				Entry<Object, OIdentifiable> entry = cursor.nextEntry();
				if (entry != null) {
					OCompositeKey entryKey = (OCompositeKey) entry.getKey();
					// The index returns all entries. We thus need to filter it manually
					if (entryKey.getKeys().get(1).equals(key)) {
						Object inId = entryKey.getKeys().get(0);
						// Only add the inbound vertex id to the list of ids
						ids.add(inId);
					}
				} else {
					break;
				}
			}
		}
	}
	return ids;
}
 
开发者ID:gentics,项目名称:mesh,代码行数:32,代码来源:OrientDBDatabase.java


示例5: addEdgeType

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
@Override
public void addEdgeType(String label, Class<?> superClazzOfEdge, String... stringPropertyKeys) {
	if (log.isDebugEnabled()) {
		log.debug("Adding edge type for label {" + label + "}");
	}
	OrientGraphNoTx noTx = factory.getNoTx();
	try {
		OrientEdgeType e = noTx.getEdgeType(label);
		if (e == null) {
			String superClazz = "E";
			if (superClazzOfEdge != null) {
				superClazz = superClazzOfEdge.getSimpleName();
			}
			e = noTx.createEdgeType(label, superClazz);
		} else {
			// Update the existing edge type and set the super class
			if (superClazzOfEdge != null) {
				OrientEdgeType superType = noTx.getEdgeType(superClazzOfEdge.getSimpleName());
				if (superType == null) {
					throw new RuntimeException("The supertype for edges with label {" + label + "} can't be set since the supertype {"
							+ superClazzOfEdge.getSimpleName() + "} was not yet added to orientdb.");
				}
				e.setSuperClass(superType);
			}
		}

		for (String key : stringPropertyKeys) {
			if (e.getProperty(key) == null) {
				e.createProperty(key, OType.STRING);
			}
		}
	} finally {
		noTx.shutdown();
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:36,代码来源:OrientDBDatabase.java


示例6: setupTypesAndIndices

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
private static void setupTypesAndIndices(OrientGraphFactory factory2) {
	OrientGraph g = factory.getTx();
	try {
		// g.setUseClassForEdgeLabel(true);
		g.setUseLightweightEdges(false);
		g.setUseVertexFieldsForEdgeLabels(false);
	} finally {
		g.shutdown();
	}

	try {
		g = factory.getTx();

		OrientEdgeType e = g.createEdgeType("HAS_ITEM");
		e.createProperty("in", OType.LINK);
		e.createProperty("out", OType.LINK);
		e.createIndex("e.has_item", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "out", "in");

		OrientVertexType v = g.createVertexType("root", "V");
		v.createProperty("name", OType.STRING);

		v = g.createVertexType("item", "V");
		v.createProperty("name", OType.STRING);
		v.createIndex("item", OClass.INDEX_TYPE.FULLTEXT_HASH_INDEX, "name");

	} finally {
		g.shutdown();
	}

}
 
开发者ID:gentics,项目名称:mesh,代码行数:31,代码来源:EdgeIndexPerformanceTest.java


示例7: createSchema

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
protected void createSchema()
{
    graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
        @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;
        }
    });
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:29,代码来源:OrientGraphDatabase.java


示例8: addEdgeIndex

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
@Override
public void addEdgeIndex(String label, boolean includeInOut, boolean includeIn, boolean includeOut, String... extraFields) {
	OrientGraphNoTx noTx = factory.getNoTx();
	try {
		OrientEdgeType e = noTx.getEdgeType(label);
		if (e == null) {
			e = noTx.createEdgeType(label);
		}
		if ((includeIn || includeInOut) && e.getProperty("in") == null) {
			e.createProperty("in", OType.LINK);
		}
		if ((includeOut || includeInOut) && e.getProperty("out") == null) {
			e.createProperty("out", OType.LINK);
		}
		for (String key : extraFields) {
			if (e.getProperty(key) == null) {
				e.createProperty(key, OType.STRING);
			}
		}
		String indexName = "e." + label.toLowerCase();
		String name = indexName + "_inout";
		if (includeInOut && e.getClassIndex(name) == null) {
			e.createIndex(name, OClass.INDEX_TYPE.NOTUNIQUE, new String[] { "in", "out" });
		}
		name = indexName + "_out";
		if (includeOut && e.getClassIndex(name) == null) {
			e.createIndex(name, OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, new String[] { "out" });
		}
		name = indexName + "_in";
		if (includeIn && e.getClassIndex(name) == null) {
			e.createIndex(name, OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, new String[] { "in" });
		}
		name = indexName + "_extra";
		if (extraFields.length != 0 && e.getClassIndex(name) == null) {
			e.createIndex(name, OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, extraFields);
		}

	} finally {
		noTx.shutdown();
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:42,代码来源:OrientDBDatabase.java


示例9: rateMovies

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
public void rateMovies() throws IOException {
    Logger.log("Connecting Movies with Users (rates).");

    graph.executeOutsideTx(arg -> {

        // drop if exist
        if (graph.getEdgeType("Rate") != null) {
            graph.dropEdgeType("Rate");
        }

        // creating the edge class
        OrientEdgeType edgeClass = graph.createEdgeType("Rate");
        edgeClass.createProperty("rating", OType.FLOAT);
        edgeClass.createProperty("timestamp", OType.INTEGER);

        return null;
    });

    // get lines as stream
    Stream<String> lines = Files.lines(Paths.get(Config.MOVIELENS_PATH + "ratings.csv"));

    lines.skip(1).forEach(line -> {
        // split by comma
        String[] tokens = line.split(",", -1);
        Integer userId = Integer.parseInt(tokens[0]);
        Integer movieId = Integer.parseInt(tokens[1]);
        Float rating = Float.parseFloat(tokens[2]);
        Integer timestamp = Integer.parseInt(tokens[3]);

        Iterable<OrientVertex> moviesRs = graph.command(new OSQLSynchQuery<OrientVertex>(
                String.format("select from Movie where movieId = %d", movieId)
        )).execute();

        Iterable<OrientVertex> userRs = graph.command(new OSQLSynchQuery<OrientVertex>(
                String.format("select from User where userId = %d", userId)
        )).execute();

        if (moviesRs.iterator().hasNext() && userRs.iterator().hasNext()) {
            OrientVertex movieVertex = moviesRs.iterator().next();
            OrientVertex userVertex = userRs.iterator().next();
            userVertex.addEdge("Rate", movieVertex, new Object[]{"rating", rating, "timestamp", timestamp});
        }

        // worked faster for me
        if (Worker.randInt(1, 20) == 5) {
            graph.commit();
        }
    });

    graph.commit();
    Logger.log("Movies and Users are connected. (rates)");
}
 
开发者ID:warriorkitty,项目名称:orientlens,代码行数:53,代码来源:Worker.java


示例10: tagMovies

import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; //导入依赖的package包/类
public void tagMovies() throws IOException {
    Logger.log("Tagging movies.");

    graph.executeOutsideTx(arg -> {

        // drop if exist
        if (graph.getEdgeType("Tag") != null) {
            graph.dropEdgeType("Tag");
        }

        // creating the edge class
        OrientEdgeType edgeClass = graph.createEdgeType("Tag");
        edgeClass.createProperty("tag", OType.STRING);
        edgeClass.createProperty("timestamp", OType.INTEGER);

        return null;
    });

    // get lines as stream
    Stream<String> lines = Files.lines(Paths.get(Config.MOVIELENS_PATH + "tags.csv"));

    lines.skip(1).forEach(line -> {
        // split by comma
        String[] tokens = line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1);
        Integer userId = Integer.parseInt(tokens[0]);
        Integer movieId = Integer.parseInt(tokens[1]);
        String tag = tokens[2].replaceAll("\\\"", "");
        Integer timestamp = Integer.parseInt(tokens[3]);

        Iterable<OrientVertex> moviesRs = graph.command(new OSQLSynchQuery<OrientVertex>(
                String.format("select from Movie where movieId = %d", movieId)
        )).execute();

        Iterable<OrientVertex> userRs = graph.command(new OSQLSynchQuery<OrientVertex>(
                String.format("select from User where userId = %d", userId)
        )).execute();

        if (moviesRs.iterator().hasNext() && userRs.iterator().hasNext()) {
            OrientVertex movieVertex = moviesRs.iterator().next();
            OrientVertex userVertex = userRs.iterator().next();
            userVertex.addEdge("Tag", movieVertex, new Object[]{"tag", tag, "timestamp", timestamp});
        }

        // worked faster for me
        if (Worker.randInt(1, 20) == 5) {
            graph.commit();
        }
    });

    graph.commit();
    Logger.log("Tagging finished.");
}
 
开发者ID:warriorkitty,项目名称:orientlens,代码行数:53,代码来源:Worker.java



注:本文中的com.tinkerpop.blueprints.impls.orient.OrientEdgeType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConnectorTableLayoutResult类代码示例发布时间:2022-05-23
下一篇:
Java ActivityThread类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap