|
@@ -206,80 +206,11 @@ public class TestCreateNode {
|
|
|
System.out.println("cost" + (System.currentTimeMillis() - start));
|
|
|
}
|
|
|
|
|
|
- public void saveEdges(List<Edge> edges) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
-
|
|
|
- sb.append("UNWIND {batch} as row ") //
|
|
|
- .append(" WITH split(row.properties.from, '/') AS fromInfo, " //
|
|
|
- + "split(row.properties.to, '/') AS toInfo, row ") //
|
|
|
- .append(" CALL apoc.cypher.doIt(" //
|
|
|
- + "'MATCH (from:`' + fromInfo[0] + '` {id: {fromId}})" //
|
|
|
- + " MATCH (to:`' + toInfo[0] + '` {id: {toId}}) " //
|
|
|
- + " MERGE (from)-[r:`' + row.properties.label + '` {id: {id}}]->(to) " //
|
|
|
- + " SET n += {properties}', " //
|
|
|
- + "{ fromId: row.properties.from, toId: row.properties.to, " //
|
|
|
- + " properties: row.properties, id: row.properties.id }" //
|
|
|
- + ") YIELD value") //
|
|
|
- .append(" RETURN 1 ");
|
|
|
-
|
|
|
- String statement = sb.toString();
|
|
|
-
|
|
|
-// Map<String, Object> params = new HashMap<>();
|
|
|
-// List<Map<String, Object>> batches = new ArrayList<>();
|
|
|
-// for (Edge e : edges) {
|
|
|
-// Map<String, Object> map = new HashMap<>();
|
|
|
-// map.put("id", e.getId());
|
|
|
-// map.put("from", e.getFrom());
|
|
|
-// map.put("to", e.getTo());
|
|
|
-// map.put("properties", e.getProperties());
|
|
|
-// batches.add(map);
|
|
|
-// }
|
|
|
-// params.put("batch", batches);
|
|
|
-//
|
|
|
-// cypher.query(statement, params, null);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
//"CALL apoc.create.relationship(person, row.relType,{status:row.status,percent:row.percent}, company) YIELD rel RETURN count(*) \n" ;
|
|
|
//Procedure apoc.create.relationship has signature: apoc.create.relationship(from :: NODE?, relType :: STRING?, props :: MAP?, to :: NODE?) :: rel :: RELATIONSHIP?
|
|
|
//Procedure apoc.merge.relationship has signature: apoc.merge.relationship(startNode :: NODE?, relationshipType :: STRING?, identProps :: MAP?, props :: MAP?, endNode :: NODE?) :: rel :: RELATIONSHIP?
|
|
|
|
|
|
@Test
|
|
|
- public void sendKafka() {
|
|
|
- String topic = "compamy_relation3";
|
|
|
- Long start = System.currentTimeMillis();
|
|
|
-
|
|
|
-// params.put("companyId", "222");
|
|
|
-// params.put("name", "bbb");
|
|
|
-// String msg = JSON.toJSONString(params);
|
|
|
-// System.out.println(msg);
|
|
|
-// kafkaProduce.produce(topic, msg);
|
|
|
-
|
|
|
-// for (int i = 0; i < 100000; i++) {
|
|
|
-// params.put("companyId", "id" + i);
|
|
|
-// params.put("name", "name" + i);
|
|
|
-// String msg = JSON.toJSONString(params);
|
|
|
-// kafkaProduce.produce(topic, msg);
|
|
|
-// }
|
|
|
-// System.out.println("cost: " + (System.currentTimeMillis() - start));
|
|
|
-
|
|
|
- for (int i = 200000; i <= 300000; i++) {
|
|
|
- Map<String, Object> m1 = new HashMap<>();
|
|
|
- m1.put("companyId", "companyId" + i);
|
|
|
- m1.put("personId", "personId" + i);
|
|
|
- m1.put("companyName", "companyName_7_" + i);
|
|
|
- m1.put("personName", "personName_7_" + i);
|
|
|
- m1.put("relType", "relType_7_" + i + 2);
|
|
|
- m1.put("status", "0");
|
|
|
- m1.put("percent", i * 0.5 + "");
|
|
|
- m1.put("rid", i * 3 + "");
|
|
|
- String msg = JSON.toJSONString(m1);
|
|
|
- System.out.println(msg);
|
|
|
- kafkaProduce.produce(topic, msg);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
public void sendKafkaTest() {
|
|
|
String topic = "test";
|
|
|
for (int i = 260; i <= 270; i++) {
|
|
@@ -317,7 +248,7 @@ public class TestCreateNode {
|
|
|
public void sendKafkaHolderV1() {
|
|
|
//String topic = "inc_holder_relation_v1";
|
|
|
String topic = "inc_node_relation_union";
|
|
|
- for (int i = 1; i <= 10; i++) {
|
|
|
+ for (int i = 1; i <= 1000; i++) {
|
|
|
HashMap<String, Object> m1 = new HashMap<>();
|
|
|
m1.put("start_id", "start_id" + i);
|
|
|
m1.put("end_id", "end_id" + i);
|
|
@@ -356,7 +287,7 @@ public class TestCreateNode {
|
|
|
public void sendKafkaLegalEntityV1() {
|
|
|
//String topic = "inc_legal_entity_relation_v1";
|
|
|
String topic = "inc_node_relation_union";
|
|
|
- for (int i = 20000; i <= 200000; i++) {
|
|
|
+ for (int i = 1; i <= 1000; i++) {
|
|
|
HashMap<String, Object> m1 = new HashMap<>();
|
|
|
m1.put("start_id", "start_id" + i);
|
|
|
m1.put("end_id", "end_id" + i);
|
|
@@ -410,7 +341,7 @@ public class TestCreateNode {
|
|
|
@Test
|
|
|
public void sendKafkStaff1() {
|
|
|
String topic = "inc_node_relation_union";
|
|
|
- String s = "C:\\Users\\batmr\\Downloads\\8ec932c2-eb74-42c0-bfb0-4e2779383af7.csv";
|
|
|
+ String s = "C:\\Users\\batmr\\Downloads\\35c14491-fbbd-4aa4-b76c-93017b13dc90.csv";
|
|
|
CsvReader reader = CsvUtil.getReader();
|
|
|
//从文件中读取CSV数据
|
|
|
CsvData data = reader.read(FileUtil.file(s));
|
|
@@ -425,5 +356,17 @@ public class TestCreateNode {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void sendKafkStaff2() {
|
|
|
+ String topic = "inc_node_relation_union";
|
|
|
+ String s = "D:\\Soft\\odpscmd_public\\bin\\tmp_xf_test4.csv";
|
|
|
+ FileReader fileReader = new FileReader(s);
|
|
|
+ List<String> lists = fileReader.readLines();
|
|
|
+ for (String mesaage : lists) {
|
|
|
+ kafkaProduce.produce(topic, mesaage);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|