Gremlin提交参数过多导致:The max number of supported arguments is 255, but found的错

14 篇文章 1 订阅
14 篇文章 1 订阅

背景

当前业务中遇到一个场景,为了提高查询效率,比如会一次要查询多个顶点详情,但是当传入的点过多时,会报参数过多的限制异常。

代码

client的获取后续会在其它文章中补充

@Test
    public void bigSubmitTest() throws ExecutionException, InterruptedException {
        Client client = GraphUtil.getClient();
        List<String> ids = Lists.newArrayList();
        for (int i = 0; i < 500; i++) {
            ids.add(i + 4000 + "");
        }
        String join = String.join(",", ids);
        List<Result> results = client.submit("g.V(" + join + ")").all().get();
        for (Result result : results) {
            System.out.println("");
        }
        client.close();
    }

异常

java.util.concurrent.ExecutionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: startup failed:
General error during class generation: The max number of supported arguments is 255, but found 500

java.lang.IllegalArgumentException: The max number of supported arguments is 255, but found 500
	at org.codehaus.groovy.classgen.asm.CallSiteWriter.getCreateArraySignature(CallSiteWriter.java:74)
	at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:336)
	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCachedCall(InvocationWriter.java:340)
	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:430)
	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:137)
	at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:121)
	at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:497)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:836)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:68)
	at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:605)
	at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeReturn(OptimizingStatementWriter.java:368)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:685)
	at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
	at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:93)
	at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:205)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:635)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:110)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:121)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:495)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:431)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:132)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:576)
	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1103)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:269)
	at org.codehaus.groovy.control.CompilationUnit$18.call(CompilationUnit.java:854)
	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1084)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:645)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:623)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:600)
	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:390)
	at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:89)
	at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:330)
	at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:327)
	at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:325)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:251)
	at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.lambda$load$0(GremlinGroovyScriptEngine.java:819)
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
	at java.util.concurrent.CompletableFuture.asyncSupplyStage(CompletableFuture.java:1604)
	at java.util.concurrent.CompletableFuture.supplyAsync(CompletableFuture.java:1830)
	at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.load(GremlinGroovyScriptEngine.java:817)
	at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.load(GremlinGroovyScriptEngine.java:812)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.lambda$new$0(BoundedLocalCache.java:3117)
	at com.github.benmanes.caffeine.cache.LocalCache.lambda$statsAware$0(LocalCache.java:144)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$16(BoundedLocalCache.java:1968)
	at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1892)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:1966)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:1949)
	at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:113)
	at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:67)
	at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.getScriptClass(GremlinGroovyScriptEngine.java:567)
	at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:374)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
	at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)

解决办法

分析错误的原因,是因为提交的参数过多,所以会导致此问题。只需要将提交的值,当作一个参数提交就可以解决该问题了。

@Test
    public void bigSubmitTest2() throws ExecutionException, InterruptedException {
        Client client = GraphUtil.getClient();
        List<String> ids = Lists.newArrayList();
        for (int i = 0; i < 500; i++) {
            ids.add(i + 4000 + "");
        }
        String join = String.join(",", ids);
        Map<String, Object> maps = Maps.newHashMap();
        maps.put("ids", ids);
        List<Result> results = client.submit("g.V(ids)", maps).all().get();
        for (Result result : results) {
            System.out.println("");
        }
        client.close();
    }

总结

虽然查询的问题解决了,但批量gremlin插入数据的问题,采用上述方式,暂时还不得解。

g.addV('person').property('name', 'test1').addV('person').property('name', 'test2')......
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值