public void MaximumRelAtt(RelationSymbol parameterSym1, string exAttribute, RelationSymbol returnSym) { Console.WriteLine("Maximum'ing..."); var index = parameterSym1.Index.Value; QLPart partForTypeExtraction = null; //first present attribute provides type info var tuples = parameterSym1.Tuples.ToArray(); foreach (var tuple in tuples) { var part = tuple[index].GetPropertyValue(exAttribute); if (part != null) { partForTypeExtraction = part; break; } } if (partForTypeExtraction == null) { return; } IEnumerable <QLEntity[]> tuplesOut = null; if (partForTypeExtraction.QLNumber != null) { var max = tuples.Max(t => t[index].GetPropertyValue(exAttribute).QLNumber.Value); tuplesOut = tuples.Where(t => t[index].GetPropertyValue(exAttribute).QLNumber.Value == max); } returnSym.SetTuples(tuplesOut); }
//only symbols and simple types in operators, no nodes //symbolTable, parameterSym1, ..., returnSym public void ProjectRelAttRelation(RelationSymbol parameterSym1, int[] attributeIndices, RelationSymbol returnSym) { Console.WriteLine("Projector'ing..."); var result = ProjectLocal(parameterSym1.Tuples, attributeIndices); returnSym.SetTuples(result); }
public void TypeFilterRelation(RelationSymbol parameterSym1, Tuple <int, string>[] indexAndTypeNames, RelationSymbol returnSym) { Console.WriteLine("TypeFilter'ing..."); var tuples = parameterSym1.Tuples; var tuplesOut = GetTuples(tuples, indexAndTypeNames); returnSym.SetTuples(tuplesOut); }
public void ReferenceRelAtt(RelationSymbol parameterSym1, string[] references, RelationSymbol returnSym) { var index = parameterSym1.Index.Value; if (references.Length == 1) { var firstTuples = ResolveReferenceTuplesIn(parameterSym1.Tuples, index, false, references[0]); returnSym.SetTuples(firstTuples); } else if (references.Length == 2) { var firstTuples = ResolveReferenceTuplesIn(parameterSym1.Tuples, index, false, references[0]); returnSym.SetTuples(ResolveReferenceTuplesIn(firstTuples, index + 1, true, references[1])); } else { throw new QueryException("The operation Dereferencer-relation has the wrong number of parameters"); } }
//only symbols and simple types in operators, no nodes //symbolTable, parameterSym1, ..., returnSym public void AttributeFilterRelAtt(RelationSymbol parameterSym1, PredicateNode[] predicateNodes, RelationSymbol returnSym) { Console.WriteLine("AttributeFilter'ing..."); //var index = parameterSym1.Index.Value; todo remove index prop var attributes = parameterSym1.Attributes; var indexAndPreps = predicateNodes.Select(p => new Tuple <int, PredicateNode>((p.FirstNode as AttributeAccessNode).RelAttNode.AttIndex, p)); var result = parameterSym1.Tuples.Where(t => indexAndPreps.All( indexAndPrep => AttributeSetTestLocal(t[indexAndPrep.Item1], indexAndPrep.Item2))); returnSym.SetTuples(result); }
public void ReferenceSet(SetSymbol parameterSym1, string[] references, RelationSymbol returnSym) { Console.WriteLine("Dereferencer'ing..."); if (references.Length == 1) { var firstPairs = ResolveReferenceSetIn(parameterSym1.Entites, references[0]); returnSym.SetTuples(firstPairs); } else if (references.Length == 2) { //pair original first arg var firstPairs = ResolveReferenceSetIn(parameterSym1.Entites, references[0]); //pair original second arg var secondPairs = ResolveReferenceTuplesIn(firstPairs, 1, true, references[1]); returnSym.SetTuples(secondPairs); } else { throw new QueryException("The operation Dereferencer-Set has the wrong number of parameters"); } }
//only symbols and simple types in operators, no nodes //symbolTable, parameterSym1, ..., returnSym public void TimeResolverRel(RelationSymbol parameterSym1, RelationSymbol returnSym) { Console.WriteLine("TimeResolver'ing..."); var index = parameterSym1.Index.Value; var tuples = deassociater.GetTuplesRelAtt(parameterSym1.Tuples, index, new [] { "ReferencedBy" }).ToArray(); var lastIndex = returnSym.Attributes.Count - 2; tuples = dereferenceOperator.ResolveReferenceTuplesIn(tuples, lastIndex, false, "TaskTime").ToArray(); var typeList = new List <Tuple <int, string> >() { new Tuple <int, string>(index, "IfcProduct"), new Tuple <int, string>(lastIndex, "IfcTask"), new Tuple <int, string>(lastIndex + 1, "IfcTaskTime"), }; //type filtering ifcTask (plus products?) var tuplesTyped = typeFilter.GetTuples(tuples, typeList.ToArray()); returnSym.SetTuples(tuplesTyped); }
public void DeassociaterSet(SetSymbol parameterSym1, string[] exAtts, RelationSymbol returnSym) { Console.WriteLine("Deassociater'ing..."); returnSym.SetTuples(GetTuplesSet(parameterSym1.Entites, exAtts)); }
public void DeassociaterRelAtt(RelationSymbol parameterSym1, string[] exAtts, RelationSymbol returnSym) { Console.WriteLine("Deassociater'ing..."); returnSym.SetTuples(GetTuplesRelAtt(parameterSym1.Tuples, parameterSym1.Index.Value, exAtts)); }