npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

linkeddatatree

v0.1.3

Published

Creation of tree structured fragmentations of RDF data

Downloads

2

Readme

Tree structured fragmentations of an RDF data collection.

This project handles the creation of tree structured fragmentations of a collection of RDF data. This is based on the ontology that can be found here: https://github.com/pietercolpaert/TREE.

Tree structured fragmentations of an RDF data collection provide a way for clients to filter the data objects of a collection over the Web with a minimal server cost. For every predicate of the stored data that needs to be filtered, a tree data structure has to be constructed that indexes the data over that predicate value. If these fragmentations are published over the Web, clients can use them to efficiently filter the data objects of the data set over the predicates for which tree structured fragmentations are available. A client implementation can be found here: https://github.com/Dexagod/ldf_tree_client.

When publishing the tree structured fragmentations over the Web, it is important to enable caching on both the server and the client, as this will increase the querying performance of the clients over the fragmentation.

Currently, four data structure types are supported: Prefix tree, R-tree, B-tree and Paged List (Hydra PartialCollectionView). The Hydra collectionView does not scale well for large datasets as the creation currently iterates over each page in order to add an item to the list.

A tree can be setup the following way:

import * as ldtree from "linkeddatatree"

let config = {
  rootDir : 'rootDir/',             // This is the root of all @id values in the tree
  dataDir : 'hydra_streets/',       // This is the relative path to the root where the fragments of the tree are stored
  treePath: 'rdf:label',            // This is the tree:path 
  fragmentSize: 100                 // The maximum size of a fragment of the tree (defaults to 50)
  memoryLimit: 1000                 // The maxumum memory size that can be used for the creation of the tree (in MB, defaults to Infinity). Currently not yet correctly implemented.'writeMetadata': true             // Flag to allow metadata to be written with the tree fragments (Allows the tree to be read for later adaptations, will be made obsolete in later iterations)
  'context': {                      // JSON-LD context to be added to the tree fragment.
      "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    }
}

// Currently there are 3 available tree data structures (and support for Hydra PartialCollectionView)
let treeManager = new ldtree.PrefixTreeManager()
                // = new ldtree.BTreeManager()
                // = new ldtree.RTreeManager()
                // = new ldtree.HydraPartialCollectionViewManager()

// Creating the tree object
let tree = treeManager.createTree(config);

// Creating a data object to add to the tree
let key_value = "Wolfgang Amadeus Mozart"      // This key value is a temporary solution. In following iterations, this will be derived from the RDF data object based on the shacl_path predicate that has been provided on the creation of the tree.
// Currently, data objects added to the tree are required to be presented in a JSON-LD format.
let data_object = { "@id": "http://dbpedia.org/resource/Wolfgang_Amadeus_Mozart",  
                    "@type": "http://dbpedia.org/ontology/Person",
                    "http://www.w3.org/2000/01/rdf-schema#label": "Wolfgang Amadeus Mozart"}    

tree.addData(key_value, data_object)           // The key_value parameter will be removed in later iterations, and will be derived from the RDF data object based ont he shacl_path predicate value.
// Add all the necessary data to the tree data structure.
tree.doneAdding() // This flushes the cache to the disk, so that the current status of the tree structured fragmentation is written to the disk.

// The fragments of the tree have now been written to the disk on the path: source_path + tree_path
// The collection object in the root node fragment can be found on the location: source_path + tree_path + node0.jsonld#Collection

// The tree can be read from disk to make alterations using the following approach
let newtree = treeManager.readTree(
    source_path,           
    tree_path,             
    shacl_path,             // In future itearations this will be derived from context,
    max_cached_fragments,   // In future itearations this will be derived from context.
    max_fragment_size)      // In future itearations this will be derived from context.

newtree.addData(key_value2, data_object20   // add new items to the tree

newtree.doneAdding()                        // This flushes the tree cache to disk after the creation of the tree. This creates a config file that can be used by the program to read the tree from the disk in order to make adaptations.



In order to add data to a tree from disk:

let location = rootDir + dataDir + config.json // This is the loaction of the config file generated by the doneAdding() call.
let readTree = treeManager.readTree(location)
readTree.addData(key, value)
readTree.doneAdding();