jlleitschuh
09/26/2018, 8:13 PM-Xjsr305=strict
enabled and you have a java class annotated with: @ParametersAreNonnullByDefault
.
If that class overrides equals(Object other)
without having @Nullable
on the other
param, kotlin can't use the ==
operator.
Eg. The following won't compile:
JavaSomething("one") == JavaSomething( "one")
Java side:
@ParametersAreNonnullByDefault
public class JavaSomething {
private final String something;
JavaSomething(String something) {
this.something = something;
}
@Override
public boolean equals(final Object other) {
if (this == other) return true;
if (other == null) return false;
if (this.getClass() != other.getClass()) return false;
final JavaSomething javaOther = (JavaSomething) other;
return something.equals(javaOther.something);
}
}
Tsvetozar Bonev
09/27/2018, 7:33 AMribesg
09/27/2018, 8:33 AMbuild.gradle.kts
?vaskir
09/27/2018, 9:45 AMvaskir
09/27/2018, 10:23 AMvaskir
09/27/2018, 10:45 AMvaskir
09/27/2018, 11:21 AMwhen (x) { is Foo && x.aFooField > 10 -> ... }
vaskir
09/27/2018, 12:16 PMcatch (e: MyException if e.foo = 25) { .. }
??Hamza
09/27/2018, 2:22 PMkarelpeeters
09/27/2018, 5:25 PMdata class Foo(var x: Int)
fun main(args: Array<String>) {
val f = Foo(3)
val s = mutableSetOf(f)
f.x = 7
println(s == setOf(Foo(7)))
}
on try.kotlinlang.org.JT
09/27/2018, 11:19 PMpavel
09/27/2018, 11:38 PMribesg
09/28/2018, 8:30 AMmarcinmoskala
09/28/2018, 10:17 AMNikky
09/28/2018, 11:38 AMpp.amorim
09/28/2018, 1:29 PMbdawg.io
09/28/2018, 9:53 PMAllan Wang
09/29/2018, 1:00 AMenum class Order {
ASCENDING {
override fun <T : Comparable<T>> sort(iterable: Iterable<T>): List<T> =
iterable.sorted()
}, DESCENDING {
override fun <T : Comparable<T>> sort(iterable: Iterable<T>): List<T> =
iterable.sortedDescending()
};
abstract fun <T : Comparable<T>> sort(iterable: Iterable<T>): List<T>
}
Such that it is something in the form of
enum class Order(...) {
ASCENDING(::sorted), DESCENDING(::sortedDescending)
}
jo
09/29/2018, 3:23 PMHexa
09/29/2018, 4:53 PMHexa
09/29/2018, 5:40 PMfun processIncomingMessages(incomingMessage: List<IncomingMessage>)
is actually a function that thats a list of SomeOtherType
but not IncomingMessage
. SomeOtherType
is just a json message, so I need to process each json message and wrap them in a IncomingMessage class. So it's actually look more like this this ( I try to use jacksonmapper library) // example incoming messages:
// {"message":"message1", phoneType":"iPhoneX", "test1"},
// {"message":"message1", phoneType":"Samsung1", "test2"}
fun processIncomingMessages(incomingMessage: List<SomeType>): Map<MessageIndex, List<Message>>{
//how do I need to process each incoming json messsage and wrap them in IncomingMessage class?
return incomingMessage.forEach {
val eventObj = jacksonObjectMapper().readValue(String(it.data.array()), IncomingMessage::class.java)
}
cygnus
09/30/2018, 5:34 AMAbdelkrim
09/30/2018, 2:13 PMmuralimohan962
09/30/2018, 2:22 PMAntero Duarte
10/01/2018, 12:27 PMoverride fun getFiles(path: String, sc: SparkContext): RDD<*> {
sc.hadoopConfiguration().set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem::class.java.name)
return sc.binaryFiles(path, 1)
}
And that was fine, It all worked properly.
But now I had to add a .filter() to that returning RDD, and I'm struggling to get the code to compile, even though I don't get any errors in the IDE
The smallest example I can give is:
override fun getFiles(path: String, sc: SparkContext): RDD<*> {
sc.hadoopConfiguration().set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem::class.java.name)
return sc.binaryFiles(path, 1).filter { true }
}
Which should just return true from the filter and not do anything
But I get this error when trying to build:
Error:(56, 47) Kotlin: Type mismatch: inferred type is () -> Boolean but Function1<Tuple2<String!, PortableDataStream!>!, Any!>! was expected
The closest I have got to making it work was:
override fun getFiles(path: String, sc: SparkContext): RDD<*> {
sc.hadoopConfiguration().set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem::class.java.name)
return sc.binaryFiles(path, 1).filter(getFilterFunction())
}
private fun getFilterFunction(): scala.Function1<Tuple2<String, PortableDataStream>, Any> {
return Function1<Tuple2<String, PortableDataStream>, Any> { tuple: Tuple2<String, PortableDataStream> ->
return@Function1 true
}
}
But I get
Error:(60, 16) Kotlin: Interface Function1 does not have constructors
Does anyone have experience with interfacing with Apache Spark from kotlin?Benoît
10/01/2018, 1:26 PM~/.gradle/caches
, scripts don't work anymore if I try to run them from the IDE I get this :
Primary constructor not found for script template class ScriptTemplateWithArgs
Any idea how to fix that ?deviant
10/01/2018, 2:34 PMinline
classes allow only one constructor param? it would be nice to have inline class Pair
to avoid extra allocationsjlleitschuh
10/01/2018, 7:50 PMgroostav
10/01/2018, 10:05 PMA.main
as its entry point, the only thing you'll see is NoClassDefFoundError: Cannot find 'com.you.A'
correct? without a caused-by ExceptionInInitializer
?Jukka Siivonen
10/02/2018, 7:16 AM