Revision 52:e0e12bd2978d common/FeatureFileIndex.cpp
| common/FeatureFileIndex.cpp | ||
|---|---|---|
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 | 35 |
m_bs = new BasicStore; |
| 36 |
m_bs->setBaseUri(Uri(QUrl::fromLocalFile(m_indexFileName))); |
|
| 37 |
|
|
| 36 | 38 |
m_index = new TransactionalStore(m_bs); |
| 37 | 39 |
|
| 38 | 40 |
TypeRegistrar::addMappings(m_bs, 0); |
| ... | ... | |
| 104 | 106 |
|
| 105 | 107 |
// and again with anything else having the same hash |
| 106 | 108 |
if (tf->hash() != "") {
|
| 107 |
Triple pattern(Node(), "foaf:sha1", Node(Node::Literal, tf->hash()));
|
|
| 109 |
Triple pattern(Node(), store->expand("foaf:sha1"), Node(tf->hash()));
|
|
| 108 | 110 |
Triples results = m_index->match(pattern); |
| 109 | 111 |
std::cerr << "FeatureFileIndex::loadFor: " << results.size() << " audio file(s) found with hash " << tf->hash().toStdString() << std::endl; |
| 110 | 112 |
foreach (Triple t, results) {
|
| ... | ... | |
| 127 | 129 |
// hash is present in the feature file but does not match, then it |
| 128 | 130 |
// cannot be the right track even if the URI matches. |
| 129 | 131 |
|
| 130 |
Triple pattern(Node(), "foaf:primaryTopic", afuri);
|
|
| 132 |
Triple pattern(Node(), store->expand("foaf:primaryTopic"), afuri);
|
|
| 131 | 133 |
Triples results = m_index->match(pattern); |
| 132 | 134 |
std::cerr << "FeatureFileIndex::loadFor: " << results.size() << " feature file(s) for audio file " << afuri << std::endl; |
| 133 | 135 |
|
| ... | ... | |
| 137 | 139 |
try {
|
| 138 | 140 |
BasicStore *b = BasicStore::load(QUrl(t.a.value)); |
| 139 | 141 |
Triples ts = b->match |
| 140 |
(Triple(afuri, "a", m_index->expand("mo:AudioFile")));
|
|
| 142 |
(Triple(afuri, store->expand("a"), m_index->expand("mo:AudioFile")));
|
|
| 141 | 143 |
std::cerr << "FeatureFileIndex::loadFor: feature file " |
| 142 | 144 |
<< t.a << " has " << ts.size() << " type node(s) for this audio file" << std::endl; |
| 143 | 145 |
bool someGood = false; |
| ... | ... | |
| 177 | 179 |
// associating these facts with our own URI for this |
| 178 | 180 |
// file, even if they originated from a different URI |
| 179 | 181 |
// with the same hash) |
| 180 |
Node from = Node(Node::URI, afuri.toString());
|
|
| 181 |
Node to = Node(Node::URI, canonicalUri.toString());
|
|
| 182 |
Node from = Node(Uri(afuri.toString()));
|
|
| 183 |
Node to = Node(Uri(canonicalUri.toString()));
|
|
| 182 | 184 |
foreach (Triple t, all) {
|
| 183 | 185 |
if (t.a == from) t.a = to; |
| 184 | 186 |
if (t.c == from) t.c = to; |
| ... | ... | |
| 235 | 237 |
void |
| 236 | 238 |
FeatureFileIndex::index(QUrl fileUrl) |
| 237 | 239 |
{
|
| 238 |
Triple typeTriple(Uri(fileUrl), "a", m_index->expand("foaf:Document"));
|
|
| 240 |
Triple typeTriple(Uri(fileUrl), m_index->expand("a"), m_index->expand("foaf:Document"));
|
|
| 239 | 241 |
|
| 240 | 242 |
if (m_index->contains(typeTriple)) {
|
| 241 | 243 |
return; |
| ... | ... | |
| 247 | 249 |
try {
|
| 248 | 250 |
BasicStore *b = BasicStore::load(fileUrl); |
| 249 | 251 |
Triples ts = b->match |
| 250 |
(Triple(Node(), "a", m_index->expand("mo:AudioFile")));
|
|
| 252 |
(Triple(Node(), m_index->expand("a"), m_index->expand("mo:AudioFile")));
|
|
| 251 | 253 |
foreach (Triple t, ts) {
|
| 252 |
tx->add(Triple(Uri(fileUrl), "foaf:primaryTopic", t.a));;
|
|
| 254 |
tx->add(Triple(Uri(fileUrl), m_index->expand("foaf:primaryTopic"), t.a));;
|
|
| 253 | 255 |
Triples hashts = b->match |
| 254 | 256 |
(Triple(t.a, m_index->expand("foaf:sha1"), Node()));
|
| 255 | 257 |
foreach (Triple hasht, hashts) {
|
Also available in: Unified diff