-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit changes our terminology for a top-level dynamic type to "Dynamic" from "Variant". The term "variant" has been corrupted by the industry to mean efficiently-encoded semi-structured data when the traditional meaning from programming languages is a tagged union. To avoid this confusion, we're following clickhouse's terminology and using the term dynamic instead. This change is internal to the code only and does not affect any user-facing documentation as the super-structured data model is strongly typed throughout and does not expose the implied top-level dynamic type as a user-visible type.
- Loading branch information
Showing
24 changed files
with
166 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package vector | ||
|
||
import ( | ||
"github.com/brimdata/zed" | ||
"github.com/brimdata/zed/zcode" | ||
) | ||
|
||
// Dynamic is an ordered sequence of values taken from one or more | ||
// hetereogenously-typed vectors. | ||
type Dynamic struct { | ||
Tags []uint32 | ||
Values []Any | ||
TagMap *TagMap | ||
} | ||
|
||
var _ Any = (*Dynamic)(nil) | ||
|
||
func NewDynamic(tags []uint32, values []Any) *Dynamic { | ||
return &Dynamic{Tags: tags, Values: values, TagMap: NewTagMap(tags, values)} | ||
} | ||
|
||
func (*Dynamic) Type() zed.Type { | ||
panic("can't call Type() on a vector.Dynamic") | ||
} | ||
|
||
func (d *Dynamic) TypeOf(slot uint32) zed.Type { | ||
vals := d.Values[d.Tags[slot]] | ||
if v2, ok := vals.(*Dynamic); ok { | ||
return v2.TypeOf(d.TagMap.Forward[slot]) | ||
} | ||
return vals.Type() | ||
} | ||
|
||
func (d *Dynamic) Len() uint32 { | ||
if d.Tags != nil { | ||
return uint32(len(d.Tags)) | ||
} | ||
var length uint32 | ||
for _, val := range d.Values { | ||
length += val.Len() | ||
} | ||
return length | ||
} | ||
|
||
func (d *Dynamic) Serialize(b *zcode.Builder, slot uint32) { | ||
d.Values[d.Tags[slot]].Serialize(b, d.TagMap.Forward[slot]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.