go/store/datas: NewTag -> newTag.

This commit is contained in:
Aaron Son
2022-02-28 16:24:56 -08:00
parent 7cb920c4fe
commit 80094769a4
10 changed files with 185 additions and 182 deletions

View File

@@ -668,168 +668,3 @@ func CommitMetaAddUserTimestamp(builder *flatbuffers.Builder, userTimestamp flat
func CommitMetaEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}
type Tag struct {
_tab flatbuffers.Table
}
func GetRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Tag{}
x.Init(buf, n+offset)
return x
}
func GetSizePrefixedRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag {
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
x := &Tag{}
x.Init(buf, n+offset+flatbuffers.SizeUint32)
return x
}
func (rcv *Tag) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
}
func (rcv *Tag) Table() flatbuffers.Table {
return rcv._tab
}
func (rcv *Tag) Commit(obj *Ref) *Ref {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
x := rcv._tab.Indirect(o + rcv._tab.Pos)
if obj == nil {
obj = new(Ref)
}
obj.Init(rcv._tab.Bytes, x)
return obj
}
return nil
}
func (rcv *Tag) Meta(obj *TagMeta) *TagMeta {
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
if o != 0 {
x := rcv._tab.Indirect(o + rcv._tab.Pos)
if obj == nil {
obj = new(TagMeta)
}
obj.Init(rcv._tab.Bytes, x)
return obj
}
return nil
}
func TagStart(builder *flatbuffers.Builder) {
builder.StartObject(2)
}
func TagAddCommit(builder *flatbuffers.Builder, commit flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(commit), 0)
}
func TagAddMeta(builder *flatbuffers.Builder, meta flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(meta), 0)
}
func TagEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}
type TagMeta struct {
_tab flatbuffers.Table
}
func GetRootAsTagMeta(buf []byte, offset flatbuffers.UOffsetT) *TagMeta {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &TagMeta{}
x.Init(buf, n+offset)
return x
}
func GetSizePrefixedRootAsTagMeta(buf []byte, offset flatbuffers.UOffsetT) *TagMeta {
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
x := &TagMeta{}
x.Init(buf, n+offset+flatbuffers.SizeUint32)
return x
}
func (rcv *TagMeta) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
}
func (rcv *TagMeta) Table() flatbuffers.Table {
return rcv._tab
}
func (rcv *TagMeta) Name() []byte {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
return rcv._tab.ByteVector(o + rcv._tab.Pos)
}
return nil
}
func (rcv *TagMeta) Email() []byte {
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
if o != 0 {
return rcv._tab.ByteVector(o + rcv._tab.Pos)
}
return nil
}
func (rcv *TagMeta) Desc() []byte {
o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
if o != 0 {
return rcv._tab.ByteVector(o + rcv._tab.Pos)
}
return nil
}
func (rcv *TagMeta) Timestamp(obj *Timestamp) *Timestamp {
o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
if o != 0 {
x := o + rcv._tab.Pos
if obj == nil {
obj = new(Timestamp)
}
obj.Init(rcv._tab.Bytes, x)
return obj
}
return nil
}
func (rcv *TagMeta) UserTimestamp(obj *Timestamp) *Timestamp {
o := flatbuffers.UOffsetT(rcv._tab.Offset(12))
if o != 0 {
x := o + rcv._tab.Pos
if obj == nil {
obj = new(Timestamp)
}
obj.Init(rcv._tab.Bytes, x)
return obj
}
return nil
}
func TagMetaStart(builder *flatbuffers.Builder) {
builder.StartObject(5)
}
func TagMetaAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(name), 0)
}
func TagMetaAddEmail(builder *flatbuffers.Builder, email flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(email), 0)
}
func TagMetaAddDesc(builder *flatbuffers.Builder, desc flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(desc), 0)
}
func TagMetaAddTimestamp(builder *flatbuffers.Builder, timestamp flatbuffers.UOffsetT) {
builder.PrependStructSlot(3, flatbuffers.UOffsetT(timestamp), 0)
}
func TagMetaAddUserTimestamp(builder *flatbuffers.Builder, userTimestamp flatbuffers.UOffsetT) {
builder.PrependStructSlot(4, flatbuffers.UOffsetT(userTimestamp), 0)
}
func TagMetaEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}

View File

@@ -17,3 +17,4 @@ package serial
// KEEP THESE IN SYNC WITH .fbs FILES!
const StoreRootFileID = "STRT"
const TagFileID = "DTAG"

150
go/gen/fb/serial/tag.go Normal file
View File

@@ -0,0 +1,150 @@
// Copyright 2022 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
package serial
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type Tag struct {
_tab flatbuffers.Table
}
func GetRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &Tag{}
x.Init(buf, n+offset)
return x
}
func GetSizePrefixedRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag {
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
x := &Tag{}
x.Init(buf, n+offset+flatbuffers.SizeUint32)
return x
}
func (rcv *Tag) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
}
func (rcv *Tag) Table() flatbuffers.Table {
return rcv._tab
}
func (rcv *Tag) CommitAddr(j int) int8 {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
a := rcv._tab.Vector(o)
return rcv._tab.GetInt8(a + flatbuffers.UOffsetT(j*1))
}
return 0
}
func (rcv *Tag) CommitAddrLength() int {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
return rcv._tab.VectorLen(o)
}
return 0
}
func (rcv *Tag) MutateCommitAddr(j int, n int8) bool {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
a := rcv._tab.Vector(o)
return rcv._tab.MutateInt8(a+flatbuffers.UOffsetT(j*1), n)
}
return false
}
func (rcv *Tag) Name() []byte {
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
if o != 0 {
return rcv._tab.ByteVector(o + rcv._tab.Pos)
}
return nil
}
func (rcv *Tag) Email() []byte {
o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
if o != 0 {
return rcv._tab.ByteVector(o + rcv._tab.Pos)
}
return nil
}
func (rcv *Tag) Desc() []byte {
o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
if o != 0 {
return rcv._tab.ByteVector(o + rcv._tab.Pos)
}
return nil
}
func (rcv *Tag) TimestampMillis() uint64 {
o := flatbuffers.UOffsetT(rcv._tab.Offset(12))
if o != 0 {
return rcv._tab.GetUint64(o + rcv._tab.Pos)
}
return 0
}
func (rcv *Tag) MutateTimestampMillis(n uint64) bool {
return rcv._tab.MutateUint64Slot(12, n)
}
func (rcv *Tag) UserTimestampMillis() uint64 {
o := flatbuffers.UOffsetT(rcv._tab.Offset(14))
if o != 0 {
return rcv._tab.GetUint64(o + rcv._tab.Pos)
}
return 0
}
func (rcv *Tag) MutateUserTimestampMillis(n uint64) bool {
return rcv._tab.MutateUint64Slot(14, n)
}
func TagStart(builder *flatbuffers.Builder) {
builder.StartObject(6)
}
func TagAddCommitAddr(builder *flatbuffers.Builder, commitAddr flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(commitAddr), 0)
}
func TagStartCommitAddrVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
return builder.StartVector(1, numElems, 1)
}
func TagAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(name), 0)
}
func TagAddEmail(builder *flatbuffers.Builder, email flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(email), 0)
}
func TagAddDesc(builder *flatbuffers.Builder, desc flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(desc), 0)
}
func TagAddTimestampMillis(builder *flatbuffers.Builder, timestampMillis uint64) {
builder.PrependUint64Slot(4, timestampMillis, 0)
}
func TagAddUserTimestampMillis(builder *flatbuffers.Builder, userTimestampMillis uint64) {
builder.PrependUint64Slot(5, userTimestampMillis, 0)
}
func TagEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}

View File

@@ -73,16 +73,3 @@ table CommitMeta {
timestamp:Timestamp (required);
user_timestamp:Timestamp (required);
}
table Tag {
commit:Ref (required);
meta:TagMeta (required);
}
table TagMeta {
name:string (required);
email:string (required);
desc:string (required);
timestamp:Timestamp (required);
user_timestamp:Timestamp (required);
}

View File

@@ -17,3 +17,4 @@ package serial
// KEEP THESE IN SYNC WITH .fbs FILES!
const StoreRootFileID = "STRT"
const TagFileID = "DTAG"

View File

@@ -11,6 +11,7 @@ flatc -o $GEN_DIR --gen-onefile --filename-suffix "" --gen-mutable --go-namespac
prolly.fbs \
schema.fbs \
storeroot.fbs \
tag.fbs \
table.fbs
# prefix files with copyright header

28
go/serial/tag.fbs Normal file
View File

@@ -0,0 +1,28 @@
// Copyright 2022 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
table Tag {
// 20-byte hash of the commit.
commit_addr:[byte] (required);
name:string (required);
email:string (required);
desc:string (required);
timestamp_millis:uint64;
user_timestamp_millis:uint64;
}
// KEEP THIS IN SYNC WITH fileidentifiers.go
file_identifier "DTAG";
root_type Tag;

View File

@@ -571,7 +571,7 @@ func (db *database) Tag(ctx context.Context, ds Dataset, commitAddr hash.Hash, o
if err != nil {
return err
}
st, err := NewTag(ctx, ref, opts.Meta)
st, err := newTag(ctx, ref, opts.Meta)
if err != nil {
return err
}

View File

@@ -43,7 +43,7 @@ type TagOptions struct {
Meta *TagMeta
}
// NewTag creates a new tag object.
// newTag creates a new tag object.
//
// A tag has the following type:
//
@@ -54,7 +54,7 @@ type TagOptions struct {
// }
// ```
// where M is a struct type and R is a ref type.
func NewTag(_ context.Context, commitRef types.Ref, meta *TagMeta) (types.Struct, error) {
func newTag(_ context.Context, commitRef types.Ref, meta *TagMeta) (types.Struct, error) {
var metaV types.Struct
if meta != nil {
var err error

View File

@@ -44,7 +44,7 @@ func TestNewTag(t *testing.T) {
cmRef, err := types.NewRef(commit, types.Format_7_18)
require.NoError(t, err)
tag, err := NewTag(context.Background(), cmRef, nil)
tag, err := newTag(context.Background(), cmRef, nil)
require.NoError(t, err)
ct, err := makeCommitStructType(