-
Notifications
You must be signed in to change notification settings - Fork 250
[compiler] Add SJavaString / SJavaBytes / SJavaArrayString #10625
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
Conversation
96362ba
to
69ef775
Compare
360e172
to
19d1ea3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. Found a few minor issues.
val v1 = cb.newLocal[String]("hamming_str_1", sc1.loadString()) | ||
val v2 = cb.newLocal[String]("hamming_str_2", sc2.loadString()) | ||
|
||
val m = v1.loadLength().cne(v2.loadLength()) | ||
val l1 = cb.newLocal[Int]("hamming_len_1", v1.invoke[Int]("length")) | ||
val l2 = cb.newLocal[Int]("hamming_len_2", v2.invoke[Int]("length")) | ||
val m = l1.cne(l2) | ||
|
||
IEmitCode(cb, m, { | ||
cb.whileLoop(i < v1.loadLength(), { | ||
cb.ifx(v1.loadByte(i).cne(v2.loadByte(i)), | ||
cb.whileLoop(i < l1, { | ||
cb.ifx(v1.invoke[Int, Char]("charAt", i).toI.cne(v2.invoke[Int, Char]("charAt", i).toI), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a behavioral change. The old version calculated the hamming distance on bytes this one does so on character sequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the old implementation was wrong.
@@ -19,7 +19,7 @@ object ShuffleOrdering { | |||
val bcode1 = x.asInstanceOf[SCanonicalShufflePointerCode].binaryRepr | |||
val bcode2 = y.asInstanceOf[SCanonicalShufflePointerCode].binaryRepr | |||
val ord = BinaryOrdering.make(bcode1.st, bcode2.st, ecb) | |||
ord.compareNonnull(cb, x.asString.asBytes(), y.asString.asBytes()) | |||
ord.compareNonnull(cb, x.asInstanceOf[SCanonicalShufflePointerCode].binaryRepr, y.asInstanceOf[SCanonicalShufflePointerCode].binaryRepr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't this just use bcode1
and bcode2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, yeah.
private[this] def memoizeWithBuilder(cb: EmitCodeBuilder, name: String, sb: SettableBuilder): SBinaryValue = { | ||
val s = new SJavaBytesSettable(sb.newSettable[Array[Byte]]("sjavabytes_memoize")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
is unused, maybe need to use SJavaBytesSettable.apply
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just need to use name
in the string passed here.
private[this] def memoizeWithBuilder(cb: EmitCodeBuilder, name: String, sb: SettableBuilder): SValue = { | ||
val s = new SJavaStringSettable(sb.newSettable[String]("sjavastring_memoize")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
unused, same as SJavaBytes
comment
case _ => | ||
val sv = code.asIndexable.memoize(cb, "scode_array_string") | ||
val arr = cb.newLocal[Array[String]]("scode_array_string", Code.newArray[String](sv.loadLength())) | ||
sv.foreach(cb) { case (cb, idx, elt) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this new foreach
method rather than foreachDefined
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, that will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
now test batch needs to pass
…0625) * [compiler] Add SJavaString / SJavaBytes / SJavaArrayString * some fixes * fix bytes * add check * fix array wrap * fix java array virtual type and settable tuple types * fix arraylen * fix rg * addressed
No description provided.