[redland-dev] [Redland RDF API 0000364]: [Wishlist] librdf_storage_count_contexts() method to get number of contexts

Mantis Bug Tracker mantis-bug-sender at librdf.org
Sat Apr 3 13:07:04 CEST 2010


The following issue has been SUBMITTED. 
====================================================================== 
http://bugs.librdf.org/mantis/view.php?id=364 
====================================================================== 
Reported By:                njh
Assigned To:                
====================================================================== 
Project:                    Redland RDF API
Issue ID:                   364
Category:                   api
Reproducibility:            N/A
Severity:                   feature
Priority:                   low
Status:                     new
====================================================================== 
Date Submitted:             2010-04-03 11:07
Last Modified:              2010-04-03 11:07
====================================================================== 
Summary:                    [Wishlist] librdf_storage_count_contexts() method to
get number of contexts
Description: 
Function to count the number of contexts in a model for statistical
reporting.

Functions to count the number of resources/literals/predicates may also be
interesting.

Performance could be improved if the storage backend implemented this
function.


My current implementation in RedStore is:

int count_contexts(librdf_storage * storage)
{
    librdf_iterator *iterator = NULL;
    int count = 0;

    assert(storage != NULL);

    iterator = librdf_storage_get_contexts(storage);
    if (!iterator) {
        redstore_error("librdf_storage_get_contexts returned NULL");
        return -1;
    }

    while (!librdf_iterator_end(iterator)) {
        count++;
        librdf_iterator_next(iterator);
    }

    librdf_free_iterator(iterator);

    return count;
}

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-04-03 11:07 njh            New Issue                                    
======================================================================



More information about the redland-dev mailing list