private int VerifyTupleKey([NotNull] IRow row) { Assert.NotNull(_tupleKeySet, "tuple keyset is null"); string errorMessage; Tuple fkTuple = TryReadForeignKeyTuple(row, _foreignKeyFieldIndices, _foreignKeyFieldTypes, _referencedKeyFieldTypes, _foreignKeyFields, _referencedKeyFields, out errorMessage); if (fkTuple == null) { // unable to read the tuple return(ReportError(errorMessage, Codes[Code.UnableToConvertFieldValue], null, row)); } if (fkTuple.IsNull) { // the composite foreign key values are all null --> ok return(NoError); } if (_referenceIsError) { return(_tupleKeySet.Contains(fkTuple) ? ReportUnallowedReference(row, fkTuple) : NoError); } return(_tupleKeySet.Contains(fkTuple) ? NoError : ReportMissingReference(row, fkTuple)); }
public void CanCheckTupleKeySetForNonExistingTuplesFastEnough() { ITupleKeySet keyset = CreateTupleKeySet(1000, 500); Stopwatch watch = Stopwatch.StartNew(); const int containsCount = 10000; for (int i = 0; i < containsCount; i++) { keyset.Contains(new Tuple("doesnotexist", "neither")); } watch.Stop(); Console.WriteLine( @"Checking key set of {0:N0} string tuples {1:N0} times for Contains: {2:N0} ms", keyset.Count, containsCount, watch.ElapsedMilliseconds); Assert.IsTrue(watch.ElapsedMilliseconds < 1000, "too slow"); }