Skip to content

Commit aa249f5

Browse files
authored
Merge pull request #1085 from ydb-platform/slo
SLO native splitted to native/table and native/query
2 parents a051ea9 + 04320be commit aa249f5

File tree

21 files changed

+1379
-21
lines changed

21 files changed

+1379
-21
lines changed

.github/workflows/examples.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
ydb-version: [ 22.5, 23.1, 23.2 ]
19-
application: [ native, database_sql, gorm, xorm ]
18+
ydb-version: [ 22.5, 23.1, 23.2, 23.3, 24.1 ]
19+
application: [ native/table, native/query, database_sql, gorm, xorm ]
2020
services:
2121
ydb:
2222
image: cr.yandex/crpsjg1coh47p81vh2lc/yandex-docker-local-ydb:${{ matrix.ydb-version }}

.github/workflows/slo.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,35 @@ jobs:
4343
timeBetweenPhases: 30
4444
shutdownTime: 30
4545

46-
language_id0: 'native'
46+
language_id0: 'native/table'
4747
workload_path0: 'tests/slo'
48-
language0: 'Go SDK native'
48+
language0: 'Go SDK native over table-service'
4949
workload_build_context0: ../..
50-
workload_build_options0: -f Dockerfile --build-arg SRC_PATH=native --build-arg JOB_NAME=workload-native
50+
workload_build_options0: -f Dockerfile --build-arg SRC_PATH=native/table --build-arg JOB_NAME=workload-native-table
5151

52-
language_id1: 'databasesql'
52+
language_id1: 'query'
5353
workload_path1: 'tests/slo'
54-
language1: 'Go SDK database/sql'
54+
language1: 'Go SDK native over query-service'
5555
workload_build_context1: ../..
56-
workload_build_options1: -f Dockerfile --build-arg SRC_PATH=database/sql --build-arg JOB_NAME=workload-databasesql
56+
workload_build_options1: -f Dockerfile --build-arg SRC_PATH=native/query --build-arg JOB_NAME=workload-native-query
5757

58-
language_id2: 'gorm'
58+
language_id2: 'database/sql'
5959
workload_path2: 'tests/slo'
60-
language2: 'Go SDK gorm'
60+
language2: 'Go SDK database/sql'
6161
workload_build_context2: ../..
62-
workload_build_options2: -f Dockerfile --build-arg SRC_PATH=gorm --build-arg JOB_NAME=workload-gorm
62+
workload_build_options2: -f Dockerfile --build-arg SRC_PATH=database/sql --build-arg JOB_NAME=workload-database-sql
6363

64-
language_id3: 'xorm'
64+
language_id3: 'gorm'
6565
workload_path3: 'tests/slo'
66-
language3: 'Go SDK xorm'
66+
language3: 'Go SDK gorm'
6767
workload_build_context3: ../..
68-
workload_build_options3: -f Dockerfile --build-arg SRC_PATH=xorm --build-arg JOB_NAME=workload-xorm
68+
workload_build_options3: -f Dockerfile --build-arg SRC_PATH=gorm --build-arg JOB_NAME=workload-gorm
69+
70+
language_id4: 'xorm'
71+
workload_path4: 'tests/slo'
72+
language4: 'Go SDK xorm'
73+
workload_build_context4: ../..
74+
workload_build_options4: -f Dockerfile --build-arg SRC_PATH=xorm --build-arg JOB_NAME=workload-xorm
6975

7076
- uses: actions/upload-artifact@v3
7177
if: always()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Basic example via native driver
2+
3+
Basic example demonstrates the possibilities of `YDB`:
4+
- create/drop/describe tables
5+
- upsert data
6+
- select with data query (request-response API)
7+
- select with scan query (streaming API)
8+
- read table (streaming API)
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
package main
2+
3+
import (
4+
"time"
5+
6+
"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
7+
)
8+
9+
func seriesData(id uint64, released time.Time, title, info, comment string) types.Value {
10+
var commentv types.Value
11+
if comment == "" {
12+
commentv = types.NullValue(types.TypeUTF8)
13+
} else {
14+
commentv = types.OptionalValue(types.TextValue(comment))
15+
}
16+
17+
return types.StructValue(
18+
types.StructFieldValue("series_id", types.Uint64Value(id)),
19+
types.StructFieldValue("release_date", types.DateValueFromTime(released)),
20+
types.StructFieldValue("title", types.TextValue(title)),
21+
types.StructFieldValue("series_info", types.TextValue(info)),
22+
types.StructFieldValue("comment", commentv),
23+
)
24+
}
25+
26+
func seasonData(seriesID, seasonID uint64, title string, first, last time.Time) types.Value {
27+
return types.StructValue(
28+
types.StructFieldValue("series_id", types.Uint64Value(seriesID)),
29+
types.StructFieldValue("season_id", types.Uint64Value(seasonID)),
30+
types.StructFieldValue("title", types.TextValue(title)),
31+
types.StructFieldValue("first_aired", types.DateValueFromTime(first)),
32+
types.StructFieldValue("last_aired", types.DateValueFromTime(last)),
33+
)
34+
}
35+
36+
func episodeData(seriesID, seasonID, episodeID uint64, title string, date time.Time) types.Value {
37+
return types.StructValue(
38+
types.StructFieldValue("series_id", types.Uint64Value(seriesID)),
39+
types.StructFieldValue("season_id", types.Uint64Value(seasonID)),
40+
types.StructFieldValue("episode_id", types.Uint64Value(episodeID)),
41+
types.StructFieldValue("title", types.TextValue(title)),
42+
types.StructFieldValue("air_date", types.DateValueFromTime(date)),
43+
)
44+
}
45+
46+
func getSeriesData() types.Value {
47+
return types.ListValue(
48+
seriesData(
49+
1, days("2006-02-03"), "IT Crowd", ""+
50+
"The IT Crowd is a British sitcom produced by Channel 4, written by Graham Linehan, produced by "+
51+
"Ash Atalla and starring Chris O'Dowd, Richard Ayoade, Katherine Parkinson, and Matt Berry.",
52+
"", // NULL comment.
53+
),
54+
seriesData(
55+
2, days("2014-04-06"), "Silicon Valley", ""+
56+
"Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and "+
57+
"Dave Krinsky. The series focuses on five young men who founded a startup company in Silicon Valley.",
58+
"Some comment here",
59+
),
60+
)
61+
}
62+
63+
func getSeasonsData() types.Value {
64+
return types.ListValue(
65+
seasonData(1, 1, "Season 1", days("2006-02-03"), days("2006-03-03")),
66+
seasonData(1, 2, "Season 2", days("2007-08-24"), days("2007-09-28")),
67+
seasonData(1, 3, "Season 3", days("2008-11-21"), days("2008-12-26")),
68+
seasonData(1, 4, "Season 4", days("2010-06-25"), days("2010-07-30")),
69+
seasonData(2, 1, "Season 1", days("2014-04-06"), days("2014-06-01")),
70+
seasonData(2, 2, "Season 2", days("2015-04-12"), days("2015-06-14")),
71+
seasonData(2, 3, "Season 3", days("2016-04-24"), days("2016-06-26")),
72+
seasonData(2, 4, "Season 4", days("2017-04-23"), days("2017-06-25")),
73+
seasonData(2, 5, "Season 5", days("2018-03-25"), days("2018-05-13")),
74+
)
75+
}
76+
77+
func getEpisodesData() types.Value {
78+
return types.ListValue(
79+
episodeData(1, 1, 1, "Yesterday's Jam", days("2006-02-03")),
80+
episodeData(1, 1, 2, "Calamity Jen", days("2006-02-03")),
81+
episodeData(1, 1, 3, "Fifty-Fifty", days("2006-02-10")),
82+
episodeData(1, 1, 4, "The Red Door", days("2006-02-17")),
83+
episodeData(1, 1, 5, "The Haunting of Bill Crouse", days("2006-02-24")),
84+
episodeData(1, 1, 6, "Aunt Irma Visits", days("2006-03-03")),
85+
episodeData(1, 2, 1, "The Work Outing", days("2006-08-24")),
86+
episodeData(1, 2, 2, "Return of the Golden Child", days("2007-08-31")),
87+
episodeData(1, 2, 3, "Moss and the German", days("2007-09-07")),
88+
episodeData(1, 2, 4, "The Dinner Party", days("2007-09-14")),
89+
episodeData(1, 2, 5, "Smoke and Mirrors", days("2007-09-21")),
90+
episodeData(1, 2, 6, "Men Without Women", days("2007-09-28")),
91+
episodeData(1, 3, 1, "From Hell", days("2008-11-21")),
92+
episodeData(1, 3, 2, "Are We Not Men?", days("2008-11-28")),
93+
episodeData(1, 3, 3, "Tramps Like Us", days("2008-12-05")),
94+
episodeData(1, 3, 4, "The Speech", days("2008-12-12")),
95+
episodeData(1, 3, 5, "Friendface", days("2008-12-19")),
96+
episodeData(1, 3, 6, "Calendar Geeks", days("2008-12-26")),
97+
episodeData(1, 4, 1, "Jen The Fredo", days("2010-06-25")),
98+
episodeData(1, 4, 2, "The Final Countdown", days("2010-07-02")),
99+
episodeData(1, 4, 3, "Something Happened", days("2010-07-09")),
100+
episodeData(1, 4, 4, "Italian For Beginners", days("2010-07-16")),
101+
episodeData(1, 4, 5, "Bad Boys", days("2010-07-23")),
102+
episodeData(1, 4, 6, "Reynholm vs Reynholm", days("2010-07-30")),
103+
episodeData(2, 1, 1, "Minimum Viable Product", days("2014-04-06")),
104+
episodeData(2, 1, 2, "The Cap Table", days("2014-04-13")),
105+
episodeData(2, 1, 3, "Articles of Incorporation", days("2014-04-20")),
106+
episodeData(2, 1, 4, "Fiduciary Duties", days("2014-04-27")),
107+
episodeData(2, 1, 5, "Signaling Risk", days("2014-05-04")),
108+
episodeData(2, 1, 6, "Third Party Insourcing", days("2014-05-11")),
109+
episodeData(2, 1, 7, "Proof of Concept", days("2014-05-18")),
110+
episodeData(2, 1, 8, "Optimal Tip-to-Tip Efficiency", days("2014-06-01")),
111+
episodeData(2, 2, 1, "Sand Hill Shuffle", days("2015-04-12")),
112+
episodeData(2, 2, 2, "Runaway Devaluation", days("2015-04-19")),
113+
episodeData(2, 2, 3, "Bad Money", days("2015-04-26")),
114+
episodeData(2, 2, 4, "The Lady", days("2015-05-03")),
115+
episodeData(2, 2, 5, "Server Space", days("2015-05-10")),
116+
episodeData(2, 2, 6, "Homicide", days("2015-05-17")),
117+
episodeData(2, 2, 7, "Adult Content", days("2015-05-24")),
118+
episodeData(2, 2, 8, "White Hat/Black Hat", days("2015-05-31")),
119+
episodeData(2, 2, 9, "Binding Arbitration", days("2015-06-07")),
120+
episodeData(2, 2, 10, "Two Days of the Condor", days("2015-06-14")),
121+
episodeData(2, 3, 1, "Founder Friendly", days("2016-04-24")),
122+
episodeData(2, 3, 2, "Two in the Box", days("2016-05-01")),
123+
episodeData(2, 3, 3, "Meinertzhagen's Haversack", days("2016-05-08")),
124+
episodeData(2, 3, 4, "Maleant Data Systems Solutions", days("2016-05-15")),
125+
episodeData(2, 3, 5, "The Empty Chair", days("2016-05-22")),
126+
episodeData(2, 3, 6, "Bachmanity Insanity", days("2016-05-29")),
127+
episodeData(2, 3, 7, "To Build a Better Beta", days("2016-06-05")),
128+
episodeData(2, 3, 8, "Bachman's Earnings Over-Ride", days("2016-06-12")),
129+
episodeData(2, 3, 9, "Daily Active Users", days("2016-06-19")),
130+
episodeData(2, 3, 10, "The Uptick", days("2016-06-26")),
131+
episodeData(2, 4, 1, "Success Failure", days("2017-04-23")),
132+
episodeData(2, 4, 2, "Terms of Service", days("2017-04-30")),
133+
episodeData(2, 4, 3, "Intellectual Property", days("2017-05-07")),
134+
episodeData(2, 4, 4, "Teambuilding Exercise", days("2017-05-14")),
135+
episodeData(2, 4, 5, "The Blood Boy", days("2017-05-21")),
136+
episodeData(2, 4, 6, "Customer Service", days("2017-05-28")),
137+
episodeData(2, 4, 7, "The Patent Troll", days("2017-06-04")),
138+
episodeData(2, 4, 8, "The Keenan Vortex", days("2017-06-11")),
139+
episodeData(2, 4, 9, "Hooli-Con", days("2017-06-18")),
140+
episodeData(2, 4, 10, "Server Error", days("2017-06-25")),
141+
episodeData(2, 5, 1, "Grow Fast or Die Slow", days("2018-03-25")),
142+
episodeData(2, 5, 2, "Reorientation", days("2018-04-01")),
143+
episodeData(2, 5, 3, "Chief Operating Officer", days("2018-04-08")),
144+
episodeData(2, 5, 4, "Tech Evangelist", days("2018-04-15")),
145+
episodeData(2, 5, 5, "Facial Recognition", days("2018-04-22")),
146+
episodeData(2, 5, 6, "Artificial Emotional Intelligence", days("2018-04-29")),
147+
episodeData(2, 5, 7, "Initial Coin Offering", days("2018-05-06")),
148+
episodeData(2, 5, 8, "Fifty-One Percent", days("2018-05-13")),
149+
)
150+
}
151+
152+
const dateISO8601 = "2006-01-02"
153+
154+
func days(date string) time.Time {
155+
t, err := time.Parse(dateISO8601, date)
156+
if err != nil {
157+
panic(err)
158+
}
159+
160+
return t
161+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
"path"
8+
"time"
9+
10+
environ "github.com/ydb-platform/ydb-go-sdk-auth-environ"
11+
"github.com/ydb-platform/ydb-go-sdk/v3"
12+
"github.com/ydb-platform/ydb-go-sdk/v3/sugar"
13+
)
14+
15+
func main() {
16+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
17+
defer cancel()
18+
19+
dsn, exists := os.LookupEnv("YDB_CONNECTION_STRING")
20+
if !exists {
21+
panic("YDB_CONNECTION_STRING environment variable not defined")
22+
}
23+
24+
db, err := ydb.Open(ctx,
25+
dsn,
26+
environ.WithEnvironCredentials(ctx),
27+
)
28+
if err != nil {
29+
panic(fmt.Errorf("connect error: %w", err))
30+
}
31+
defer func() { _ = db.Close(ctx) }()
32+
33+
prefix := path.Join(db.Name(), "native")
34+
35+
err = sugar.RemoveRecursive(ctx, db, prefix)
36+
if err != nil {
37+
panic(err)
38+
}
39+
40+
err = describeTableOptions(ctx, db.Table())
41+
if err != nil {
42+
panic(fmt.Errorf("describe table options error: %w", err))
43+
}
44+
45+
err = createTables(ctx, db.Table(), prefix)
46+
if err != nil {
47+
panic(fmt.Errorf("create tables error: %w", err))
48+
}
49+
50+
err = describeTable(ctx, db.Table(), path.Join(prefix, "series"))
51+
if err != nil {
52+
panic(fmt.Errorf("describe table error: %w", err))
53+
}
54+
55+
err = fillTablesWithData(ctx, db.Table(), prefix)
56+
if err != nil {
57+
panic(fmt.Errorf("fill tables with data error: %w", err))
58+
}
59+
60+
err = selectSimple(ctx, db.Table(), prefix)
61+
if err != nil {
62+
panic(fmt.Errorf("select simple error: %w", err))
63+
}
64+
65+
err = scanQuerySelect(ctx, db.Table(), prefix)
66+
if err != nil {
67+
panic(fmt.Errorf("scan query select error: %w", err))
68+
}
69+
70+
err = readTable(ctx, db.Table(), path.Join(prefix, "series"))
71+
if err != nil {
72+
panic(fmt.Errorf("read table error: %w", err))
73+
}
74+
}

0 commit comments

Comments
 (0)