on master help sign in
fix exception thrown due to bug in when the incoming, unverified tuples are hashed
46b4509AgentM
ProjectM36/Base.hs+8−3
@@ -155,9 +155,14 @@ instance NFData RelationTupleSet where rnf = genericRnf
155
155
156--the same hash must be generated for equal tuples so that the hashset equality works
156--the same hash must be generated for equal tuples so that the hashset equality works
157instance Hashable RelationTuple where
157instance Hashable RelationTuple where
158+ --sanity check the tuple for attribute and tuple counts
159+ --this bit me when tuples were being hashed before being verified
158− hashWithSalt salt (RelationTuple attrs tupVec) = salt `hashWithSalt`
160+ hashWithSalt salt (RelationTuple attrs tupVec) = if V.length attrs /= V.length tupVec then
161+ error "invalid tuple: attributes and tuple count mismatch"
162+ else
163+ salt `hashWithSalt`
159− sortedAttrs `hashWithSalt`
164+ sortedAttrs `hashWithSalt`
160− (V.toList sortedTupVec)
165+ (V.toList sortedTupVec)
161 where
166 where
162 sortedAttrsIndices = sortedAttributesIndices attrs
167 sortedAttrsIndices = sortedAttributesIndices attrs
163 sortedAttrs = map snd sortedAttrsIndices
168 sortedAttrs = map snd sortedAttrsIndices
ProjectM36/TransactionGraph.hs+4−3
@@ -221,9 +221,10 @@ graphAsRelation (DisconnectedTransaction parentUUID _) graph@(TransactionGraph _
221 parentAttributes = A.attributesFromList [Attribute "id" stringAtomType]
221 parentAttributes = A.attributesFromList [Attribute "id" stringAtomType]
222 tupleGenerator transaction = case transactionParentsRelation transaction graph of
222 tupleGenerator transaction = case transactionParentsRelation transaction graph of
223 Left err -> Left err
223 Left err -> Left err
224− Right _ -> Right [Atom $ T.pack $ show (transactionUUID transaction),
224+ Right parentTransRel -> Right [Atom $ T.pack $ show (transactionUUID transaction),
225+ Atom parentTransRel,
225− Atom $ parentUUID == transactionUUID transaction,
226+ Atom $ parentUUID == transactionUUID transaction,
226− Atom $ case headNameForTransaction transaction graph of
227+ Atom $ case headNameForTransaction transaction graph of
227 Just headName -> headName
228 Just headName -> headName
228 Nothing -> ""
229 Nothing -> ""
229 ]
230 ]