com.google.common.base.Objects Scala Examples
The following examples show how to use com.google.common.base.Objects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: TableCluster.scala From carbondata with Apache License 2.0 | 5 votes |
package org.apache.carbondata.mv.plans.util import com.fasterxml.jackson.annotation.{JsonCreator, JsonProperty, JsonRawValue} import com.google.common.base.Objects class TableCluster @JsonCreator()(@JsonProperty("fact") @JsonRawValue fact: Set[String], @JsonProperty("dimension") @JsonRawValue dimension: Set[String]) { // @JsonProperty def getFact(): Set[String] = { fact } // // @JsonProperty def getDimension(): Set[String] = { dimension } @Override override def toString: String = { Objects.toStringHelper(this) .add("fact", fact) .add("dimension", dimension) .toString } }
Example 2
Source File: LibSVMRelation.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.ml.source.libsvm import com.google.common.base.Objects import org.apache.spark.Logging import org.apache.spark.annotation.Since import org.apache.spark.mllib.linalg.{Vector, VectorUDT} import org.apache.spark.mllib.util.MLUtils import org.apache.spark.rdd.RDD import org.apache.spark.sql.{DataFrameReader, DataFrame, Row, SQLContext} import org.apache.spark.sql.sources._ import org.apache.spark.sql.types.{DoubleType, StructField, StructType} @Since("1.6.0") class DefaultSource extends RelationProvider with DataSourceRegister { @Since("1.6.0") override def shortName(): String = "libsvm" @Since("1.6.0") override def createRelation(sqlContext: SQLContext, parameters: Map[String, String]) : BaseRelation = { val path = parameters.getOrElse("path", throw new IllegalArgumentException("'path' must be specified")) val numFeatures = parameters.getOrElse("numFeatures", "-1").toInt val vectorType = parameters.getOrElse("vectorType", "sparse") new LibSVMRelation(path, numFeatures, vectorType)(sqlContext) } }
Example 3
Source File: QueryGuardEvent.scala From gimel with Apache License 2.0 | 5 votes |
package com.paypal.gimel.common.query.guard import java.time.Instant import java.util.concurrent.{Delayed, TimeUnit} import com.google.common.base.Objects import com.google.common.primitives.Ints import org.joda.time.DateTime import com.paypal.gimel.logger.Logger private[query] sealed trait QueryGuardEvent private[query] trait QueryGuardDelayedEvent extends QueryGuardEvent with Delayed private[query] case class JobSubmitted(jobId: Int, jobType: String, startTime: Long = Instant.now().toEpochMilli, estimatedJobEndTime: Long, estimatedDelayEndTime: Long) extends QueryGuardDelayedEvent { private val logger = Logger(this.getClass.getName) override def getDelay(unit: TimeUnit): Long = { val currentInstant = Instant.now().toEpochMilli val diff = estimatedDelayEndTime - currentInstant logger.info( s"[JobSubmitted] Comparing Job with ID: $jobId diff: $diff with end time:" + s" ${new DateTime(estimatedDelayEndTime)}, and current instant:" + s" ${new DateTime(currentInstant)}" ) unit.convert(diff, TimeUnit.MILLISECONDS) } override def compareTo(o: Delayed): Int = { Ints.saturatedCast( this.estimatedDelayEndTime - o .asInstanceOf[JobSubmitted] .estimatedDelayEndTime ) } override def toString: String = Objects .toStringHelper(this) .add("jobId", jobId) .add("jobType", jobType) .add("startTime", startTime) .add("estimatedJobEndTime", estimatedJobEndTime) .add("estimatedDelayEndTime", estimatedDelayEndTime) .toString } object JobSubmitted { def apply(jobId: Int, jobType: String, startTime: Long, jobTtl: Int, delayTtl: Int): JobSubmitted = new JobSubmitted( jobId, jobType, startTime, startTime + jobTtl, startTime + delayTtl ) def apply(job: JobSubmitted, jobTtl: Int, delayTime: Long): JobSubmitted = new JobSubmitted( jobId = job.jobId, jobType = job.jobType, startTime = job.startTime, estimatedJobEndTime = job.startTime + jobTtl, estimatedDelayEndTime = delayTime ) } private[query] case class JobKill(jobId: Int, jobType: String, reason: String) extends QueryGuardEvent { override def toString: String = Objects .toStringHelper(this) .add("jobId", jobId) .add("jobType", jobType) .add("reason", reason) .toString }
Example 4
Source File: RpcRequest.scala From aloha with Apache License 2.0 | 5 votes |
package me.jrwang.aloha.transport.message import com.google.common.base.{MoreObjects, Objects} import io.netty.buffer.ByteBuf import me.jrwang.aloha.transport.server.RpcHandler override def isBodyInFrame: Boolean = true override def encodeLength: Int = { // The integer (a.k.a. the body size) is not really used, since that information is already // encoded in the frame length. But this maintains backwards compatibility with versions of // RpcRequest that use Encoders.ByteArrays. 8 + 4 } override def encode(buf: ByteBuf): Unit = { buf.writeLong(requestId) // See comment in encodedLength(). buf.writeInt(body.readableBytes()) } override def hashCode: Int = Objects.hashCode(requestId.asInstanceOf[AnyRef], body) override def equals(other: Any): Boolean = { other match { case o: RpcRequest => return requestId == o.requestId && super.equals(o) case _ => } false } override def toString: String = MoreObjects.toStringHelper(this) .add("requestId", requestId) .add("body", body) .toString } object RpcRequest { def decode(buf: ByteBuf): RpcRequest = { val requestId = buf.readLong() // See comment in encodedLength(). buf.readInt() new RpcRequest(requestId, buf.retain()) } }
Example 5
Source File: RpcResponse.scala From aloha with Apache License 2.0 | 5 votes |
package me.jrwang.aloha.transport.message import com.google.common.base.{MoreObjects, Objects} import io.netty.buffer.ByteBuf class RpcResponse(val requestId: Long, private val message: ByteBuf) extends ResponseMessage { override def isBodyInFrame: Boolean = true override def encodeLength: Int = { // The integer (a.k.a. the body size) is not really used, since that information is already // encoded in the frame length. But this maintains backwards compatibility with versions of // RpcRequest that use Encoders.ByteArrays. 8 + 4 } override def encode(buf: ByteBuf): Unit = { buf.writeLong(requestId) // See comment in encodedLength(). buf.writeInt(body.readableBytes()) } override def hashCode: Int = Objects.hashCode(requestId.asInstanceOf[AnyRef], body) override def equals(other: Any): Boolean = { other match { case o: RpcResponse => return requestId == o.requestId && super.equals(o) case _ => } false } override def toString: String = MoreObjects.toStringHelper(this) .add("requestId", requestId) .add("body", body) .toString } object RpcResponse { def decode(buf: ByteBuf): RpcResponse = { val requestId = buf.readLong() // See comment in encodedLength(). buf.readInt() new RpcResponse(requestId, buf.retain()) } }
Example 6
Source File: OneWayMessage.scala From aloha with Apache License 2.0 | 5 votes |
package me.jrwang.aloha.transport.message import com.google.common.base.{MoreObjects, Objects} import io.netty.buffer.ByteBuf class OneWayMessage(private val message: ByteBuf) extends RequestMessage { override def encode(buf: ByteBuf): Unit = { // See comment in encodedLength(). buf.writeInt(body.readableBytes()) } override def hashCode: Int = Objects.hashCode(body) override def equals(other: Any): Boolean = { other match { case o: OneWayMessage => return super.equals(o) case _ => } false } override def toString: String = MoreObjects.toStringHelper(this).add("body", body).toString } object OneWayMessage { def decode(buf: ByteBuf): OneWayMessage = { // See comment in encodedLength(). buf.readInt new OneWayMessage(buf.retain) } }
Example 7
Source File: RpcFailure.scala From aloha with Apache License 2.0 | 5 votes |
package me.jrwang.aloha.transport.message import com.google.common.base.{MoreObjects, Objects} import io.netty.buffer.ByteBuf class RpcFailure(val requestId: Long, val errorString: String) extends ResponseMessage { override def isBodyInFrame: Boolean = false override def encodeLength: Int = { 8 + Encoders.Strings.encodedLength(errorString) } override def encode(buf: ByteBuf): Unit = { buf.writeLong(requestId) Encoders.Strings.encode(buf, errorString) } override def hashCode: Int = Objects.hashCode(requestId.asInstanceOf[AnyRef], errorString) override def equals(other: Any): Boolean = { other match { case o: RpcFailure => return requestId == o.requestId && errorString == o.errorString case _ => } false } override def toString: String = { MoreObjects.toStringHelper(this) .add("requestId", requestId) .add("errorString", errorString) .toString } } object RpcFailure { def decode(buf: ByteBuf): RpcFailure = { val requestId = buf.readLong val errorString = Encoders.Strings.decode(buf) new RpcFailure(requestId, errorString) } }