Skip to content

Commit

Permalink
added new column for cache location in show cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal642 committed Jun 13, 2019
1 parent 51bf8d5 commit b974a1c
Showing 1 changed file with 31 additions and 22 deletions.
Expand Up @@ -58,12 +58,14 @@ case class CarbonShowCacheCommand(tableIdentifier: Option[TableIdentifier],
AttributeReference("Table", StringType, nullable = false)(),
AttributeReference("Index size", StringType, nullable = false)(),
AttributeReference("Datamap size", StringType, nullable = false)(),
AttributeReference("Dictionary size", StringType, nullable = false)())
AttributeReference("Dictionary size", StringType, nullable = false)(),
AttributeReference("Cache Location", StringType, nullable = false)())
} else {
Seq(
AttributeReference("Field", StringType, nullable = false)(),
AttributeReference("Size", StringType, nullable = false)(),
AttributeReference("Comment", StringType, nullable = false)())
AttributeReference("Comment", StringType, nullable = false)(),
AttributeReference("Cache Location", StringType, nullable = false)())
}
}

Expand Down Expand Up @@ -95,15 +97,14 @@ case class CarbonShowCacheCommand(tableIdentifier: Option[TableIdentifier],
indexRawResults.drop(2).map { row =>
Row(row.get(0), row.getLong(1) + row.getLong(2), row.get(3))
}
Seq(Row("DRIVER CACHE", "", "")) ++ result.map {
result.map {
row =>
Row(row.get(0), bytesToDisplaySize(row.getLong(1)), row.get(2))
Row(row.get(0), bytesToDisplaySize(row.getLong(1)), row.get(2), "DRIVER")
} ++ (serverResults match {
case Nil => Seq()
case list =>
Seq(Row("-----------", "-----------", "-----------"), Row("INDEX CACHE", "", "")) ++
list.map {
row => Row(row.get(0), bytesToDisplaySize(row.getLong(1)), row.get(2))
row => Row(row.get(0), bytesToDisplaySize(row.getLong(1)), row.get(2), "INDEX SERVER")
}
})
}
Expand Down Expand Up @@ -166,15 +167,19 @@ case class CarbonShowCacheCommand(tableIdentifier: Option[TableIdentifier],
val (driverIndexSize, driverDatamapSize, allDictSize) = getAllDriverCacheSize(tablePaths
.toList)
if (driverRows.nonEmpty) {
val rows = (Seq(
Row("ALL", "ALL", driverIndexSize, driverDatamapSize, allDictSize),
Row(currentDatabase, "ALL", driverdbIndexSize, driverdbDatamapSize, driverdbDictSize)
(Seq(
Row("ALL", "ALL", driverIndexSize, driverDatamapSize, allDictSize, "DRIVER"),
Row(currentDatabase,
"ALL",
driverdbIndexSize,
driverdbDatamapSize,
driverdbDictSize,
"DRIVER")
) ++ driverRows).collect {
case row if row.getLong(2) != 0L || row.getLong(3) != 0L || row.getLong(4) != 0L =>
Row(row(0), row(1), bytesToDisplaySize(row.getLong(2)),
bytesToDisplaySize(row.getLong(3)), bytesToDisplaySize(row.getLong(4)))
bytesToDisplaySize(row.getLong(3)), bytesToDisplaySize(row.getLong(4)), "DRIVER")
}
Seq(Row("DRIVER CACHE", "", "", "", "")) ++ rows
} else {
makeEmptyCacheRows(currentDatabase)
}
Expand All @@ -184,15 +189,19 @@ case class CarbonShowCacheCommand(tableIdentifier: Option[TableIdentifier],

// val (serverIndexSize, serverDataMapSize) = getAllIndexServerCacheSize
val indexDisplayRows = if (indexServerRows.nonEmpty) {
val rows = (Seq(
Row("ALL", "ALL", indexAllIndexSize, indexAllDatamapSize, indexAllDictSize),
Row(currentDatabase, "ALL", indexdbIndexSize, indexdbDatamapSize, driverdbDictSize)
(Seq(
Row("ALL", "ALL", indexAllIndexSize, indexAllDatamapSize, indexAllDictSize, "INDEX SERVER"),
Row(currentDatabase,
"ALL",
indexdbIndexSize,
indexdbDatamapSize,
driverdbDictSize,
"INDEX SERVER")
) ++ indexServerRows).collect {
case row if row.getLong(2) != 0L || row.getLong(3) != 0L || row.getLong(4) != 0L =>
Row(row.get(0), row.get(1), bytesToDisplaySize(row.getLong(2)),
bytesToDisplaySize(row.getLong(3)), bytesToDisplaySize(row.getLong(4)))
bytesToDisplaySize(row.getLong(3)), bytesToDisplaySize(row.getLong(4)), "INDEX SERVER")
}
Seq(Row("INDEX SERVER CACHE", "", "", "", "")) ++ rows
} else {
Seq()
}
Expand Down Expand Up @@ -237,13 +246,13 @@ case class CarbonShowCacheCommand(tableIdentifier: Option[TableIdentifier],
comments += " (external table)"
}
Seq(
Row("Index", parentMetaCacheInfo._3, comments),
Row("Dictionary", parentDictionary, "")
Row("Index", parentMetaCacheInfo._3, comments, ""),
Row("Dictionary", parentDictionary, "", "")
) ++ childMetaCacheInfos
} else {
Seq(
Row("Index", 0L, ""),
Row("Dictionary", 0L, "")
Row("Index", 0L, "", ""),
Row("Dictionary", 0L, "", "")
)
}
}
Expand All @@ -252,9 +261,9 @@ case class CarbonShowCacheCommand(tableIdentifier: Option[TableIdentifier],

private def makeEmptyCacheRows(currentDatabase: String) = {
Seq(
Row("ALL", "ALL", bytesToDisplaySize(0), bytesToDisplaySize(0), bytesToDisplaySize(0)),
Row("ALL", "ALL", bytesToDisplaySize(0), bytesToDisplaySize(0), bytesToDisplaySize(0), ""),
Row(currentDatabase, "ALL", bytesToDisplaySize(0), bytesToDisplaySize(0),
bytesToDisplaySize(0)))
bytesToDisplaySize(0), ""))
}

private def calculateDBIndexAndDatamapSize(rows: Seq[Row]): (Long, Long, Long) = {
Expand Down

0 comments on commit b974a1c

Please sign in to comment.