Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

mt-store-cat improvements: glob filter, chunk-csv output #1147

Merged
merged 9 commits into from
Nov 23, 2018

Conversation

Dieterbe
Copy link
Contributor

No description provided.

@Dieterbe Dieterbe changed the title Mt store cat improvements mt-store-cat improvements Nov 23, 2018
@Dieterbe Dieterbe changed the title mt-store-cat improvements mt-store-cat improvements: glob filter, chunk-csv output Nov 23, 2018
@Dieterbe Dieterbe force-pushed the mt-store-cat-improvements branch from 2cd8b33 to 9cc3a5f Compare November 23, 2018 16:27
@@ -266,22 +293,28 @@ func main() {
fmt.Printf("metric id %v not found", amkey.MKey)
return
}
for _, m := range metrics {
fmt.Println(m)
if verbose {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd just create some wrapper function logIfVerbose(). I guess we don't need to worry about an extra function call here

@@ -194,24 +196,31 @@ func main() {
log.Fatalf("failed to read tables from cassandra. %s", err.Error())
}

// set up is done, now actually execute the business logic

// handle "tables"
if tableSelector == "tables" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're assuming that there will never be a table called tables i guess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. which seems fair

if strings.HasPrefix(metricSelector, "substr:") {
substr = strings.Replace(metricSelector, "substr:", "", 1)
}
if strings.HasPrefix(metricSelector, "glob:") {
Copy link
Contributor

@replay replay Nov 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section with so many redundant strings.HasPrefix() seems kind of strange to me. Wouldn't it be way cleared if there's simply one case for each of the possible metric selector methods. Then each of those metric selectors could have its own matching method instead of the current match(prefix, substr, glob, ...) which needs to go through all the possible matching methods even though only one of them can ever be used at once. That selector-specific matching method could then simply be passed into getMetrics() by reference. This might be personal taste, but i think that would be cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though only one of them can ever be used at once

in the future i'ld like to combine multiple selectors. e.g. prefix and substr.

func printChunkCsv(ctx context.Context, store *cassandra.CassandraStore, table cassandra.Table, metrics []Metric, start, end uint32) {

// see CassandraStore.SearchTable for more information
start_month := start - (start % cassandra.Month_sec) // starting row has to be at, or before, requested start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible I just don't get it why this is necessary... but:
start_month is only used 2 lines down, where it will be divided by cassandra.Month_sec. Since integer divisions would drop the start % cassandra.Month_sec anyway, how is this code different from:

startMonthNum := start / cassandra.Month_sec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds good.
i suppose similarly we can also do:

endMonthNum := (end - 1) / cassandra.Month_sec

right?
note: this code comes from the cassandra code, and i think we do it elsewhere too. so perhaps better to do a separate cleanup PR for just that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i think you're right. i wasn't completely sure by using logic, so i just tested it: https://play.golang.org/p/DOl02-EibSU

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> #1148

Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some comments

@Dieterbe Dieterbe force-pushed the mt-store-cat-improvements branch from 19b9383 to d174fbe Compare November 23, 2018 19:29
@Dieterbe Dieterbe merged commit 6aa4eaa into master Nov 23, 2018
@Dieterbe Dieterbe deleted the mt-store-cat-improvements branch March 27, 2019 21:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants