Skip to content

Commit

Permalink
fix issue 1047 (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhexuany authored Aug 26, 2019
1 parent f578c3b commit 8bebb76
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ case class ColumnValueGenerator(dataType: ReflectedDataType,
generatedRandomValues = if (generateUnique) {
assert(n <= rangeSize, "random generator cannot generate unique value less than available")
val set: mutable.Set[Any] = mutable.HashSet.empty[Any]
set += specialBound.map(TestDataGenerator.hash)
set ++= specialBound.map(TestDataGenerator.hash)
(0L until n - specialBound.size).map { _ =>
randomUniqueValue(r, set)
}.toList ++ specialBound
Expand All @@ -245,9 +245,16 @@ case class ColumnValueGenerator(dataType: ReflectedDataType,
randomValue(r)
}.toList ++ specialBound
}

val expectedGeneratedRandomValuesLen = if (generateUnique) {
generatedRandomValues.toSet.size
} else {
generatedRandomValues.size
}

assert(
generatedRandomValues.size >= n,
s"Generate values size=$generatedRandomValues less than n=$n"
expectedGeneratedRandomValuesLen >= n,
s"Generate values size=$generatedRandomValues less than n=$n on datatype $dataType"
)
curPos = 0
}
Expand Down

0 comments on commit 8bebb76

Please sign in to comment.