Skip to content

Instantly share code, notes, and snippets.

@arekinath
Created March 1, 2013 06:05
Show Gist options
  • Save arekinath/5062750 to your computer and use it in GitHub Desktop.
Save arekinath/5062750 to your computer and use it in GitHub Desktop.
Let's have another go at this
diff --git a/src/de/fuberlin/wiwiss/d2rq/engine/TripleRelationJoiner.java b/src/de/fuberlin/wiwiss/d2rq/engine/TripleRelationJoiner.java
index e9efd77..3211078 100644
--- a/src/de/fuberlin/wiwiss/d2rq/engine/TripleRelationJoiner.java
+++ b/src/de/fuberlin/wiwiss/d2rq/engine/TripleRelationJoiner.java
@@ -67,9 +67,20 @@ class TripleRelationJoiner {
Set<String> attributeNames)
{
Map<String,List<String>> uniqueKeys = database.getUniqueKeyColumns(originalName);
- if (uniqueKeys == null) return false;
+ if (uniqueKeys != null) {
for (List<String> indexColumns: uniqueKeys.values()) {
- if (attributeNames.containsAll(indexColumns)) return true;
+ if (attributeNames.containsAll(indexColumns)) {
+ return true;
+ }
+ }
+ }
+ List<Attribute> primaryKeys = database.schemaInspector().primaryKeyColumns(originalName);
+ if (primaryKeys != null) {
+ for (Attribute attr: primaryKeys) {
+ if (!attributeNames.contains(attr.attributeName()))
+ return false;
+ }
+ return true;
}
return false;
}
@@ -163,17 +174,17 @@ class TripleRelationJoiner {
names.add(t.getObject().getName());
for (String name: names) {
- NodeMaker n = (NodeMaker) nodeSets.toMap().get(name);
+ Var nameVar = Var.alloc(name);
+ NodeMaker n = (NodeMaker) nodeSets.toMap().get(nameVar);
if (n != null/* && n instanceof TypedNodeMaker*/) {
-
AttributeSet attributes = AttributeSet.createFrom(n);
/*
* If we would set an alias to this table...
*/
if (attributes != null) {
- RelationName originalName = ((AliasMap)nodeSets.relationAliases().get(name)).origina
+ AliasMap amap = (AliasMap)(nodeSets.relationAliases().get(nameVar));
+ RelationName originalName = amap.originalOf(attributes.relationName);
if (r.baseRelation().aliases().hasAlias(originalName)) {
-
/*
* ... and indexes are in place to guarantee uniqueness of the attribute com
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment