Skip to content
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

fix unused imports and minor warnings #1578

Merged
merged 3 commits into from
Sep 18, 2023
Merged
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 @@ -32,7 +32,7 @@ class CsvGraphEngine(val name: String, val contentType: String, sep: String) ext
val numberFmt = config.numberFormat
writer.append("\"timestamp\"")
(0 until count).zip(seriesList).map {
case (i, series) =>
case (_, series) =>
val label = "\"%s\"".format(series.data.label)
writer.append(sep).append(label)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import java.awt.Font
import java.awt.Stroke
import java.awt.image.BufferedImage
import java.util.concurrent.ConcurrentHashMap

import com.netflix.atlas.chart.util.Fonts
import com.netflix.iep.config.ConfigManager

import java.awt.Graphics2D

object ChartSettings {

private val config = ConfigManager.dynamicConfig().getConfig("atlas.chart")
Expand Down Expand Up @@ -52,7 +53,7 @@ object ChartSettings {
* is created.
*/
val refImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)
val refGraphics = refImage.createGraphics()
val refGraphics: Graphics2D = refImage.createGraphics()

/** Dashed stroke typically used for grid lines. */
val dashedStroke: Stroke = {
Expand All @@ -69,38 +70,38 @@ object ChartSettings {
/**
* Base monospaced font used for graphics. Monospace is used to make the layout easier.
*/
val monospaceFont = Fonts.loadFont(config.getString("fonts.monospace"))
val monospaceFont: Font = Fonts.loadFont(config.getString("fonts.monospace"))

/** Small sized monospaced font. */
val smallFont = monospaceFont.deriveFont(10.0f)
val smallFont: Font = monospaceFont.deriveFont(10.0f)

/** Normal sized monospaced font. */
val normalFont = monospaceFont
val normalFont: Font = monospaceFont

/** Large sized monospaced font. */
val largeFont = monospaceFont.deriveFont(14.0f)
val largeFont: Font = monospaceFont.deriveFont(14.0f)

/** Dimensions for a character using the small font. */
val smallFontDims = dimensions(smallFont)
val smallFontDims: Dimensions = dimensions(smallFont)

/** Dimensions for a character using the normal font. */
val normalFontDims = dimensions(normalFont)
val normalFontDims: Dimensions = dimensions(normalFont)

/** Dimensions for a character using the large font. */
val largeFontDims = dimensions(largeFont)
val largeFontDims: Dimensions = dimensions(largeFont)

/**
* Minimum width required for text elements. Value was chosen to allow typical messages to
* display with a reasonable level of wrapping.
*/
val minWidthForText = smallFontDims.width * "Warnings: abcdef".length
val minWidthForText: Int = smallFontDims.width * "Warnings: abcdef".length

/**
* Minimum width required for text elements. Value was chosen to allow the typical legend with
* stats to show cleanly. It also keeps the cutoff below the level of sizes that are frequently
* used in practice.
*/
val minWidthForStats = smallFontDims.width * 45
val minWidthForStats: Int = smallFontDims.width * 45

/**
* Determine the dimensions for a single character using `font`. It is assumed that the font
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ case class Style(color: Color = Color.BLACK, stroke: Stroke = new BasicStroke(1.
}

object Style {
val default = Style()
val default: Style = Style()
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ case class Text(
) extends Element
with VariableHeight {

lazy val dims = ChartSettings.dimensions(font)
lazy val dims: ChartSettings.Dimensions = ChartSettings.dimensions(font)

def truncate(width: Int): Text = {
val maxChars = (width - Text.rightPadding) / dims.width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object Ticks {
private val monthTimeFmt: DateTimeFormatter = DateTimeFormatter.ofPattern("MMM")
private val yearTimeFmt: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy")

val timeBoundaries = List(
val timeBoundaries: List[(ChronoField, DateTimeFormatter)] = List(
ChronoField.SECOND_OF_MINUTE -> DateTimeFormatter.ofPattern(":ss"),
ChronoField.MINUTE_OF_HOUR -> DateTimeFormatter.ofPattern("HH:mm"),
ChronoField.HOUR_OF_DAY -> DateTimeFormatter.ofPattern("HH:mm")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ case class RightValueAxis(plotDef: PlotDef, styles: Styles, min: Double, max: Do

object ValueAxis {

val labelHeight = ChartSettings.normalFontDims.height
val labelHeight: Int = ChartSettings.normalFontDims.height

/**
* Width of value tick labels. The assumption is a monospace font with 7 characters. The 7 is
Expand All @@ -300,9 +300,9 @@ object ValueAxis {
* - `[sign][3digits][decimal point][1digit][suffix]`: e.g., `-102.3K`
* - `-1.0e-5`
*/
val tickLabelWidth = ChartSettings.smallFontDims.width * 7
val tickLabelWidth: Int = ChartSettings.smallFontDims.width * 7

val tickMarkLength = 4

val minTickLabelHeight = ChartSettings.smallFontDims.height * 3
val minTickLabelHeight: Int = ChartSettings.smallFontDims.height * 3
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@ public enum TickLabelMode {
OFF,

/**
* Use decimal metric prefixes for tick labels.
*
* https://en.wikipedia.org/wiki/Metric_prefix
* Use decimal <a href="https://en.wikipedia.org/wiki/Metric_prefix">metric prefixes</a> for
* tick labels.
*/
DECIMAL,

/**
* Use binary prefixes for tick labels. Typically only used for data in bytes such as disk
* sizes.
*
* https://en.wikipedia.org/wiki/Binary_prefix
* Use <a href="https://en.wikipedia.org/wiki/Binary_prefix">binary prefixes</a> for tick
* labels. Typically only used for data in bytes such as disk sizes.
*/
BINARY,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
* Convert a color to simulate a type of color blindness for those with normal vision. Based on:
* http://web.archive.org/web/20081014161121/http://www.colorjack.com/labs/colormatrix/
* <a href="http://web.archive.org/web/20081014161121/http://www.colorjack.com/labs/colormatrix/">colormatrix</a>.
*/
public enum VisionType {
normal(new double[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class GraphAssertions(goldenDir: String, targetDir: String, assert: (Any, Any) =
</html>"""

Using.resource(Streams.fileOut(new File(s"$targetDir/report.html"))) { out =>
out.write(report.toString.getBytes("UTF-8"))
out.write(report.getBytes("UTF-8"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ object PngImage {

case class PngImage(data: RenderedImage, metadata: Map[String, String] = Map.empty) {

type JList = java.util.List[String]

def toByteArray: Array[Byte] = {
val buffer = new ByteArrayOutputStream
write(buffer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class MemoryBlockStore(step: Long, blockSize: Int, numBlocks: Int) extends Block
}

override def toString: String = {
val buf = new StringBuilder
val buf = new java.lang.StringBuilder
(0 until numBlocks).foreach { i =>
buf.append(i.toString).append(" => ").append(blocks(i))
if (i == currentPos) buf.append(" (current)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ sealed trait Block {
* @param aggr the aggregate value to read from the block
*/
def get(pos: Int, aggr: Int = Block.Sum): Double = {
import java.lang.{Double as JDouble}
import java.lang.Double as JDouble
val v = get(pos)
(aggr: @scala.annotation.switch) match {
case Block.Sum => v
Expand Down Expand Up @@ -312,7 +312,7 @@ case class ArrayBlock(var start: Long, size: Int) extends MutableBlock {
* @return number of values that were changed as a result of the merge operation
*/
def merge(b: Block): Int = {
import java.lang.{Double as JDouble}
import java.lang.Double as JDouble
var changed = 0
var i = 0
while (i < size) {
Expand Down Expand Up @@ -353,7 +353,7 @@ case class ArrayBlock(var start: Long, size: Int) extends MutableBlock {
}

override def toString: String = {
val buf = new StringBuilder
val buf = new java.lang.StringBuilder
buf.append("ArrayBlock(").append(start).append(",").append(size).append(",")
buf.append("Array(").append(buffer.mkString(",")).append(")")
buf.append(")")
Expand Down Expand Up @@ -383,7 +383,7 @@ object FloatArrayBlock {
*/
case class FloatArrayBlock(start: Long, size: Int) extends Block {

val buffer = ArrayHelper.fill(size, Float.NaN)
val buffer: Array[Float] = ArrayHelper.fill(size, Float.NaN)

def get(pos: Int): Double = buffer(pos).asInstanceOf[Double]
val byteCount: Int = 2 + sizeOf(buffer)
Expand Down Expand Up @@ -411,7 +411,7 @@ case class FloatArrayBlock(start: Long, size: Int) extends Block {
}

override def toString: String = {
val buf = new StringBuilder
val buf = new java.lang.StringBuilder
buf.append("FloatArrayBlock(").append(start).append(",").append(size).append(",")
buf.append("Array(").append(buffer.mkString(",")).append(")")
buf.append(")")
Expand Down Expand Up @@ -736,7 +736,7 @@ object SparseBlock {
case v if v != v => NaN
case v if v == 0.0 => ZERO
case v if v == 1.0 => ONE
case v => UNDEFINED
case _ => UNDEFINED
}
}

Expand Down Expand Up @@ -797,7 +797,7 @@ case class SparseBlock(start: Long, indexes: Array[Byte], values: Array[Double])
}

override def toString: String = {
val buf = new StringBuilder
val buf = new java.lang.StringBuilder
buf.append("SparseBlock(").append(start).append(",")
buf.append("Array(").append(indexes.mkString(",")).append("),")
buf.append("Array(").append(values.mkString(",")).append(")")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ object DataExpr {
val sorted = groups.sortWith(_._1 < _._1)
val newData = sorted.flatMap {
case (null, _) => Nil
case (k, Nil) => List(TimeSeries.noData(query, context.step))
case (_, Nil) => List(TimeSeries.noData(query, context.step))
case (k, ts) =>
val tags = ts.head.tags.filter(e => ks.contains(e._1))
af.eval(context, ts).data.map { t =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ object MathExpr {
// aggregate function. Modifications to the aggregate need to be represented
// after the operation as part of the expression string. There are two
// categories: offsets applied to the data function and group by.
val buffer = new StringBuilder
val buffer = new java.lang.StringBuilder
buffer.append(s"$q,:$name")
getOffset(evalExpr).foreach(d => buffer.append(s",$d,:offset"))

Expand All @@ -1018,7 +1018,7 @@ object MathExpr {
buffer.append(grouping.mkString(",(,", ",", ",),:by"))
}

buffer.toString()
buffer.toString
case t: TimeSeriesExpr if groupingMatches =>
// The passed in expression maybe the result of a rewrite to the display expression
// that was not applied to the eval expression. If it changes the grouping, then it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ object MathVocabulary extends Vocabulary {
case StringListType(_) :: TimeSeriesType(t) :: _ if t.isGrouped =>
// Multi-level group by with an implicit aggregate of :sum
true
case StringListType(_) :: TimeSeriesType(t) :: _ =>
case StringListType(_) :: TimeSeriesType(_) :: _ =>
// Default data or math aggregate group by applied across math operations
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ object QueryVocabulary extends Vocabulary {
}

protected def executor: PartialFunction[List[Any], List[Any]] = {
case Nil :: (k: String) :: s => Query.False :: s
case Nil :: (_: String) :: s => Query.False :: s
case ((v: String) :: Nil) :: (k: String) :: s => Query.Equal(k, v) :: s
case StringListType(vs) :: (k: String) :: s => Query.In(k, vs) :: s
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object SummaryStats {
var min = Double.PositiveInfinity
var last = Double.NaN

ts.foreach(start, end) { (t, v) =>
ts.foreach(start, end) { (_, v) =>
if (!v.isNaN) {
total += v
count += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait TimeSeq {
val length = ((end - start) / step).toInt
val data = new Array[Double](length)
var i = 0
foreach(start, end) { (t, v) =>
foreach(start, end) { (_, v) =>
data(i) = v
i += 1
}
Expand Down Expand Up @@ -102,7 +102,7 @@ final class ArrayTimeSeq(
def update(ts: TimeSeq)(op: BinaryOp): Unit = {
require(step == ts.step, "step sizes must be the same")
var i = 0
ts.foreach(start, end) { (t, v) =>
ts.foreach(start, end) { (_, v) =>
data(i) = op(data(i), v)
i += 1
}
Expand Down Expand Up @@ -131,7 +131,7 @@ final class ArrayTimeSeq(
}

override def hashCode: Int = {
import java.lang.{Long as JLong}
import java.lang.Long as JLong
val prime = 31
var hc = prime
hc = hc * prime + dsType.hashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ package object model {

type UnaryOp = Double => Double
type BinaryOp = (Double, Double) => Double
type TimeSeriesInput = Iterator[(String, TimeSeries)]
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ object IsoDateTimeParser {
str match {
case IsoDate(d) => s"${d}T00:00:00"
case IsoDateZ(d, z) => s"${d}T00:00:00${normalizeZone(z)}"
case IsoDateTimeHHMM(d) => s"${d}:00"
case IsoDateTimeHHMMZ(d, z) => s"${d}:00${normalizeZone(z)}"
case IsoDateTimeHHMMSS(d) => s"${d}"
case IsoDateTimeHHMMSSZ(d, z) => s"${d}${normalizeZone(z)}"
case IsoDateTimeHHMMSSmmm(d) => s"${d}"
case IsoDateTimeHHMMSSmmmZ(d, z) => s"${d}${normalizeZone(z)}"
case IsoDateTimeHHMM(d) => s"$d:00"
case IsoDateTimeHHMMZ(d, z) => s"$d:00${normalizeZone(z)}"
case IsoDateTimeHHMMSS(d) => d
case IsoDateTimeHHMMSSZ(d, z) => s"$d${normalizeZone(z)}"
case IsoDateTimeHHMMSSmmm(d) => d
case IsoDateTimeHHMMSSmmmZ(d, z) => s"$d${normalizeZone(z)}"
case _ => str
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Copied from the apache-mahout project.
*
* Not of interest for users; only for implementors of hashtables.
* <p>Not of interest for users; only for implementors of hashtables.
* Used to keep hash table capacities prime numbers.
*
* <p>Choosing prime numbers as hash table capacities is a good idea to keep them working fast,
Expand All @@ -43,19 +43,19 @@ class PrimeFinder {
* next element is a prime P2. P2 is the smallest prime for which holds: P2 >= 2*P1. The next element is P3, for which
* the same holds with respect to P2, and so on.
*
* Chunks are chosen such that for any desired capacity >= 1000 the list includes a prime number <= desired capacity *
* <p>Chunks are chosen such that for any desired capacity >= 1000 the list includes a prime number <= desired capacity *
* 1.11 (11%). For any desired capacity >= 200 the list includes a prime number <= desired capacity * 1.16 (16%). For
* any desired capacity >= 16 the list includes a prime number <= desired capacity * 1.21 (21%).
*
* Therefore, primes can be retrieved which are quite close to any desired capacity, which in turn avoids wasting
* <p>Therefore, primes can be retrieved which are quite close to any desired capacity, which in turn avoids wasting
* memory. For example, the list includes 1039,1117,1201,1277,1361,1439,1523,1597,1759,1907,2081. So if you need a
* prime >= 1040, you will find a prime <= 1040*1.11=1154.
*
* Chunks are chosen such that they are optimized for a hashtable growthfactor of 2.0; If your hashtable has such a
* <p>Chunks are chosen such that they are optimized for a hashtable growthfactor of 2.0; If your hashtable has such a
* growthfactor then, after initially "rounding to a prime" upon hashtable construction, it will later expand to prime
* capacities such that there exist no better primes.
*
* In total these are about 32*10=320 numbers -> 1 KB of static memory needed. If you are stingy, then delete every
* <p>In total these are about 32*10=320 numbers -> 1 KB of static memory needed. If you are stingy, then delete every
* second or fourth chunk.
*/

Expand Down
Loading