甜RDF / in-memory-store-sqlite
使用PDO和SQLite实现的RDF内存四元组存储库。
1.1.1
2024-02-29 10:12 UTC
Requires
- php: >=8.0
- sweetrdf/rdf-interface: ^2.0.0
- sweetrdf/simple-rdf: ^2.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- phpunit/phpunit: ^9.5 || ^10.0
- sweetrdf/sparql-client: ^0.1
This package is auto-updated.
Last update: 2024-09-05 13:51:08 UTC
README
使用PDO和SQLite实现的RDF内存四元组存储库的PoC。
安装
要安装此库,请使用Composer通过以下方式
composer require sweetrdf/in-memory-store-sqlite
使用
使用InMemoryStoreSqlite::createInstance()
获取一个可用的存储实例(请参阅下面的示例)。发送SPARQL查询可以通过query
方法完成。您的数据存储在一个内存SQLite数据库文件中。脚本结束后,存储中的所有数据都将消失。
示例
示例1(第一步)
创建一个存储实例,将一些三元组加载到其中并运行查询。
use sweetrdf\InMemoryStoreSqlite\Store\InMemoryStoreSqlite; // get ready to use store instance $store = InMemoryStoreSqlite::createInstance(); // send a SPARQL query which creates two triples $store->query('INSERT INTO <http://example.com/> { <http://s> <http://p1> "baz" . <http://s> <http://xmlns.com/foaf/0.1/name> "label1" . }'); // send another SPARQL query asking for all triples $res = $store->query('SELECT * WHERE {?s ?p ?o.}'); $triples = $res['result']['rows']; echo \count($triples); // outputs: 2 // $triples contains result set, which consists of arrays and scalar values
SPARQL支持
存储支持许多SPARQL 1.0/1.1特性。有关更多信息,请参阅SPARQL-support.md。
性能
存储使用配置为
PRAGMA synchronous = OFF
PRAGMA journal_mode = OFF
PRAGMA locking_mode = EXCLUSIVE
PRAGMA page_size = 4096
更多信息请查看PDOSQLiteAdapter.php。
当一次性添加几百个或更多三元组时,您可能会遇到执行时间增加的情况。本地测试显示,每秒可以添加大约1500个三元组。
许可证
此作品根据GPL 2许可证的条款。
致谢
此作品基于来自https://github.com/semsol/arc2(由Benjamin Nowak及其贡献者)的ARC2代码。要查看提取的内容,请查看拉取请求#1。ARC2根据GPL 2(或更高版本)以及W3C软件许可证双许可。