Skip to content

Instantly share code, notes, and snippets.

@olafurpg
Created March 12, 2020 10:39
Show Gist options
  • Save olafurpg/1c9f8953ac591e5541f61d1b79b40236 to your computer and use it in GitHub Desktop.
Save olafurpg/1c9f8953ac591e5541f61d1b79b40236 to your computer and use it in GitHub Desktop.
[[syntax trees at end of typer]] // foo.scala
package <empty> {
import com.twitter.scalding.serialization.RequiredBinaryComparators;
abstract trait MagicRecsNotificationsTrait extends com.twitter.scalding.Job with com.twitter.scalding.serialization.RequiredBinaryComparators {
def /*MagicRecsNotificationsTrait*/$init$(): Unit = {
()
};
<stable> <accessor> val aggregatedData: com.twitter.scalding.typed.TypedPipe[(Long, Option[Long])] = scala.Predef.???;
def infinite: com.twitter.scalding.typed.TypedPipe[(Long, Option[Long])] = MagicRecsNotificationsTrait.this.aggregatedData.distinct({
final class $anon extends com.twitter.scalding.serialization.macros.impl.ordered_serialization.runtime_helpers.MacroEqualityOrderedSerialization[(Long, Option[Long])] {
def <init>(): <$anon: com.twitter.scalding.serialization.macros.impl.ordered_serialization.runtime_helpers.MacroEqualityOrderedSerialization[(Long, Option[Long])]> = {
$anon.super.<init>();
()
};
private[this] val uniqueId: String = "(Long, Option[Long])";
override <stable> <accessor> def uniqueId: String = $anon.this.uniqueId;
private[this] var lengthCalculationAttempts: Long = 0L;
private[this] var couldNotLenCalc: Long = 0L;
private[this] var skipLenCalc: Boolean = false;
import com.twitter.scalding.serialization.JavaStreamEnrichments._;
override def compareBinary(fresh_inputStreamA$macro$4: java.io.InputStream, fresh_inputStreamB$macro$5: java.io.InputStream): com.twitter.scalding.serialization.OrderedSerialization.Result = try {
com.twitter.scalding.serialization.OrderedSerialization.resultFrom({
val fresh_lenA$macro$8: Int = com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_inputStreamA$macro$4).readPosVarInt;
val fresh_lenB$macro$9: Int = com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_inputStreamB$macro$5).readPosVarInt;
val fresh_posStreamA$macro$6: com.twitter.scalding.serialization.PositionInputStream = com.twitter.scalding.serialization.PositionInputStream.apply(fresh_inputStreamA$macro$4);
val initialPositionA: Long = fresh_posStreamA$macro$6.position;
val fresh_posStreamB$macro$7: com.twitter.scalding.serialization.PositionInputStream = com.twitter.scalding.serialization.PositionInputStream.apply(fresh_inputStreamB$macro$5);
val initialPositionB: Long = fresh_posStreamB$macro$7.position;
val innerR: Int = {
val lastCmp$macro$10: Int = java.lang.Long.compare(com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_posStreamA$macro$6).readLong, com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_posStreamB$macro$7).readLong);
if (lastCmp$macro$10.!=(0))
lastCmp$macro$10
else
{
val valueOfA$macro$11: Byte = com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_posStreamA$macro$6).readByte;
val valueOfB$macro$12: Byte = com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_posStreamB$macro$7).readByte;
val tmpHolder$macro$13: Int = java.lang.Byte.compare(valueOfA$macro$11, valueOfB$macro$12);
if (tmpHolder$macro$13.!=(0).||(valueOfA$macro$11.==((0: Byte))))
tmpHolder$macro$13
else
java.lang.Long.compare(com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_posStreamA$macro$6).readLong, com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(fresh_posStreamB$macro$7).readLong)
}
};
fresh_posStreamA$macro$6.seekToPosition(initialPositionA.+(fresh_lenA$macro$8));
fresh_posStreamB$macro$7.seekToPosition(initialPositionB.+(fresh_lenB$macro$9));
innerR
})
} catch {
case scala.util.control.NonFatal.unapply(<unapply-selector>) <unapply> ((e @ _)) => com.twitter.scalding.serialization.OrderedSerialization.CompareFailure.apply(e)
};
override def hash(passedInObjectToHash: (Long, Option[Long])): Int = {
var last$macro$14: Int = -137723950;
{
val target$macro$15: Long = passedInObjectToHash._1;
last$macro$14 = com.twitter.scalding.serialization.MurmurHashUtils.mixH1(last$macro$14, com.twitter.scalding.serialization.Hasher.long.hash(target$macro$15))
};
{
val target$macro$16: Option[Long] = passedInObjectToHash._2;
last$macro$14 = com.twitter.scalding.serialization.MurmurHashUtils.mixH1(last$macro$14, if (target$macro$16.isEmpty)
0
else
{
val innerValue$macro$17: Long = target$macro$16.get;
com.twitter.scalding.serialization.Hasher.long.hash(innerValue$macro$17)
})
};
com.twitter.scalding.serialization.MurmurHashUtils.fmix(last$macro$14, 2)
};
private[this] def failedLengthCalc(): Unit = {
$anon.this.couldNotLenCalc = $anon.this.couldNotLenCalc.+(1L);
if ($anon.this.lengthCalculationAttempts.>(50).&&($anon.this.couldNotLenCalc.toDouble./($anon.this.lengthCalculationAttempts).>(0.4)))
$anon.this.skipLenCalc = true
else
()
};
private[this] def noLengthWrite(fresh_element$macro$19: (Long, Option[Long]), fresh_os$macro$20: java.io.OutputStream): Unit = {
val fresh_baos$macro$18: java.io.ByteArrayOutputStream = new java.io.ByteArrayOutputStream(512);
{
{
val innerElement$macro$22: Long = fresh_element$macro$19._1;
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(fresh_baos$macro$18).writeLong(innerElement$macro$22)
};
val innerElement$macro$22: Option[Long] = fresh_element$macro$19._2;
if (innerElement$macro$22.isDefined)
{
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(fresh_baos$macro$18).writeByte((1: Byte));
val innerValue$macro$24: Long = innerElement$macro$22.get;
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(fresh_baos$macro$18).writeLong(innerValue$macro$24)
}
else
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(fresh_baos$macro$18).writeByte((0: Byte))
};
val fresh_len$macro$21: Int = fresh_baos$macro$18.size();
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(fresh_os$macro$20).writePosVarInt(fresh_len$macro$21);
fresh_baos$macro$18.writeTo(fresh_os$macro$20)
};
private[this] def payloadLength(fresh_element$macro$2: (Long, Option[Long])): com.twitter.scalding.serialization.macros.impl.ordered_serialization.runtime_helpers.MaybeLength = {
$anon.this.lengthCalculationAttempts = $anon.this.lengthCalculationAttempts.+(1);
com.twitter.scalding.serialization.macros.impl.ordered_serialization.runtime_helpers.DynamicLen.apply(8.+(if (fresh_element$macro$2._2.isDefined)
9
else
1))
};
override def staticSize: Option[Int] = scala.None;
override def dynamicSize(fresh_element$macro$30: (Long, Option[Long])): Option[Int] = if ($anon.this.skipLenCalc)
scala.None
else
{
val fresh_tempLen$macro$28: Option[Int] = $anon.this.payloadLength(fresh_element$macro$30) match {
case com.twitter.scalding.serialization.macros.impl.ordered_serialization.runtime_helpers.NoLengthCalculation => {
$anon.this.failedLengthCalc();
scala.None
}
case (toInt: Int)com.twitter.scalding.serialization.macros.impl.ordered_serialization.runtime_helpers.ConstLen((l @ _)) => scala.Some.apply[Int](l)
case (toInt: Int)com.twitter.scalding.serialization.macros.impl.ordered_serialization.runtime_helpers.DynamicLen((l @ _)) => scala.Some.apply[Int](l)
};
(if (fresh_tempLen$macro$28.isDefined)
{
val innerLen: Int = fresh_tempLen$macro$28.get;
val fresh_lensLen$macro$29: Int = com.twitter.scalding.serialization.JavaStreamEnrichments.posVarIntSize(innerLen);
scala.Some.apply[Int](innerLen.+(fresh_lensLen$macro$29))
}
else
scala.None: Option[Int])
};
override def read(from: java.io.InputStream): scala.util.Try[(Long, Option[Long])] = try {
com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(from).readPosVarInt;
scala.util.Success.apply[(Long, Option[Long])]({
val curR$macro$31: Long = com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(from).readLong;
val curR$macro$32: Option[Long] = {
val tmpGetHolder$macro$33: Byte = com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(from).readByte;
if (tmpGetHolder$macro$33.==((0: Byte)))
scala.None
else
scala.Some.apply[Long](com.twitter.scalding.serialization.JavaStreamEnrichments.RichInputStream(from).readLong)
};
Tuple2.apply[Long, Option[Long]](curR$macro$31, curR$macro$32)
})
} catch {
case scala.util.control.NonFatal.unapply(<unapply-selector>) <unapply> ((e @ _)) => scala.util.Failure.apply[Nothing](e)
};
override def write(into: java.io.OutputStream, e: (Long, Option[Long])): scala.util.Try[Unit] = try {
{
val fresh_len$macro$35: Int = 8.+(if (e._2.isDefined)
9
else
1);
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(into).writePosVarInt(fresh_len$macro$35);
{
{
val innerElement$macro$36: Long = e._1;
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(into).writeLong(innerElement$macro$36)
};
val innerElement$macro$36: Option[Long] = e._2;
if (innerElement$macro$36.isDefined)
{
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(into).writeByte((1: Byte));
val innerValue$macro$38: Long = innerElement$macro$36.get;
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(into).writeLong(innerValue$macro$38)
}
else
com.twitter.scalding.serialization.JavaStreamEnrichments.RichOutputStream(into).writeByte((0: Byte))
}
};
com.twitter.scalding.serialization.Serialization.successUnit
} catch {
case scala.util.control.NonFatal.unapply(<unapply-selector>) <unapply> ((e @ _)) => scala.util.Failure.apply[Nothing](e)
};
override def compare(x: (Long, Option[Long]), y: (Long, Option[Long])): Int = {
val curCmp$macro$41: Int = {
val innerElementA$macro$39: Long = x._1;
val innerElementB$macro$40: Long = y._1;
java.lang.Long.compare(innerElementA$macro$39, innerElementB$macro$40)
};
if (curCmp$macro$41.!=(0))
curCmp$macro$41
else
{
val curCmp$macro$42: Int = {
val innerElementA$macro$39: Option[Long] = x._2;
val innerElementB$macro$40: Option[Long] = y._2;
{
val aIsDefined$macro$43: Boolean = innerElementA$macro$39.isDefined;
val bIsDefined$macro$44: Boolean = innerElementB$macro$40.isDefined;
if (aIsDefined$macro$43.unary_!)
if (bIsDefined$macro$44.unary_!)
0
else
-1
else
if (bIsDefined$macro$44.unary_!)
1
else
{
val innerValueA$macro$45: Long = innerElementA$macro$39.get;
val innerValueB$macro$46: Long = innerElementB$macro$40.get;
java.lang.Long.compare(innerValueA$macro$45, innerValueB$macro$46)
}
}
};
curCmp$macro$42
}
}
};
new $anon()
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment