public void visit(QueryGroupPatterns group) { ArrayList groupJoins = new ArrayList(); Hashtable variableMentionsWithinThisGroup = new Hashtable(); bool allPatternsAreMatchable = true; foreach (Pattern pattern in group.Patterns) { if (!(pattern.GetSubject() is Variable) && !itsResourcesIndexedByNode.Contains(pattern.GetSubject())) { allPatternsAreMatchable = false; } else if (!(pattern.GetPredicate() is Variable) && !itsResourcesIndexedByNode.Contains(pattern.GetPredicate())) { allPatternsAreMatchable = false; } else if (!(pattern.GetObject() is Variable) && !itsResourcesIndexedByNode.Contains(pattern.GetObject())) { allPatternsAreMatchable = false; } } if (allPatternsAreMatchable) { foreach (Pattern pattern in group.Patterns) { ++itsStatementTableCount; string tableName = "s" + itsStatementTableCount; ArrayList constraints = new ArrayList(); bool referencesExternalVariables = false; if (ProcessPatternTerm(pattern.GetSubject(), tableName, "subjectHash", constraints, variableMentionsWithinThisGroup)) { referencesExternalVariables = true; } if (ProcessPatternTerm(pattern.GetPredicate(), tableName, "predicateHash", constraints, variableMentionsWithinThisGroup)) { referencesExternalVariables = true; } if (ProcessPatternTerm(pattern.GetObject(), tableName, "objectHash", constraints, variableMentionsWithinThisGroup)) { referencesExternalVariables = true; } constraints.Add(tableName + ".graphId=" + itsResourceMap.GetHashCode()); if (itsStatementTableCount > 1) { StringBuilder join = new StringBuilder(); if (referencesExternalVariables && itsOptionalNestingDepth > 0) { join.Append("LEFT OUTER "); } join.Append("JOIN Statements " + tableName + " ON "); bool doneFirst = false; foreach (string constraint in constraints) { if (constraint != null && constraint.Length > 0) { if (doneFirst) { join.Append(" AND "); } join.Append(constraint); doneFirst = true; } } groupJoins.Add(join.ToString()); } else { foreach (string constraint in constraints) { if (constraint != null && constraint.Length > 0) { itsWhereTerms.Add(constraint); } } } } itsJoins.AddRange(groupJoins); } else { if (itsOptionalNestingDepth == 0) { NoSolutionIsPossible(); } } }