本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 SPARQL 更新卸载从 Neptune 中删除数据
Neptune 还提供了自定义的 SPARQL 操作,UNLOAD
,用于删除远程源中指定的数据。UNLOAD
可以被视为对应LOAD
operation. 其语法如下:
此功能可以从Neptune 引擎版本 1.0.4.1.
UNLOAD SILENT
(URL of the remote data to be unloaded)
FROM GRAPH(named graph from which to remove the data)
-
SILENT
— (可选) 即使处理数据时出错,也会导致操作返回成功。当单个交易包含多个语句时,这可能非常有用
"LOAD ...; LOAD ...; UNLOAD ...; LOAD ...;"
而且即使某些远程数据无法处理,也希望交易也能完成。 -
要卸载的远程数据的 URL
— (必需) 指定远程数据文件,其中包含要从图表中卸载的数据。远程文件必须具有以下扩展名之一(这些与 UPDATE-LOAD 支持的格式相同):
.nt
表示 NTriples。.nq
表示 NQuads。.trig
表示 Trig。.rdf
表示 RDF/XML。.ttl
表示 Turtle。.n3
表示 N3。.jsonld
表示 JSON-LD。
此文件包含的所有数据都将从数据库集群中移除
UNLOAD
operation.任何 Amazon S3 身份验证都必须包含在 URL 中以进行卸载数据。您可以预先签署 Amazon S3 文件,然后使用生成的 URL 安全地访问该文件。例如:
aws s3 presign --expires-in
(number of seconds)
s3://(bucket name)
/(path to file of data to unload)
然后:
curl https://
(a Neptune endpoint URL)
:8182/sparql \ --data-urlencode 'update=unload(pre-signed URL of the remote Amazon S3 data to be unloaded)
\ from graph(named graph)
'有关更多信息,请参阅 。验证请求:使用查询参数.
-
FROM GRAPH
(要从中删除数据的命名图)
— (可选) 指定应从中卸载远程数据的命名图表。Neptune 将每个三元组与一个命名图形相关联。您可以使用后备命名图 URI 指定默认的命名图表,
http://aws.amazon.com/neptune/vocab/v01/DefaultNamedGraph
,类似于以下内容:FROM GRAPH <http://aws.amazon.com/neptune/vocab/v01/DefaultNamedGraph>
以同样的方式LOAD
对应于INSERT DATA
{
、(inline data)
}UNLOAD
对应于DELETE DATA {
. LIKE(inline data)
}DELETE DATA
、UNLOAD
不适用于包含空白节点的数据。
例如,如果本地 Web 服务器提供名为的文件data.nt
其中包含以下 2 个三元组:
<http://example.org/resource#a> <http://example.org/resource#p> <http://example.org/resource#b> . <http://example.org/resource#a> <http://example.org/resource#p> <http://example.org/resource#c> .
以下UNLOAD
命令将从命名图中删除这两个三元组,<http://example.org/graph1>
:
UNLOAD <http://localhost:80/data.nt> FROM GRAPH <http://example.org/graph1>
这与使用以下内容效果相同。DELETE DATA
命令:
DELETE DATA { GRAPH <http://example.org/graph1> { <http://example.org/resource#a> <http://example.org/resource#p> <http://example.org/resource#b> . <http://example.org/resource#a> <http://example.org/resource#p> <http://example.org/resource#c> . } }
引发的异常UNLOAD
命令
-
InvalidParameterException
— 数据中有空白节点。HTTP 状态:400 错误请求。消息:
Blank nodes are not allowed for UNLOAD
-
InvalidParameterException
— 数据中存在错误的语法。HTTP 状态:400 错误请求。消息:
Invalid syntax in the specified file.
-
UnloadUrlAccessDeniedException
— 访问被拒绝。HTTP 状态:400 错误请求。消息:
Update failure: Endpoint
(Neptune endpoint)
reported access denied error. Please verify access. -
BadRequestException
— 无法检索远程数据。HTTP 状态:400 错误请求。消息:(取决于 HTTP 响应)。