-
Notifications
You must be signed in to change notification settings - Fork 454
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
[query] Fix time() function in binary comparisons #1888
Changes from 4 commits
d54e2fe
cce963a
657a731
a0d20af
146ec51
3a6c470
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2019 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package block | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/m3db/m3/src/query/cost" | ||
"github.com/m3db/m3/src/query/models" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/uber-go/tally" | ||
) | ||
|
||
func TestColumnBuilderInfoTypes(t *testing.T) { | ||
ctx := models.NewQueryContext(context.Background(), | ||
tally.NoopScope, cost.NoopChainedEnforcer(), | ||
models.QueryContextOptions{}) | ||
|
||
builder := NewColumnBlockBuilder(ctx, Metadata{}, []SeriesMeta{}) | ||
block := builder.Build() | ||
assert.Equal(t, BlockDecompressed, block.Info().blockType) | ||
|
||
block = builder.Build() | ||
builder.SetBlockType(BlockScalar) | ||
assert.Equal(t, BlockScalar, block.Info().blockType) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright (c) 2019 Uber Technologies, Inc. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit: Rename this file |
||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package block | ||
|
||
func (t BlockType) String() string { | ||
switch t { | ||
case BlockM3TSZCompressed: | ||
return "M3TSZ_compressed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason this should be upper case and rest lower? Maybe we should make it just "compressedM3TSZ" for lower camel casing or "compressed_m3tsz" if we want to do lowercase underscore separated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM; don't really see this used as anything other than as human-readable debug info since it's all runtime stuff so makes sense to pretty it up 👍 |
||
case BlockDecompressed: | ||
return "decompressed" | ||
case BlockScalar: | ||
return "scalar" | ||
case BlockLazy: | ||
return "lazy" | ||
case BlockTime: | ||
return "time" | ||
case BlockContainer: | ||
return "container" | ||
case BlockWrapper: | ||
return "wrapper" | ||
case BlockConsolidated: | ||
return "consolidated" | ||
} | ||
|
||
return "unknown" | ||
} | ||
|
||
type BlockInformation struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we call this just Also needs comment yeah? (think the exported types in this file are all missing comments) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah fair enough; thought the general idea was functions and types have full names but variables have Go-ish names, will change it |
||
blockType BlockType | ||
inner []BlockType | ||
} | ||
|
||
func NewBlockInformation(blockType BlockType) BlockInformation { | ||
return BlockInformation{blockType: blockType} | ||
} | ||
|
||
func NewWrappedBlockInformation( | ||
blockType BlockType, | ||
wrap BlockInformation, | ||
) BlockInformation { | ||
inner := make([]BlockType, len(wrap.inner)+1) | ||
copy(inner[:1], wrap.inner) | ||
inner[0] = wrap.blockType | ||
return BlockInformation{ | ||
blockType: blockType, | ||
inner: inner, | ||
} | ||
} | ||
|
||
func (b BlockInformation) Type() BlockType { | ||
return b.blockType | ||
} | ||
|
||
func (b BlockInformation) InnerType() BlockType { | ||
if b.inner == nil { | ||
return b.Type() | ||
} | ||
|
||
return b.inner[0] | ||
} | ||
|
||
func (b BlockInformation) BaseType() BlockType { | ||
if b.inner == nil { | ||
return b.Type() | ||
} | ||
|
||
return b.inner[len(b.inner)-1] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Combine the external imports here? (don't know why linter is clearly not working...)
i.e. this should be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha can't say I miss the linter no longer breaking builds, but will fix it up