How to use exists method of regression Package

Best Keploy code snippet using regression.exists

operator.go

Source:operator.go Github

copy

Full Screen

1// Copyright 2018 The Cockroach Authors.2//3// Use of this software is governed by the Business Source License4// included in the file licenses/BSL.txt.5//6// As of the Change Date specified in that file, in accordance with7// the Business Source License, use of this software will be governed8// by the Apache License, Version 2.0, included in the file9// licenses/APL.txt.10package opt11import (12 "fmt"13 "github.com/cockroachdb/cockroach/pkg/sql/catalog/colinfo"14 "github.com/cockroachdb/cockroach/pkg/sql/sem/tree"15 "github.com/cockroachdb/cockroach/pkg/sql/types"16 "github.com/cockroachdb/cockroach/pkg/util/log"17 "github.com/cockroachdb/errors"18)19// Operator describes the type of operation that a memo expression performs.20// Some operators are relational (join, select, project) and others are scalar21// (and, or, plus, variable).22type Operator uint1623// String returns the name of the operator as a string.24func (op Operator) String() string {25 if op >= Operator(len(opNames)-1) {26 return fmt.Sprintf("Operator(%d)", op)27 }28 return opNames[opNameIndexes[op]:opNameIndexes[op+1]]29}30// SyntaxTag returns the name of the operator using the SQL syntax that most31// closely matches it.32func (op Operator) SyntaxTag() string {33 // Handle any special cases where default codegen tag isn't best choice as34 // switch cases.35 switch op {36 default:37 // Use default codegen tag, which is mechanically derived from the38 // operator name.39 if op >= Operator(len(opNames)-1) {40 // Use UNKNOWN.41 op = 042 }43 return opSyntaxTags[opSyntaxTagIndexes[op]:opSyntaxTagIndexes[op+1]]44 }45}46// Expr is a node in an expression tree. It offers methods to traverse and47// inspect the tree. Each node in the tree has an enumerated operator type, zero48// or more children, and an optional private value. The entire tree can be49// easily visited using a pattern like this:50//51// var visit func(e Expr)52// visit := func(e Expr) {53// for i, n := 0, e.ChildCount(); i < n; i++ {54// visit(e.Child(i))55// }56// }57//58type Expr interface {59 // Op returns the operator type of the expression.60 Op() Operator61 // ChildCount returns the number of children of the expression.62 ChildCount() int63 // Child returns the nth child of the expression.64 Child(nth int) Expr65 // Private returns operator-specific data. Callers are expected to know the66 // type and format of the data, which will differ from operator to operator.67 // For example, an operator may choose to return one of its fields, or perhaps68 // a pointer to itself, or nil if there is nothing useful to return.69 Private() interface{}70 // String returns a human-readable string representation for the expression71 // that can be used for debugging and testing.72 String() string73}74// ScalarID is the type of the memo-unique identifier given to every scalar75// expression.76type ScalarID int77// ScalarExpr is a scalar expression, which is an expression that returns a78// primitive-typed value like boolean or string rather than rows and columns.79type ScalarExpr interface {80 Expr81 // ID is a unique (within the context of a memo) ID that can be82 // used to define a total order over ScalarExprs.83 ID() ScalarID84 // DataType is the SQL type of the expression.85 DataType() *types.T86}87// MutableExpr is implemented by expressions that allow their children to be88// updated.89type MutableExpr interface {90 // SetChild updates the nth child of the expression to instead be the given91 // child expression.92 SetChild(nth int, child Expr)93}94// ComparisonOpMap maps from a semantic tree comparison operator type to an95// optimizer operator type.96var ComparisonOpMap [tree.NumComparisonOperatorSymbols]Operator97// ComparisonOpReverseMap maps from an optimizer operator type to a semantic98// tree comparison operator type.99var ComparisonOpReverseMap = map[Operator]tree.ComparisonOperatorSymbol{100 EqOp: tree.EQ,101 LtOp: tree.LT,102 GtOp: tree.GT,103 LeOp: tree.LE,104 GeOp: tree.GE,105 NeOp: tree.NE,106 InOp: tree.In,107 NotInOp: tree.NotIn,108 LikeOp: tree.Like,109 NotLikeOp: tree.NotLike,110 ILikeOp: tree.ILike,111 NotILikeOp: tree.NotILike,112 SimilarToOp: tree.SimilarTo,113 NotSimilarToOp: tree.NotSimilarTo,114 RegMatchOp: tree.RegMatch,115 NotRegMatchOp: tree.NotRegMatch,116 RegIMatchOp: tree.RegIMatch,117 NotRegIMatchOp: tree.NotRegIMatch,118 IsOp: tree.IsNotDistinctFrom,119 IsNotOp: tree.IsDistinctFrom,120 ContainsOp: tree.Contains,121 ContainedByOp: tree.ContainedBy,122 JsonExistsOp: tree.JSONExists,123 JsonSomeExistsOp: tree.JSONSomeExists,124 JsonAllExistsOp: tree.JSONAllExists,125 OverlapsOp: tree.Overlaps,126 BBoxCoversOp: tree.RegMatch,127 BBoxIntersectsOp: tree.Overlaps,128}129// BinaryOpReverseMap maps from an optimizer operator type to a semantic tree130// binary operator type.131var BinaryOpReverseMap = map[Operator]tree.BinaryOperatorSymbol{132 BitandOp: tree.Bitand,133 BitorOp: tree.Bitor,134 BitxorOp: tree.Bitxor,135 PlusOp: tree.Plus,136 MinusOp: tree.Minus,137 MultOp: tree.Mult,138 DivOp: tree.Div,139 FloorDivOp: tree.FloorDiv,140 ModOp: tree.Mod,141 PowOp: tree.Pow,142 ConcatOp: tree.Concat,143 LShiftOp: tree.LShift,144 RShiftOp: tree.RShift,145 FetchValOp: tree.JSONFetchVal,146 FetchTextOp: tree.JSONFetchText,147 FetchValPathOp: tree.JSONFetchValPath,148 FetchTextPathOp: tree.JSONFetchTextPath,149}150// UnaryOpReverseMap maps from an optimizer operator type to a semantic tree151// unary operator type.152var UnaryOpReverseMap = map[Operator]tree.UnaryOperatorSymbol{153 UnaryMinusOp: tree.UnaryMinus,154 UnaryComplementOp: tree.UnaryComplement,155 UnarySqrtOp: tree.UnarySqrt,156 UnaryCbrtOp: tree.UnaryCbrt,157 UnaryPlusOp: tree.UnaryPlus,158}159// AggregateOpReverseMap maps from an optimizer operator type to the name of an160// aggregation function.161var AggregateOpReverseMap = map[Operator]string{162 ArrayAggOp: "array_agg",163 AvgOp: "avg",164 BitAndAggOp: "bit_and",165 BitOrAggOp: "bit_or",166 BoolAndOp: "bool_and",167 BoolOrOp: "bool_or",168 ConcatAggOp: "concat_agg",169 CountOp: "count",170 CorrOp: "corr",171 CountRowsOp: "count_rows",172 CovarPopOp: "covar_pop",173 CovarSampOp: "covar_samp",174 RegressionAvgXOp: "regr_avgx",175 RegressionAvgYOp: "regr_avgy",176 RegressionInterceptOp: "regr_intercept",177 RegressionR2Op: "regr_r2",178 RegressionSlopeOp: "regr_slope",179 RegressionSXXOp: "regr_sxx",180 RegressionSXYOp: "regr_sxy",181 RegressionSYYOp: "regr_syy",182 RegressionCountOp: "regr_count",183 MaxOp: "max",184 MinOp: "min",185 SumIntOp: "sum_int",186 SumOp: "sum",187 SqrDiffOp: "sqrdiff",188 VarianceOp: "variance",189 StdDevOp: "stddev",190 XorAggOp: "xor_agg",191 JsonAggOp: "json_agg",192 JsonbAggOp: "jsonb_agg",193 JsonObjectAggOp: "json_object_agg",194 JsonbObjectAggOp: "jsonb_object_agg",195 StringAggOp: "string_agg",196 ConstAggOp: "any_not_null",197 ConstNotNullAggOp: "any_not_null",198 AnyNotNullAggOp: "any_not_null",199 PercentileDiscOp: "percentile_disc_impl",200 PercentileContOp: "percentile_cont_impl",201 VarPopOp: "var_pop",202 StdDevPopOp: "stddev_pop",203 STMakeLineOp: "st_makeline",204 STUnionOp: "st_union",205 STCollectOp: "st_collect",206 STExtentOp: "st_extent",207}208// WindowOpReverseMap maps from an optimizer operator type to the name of a209// window function.210var WindowOpReverseMap = map[Operator]string{211 RankOp: "rank",212 RowNumberOp: "row_number",213 DenseRankOp: "dense_rank",214 PercentRankOp: "percent_rank",215 CumeDistOp: "cume_dist",216 NtileOp: "ntile",217 LagOp: "lag",218 LeadOp: "lead",219 FirstValueOp: "first_value",220 LastValueOp: "last_value",221 NthValueOp: "nth_value",222}223// NegateOpMap maps from a comparison operator type to its negated operator224// type, as if the Not operator was applied to it. Some comparison operators,225// like Contains and JsonExists, do not have negated versions.226var NegateOpMap = map[Operator]Operator{227 EqOp: NeOp,228 LtOp: GeOp,229 GtOp: LeOp,230 LeOp: GtOp,231 GeOp: LtOp,232 NeOp: EqOp,233 InOp: NotInOp,234 NotInOp: InOp,235 LikeOp: NotLikeOp,236 NotLikeOp: LikeOp,237 ILikeOp: NotILikeOp,238 NotILikeOp: ILikeOp,239 SimilarToOp: NotSimilarToOp,240 NotSimilarToOp: SimilarToOp,241 RegMatchOp: NotRegMatchOp,242 NotRegMatchOp: RegMatchOp,243 RegIMatchOp: NotRegIMatchOp,244 NotRegIMatchOp: RegIMatchOp,245 IsOp: IsNotOp,246 IsNotOp: IsOp,247}248// ScalarOperatorTransmitsNulls returns true if the given scalar operator always249// returns NULL when at least one of its inputs is NULL.250func ScalarOperatorTransmitsNulls(op Operator) bool {251 switch op {252 case BitandOp, BitorOp, BitxorOp, PlusOp, MinusOp, MultOp, DivOp, FloorDivOp,253 ModOp, PowOp, EqOp, NeOp, LtOp, GtOp, LeOp, GeOp, LikeOp, NotLikeOp, ILikeOp,254 NotILikeOp, SimilarToOp, NotSimilarToOp, RegMatchOp, NotRegMatchOp, RegIMatchOp,255 NotRegIMatchOp, ConstOp, BBoxCoversOp, BBoxIntersectsOp:256 return true257 default:258 return false259 }260}261// BoolOperatorRequiresNotNullArgs returns true if the operator can never262// evaluate to true if one of its children is NULL.263func BoolOperatorRequiresNotNullArgs(op Operator) bool {264 switch op {265 case266 EqOp, LtOp, LeOp, GtOp, GeOp, NeOp,267 LikeOp, NotLikeOp, ILikeOp, NotILikeOp, SimilarToOp, NotSimilarToOp,268 RegMatchOp, NotRegMatchOp, RegIMatchOp, NotRegIMatchOp, BBoxCoversOp,269 BBoxIntersectsOp:270 return true271 }272 return false273}274// AggregateIgnoresNulls returns true if the given aggregate operator ignores275// rows where its first argument evaluates to NULL. In other words, it always276// evaluates to the same result even if those rows are filtered. For example:277//278// SELECT string_agg(x, y)279// FROM (VALUES ('foo', ','), ('bar', ','), (NULL, ',')) t(x, y)280//281// In this example, the NULL row can be removed from the input, and the282// string_agg function still returns the same result. Contrast this to the283// array_agg function:284//285// SELECT array_agg(x)286// FROM (VALUES ('foo'), (NULL), ('bar')) t(x)287//288// If the NULL row is removed here, array_agg returns {foo,bar} instead of289// {foo,NULL,bar}.290func AggregateIgnoresNulls(op Operator) bool {291 switch op {292 case AnyNotNullAggOp, AvgOp, BitAndAggOp, BitOrAggOp, BoolAndOp, BoolOrOp,293 ConstNotNullAggOp, CorrOp, CountOp, MaxOp, MinOp, SqrDiffOp, StdDevOp,294 StringAggOp, SumOp, SumIntOp, VarianceOp, XorAggOp, PercentileDiscOp,295 PercentileContOp, STMakeLineOp, STCollectOp, STExtentOp, STUnionOp, StdDevPopOp,296 VarPopOp, CovarPopOp, CovarSampOp, RegressionAvgXOp, RegressionAvgYOp,297 RegressionInterceptOp, RegressionR2Op, RegressionSlopeOp, RegressionSXXOp,298 RegressionSXYOp, RegressionSYYOp, RegressionCountOp:299 return true300 case ArrayAggOp, ConcatAggOp, ConstAggOp, CountRowsOp, FirstAggOp, JsonAggOp,301 JsonbAggOp, JsonObjectAggOp, JsonbObjectAggOp:302 return false303 default:304 panic(errors.AssertionFailedf("unhandled op %s", log.Safe(op)))305 }306}307// AggregateIsNullOnEmpty returns true if the given aggregate operator returns308// NULL when the input set contains no values. This group of aggregates turns309// out to be the inverse of AggregateIsNeverNull in practice.310func AggregateIsNullOnEmpty(op Operator) bool {311 switch op {312 case AnyNotNullAggOp, ArrayAggOp, AvgOp, BitAndAggOp,313 BitOrAggOp, BoolAndOp, BoolOrOp, ConcatAggOp, ConstAggOp,314 ConstNotNullAggOp, CorrOp, FirstAggOp, JsonAggOp, JsonbAggOp,315 MaxOp, MinOp, SqrDiffOp, StdDevOp, STMakeLineOp, StringAggOp, SumOp, SumIntOp,316 VarianceOp, XorAggOp, PercentileDiscOp, PercentileContOp,317 JsonObjectAggOp, JsonbObjectAggOp, StdDevPopOp, STCollectOp, STExtentOp, STUnionOp,318 VarPopOp, CovarPopOp, CovarSampOp, RegressionAvgXOp, RegressionAvgYOp,319 RegressionInterceptOp, RegressionR2Op, RegressionSlopeOp, RegressionSXXOp,320 RegressionSXYOp, RegressionSYYOp:321 return true322 case CountOp, CountRowsOp, RegressionCountOp:323 return false324 default:325 panic(errors.AssertionFailedf("unhandled op %s", log.Safe(op)))326 }327}328// AggregateIsNeverNullOnNonNullInput returns true if the given aggregate329// operator never returns NULL when the input set contains at least one non-NULL330// value. This is true of most aggregates.331//332// For multi-input aggregations, returns true if the aggregate is never NULL333// when all inputs have at least a non-NULL value (though not necessarily on the334// same input row).335func AggregateIsNeverNullOnNonNullInput(op Operator) bool {336 switch op {337 case AnyNotNullAggOp, ArrayAggOp, AvgOp, BitAndAggOp,338 BitOrAggOp, BoolAndOp, BoolOrOp, ConcatAggOp, ConstAggOp,339 ConstNotNullAggOp, CountOp, CountRowsOp, FirstAggOp,340 JsonAggOp, JsonbAggOp, MaxOp, MinOp, SqrDiffOp, STMakeLineOp,341 StringAggOp, SumOp, SumIntOp, XorAggOp, PercentileDiscOp, PercentileContOp,342 JsonObjectAggOp, JsonbObjectAggOp, StdDevPopOp, STCollectOp, STExtentOp, STUnionOp,343 VarPopOp, CovarPopOp, RegressionAvgXOp, RegressionAvgYOp, RegressionSXXOp,344 RegressionSXYOp, RegressionSYYOp, RegressionCountOp:345 return true346 case VarianceOp, StdDevOp, CorrOp, CovarSampOp, RegressionInterceptOp,347 RegressionR2Op, RegressionSlopeOp:348 // These aggregations return NULL if they are given a single not-NULL input.349 return false350 default:351 panic(errors.AssertionFailedf("unhandled op %s", log.Safe(op)))352 }353}354// AggregateIsNeverNull returns true if the given aggregate operator never355// returns NULL, even if the input is empty, or one more more inputs are NULL.356func AggregateIsNeverNull(op Operator) bool {357 switch op {358 case CountOp, CountRowsOp, RegressionCountOp:359 return true360 }361 return false362}363// AggregatesCanMerge returns true if the given inner and outer operators can be364// replaced with a single equivalent operator, assuming the outer operator is365// aggregating on the inner and that both operators are unordered. In other366// words, the inner-outer aggregate pair forms a valid "decomposition" of a367// single aggregate. For example, the following pairs of queries are equivalent:368//369// SELECT sum(s) FROM (SELECT sum(y) FROM xy GROUP BY x) AS f(s);370// SELECT sum(y) FROM xy;371//372// SELECT sum_int(c) FROM (SELECT count(y) FROM xy GROUP BY x) AS f(c);373// SELECT count(y) FROM xy;374//375// Note: some aggregates like StringAggOp are decomposable in theory, but in376// practice can not be easily merged as in the examples above.377func AggregatesCanMerge(inner, outer Operator) bool {378 switch inner {379 case AnyNotNullAggOp, BitAndAggOp, BitOrAggOp, BoolAndOp,380 BoolOrOp, ConstAggOp, ConstNotNullAggOp, FirstAggOp,381 MaxOp, MinOp, STMakeLineOp, STExtentOp, STUnionOp, SumOp, SumIntOp, XorAggOp:382 return inner == outer383 case CountOp, CountRowsOp:384 // Only SumIntOp can be used here because SumOp outputs a decimal value,385 // while CountOp and CountRowsOp both output int values.386 return outer == SumIntOp387 case ArrayAggOp, AvgOp, ConcatAggOp, CorrOp, JsonAggOp, JsonbAggOp,388 JsonObjectAggOp, JsonbObjectAggOp, PercentileContOp, PercentileDiscOp,389 SqrDiffOp, STCollectOp, StdDevOp, StringAggOp, VarianceOp, StdDevPopOp,390 VarPopOp, CovarPopOp, CovarSampOp, RegressionAvgXOp, RegressionAvgYOp,391 RegressionInterceptOp, RegressionR2Op, RegressionSlopeOp, RegressionSXXOp,392 RegressionSXYOp, RegressionSYYOp, RegressionCountOp:393 return false394 default:395 panic(errors.AssertionFailedf("unhandled ops: %s, %s", log.Safe(inner), log.Safe(outer)))396 }397}398// AggregateIgnoresDuplicates returns true if the output of the given aggregate399// operator does not change when duplicate rows are added to the input.400func AggregateIgnoresDuplicates(op Operator) bool {401 switch op {402 case AnyNotNullAggOp, BitAndAggOp, BitOrAggOp, BoolAndOp, BoolOrOp,403 ConstAggOp, ConstNotNullAggOp, FirstAggOp, MaxOp, MinOp, STExtentOp, STUnionOp:404 return true405 case ArrayAggOp, AvgOp, ConcatAggOp, CountOp, CorrOp, CountRowsOp, SumIntOp,406 SumOp, SqrDiffOp, VarianceOp, StdDevOp, XorAggOp, JsonAggOp, JsonbAggOp,407 StringAggOp, PercentileDiscOp, PercentileContOp, StdDevPopOp, STMakeLineOp,408 VarPopOp, JsonObjectAggOp, JsonbObjectAggOp, STCollectOp, CovarPopOp,409 CovarSampOp, RegressionAvgXOp, RegressionAvgYOp, RegressionInterceptOp,410 RegressionR2Op, RegressionSlopeOp, RegressionSXXOp, RegressionSXYOp,411 RegressionSYYOp, RegressionCountOp:412 return false413 default:414 panic(errors.AssertionFailedf("unhandled op %s", log.Safe(op)))415 }416}417// OpaqueMetadata is an object stored in OpaqueRelExpr and passed418// through to the exec factory.419type OpaqueMetadata interface {420 ImplementsOpaqueMetadata()421 // String is a short description used when printing optimizer trees and when422 // forming error messages; it should be the SQL statement tag.423 String() string424 // Columns returns the columns that are produced by this operator.425 Columns() colinfo.ResultColumns426}427func init() {428 for optOp, treeOp := range ComparisonOpReverseMap {429 ComparisonOpMap[treeOp] = optOp430 }431}...

Full Screen

Full Screen

linear_regression_test.go

Source:linear_regression_test.go Github

copy

Full Screen

...159 bNode := node.(*baseNode)160 err = node.Process(models.NoopQueryContext(), parser.NodeID(0), block3)161 require.NoError(t, err)162 assert.Len(t, sink.Values, 0, "nothing processed yet")163 b, exists := bNode.cache.get(boundStart)164 assert.True(t, exists, "block cached for future")165 _, err = b.StepIter()166 assert.NoError(t, err)167 original := values[0][0]168 values[0][0] = math.NaN()169 block1 := test.NewUnconsolidatedBlockFromDatapoints(models.Bounds{170 Start: bounds.Start.Add(-2 * bounds.Duration),171 Duration: bounds.Duration,172 StepSize: bounds.StepSize,173 }, values)174 values[0][0] = original175 err = node.Process(models.NoopQueryContext(), parser.NodeID(0), block1)176 require.NoError(t, err)177 assert.Len(t, sink.Values, 2, "output from first block only")178 test.EqualsWithNansWithDelta(t, tt.afterBlockOne[0], sink.Values[0], 0.0001)179 test.EqualsWithNansWithDelta(t, tt.afterBlockOne[1], sink.Values[1], 0.0001)180 _, exists = bNode.cache.get(boundStart)181 assert.True(t, exists, "block still cached")182 _, exists = bNode.cache.get(boundStart.Add(-1 * bounds.Duration))183 assert.False(t, exists, "block cached")184 block2 := test.NewUnconsolidatedBlockFromDatapoints(models.Bounds{185 Start: bounds.Start.Add(-1 * bounds.Duration),186 Duration: bounds.Duration,187 StepSize: bounds.StepSize,188 }, values)189 err = node.Process(models.NoopQueryContext(), parser.NodeID(0), block2)190 require.NoError(t, err)191 assert.Len(t, sink.Values, 6, "output from all 3 blocks")192 test.EqualsWithNansWithDelta(t, tt.afterBlockOne[0], sink.Values[0], 0.0001)193 test.EqualsWithNansWithDelta(t, tt.afterBlockOne[1], sink.Values[1], 0.0001)194 expectedOne := tt.afterAllBlocks[0]195 expectedTwo := tt.afterAllBlocks[1]196 test.EqualsWithNansWithDelta(t, expectedOne, sink.Values[2], 0.0001)197 test.EqualsWithNansWithDelta(t, expectedTwo, sink.Values[3], 0.0001)198 _, exists = bNode.cache.get(bounds.Previous(2).Start)199 assert.False(t, exists, "block removed from cache")200 _, exists = bNode.cache.get(bounds.Previous(1).Start)201 assert.False(t, exists, "block not cached")202 _, exists = bNode.cache.get(bounds.Start)203 assert.False(t, exists, "block removed from cache")204 blks, err := bNode.cache.multiGet(bounds.Previous(2), 3, false)205 require.NoError(t, err)206 assert.Len(t, blks, 0)207 })208 }209}210func TestUnknownLinearRegression(t *testing.T) {211 _, err := NewLinearRegressionOp([]interface{}{5 * time.Minute}, "unknown_linear_regression_func")212 require.Error(t, err)213}...

Full Screen

Full Screen

bench.go

Source:bench.go Github

copy

Full Screen

1package main2import (3 "flag"4 "fmt"5 "github.com/ildus/pqt"6 "log"7 "os"8 "os/signal"9 "runtime"10 "sync"11 "sync/atomic"12 "syscall"13 "time"14)15var (16 connections = flag.Int("connections", 0, "Connections count (by default number of cores)")17 bench_time = flag.Int("bench_time", 60, "Bench time (seconds)")18 counter uint64 = 019)20const (21 initinit = "CREATE EXTENSION clickhouse_fdw;"22 initscript = `23DROP SCHEMA IF EXISTS clickhouse CASCADE;24DROP SERVER IF EXISTS loopback CASCADE;25CREATE SERVER loopback FOREIGN DATA WRAPPER clickhouse_fdw26 OPTIONS(dbname 'regression', driver '%s');27CREATE USER MAPPING FOR CURRENT_USER SERVER loopback;28SELECT clickhousedb_raw_query('DROP DATABASE IF EXISTS regression');29SELECT clickhousedb_raw_query('CREATE DATABASE regression');30-- integer types31SELECT clickhousedb_raw_query('CREATE TABLE regression.ints (32 c1 Int8, c2 Int16, c3 Int32, c4 Int64,33 c5 UInt8, c6 UInt16, c7 UInt32, c8 UInt64,34 c9 Float32, c10 Float6435) ENGINE = MergeTree PARTITION BY c1 ORDER BY (c1);36');37SELECT clickhousedb_raw_query('INSERT INTO regression.ints SELECT38 number, number + 1, number + 2, number + 3, number + 4, number + 5,39 number + 6, number + 7, number + 8.1, number + 9.2 FROM numbers(10);');40-- date and string types41SELECT clickhousedb_raw_query('CREATE TABLE regression.types (42 c1 Date, c2 DateTime, c3 String, c4 FixedString(5), c5 UUID,43 c6 Enum8(''one'' = 1, ''two'' = 2),44 c7 Enum16(''one'' = 1, ''two'' = 2, ''three'' = 3)45) ENGINE = MergeTree PARTITION BY c1 ORDER BY (c1);46');47SELECT clickhousedb_raw_query('INSERT INTO regression.types SELECT48 addDays(toDate(''1990-01-01''), number),49 addMinutes(addSeconds(addDays(toDateTime(''1990-01-01 10:00:00''), number), number), number),50 format(''number {0}'', toString(number)),51 format(''num {0}'', toString(number)),52 format(''f4bf890f-f9dc-4332-ad5c-0c18e73f28e{0}'', toString(number)),53 ''two'',54 ''three''55 FROM numbers(10);');56-- array types57SELECT clickhousedb_raw_query('CREATE TABLE regression.arrays (58 c1 Array(Int), c2 Array(String)59) ENGINE = MergeTree PARTITION BY c1 ORDER BY (c1);60');61SELECT clickhousedb_raw_query('INSERT INTO regression.arrays SELECT62 [number, number + 1],63 [format(''num{0}'', toString(number)), format(''num{0}'', toString(number + 1))]64 FROM numbers(10);');65SELECT clickhousedb_raw_query('CREATE TABLE regression.tuples (66 c1 Int8,67 c2 Tuple(Int, String, Float32)68) ENGINE = MergeTree PARTITION BY c1 ORDER BY (c1);69');70SELECT clickhousedb_raw_query('INSERT INTO regression.tuples SELECT71 number,72 (number, toString(number), number + 1.0)73 FROM numbers(10);');74CREATE SCHEMA clickhouse;75IMPORT FOREIGN SCHEMA "ok" FROM SERVER loopback INTO clickhouse;76`77)78var (79 queries = []string{80 "SELECT * FROM clickhouse.tuples;",81 "SELECT * FROM clickhouse.arrays;",82 "SELECT * FROM clickhouse.types;",83 "SELECT * FROM clickhouse.ints;",84 }85)86func listener(wg *sync.WaitGroup, chm chan int, node *pqt.PostgresNode) {87 defer wg.Done()88 conn := pqt.MakePostgresConn(node, "postgres")89 defer conn.Close()90 for query_idx := range chm {91 sql := queries[query_idx]92 rows := conn.Fetch(sql)93 defer rows.Close()94 for rows.Next() {95 }96 atomic.AddUint64(&counter, 1)97 }98}99func processQueries(node *pqt.PostgresNode, init_sql string, title string) {100 var wg sync.WaitGroup101 chm := make(chan int, 1)102 node.Execute("postgres", init_sql)103 for i := 0; i < *connections; i++ {104 wg.Add(1)105 go listener(&wg, chm, node)106 }107 start_time := time.Now()108 for {109 for i := 0; i < len(queries); i++ {110 chm <- i111 if time.Since(start_time) > (time.Duration(*bench_time) * time.Second) {112 goto end113 }114 }115 }116end:117 close(chm)118 log.Printf("Processed in %s mode: %d", title, atomic.LoadUint64(&counter))119 wg.Wait()120}121func main() {122 var node *pqt.PostgresNode123 defer func() {124 if node != nil {125 node.Stop()126 }127 if err := recover(); err != nil {128 log.Fatal("Program is exiting with exception: ", err)129 }130 }()131 go func() {132 sigchan := make(chan os.Signal, 10)133 signal.Notify(sigchan, os.Interrupt, syscall.SIGTERM)134 <-sigchan135 log.Println("Got interrupt signal. Exited")136 os.Exit(0)137 }()138 flag.Parse()139 node = pqt.MakePostgresNode("master")140 node.Init()141 node.AppendConf("postgresql.conf", "log_statement=none")142 node.Start()143 node.Execute("postgres", initinit)144 if *connections <= 0 {145 *connections = runtime.NumCPU()146 }147 log.Println("Number of connections: ", *connections)148 processQueries(node, fmt.Sprintf(initscript, "http"), "http")149 processQueries(node, fmt.Sprintf(initscript, "binary"), "binary")150}...

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 r.Add(1, 1)4 r.Add(2, 2)5 r.Add(3, 3)6 r.Add(4, 4)7 r.Add(5, 5)8 r.Add(6, 6)9 r.Add(7, 7)10 r.Add(8, 8)11 r.Add(9, 9)12 r.Add(10, 10)13 r.Add(11, 11)14 r.Add(12, 12)15 r.Add(13, 13)16 r.Add(14, 14)17 r.Add(15, 15)18 r.Add(16, 16)19 r.Add(17, 17)20 r.Add(18, 18)21 r.Add(19, 19)22 r.Add(20, 20)23 r.Add(21, 21)24 r.Add(22, 22)25 r.Add(23, 23)26 r.Add(24, 24)27 r.Add(25, 25)28 r.Add(26, 26)29 r.Add(27, 27)30 r.Add(28, 28)31 r.Add(29, 29)32 r.Add(30, 30)33 r.Add(31, 31)34 r.Add(32, 32)35 r.Add(33, 33)36 r.Add(34, 34)37 r.Add(35, 35)38 r.Add(36, 36)39 r.Add(37, 37)40 r.Add(38, 38)41 r.Add(39, 39)42 r.Add(40, 40)43 r.Add(41, 41)44 r.Add(42, 42)45 r.Add(43, 43)46 r.Add(44, 44)47 r.Add(45, 45)48 r.Add(46, 46)49 r.Add(47, 47)50 r.Add(48, 48)51 r.Add(49, 49)52 r.Add(50, 50)53 r.Add(51, 51)54 r.Add(52, 52)55 r.Add(53, 53)56 r.Add(54, 54)57 r.Add(55, 55)58 r.Add(56, 56)59 r.Add(57, 57)60 r.Add(58, 58)61 r.Add(59, 59)

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 r.SetObserved("Y")4 r.SetVar(0, "X")5 r.Train(regression.DataPoint(1.0, []float64{1.0}))6 r.Train(regression.DataPoint(2.0, []float64{2.0}))7 r.Train(regression.DataPoint(3.0, []float64{3.0}))8 r.Run()9 fmt.Printf("\nRegression Formula:\n%v\n", r.Formula)10 fmt.Printf("\nR²: %v\n", r.R2)11 fmt.Printf("\nX=1.0, Predicted Y: %v\n", r.Predict([]float64{1.0}))12 fmt.Printf("\nX=2.0, Predicted Y: %v\n", r.Predict([]float64{2.0}))13 fmt.Printf("\nX=3.0, Predicted Y: %v\n", r.Predict([]float64{3.0}))14}

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2type Regression struct {3}4func (r Regression) Exists(x float64) bool {5 for _, v := range r.X {6 if v == x {7 }8 }9}10func main() {11 r := Regression{X: []float64{1, 2, 3, 4, 5}, Y: []float64{1, 2, 3, 4, 5}}12 fmt.Println(r.Exists(1))13 fmt.Println(r.Exists(6))14}15import (16type Regression struct {17}18func (r Regression) Exists(x float64) bool {19 for _, v := range r.X {20 if v == x {21 }22 }23}24func main() {25 r := Regression{X: []float64{1, 2, 3, 4, 5}, Y: []float64{1, 2, 3, 4, 5}}26 fmt.Println(r.Exists(1))27 fmt.Println(r.Exists(6))28}29import (30type Regression struct {31}32func (r Regression) Exists(x float64) bool {33 for _, v := range r.X {34 if v == x {35 }36 }37}38func main() {39 r := Regression{X: []float64{1, 2, 3, 4, 5}, Y: []float64{1, 2, 3, 4, 5}}40 fmt.Println(r.Exists(1))41 fmt.Println(r.Exists(6))42}43import (44type Regression struct {45}46func (r Regression) Exists(x float64) bool {47 for _, v := range r.X {48 if v == x {49 }

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 for i = 1; i <= 10; i++ {4 x = append(x, i)5 j = math.Pow(i, 2)6 y = append(y, j)7 }8 reg := new(Regression)9 reg.SetData(x, y)10 reg.Calculate()11 fmt.Println("slope: ", reg.Slope())12 fmt.Println("intercept: ", reg.Intercept())13 fmt.Println("correlation: ", reg.Correlation())14 fmt.Println("r2: ", reg.R2())15 fmt.Println("predict(5): ", reg.Predict(5))16 fmt.Println("predict(10): ", reg.Predict(10))17}18import (19func main() {20 for i = 1; i <= 10; i++ {21 x = append(x, i)22 j = math.Pow(i, 2)23 y = append(y, j)24 }25 reg := new(Regression)26 reg.SetData(x, y)27 reg.Calculate()28 fmt.Println("slope: ", reg.Slope())29 fmt.Println("intercept: ", reg.Intercept())30 fmt.Println("correlation: ", reg.Correlation())31 fmt.Println("r2: ", reg.R2())32 fmt.Println("predict(5): ", reg.Predict(5))33 fmt.Println("predict(10): ", reg.Predict(10))34}35import (36func main() {37 for i = 1; i <= 10; i++ {38 x = append(x, i)39 j = math.Pow(i, 2)40 y = append(y, j)41 }42 reg := new(Regression)43 reg.SetData(x, y)44 reg.Calculate()45 fmt.Println("slope: ", reg.Slope())46 fmt.Println("intercept: ", reg.Intercept())47 fmt.Println("correlation: ", reg

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2type regression struct {3}4func (r regression) exists() bool {5 if len(r.x) != len(r.y) {6 } else {7 }8}9func (r regression) length() int {10 return len(r.x)11}12func (r regression) sumx() float64 {13 for i := 0; i < len(r.x); i++ {14 }15}16func (r regression) sumy() float64 {17 for i := 0; i < len(r.y); i++ {18 }19}20func (r regression) sumxy() float64 {21 for i := 0; i < len(r.x); i++ {22 sum += (r.x[i] * r.y[i])23 }24}25func (r regression) sumxsq() float64 {26 for i := 0; i < len(r.x); i++ {27 sum += math.Pow(r.x[i], 2)28 }29}30func (r regression) sumysq() float64 {31 for i := 0; i < len(r.y); i++ {32 sum += math.Pow(r.y[i], 2)33 }34}35func (r regression) slope() float64 {36 if r.exists() {37 n := float64(r.length())38 num := (n * r.sumxy()) - (r.sumx() * r.sumy())39 den := (n * r.sumxsq()) - math.Pow(r.sumx(), 2)40 } else {41 }42}43func (r regression) intercept() float64 {44 if r.exists() {45 n := float64(r.length())46 num := (r.sumy() * r.sumxsq()) - (r.sumx() * r.sumxy())47 den := (n * r.sumxsq()) - math.Pow(r.sumx(), 2)48 } else {49 }50}

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 r.Read("data.csv")4 fmt.Println(r.Exists("x1"))5 fmt.Println(r.Exists("x2"))6 fmt.Println(r.Exists("x3"))7 fmt.Println(r.Exists("x4"))8 fmt.Println(r.Exists("x5"))9 fmt.Println(r.Exists("x6"))10 fmt.Println(r.Exists("x7"))11 fmt.Println(r.Exists("x8"))12 fmt.Println(r.Exists("x9"))13 fmt.Println(r.Exists("x10"))14 fmt.Println(r.Exists("x11"))15 fmt.Println(r.Exists("x12"))16 fmt.Println(r.Exists("x13"))17 fmt.Println(r.Exists("x14"))18 fmt.Println(r.Exists("x15"))19 fmt.Println(r.Exists("x16"))20 fmt.Println(r.Exists("x17"))21 fmt.Println(r.Exists("x18"))22 fmt.Println(r.Exists("x19"))23 fmt.Println(r.Exists("x20"))24 fmt.Println(r.Exists("x21"))25 fmt.Println(r.Exists("x22"))26 fmt.Println(r.Exists("x23"))27 fmt.Println(r.Exists("x24"))28 fmt.Println(r.Exists("x25"))29 fmt.Println(r.Exists("x26"))30 fmt.Println(r.Exists("x27"))31 fmt.Println(r.Exists("x28"))32 fmt.Println(r.Exists("x29"))33 fmt.Println(r.Exists("x30"))34 fmt.Println(r.Exists("x31"))35 fmt.Println(r.Exists("x32"))36 fmt.Println(r.Exists("x33"))37 fmt.Println(r.Exists("x34"))38 fmt.Println(r.Exists("x35"))39 fmt.Println(r.Exists("x36"))40 fmt.Println(r.Exists("x37"))41 fmt.Println(r.Exists("x38"))42 fmt.Println(r.Exists("x39"))43 fmt.Println(r.Exists("x40"))44 fmt.Println(r.Exists("x41"))45 fmt.Println(r.Exists("x42"))46 fmt.Println(r.Exists("x43"))47 fmt.Println(r.Exists("x44"))48 fmt.Println(r.Exists("x45"))49 fmt.Println(r.Exists("x46"))50 fmt.Println(r.Exists("x47"))51 fmt.Println(r.Exists("x48"))52 fmt.Println(r.Exists("x49"))53 fmt.Println(r.Exists("x50"))54 fmt.Println(r.Exists("x51"))55 fmt.Println(r.Exists("x52"))56 fmt.Println(r.Exists("x53"))57 fmt.Println(r.Exists("x54"))58 fmt.Println(r.Exists("x55"))59 fmt.Println(r.Exists("x56"))60 fmt.Println(r.Exists("x57"))61 fmt.Println(r.Exists("x58"))62 fmt.Println(r.Exists

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if len(os.Args) != 4 {4 fmt.Println("Usage: 1.go <filename> <x> <y>")5 os.Exit(1)6 }7 r := regression.NewRegression()8 r.ReadData(filename)9 if r.Exists(x, y) {10 fmt.Printf("The pair (%s, %s) exists\n", x, y)11 } else {12 fmt.Printf("The pair (%s, %s) does not exist\n", x, y)13 }14}

Full Screen

Full Screen

exists

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 reg := regression.Regression{}4 x := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9}5 y := []float64{2, 4, 6, 8, 10, 12, 14, 16, 18}6 reg.AddData(x, y)7 fmt.Println(reg.Exists())8 reg.RemoveData()9 fmt.Println(reg.Exists())10}11import (12func main() {13 reg := regression.Regression{}14 x := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9}15 y := []float64{2, 4, 6, 8, 10, 12, 14, 16, 18}16 reg.AddData(x, y)17 fmt.Println(reg.Exists())18}19import (20func main() {21 reg := regression.Regression{}22 x := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9}23 y := []float64{2, 4, 6, 8, 10, 12, 14, 16,

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Keploy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful