Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ public void onFailure(Throwable e) {
@Test
public void singleRPC() throws Exception {
RpcResult res = sendRPC("hello/Aaron");
assertEquals(res.successMessages, Sets.newHashSet("Hello, Aaron!"));
assertEquals(Sets.newHashSet("Hello, Aaron!"), res.successMessages);
assertTrue(res.errorMessages.isEmpty());
}

@Test
public void doubleRPC() throws Exception {
RpcResult res = sendRPC("hello/Aaron", "hello/Reynold");
assertEquals(res.successMessages, Sets.newHashSet("Hello, Aaron!", "Hello, Reynold!"));
assertEquals(Sets.newHashSet("Hello, Aaron!", "Hello, Reynold!"), res.successMessages);
assertTrue(res.errorMessages.isEmpty());
}

Expand Down Expand Up @@ -295,7 +295,7 @@ public void doubleTrouble() throws Exception {
@Test
public void sendSuccessAndFailure() throws Exception {
RpcResult res = sendRPC("hello/Bob", "throw error/the", "hello/Builder", "return error/!");
assertEquals(res.successMessages, Sets.newHashSet("Hello, Bob!", "Hello, Builder!"));
assertEquals(Sets.newHashSet("Hello, Bob!", "Hello, Builder!"), res.successMessages);
assertErrorsContain(res.errorMessages, Sets.newHashSet("Thrown: the", "Returned: !"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,25 @@ public void memoryDebugFillEnabledInTest() {
Assert.assertTrue(MemoryAllocator.MEMORY_DEBUG_FILL_ENABLED);
MemoryBlock onheap = MemoryAllocator.HEAP.allocate(1);
Assert.assertEquals(
Platform.getByte(onheap.getBaseObject(), onheap.getBaseOffset()),
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE,
Platform.getByte(onheap.getBaseObject(), onheap.getBaseOffset()));

MemoryBlock onheap1 = MemoryAllocator.HEAP.allocate(1024 * 1024);
Object onheap1BaseObject = onheap1.getBaseObject();
long onheap1BaseOffset = onheap1.getBaseOffset();
MemoryAllocator.HEAP.free(onheap1);
Assert.assertEquals(
Platform.getByte(onheap1BaseObject, onheap1BaseOffset),
MemoryAllocator.MEMORY_DEBUG_FILL_FREED_VALUE);
MemoryAllocator.MEMORY_DEBUG_FILL_FREED_VALUE,
Platform.getByte(onheap1BaseObject, onheap1BaseOffset));
MemoryBlock onheap2 = MemoryAllocator.HEAP.allocate(1024 * 1024);
Assert.assertEquals(
Platform.getByte(onheap2.getBaseObject(), onheap2.getBaseOffset()),
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE,
Platform.getByte(onheap2.getBaseObject(), onheap2.getBaseOffset()));

MemoryBlock offheap = MemoryAllocator.UNSAFE.allocate(1);
Assert.assertEquals(
Platform.getByte(offheap.getBaseObject(), offheap.getBaseOffset()),
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE,
Platform.getByte(offheap.getBaseObject(), offheap.getBaseOffset()));
MemoryAllocator.UNSAFE.free(offheap);
}

Expand All @@ -150,11 +150,11 @@ public void heapMemoryReuse() {
// The size is greater than `HeapMemoryAllocator.POOLING_THRESHOLD_BYTES`,
// reuse the previous memory which has released.
MemoryBlock onheap3 = heapMem.allocate(1024 * 1024 + 1);
Assert.assertEquals(onheap3.size(), 1024 * 1024 + 1);
Assert.assertEquals(1024 * 1024 + 1, onheap3.size());
Object obj3 = onheap3.getBaseObject();
heapMem.free(onheap3);
MemoryBlock onheap4 = heapMem.allocate(1024 * 1024 + 7);
Assert.assertEquals(onheap4.size(), 1024 * 1024 + 7);
Assert.assertEquals(1024 * 1024 + 7, onheap4.size());
Assert.assertEquals(obj3, onheap4.getBaseObject());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ public void toStringTest() {
public void addTest() {
CalendarInterval input1 = new CalendarInterval(3, 1, 1 * MICROS_PER_HOUR);
CalendarInterval input2 = new CalendarInterval(2, 4, 100 * MICROS_PER_HOUR);
assertEquals(input1.add(input2), new CalendarInterval(5, 5, 101 * MICROS_PER_HOUR));
assertEquals(new CalendarInterval(5, 5, 101 * MICROS_PER_HOUR), input1.add(input2));

input1 = new CalendarInterval(-10, -30, -81 * MICROS_PER_HOUR);
input2 = new CalendarInterval(75, 150, 200 * MICROS_PER_HOUR);
assertEquals(input1.add(input2), new CalendarInterval(65, 120, 119 * MICROS_PER_HOUR));
assertEquals(new CalendarInterval(65, 120, 119 * MICROS_PER_HOUR), input1.add(input2));
}

@Test
public void subtractTest() {
CalendarInterval input1 = new CalendarInterval(3, 1, 1 * MICROS_PER_HOUR);
CalendarInterval input2 = new CalendarInterval(2, 4, 100 * MICROS_PER_HOUR);
assertEquals(input1.subtract(input2), new CalendarInterval(1, -3, -99 * MICROS_PER_HOUR));
assertEquals(new CalendarInterval(1, -3, -99 * MICROS_PER_HOUR), input1.subtract(input2));

input1 = new CalendarInterval(-10, -30, -81 * MICROS_PER_HOUR);
input2 = new CalendarInterval(75, 150, 200 * MICROS_PER_HOUR);
assertEquals(input1.subtract(input2), new CalendarInterval(-85, -180, -281 * MICROS_PER_HOUR));
assertEquals(new CalendarInterval(-85, -180, -281 * MICROS_PER_HOUR), input1.subtract(input2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class UTF8StringSuite {
private static void checkBasic(String str, int len) {
UTF8String s1 = fromString(str);
UTF8String s2 = fromBytes(str.getBytes(StandardCharsets.UTF_8));
assertEquals(s1.numChars(), len);
assertEquals(s2.numChars(), len);
assertEquals(len, s1.numChars());
assertEquals(len, s2.numChars());

assertEquals(s1.toString(), str);
assertEquals(s2.toString(), str);
assertEquals(str, s1.toString());
assertEquals(str, s2.toString());
assertEquals(s1, s2);

assertEquals(s1.hashCode(), s2.hashCode());
Expand Down Expand Up @@ -375,20 +375,20 @@ public void pad() {
@Test
public void substringSQL() {
UTF8String e = fromString("example");
assertEquals(e.substringSQL(0, 2), fromString("ex"));
assertEquals(e.substringSQL(1, 2), fromString("ex"));
assertEquals(e.substringSQL(0, 7), fromString("example"));
assertEquals(e.substringSQL(1, 2), fromString("ex"));
assertEquals(e.substringSQL(0, 100), fromString("example"));
assertEquals(e.substringSQL(1, 100), fromString("example"));
assertEquals(e.substringSQL(2, 2), fromString("xa"));
assertEquals(e.substringSQL(1, 6), fromString("exampl"));
assertEquals(e.substringSQL(2, 100), fromString("xample"));
assertEquals(e.substringSQL(0, 0), fromString(""));
assertEquals(e.substringSQL(100, 4), EMPTY_UTF8);
assertEquals(e.substringSQL(0, Integer.MAX_VALUE), fromString("example"));
assertEquals(e.substringSQL(1, Integer.MAX_VALUE), fromString("example"));
assertEquals(e.substringSQL(2, Integer.MAX_VALUE), fromString("xample"));
assertEquals(fromString("ex"), e.substringSQL(0, 2));
assertEquals(fromString("ex"), e.substringSQL(1, 2));
assertEquals(fromString("example"), e.substringSQL(0, 7));
assertEquals(fromString("ex"), e.substringSQL(1, 2));
assertEquals(fromString("example"), e.substringSQL(0, 100));
assertEquals(fromString("example"), e.substringSQL(1, 100));
assertEquals(fromString("xa"), e.substringSQL(2, 2));
assertEquals(fromString("exampl"), e.substringSQL(1, 6));
assertEquals(fromString("xample"), e.substringSQL(2, 100));
assertEquals(fromString(""), e.substringSQL(0, 0));
assertEquals(EMPTY_UTF8, e.substringSQL(100, 4));
assertEquals(fromString("example"), e.substringSQL(0, Integer.MAX_VALUE));
assertEquals(fromString("example"), e.substringSQL(1, Integer.MAX_VALUE));
assertEquals(fromString("xample"), e.substringSQL(2, Integer.MAX_VALUE));
}

@Test
Expand Down Expand Up @@ -506,50 +506,50 @@ public void findInSet() {

@Test
public void soundex() {
assertEquals(fromString("Robert").soundex(), fromString("R163"));
assertEquals(fromString("Rupert").soundex(), fromString("R163"));
assertEquals(fromString("Rubin").soundex(), fromString("R150"));
assertEquals(fromString("Ashcraft").soundex(), fromString("A261"));
assertEquals(fromString("Ashcroft").soundex(), fromString("A261"));
assertEquals(fromString("Burroughs").soundex(), fromString("B620"));
assertEquals(fromString("Burrows").soundex(), fromString("B620"));
assertEquals(fromString("Ekzampul").soundex(), fromString("E251"));
assertEquals(fromString("Example").soundex(), fromString("E251"));
assertEquals(fromString("Ellery").soundex(), fromString("E460"));
assertEquals(fromString("Euler").soundex(), fromString("E460"));
assertEquals(fromString("Ghosh").soundex(), fromString("G200"));
assertEquals(fromString("Gauss").soundex(), fromString("G200"));
assertEquals(fromString("Gutierrez").soundex(), fromString("G362"));
assertEquals(fromString("Heilbronn").soundex(), fromString("H416"));
assertEquals(fromString("Hilbert").soundex(), fromString("H416"));
assertEquals(fromString("Jackson").soundex(), fromString("J250"));
assertEquals(fromString("Kant").soundex(), fromString("K530"));
assertEquals(fromString("Knuth").soundex(), fromString("K530"));
assertEquals(fromString("Lee").soundex(), fromString("L000"));
assertEquals(fromString("Lukasiewicz").soundex(), fromString("L222"));
assertEquals(fromString("Lissajous").soundex(), fromString("L222"));
assertEquals(fromString("Ladd").soundex(), fromString("L300"));
assertEquals(fromString("Lloyd").soundex(), fromString("L300"));
assertEquals(fromString("Moses").soundex(), fromString("M220"));
assertEquals(fromString("O'Hara").soundex(), fromString("O600"));
assertEquals(fromString("Pfister").soundex(), fromString("P236"));
assertEquals(fromString("Rubin").soundex(), fromString("R150"));
assertEquals(fromString("Robert").soundex(), fromString("R163"));
assertEquals(fromString("Rupert").soundex(), fromString("R163"));
assertEquals(fromString("Soundex").soundex(), fromString("S532"));
assertEquals(fromString("Sownteks").soundex(), fromString("S532"));
assertEquals(fromString("Tymczak").soundex(), fromString("T522"));
assertEquals(fromString("VanDeusen").soundex(), fromString("V532"));
assertEquals(fromString("Washington").soundex(), fromString("W252"));
assertEquals(fromString("Wheaton").soundex(), fromString("W350"));

assertEquals(fromString("a").soundex(), fromString("A000"));
assertEquals(fromString("ab").soundex(), fromString("A100"));
assertEquals(fromString("abc").soundex(), fromString("A120"));
assertEquals(fromString("abcd").soundex(), fromString("A123"));
assertEquals(fromString("").soundex(), fromString(""));
assertEquals(fromString("123").soundex(), fromString("123"));
assertEquals(fromString("世界千世").soundex(), fromString("世界千世"));
assertEquals(fromString("R163"), fromString("Robert").soundex());
assertEquals(fromString("R163"), fromString("Rupert").soundex());
assertEquals(fromString("R150"), fromString("Rubin").soundex());
assertEquals(fromString("A261"), fromString("Ashcraft").soundex());
assertEquals(fromString("A261"), fromString("Ashcroft").soundex());
assertEquals(fromString("B620"), fromString("Burroughs").soundex());
assertEquals(fromString("B620"), fromString("Burrows").soundex());
assertEquals(fromString("E251"), fromString("Ekzampul").soundex());
assertEquals(fromString("E251"), fromString("Example").soundex());
assertEquals(fromString("E460"), fromString("Ellery").soundex());
assertEquals(fromString("E460"), fromString("Euler").soundex());
assertEquals(fromString("G200"), fromString("Ghosh").soundex());
assertEquals(fromString("G200"), fromString("Gauss").soundex());
assertEquals(fromString("G362"), fromString("Gutierrez").soundex());
assertEquals(fromString("H416"), fromString("Heilbronn").soundex());
assertEquals(fromString("H416"), fromString("Hilbert").soundex());
assertEquals(fromString("J250"), fromString("Jackson").soundex());
assertEquals(fromString("K530"), fromString("Kant").soundex());
assertEquals(fromString("K530"), fromString("Knuth").soundex());
assertEquals(fromString("L000"), fromString("Lee").soundex());
assertEquals(fromString("L222"), fromString("Lukasiewicz").soundex());
assertEquals(fromString("L222"), fromString("Lissajous").soundex());
assertEquals(fromString("L300"), fromString("Ladd").soundex());
assertEquals(fromString("L300"), fromString("Lloyd").soundex());
assertEquals(fromString("M220"), fromString("Moses").soundex());
assertEquals(fromString("O600"), fromString("O'Hara").soundex());
assertEquals(fromString("P236"), fromString("Pfister").soundex());
assertEquals(fromString("R150"), fromString("Rubin").soundex());
assertEquals(fromString("R163"), fromString("Robert").soundex());
assertEquals(fromString("R163"), fromString("Rupert").soundex());
assertEquals(fromString("S532"), fromString("Soundex").soundex());
assertEquals(fromString("S532"), fromString("Sownteks").soundex());
assertEquals(fromString("T522"), fromString("Tymczak").soundex());
assertEquals(fromString("V532"), fromString("VanDeusen").soundex());
assertEquals(fromString("W252"), fromString("Washington").soundex());
assertEquals(fromString("W350"), fromString("Wheaton").soundex());

assertEquals(fromString("A000"), fromString("a").soundex());
assertEquals(fromString("A100"), fromString("ab").soundex());
assertEquals(fromString("A120"), fromString("abc").soundex());
assertEquals(fromString("A123"), fromString("abcd").soundex());
assertEquals(fromString(""), fromString("").soundex());
assertEquals(fromString("123"), fromString("123").soundex());
assertEquals(fromString("世界千世"), fromString("世界千世").soundex());
}

@Test
Expand Down Expand Up @@ -849,7 +849,7 @@ public void skipWrongFirstByte() {

for (int i = 0; i < wrongFirstBytes.length; ++i) {
c[0] = (byte)wrongFirstBytes[i];
assertEquals(fromBytes(c).numChars(), 1);
assertEquals(1, fromBytes(c).numChars());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public static class InProcessTestApp {

public static void main(String[] args) throws Exception {
assertNotEquals(0, args.length);
assertEquals(args[0], "hello");
assertEquals("hello", args[0]);
new SparkContext().stop();

synchronized (LOCK) {
Expand All @@ -340,7 +340,7 @@ public static class ErrorInProcessTestApp {

public static void main(String[] args) {
assertNotEquals(0, args.length);
assertEquals(args[0], "hello");
assertEquals("hello", args[0]);
throw DUMMY_EXCEPTION;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public void testSerializableConfiguration() {
hadoopConfiguration.set("test.property", "value");
SerializableConfiguration scs = new SerializableConfiguration(hadoopConfiguration);
SerializableConfiguration actual = rdd.map(val -> scs).collect().get(0);
assertEquals(actual.value().get("test.property"), "value");
assertEquals("value", actual.value().get("test.property"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ public void testSortingEmptyArrays() throws Exception {
public void testSortTimeMetric() throws Exception {
final UnsafeExternalSorter sorter = newSorter();
long prevSortTime = sorter.getSortTimeNanos();
assertEquals(prevSortTime, 0);
assertEquals(0, prevSortTime);

sorter.insertRecord(null, 0, 0, 0, false);
sorter.spill();
assertThat(sorter.getSortTimeNanos(), greaterThan(prevSortTime));
prevSortTime = sorter.getSortTimeNanos();

sorter.spill(); // no sort needed
assertEquals(sorter.getSortTimeNanos(), prevSortTime);
assertEquals(prevSortTime, sorter.getSortTimeNanos());

sorter.insertRecord(null, 0, 0, 0, false);
UnsafeSorterIterator iter = sorter.getSortedIterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ public void testRedirectsSimple() throws Exception {
SparkLauncher launcher = new SparkLauncher();
launcher.redirectError(ProcessBuilder.Redirect.PIPE);
assertNotNull(launcher.errorStream);
assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.PIPE);
assertEquals(ProcessBuilder.Redirect.Type.PIPE, launcher.errorStream.type());

launcher.redirectOutput(ProcessBuilder.Redirect.PIPE);
assertNotNull(launcher.outputStream);
assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.PIPE);
assertEquals(ProcessBuilder.Redirect.Type.PIPE, launcher.outputStream.type());
}

@Test
public void testRedirectLastWins() throws Exception {
SparkLauncher launcher = new SparkLauncher();
launcher.redirectError(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.INHERIT);
assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.INHERIT);
assertEquals(ProcessBuilder.Redirect.Type.INHERIT, launcher.errorStream.type());

launcher.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectOutput(ProcessBuilder.Redirect.INHERIT);
assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.INHERIT);
assertEquals(ProcessBuilder.Redirect.Type.INHERIT, launcher.outputStream.type());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUp() throws IOException {
@Test
public void logisticRegressionDefaultParams() {
LogisticRegression lr = new LogisticRegression();
Assert.assertEquals(lr.getLabelCol(), "label");
Assert.assertEquals("label", lr.getLabelCol());
LogisticRegressionModel model = lr.fit(dataset);
model.transform(dataset).createOrReplaceTempView("prediction");
Dataset<Row> predictions = spark.sql("SELECT label, probability, prediction FROM prediction");
Expand Down Expand Up @@ -119,8 +119,8 @@ public void logisticRegressionPredictorClassifierMethods() {
for (Row row : trans1.collectAsList()) {
Vector raw = (Vector) row.get(0);
Vector prob = (Vector) row.get(1);
Assert.assertEquals(raw.size(), 2);
Assert.assertEquals(prob.size(), 2);
Assert.assertEquals(2, raw.size());
Assert.assertEquals(2, prob.size());
double probFromRaw1 = 1.0 / (1.0 + Math.exp(-raw.apply(1)));
Assert.assertEquals(0, Math.abs(prob.apply(1) - probFromRaw1), eps);
Assert.assertEquals(0, Math.abs(prob.apply(0) - (1.0 - probFromRaw1)), eps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public void setUp() throws IOException {
public void oneVsRestDefaultParams() {
OneVsRest ova = new OneVsRest();
ova.setClassifier(new LogisticRegression());
Assert.assertEquals(ova.getLabelCol(), "label");
Assert.assertEquals(ova.getPredictionCol(), "prediction");
Assert.assertEquals("label", ova.getLabelCol());
Assert.assertEquals("prediction", ova.getPredictionCol());
OneVsRestModel ovaModel = ova.fit(dataset);
Dataset<Row> predictions = ovaModel.transform(dataset).select("label", "prediction");
predictions.collectAsList();
Assert.assertEquals(ovaModel.getLabelCol(), "label");
Assert.assertEquals(ovaModel.getPredictionCol(), "prediction");
Assert.assertEquals("label", ovaModel.getLabelCol());
Assert.assertEquals("prediction", ovaModel.getPredictionCol());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void hashingTF() {
Dataset<Row> rescaledData = idfModel.transform(featurizedData);
for (Row r : rescaledData.select("features", "label").takeAsList(3)) {
Vector features = r.getAs(0);
Assert.assertEquals(features.size(), numFeatures);
Assert.assertEquals(numFeatures, features.size());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void vectorIndexerAPI() {
.setOutputCol("indexed")
.setMaxCategories(2);
VectorIndexerModel model = indexer.fit(data);
Assert.assertEquals(model.numFeatures(), 2);
Assert.assertEquals(2, model.numFeatures());
Map<Integer, Map<Double, Integer>> categoryMaps = model.javaCategoryMaps();
Assert.assertEquals(categoryMaps.size(), 1);
Assert.assertEquals(1, categoryMaps.size());
Dataset<Row> indexedData = model.transform(data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void vectorSlice() {

for (Row r : output.select("userFeatures", "features").takeAsList(2)) {
Vector features = r.getAs(1);
Assert.assertEquals(features.size(), 2);
Assert.assertEquals(2, features.size());
}
}
}
Loading