调整代码
This commit is contained in:
		
							parent
							
								
									23490f8993
								
							
						
					
					
						commit
						9f1f634095
					
				| 
						 | 
					@ -68,15 +68,8 @@ public class GraphCommonService {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            return new SessionPool(nebulaGraphProperties.getMaxConnSize(), nebulaGraphProperties.getMinConnsSize(), nebulaGraphProperties.getHostAddresses(),
 | 
					            return new SessionPool(nebulaGraphProperties.getMaxConnSize(), nebulaGraphProperties.getMinConnsSize(), nebulaGraphProperties.getHostAddresses(),
 | 
				
			||||||
                    nebulaGraphProperties.getUserName(), nebulaGraphProperties.getPassword());
 | 
					                    nebulaGraphProperties.getUserName(), nebulaGraphProperties.getPassword());
 | 
				
			||||||
        } catch (UnknownHostException e) {
 | 
					        } catch (UnknownHostException | IOErrorException | ClientServerIncompatibleException | AuthFailedException |
 | 
				
			||||||
            throw new RuntimeException(e);
 | 
					                 NotValidConnectionException e) {
 | 
				
			||||||
        } catch (IOErrorException e) {
 | 
					 | 
				
			||||||
            throw new RuntimeException(e);
 | 
					 | 
				
			||||||
        } catch (AuthFailedException e) {
 | 
					 | 
				
			||||||
            throw new RuntimeException(e);
 | 
					 | 
				
			||||||
        } catch (ClientServerIncompatibleException e) {
 | 
					 | 
				
			||||||
            throw new RuntimeException(e);
 | 
					 | 
				
			||||||
        } catch (NotValidConnectionException e) {
 | 
					 | 
				
			||||||
            throw new RuntimeException(e);
 | 
					            throw new RuntimeException(e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,26 +82,18 @@ public class RelationCompletion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while (true) {
 | 
					        while (true) {
 | 
				
			||||||
            for (TagEnum tagEnum : TagEnum.values()) {
 | 
					            for (TagEnum tagEnum : TagEnum.values()) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                Object allGetNum = redisClient.get(ALLNUM);
 | 
					                Object allGetNum = redisClient.get(ALLNUM);
 | 
				
			||||||
                if (allGetNum != null && (Integer) allGetNum >= 5) {
 | 
					                if (allGetNum != null && (Integer) allGetNum >= 5) {
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                String tag = tagEnum.getTag();
 | 
					                String tag = tagEnum.getTag();
 | 
				
			||||||
 | 
					 | 
				
			||||||
                Object num = redisClient.get(tag + "_num");
 | 
					                Object num = redisClient.get(tag + "_num");
 | 
				
			||||||
 | 
					 | 
				
			||||||
                Integer skip = (Integer) (num == null ? 0 : num);
 | 
					                Integer skip = (Integer) (num == null ? 0 : num);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (tagNumsMap.get(tag) < skip) {
 | 
					                if (tagNumsMap.get(tag) < skip) {
 | 
				
			||||||
                    redisClient.increment(ALLNUM);
 | 
					                    redisClient.increment(ALLNUM);
 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                log.info("开启{}类型的点为起始节点的第{}条数据到第{}条数据反向关系补全", tag, skip, skip + this.limitNum);
 | 
					                log.info("开启{}类型的点为起始节点的第{}条数据到第{}条数据反向关系补全", tag, skip, skip + this.limitNum);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                List<NebulaMultiMatchJsonResult> idJsonResults =
 | 
					                List<NebulaMultiMatchJsonResult> idJsonResults =
 | 
				
			||||||
                        graphCommonService.executeJson(NebulaUtil.getTagIdsWithLimit(spaceName, tag, skip, this.limitNum),
 | 
					                        graphCommonService.executeJson(NebulaUtil.getTagIdsWithLimit(spaceName, tag, skip, this.limitNum),
 | 
				
			||||||
                                NebulaMultiMatchJsonResult.class);
 | 
					                                NebulaMultiMatchJsonResult.class);
 | 
				
			||||||
| 
						 | 
					@ -109,9 +101,10 @@ public class RelationCompletion {
 | 
				
			||||||
                if (CollectionUtils.isEmpty(idJsonResults)) {
 | 
					                if (CollectionUtils.isEmpty(idJsonResults)) {
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                List<String> idLists = NebulaMultiMatchJsonResult.getIdLists(idJsonResults.get(0));
 | 
					                List<String> idLists = NebulaMultiMatchJsonResult.getIdLists(idJsonResults.get(0));
 | 
				
			||||||
 | 
					                if (CollectionUtils.isEmpty(idLists)) {
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                List<CompletableFuture<?>> futures = new ArrayList<>();
 | 
					                List<CompletableFuture<?>> futures = new ArrayList<>();
 | 
				
			||||||
                // 遍历边
 | 
					                // 遍历边
 | 
				
			||||||
                EdgeEnum[] edgeEnums = EdgeEnum.values();
 | 
					                EdgeEnum[] edgeEnums = EdgeEnum.values();
 | 
				
			||||||
| 
						 | 
					@ -119,15 +112,10 @@ public class RelationCompletion {
 | 
				
			||||||
                    Integer finalSkip = skip;
 | 
					                    Integer finalSkip = skip;
 | 
				
			||||||
                    CompletableFuture<Void> setVertexAndEdgeTotalsMap = CompletableFuture.supplyAsync(() -> {
 | 
					                    CompletableFuture<Void> setVertexAndEdgeTotalsMap = CompletableFuture.supplyAsync(() -> {
 | 
				
			||||||
                        try {
 | 
					                        try {
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            String srcTag = edgeEnum.getSrcTag();
 | 
					                            String srcTag = edgeEnum.getSrcTag();
 | 
				
			||||||
                            String edgeType = edgeEnum.getEdgeType();
 | 
					                            String edgeType = edgeEnum.getEdgeType();
 | 
				
			||||||
                            String reverseRelation = edgeEnum.getReverseRelation();
 | 
					                            String reverseRelation = edgeEnum.getReverseRelation();
 | 
				
			||||||
 | 
					 | 
				
			||||||
                            Instant now = Instant.now();
 | 
					                            Instant now = Instant.now();
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            List<NebulaVertexJsonResult> vertexJsonResults = graphCommonService.executeJsonWithoutLogs(
 | 
					                            List<NebulaVertexJsonResult> vertexJsonResults = graphCommonService.executeJsonWithoutLogs(
 | 
				
			||||||
                                    NebulaUtil.getDstVerticesById(spaceName, srcTag, idLists, edgeType),
 | 
					                                    NebulaUtil.getDstVerticesById(spaceName, srcTag, idLists, edgeType),
 | 
				
			||||||
                                    NebulaVertexJsonResult.class,
 | 
					                                    NebulaVertexJsonResult.class,
 | 
				
			||||||
| 
						 | 
					@ -153,7 +141,6 @@ public class RelationCompletion {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
 | 
					                CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
 | 
				
			||||||
 | 
					 | 
				
			||||||
                skip = skip + this.limitNum;
 | 
					                skip = skip + this.limitNum;
 | 
				
			||||||
                redisClient.set(tag + "_num", skip);
 | 
					                redisClient.set(tag + "_num", skip);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,6 @@ package com.idata.tools.relationcompletion.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.idata.tools.relationcompletion.dto.NebulaVertexJsonResult;
 | 
					import com.idata.tools.relationcompletion.dto.NebulaVertexJsonResult;
 | 
				
			||||||
import com.idata.tools.relationcompletion.vo.SearchSubgraphVo;
 | 
					import com.idata.tools.relationcompletion.vo.SearchSubgraphVo;
 | 
				
			||||||
import com.vesoft.nebula.Edge;
 | 
					 | 
				
			||||||
import org.apache.commons.collections4.CollectionUtils;
 | 
					import org.apache.commons.collections4.CollectionUtils;
 | 
				
			||||||
import org.apache.commons.lang3.StringUtils;
 | 
					import org.apache.commons.lang3.StringUtils;
 | 
				
			||||||
import org.slf4j.Logger;
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
| 
						 | 
					@ -54,7 +53,7 @@ public class NebulaUtil {
 | 
				
			||||||
                .map(id -> "'" + id + "'")
 | 
					                .map(id -> "'" + id + "'")
 | 
				
			||||||
                .collect(Collectors.joining(", "));
 | 
					                .collect(Collectors.joining(", "));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String format = String.format("USE %s; MATCH (v:%s)-[:%s]->(v2) WHERE id(v) IN [%s] RETURN v2",
 | 
					        String format = String.format("USE %s; MATCH (v:%s)-[e:%s]->(v2) WHERE id(v) IN [%s] RETURN v2",
 | 
				
			||||||
                spaceName, tag, edgeType, idList);
 | 
					                spaceName, tag, edgeType, idList);
 | 
				
			||||||
        return format;
 | 
					        return format;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,15 +1,15 @@
 | 
				
			||||||
nebula:
 | 
					nebula:
 | 
				
			||||||
  userName: root
 | 
					  userName: root
 | 
				
			||||||
  password: nebula
 | 
					  password: nebula
 | 
				
			||||||
  hostAddresses: 172.16.20.2:9669,172.16.20.4:9669,172.16.20.5:9669
 | 
					  hostAddresses: 192.168.7.32:9669,192.168.7.153:9669
 | 
				
			||||||
  minConnsSize: 20
 | 
					  minConnsSize: 20
 | 
				
			||||||
  maxConnSize: 100
 | 
					  maxConnSize: 50
 | 
				
			||||||
  timeout: 600000
 | 
					  timeout: 600000
 | 
				
			||||||
  idleTime: 180000
 | 
					  idleTime: 180000
 | 
				
			||||||
  spaceName: Y24_1206
 | 
					  spaceName: Y24_1206
 | 
				
			||||||
  limitNum: 10000  #
 | 
					  limitNum: 10000  #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
redis:
 | 
					redis:
 | 
				
			||||||
  host: 172.16.20.1
 | 
					  host: 192.168.7.32
 | 
				
			||||||
  port: 6379
 | 
					  port: 6379
 | 
				
			||||||
  password: 123456
 | 
					  password: 123456
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user