[SPARK-35824][CORE][TESTS] Convert LevelDBSuite.IntKeyType from a nested class to a normal class
### What changes were proposed in this pull request? This PR aims to promote `LevelDBSuite.IntKeyType` class to a normal class to isolate `InMemoryIteratorSuite` from `LevelDBSuite`. ### Why are the changes needed? We have the following test suite hierarchy. ``` DBIteratorSuite - InMemoryIteratorSuite - LevelDBIteratorSuite ``` `DBIteratorSuite.testRefWithIntNaturalKey` depends on `LevelDBSuite` and `InMemoryIteratorSuite` derived it. `InMemoryIteratorSuite` should not depend not `LevelDB`-specific stuff. This PR will make it sure. ``` public void testRefWithIntNaturalKey() throws Exception { LevelDBSuite.IntKeyType i = new LevelDBSuite.IntKeyType(); ... ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. ``` $ build/sbt "kvstore/test" ``` Closes #32971 from dongjoon-hyun/SPARK-35824. Authored-by: Dongjoon Hyun <dhyun@apple.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
This commit is contained in:
parent
aab37edefc
commit
a39f1eadb7
|
@ -380,7 +380,7 @@ public abstract class DBIteratorSuite {
|
|||
|
||||
@Test
|
||||
public void testRefWithIntNaturalKey() throws Exception {
|
||||
LevelDBSuite.IntKeyType i = new LevelDBSuite.IntKeyType();
|
||||
IntKeyType i = new IntKeyType();
|
||||
i.key = 1;
|
||||
i.id = "1";
|
||||
i.values = Arrays.asList("1");
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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.util.kvstore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IntKeyType {
|
||||
|
||||
@KVIndex
|
||||
public int key;
|
||||
|
||||
@KVIndex("id")
|
||||
public String id;
|
||||
|
||||
public List<String> values;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof IntKeyType) {
|
||||
IntKeyType other = (IntKeyType) o;
|
||||
return key == other.key && id.equals(other.id) && values.equals(other.values);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -338,31 +338,4 @@ public class LevelDBSuite {
|
|||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static class IntKeyType {
|
||||
|
||||
@KVIndex
|
||||
public int key;
|
||||
|
||||
@KVIndex("id")
|
||||
public String id;
|
||||
|
||||
public List<String> values;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof IntKeyType) {
|
||||
IntKeyType other = (IntKeyType) o;
|
||||
return key == other.key && id.equals(other.id) && values.equals(other.values);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue