-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-36702][SQL] ArrayUnion handle duplicated Double.NaN and Float.Nan #33955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8579c97
d6e4f39
a481196
1857988
4e533fd
119679c
45d1fee
08cc967
8d0e4a9
36758d1
5b077a5
89a4263
1ac5ab3
08da413
0da6ea5
3059ea1
991fddd
db8159e
eb1f028
f59c0a8
f27c4e1
affd31a
fe407c9
4e5e085
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.util | ||
|
|
||
| import scala.reflect._ | ||
|
|
||
| import org.apache.spark.annotation.Private | ||
| import org.apache.spark.util.collection.OpenHashSet | ||
|
|
||
| /** | ||
| * A wrap of [[OpenHashSet]] that can handle null, Double.NaN and Float.NaN. | ||
AngersZhuuuu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| @Private | ||
| class SQLOpenHashSet[@specialized(Long, Int, Double, Float) T: ClassTag]( | ||
| initialCapacity: Int, | ||
| loadFactor: Double) { | ||
|
|
||
| def this(initialCapacity: Int) = this(initialCapacity, 0.7) | ||
|
|
||
| def this() = this(64) | ||
|
|
||
| private val hashSet = new OpenHashSet[T](initialCapacity, loadFactor) | ||
|
|
||
| private var containsNull = false | ||
| private var containsDoubleNaN = false | ||
| private var containsFloatNaN = false | ||
|
||
|
|
||
| def add(k: T): Unit = { | ||
| if (k == null) { | ||
| containsNull = true | ||
| } else if (Double.NaN.equals(k)) { | ||
| containsDoubleNaN = true | ||
| } else if (Float.NaN.equals(k)) { | ||
| containsFloatNaN = true | ||
| } else { | ||
| hashSet.add(k) | ||
| } | ||
| } | ||
|
|
||
| def contains(k: T): Boolean = { | ||
AngersZhuuuu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (k == null) { | ||
| containsNull | ||
| } else if (Double.NaN.equals(k)) { | ||
| containsDoubleNaN | ||
| } else if (Float.NaN.equals(k)) { | ||
| containsFloatNaN | ||
| } else { | ||
| hashSet.contains(k) | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.