gpt4 book ai didi

spring - 在 Spring Data ArangoDB 中使用地理空间查询时出现内存不足异常

转载 作者:行者123 更新时间:2023-12-01 15:11:23 26 4
gpt4 key购买 nike

我正在使用 spring-boot 2.0.0 和 arangodb-spring-data 2.0.3,我正在学习 here 中的地理空间查询教程。用我自己的数据结构。

@Data
@NoArgsConstructor
@Document(value = "hospital")
public class Hospital {
@Id
private String id;
private String name;
private String phone;
private String address;
@GeoIndexed
private double[] location;

public Hospital(String name, String phone, String address, double[] location) {
super();
this.name = name;
this.phone = phone;
this.address = address;
this.location = location;
}
}

@Repository
public interface HospitalRepository extends ArangoRepository<Hospital> {
GeoResults<Hospital> findByLocationWithin(Point location, Distance distance);
}

@Test
public void geoSpatialTest() throws IOException {
populateDb();
Point point = new Point(-7.2895286, 112.7731704);
Distance distance = new Distance(2, Metrics.KILOMETERS);
GeoResults<Hospital> results = repository.findByLocationWithin(point, distance);
results.getContent().forEach(System.out::println);
}

如果我调用 findByLocationWithin() 方法,它只会抛出内存异常。

com.arangodb.ArangoDBException: Response: 500, Error: 3 - AQL: out of memory (exception location: /var/lib/otherjenkins/workspace/RELEASE__BuildPackages/arangod/MMFiles/MMFilesGeoIndex.cpp:151) (while executing) (exception location: /var/lib/otherjenkins/workspace/RELEASE__BuildPackages/arangod/RestHandler/RestCursorHandler.cpp:135)

我想做的是到距离小于 X 公里的附近医院。我可以通过在 ArangoDB 中使用这个查询来实现这一点。

FOR hospital IN WITHIN(hospital, -7.2895286, 112.7731704, 2000)
RETURN hospital

arangodb-spring-data 是否以某种方式损坏了?我需要为此自定义 @Query 吗?

最佳答案

您必须切换 Point 的值才能在您的 Java 应用程序中执行与在 AQL 查询中相同的操作。

Point point = new Point(112.7731704, -7.2895286);

ArangoDB Spring数据假定Point的第一个参数是经度,第二个是纬度。

错误 AQL: out of memory 发生是因为在 ArangoDB 地理索引中检查经度在 -180 和 180 之间,纬度在 -90 和 90 之间。错误消息非常具有误导性,但已经有一个 PR on github解决这个问题。

关于spring - 在 Spring Data ArangoDB 中使用地理空间查询时出现内存不足异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49691991/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com