导出至 Apache Arrow
这些过程将数据导出为许多 Apache 及非 Apache 工具所使用的格式。
可用过程
下表描述了可用的过程:
| 限定名称 | 类型 |
|---|---|
apoc.export.arrow.all |
|
apoc.export.arrow.graph.adoc |
|
apoc.export.arrow.query.adoc |
|
apoc.export.arrow.stream.all |
|
apoc.export.arrow.stream.graph.adoc |
|
apoc.export.arrow.stream.query.adoc |
|
导出至文件
默认情况下,导出到文件系统是被禁用的。我们可以通过在 apoc.conf 中设置以下属性来启用它:
apoc.export.file.enabled=true
如果我们尝试在未先设置此属性的情况下使用任何导出过程,我们将收到以下错误消息:
无法调用过程:由以下原因引起:java.lang.RuntimeException: 未启用导出至文件功能,请在 apoc.conf 中设置 apoc.export.file.enabled=true。此外,如果您是在没有文件系统访问权限的云环境中运行,请使用 |
导出文件被写入 import 目录,该目录由 server.directories.import 属性定义。这意味着我们提供的任何文件路径都是相对于此目录的。如果我们尝试写入绝对路径(例如 /tmp/filename),我们将收到类似于以下内容的错误消息:
Failed to invoke procedure: Caused by: java.io.FileNotFoundException: /path/to/neo4j/import/tmp/fileName (No such file or directory) |
我们可以通过在 apoc.conf 中设置以下属性来允许写入文件系统上的任何位置:
apoc.import.file.use_neo4j_config=false
|
Neo4j 现在将能够写入文件系统上的任何位置,因此在设置此属性之前,请确保这是您的意图。 |
示例
将 Cypher 查询结果导出为 Apache Arrow 文件
CALL apoc.export.arrow.query('query_test.arrow',
"RETURN 1 AS intData, 'a' AS stringData,
true AS boolData,
[1, 2, 3] AS intArray,
[1.1, 2.2, 3.3] AS doubleArray,
[true, false, true] AS boolArray,
[1, '2', true, null] AS mixedArray,
{foo: 'bar'} AS mapData,
localdatetime('2015-05-18T19:32:24') as dateData,
[[0]] AS arrayArray,
1.1 AS doubleData"
) YIELD file
| file | source | format | 节点 | relationships | 属性 | time | rows | batchSize | batches | done | data |
|---|---|---|---|---|---|---|---|---|---|---|---|
"query_test.arrow" |
"statement: cols(11)" |
"arrow" |
0 |
0 |
11 |
468 |
11 |
2000 |
1 |
true |
<null> |
将 Cypher 查询结果导出为 Apache Arrow 二进制输出
CALL apoc.export.arrow.stream.query('query_test.arrow',
"RETURN 1 AS intData, 'a' AS stringData,
true AS boolData,
[1, 2, 3] AS intArray,
[1.1, 2.2, 3.3] AS doubleArray,
[true, false, true] AS boolArray,
[1, '2', true, null] AS mixedArray,
{foo: 'bar'} AS mapData,
localdatetime('2015-05-18T19:32:24') as dateData,
[[0]] AS arrayArray,
1.1 AS doubleData"
) YIELD value
| 值 |
|---|
<二进制 Apache Arrow 输出> |