简体   繁体   English

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

[英]Out of memory exception when using Geospatial queries in Spring Data ArangoDB

i'm using spring-boot 2.0.0 and arangodb-spring-data 2.0.3, i was following geospatial queries tutorial in here with my own data structure. 我正在使用spring-boot 2.0.0和arangodb-spring-data 2.0.3,我在这里使用我自己的数据结构跟踪地理空间查询教程。

@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);
}

it'll throw out of memory exception only if i call findByLocationWithin() method. 只有当我调用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)

what i want to do is to get nearby hospital with distance less than X Km. 我想做的是到附近的医院,距离小于X公里。 I can achieve this by using this query in ArangoDB. 我可以通过在ArangoDB中使用此查询来实现此目的。

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

Is arangodb-spring-data somehow broken? arangodb-spring-data有点破碎吗? Do i need to make custom @Query for this? 我需要为此制作自定义@Query吗?

You have to switch the values for Point to do the same in your Java application as in your AQL query. 您必须切换Point的值,以便在Java应用程序中执行与AQL查询中相同的操作。

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

ArangoDB Spring data assumes that the first parameter of Point is longitude and the second latitude. ArangoDB Spring数据假设Point的第一个参数是经度和第二个纬度。

The Error AQL: out of memory occurs because of a check within the ArangoDB geo-index which checks that longitude is between -180 and 180 and latitude is between -90 and 90. The error message is very misleading but there is already a PR on github to fix this. 错误AQL: out of memory由于ArangoDB地理索引中的检查而发生AQL: out of memory不足,该检查检查经度介于-180和180之间,纬度介于-90和90之间。错误消息非常误导但是已经有PR github解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM