sweetrdf/quick-rdf
Composer 安装命令:
composer require sweetrdf/quick-rdf
包简介
Yet another RDF library
README 文档
README
An RDF library for PHP providing implementation of https://github.com/sweetrdf/rdfInterface terms and dataset.
Implemented to be fast and memory efficient.
This is achieved by using a global terms hash table with only a single copy of equal rdfInterface terms being stored in memory at a given time. It allows to save quite some memory in dense graphs and provides a lightning fast terms comparison (equal if and only if it's the same object). It also provides a very efficient implementation of Dataset set operations using PHP's SplObjectStorage.
The Dataset implementation maintains indexes allowing quick quads search (indexing can be turned off if needed as it significantly slows down a dataset creation).
Installation
- Obtain the Composer
- Run
composer require sweetrdf/quick-rdf - Run
composer require sweetrdf/quick-rdf-ioto install parsers and serializers.
Automatically generated documentation
https://sweetrdf.github.io/quickRdf/namespaces/quickrdf.html
It's very incomplete but better than nothing.
RdfInterface documentation is included which explains the most important design decisions.
Usage
(you can also take a look at generic rdfInterface examples)
include 'vendor/autoload.php'; use quickRdf\DataFactory as DF; $graph = new quickRdf\Dataset(); $parser = new quickRdfIo\TriGParser(); $stream = fopen('pathToTurtleFile', 'r'); $graph->add($parser->parseStream($stream)); fclose($stream); // count edges in the graph echo count($graph); // go trough all edges in the graph foreach ($graph as $i) { echo "$i\n"; } // find all graph edges with a given subject echo $graph->copy(DF::quadTemplate(DF::namedNode('http://mySubject'))); // find all graph edges with a given predicate echo $graph->copy(DF::quadTemplate(null, DF::namedNode('http://myPredicate'))); // find all graph edges with a given object echo $graph->copy(DF::quadTemplate(null, null, DF::literal('value', 'en'))); // replace an edge in the graph $edge = DF::quad(DF::namedNode('http://edgeSubject'), DF::namedNode('http://edgePredicate'), DF::namedNode('http://edgeObject')); $graph[$edge] = $edge->withObject(DF::namedNode('http://anotherObject')); // find intersection with other graph $graph->copy($otherGraph); // immutable $graph->delete($otherGraph); // in-place // compute union with other graph $graph->union($otherGraph); // immutable $graph->add($otherGraph); // in-place // compute set difference with other graph $graph->copyExcept($otherGraph); // immutable $graph->delete($otherGraph); // in-place $serializer = new quickRdfIo\TurtleSerializer(); $stream = fopen('pathToOutputTurtleFile', 'w'); $serializer->serializeStream($stream, $graph); fclose($stream);
sweetrdf/quick-rdf 适用场景与选型建议
sweetrdf/quick-rdf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.44k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 sweetrdf/quick-rdf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sweetrdf/quick-rdf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 16.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 7
- 推荐数: 4
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-16