Skip to content

Commit

Permalink
Update to version v4.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MadSchemas committed Apr 22, 2024
1 parent 29c10fa commit d372adf
Show file tree
Hide file tree
Showing 426 changed files with 21,691 additions and 6,513 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ jobs:
- name: Build Reindexer
run: |
mkdir build && cd build
cmake -G "${{matrix.compiler}}" ..
cmake -G "${{matrix.compiler}}" .. -Ax64
cmake --build . --config Release
cmake --build . --config Release --target face
cmake --build . --config Release --target swagger
cpack
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: windows-latest
path: build/*.exe
if-no-files-found: error

build-windows-2019:
runs-on: windows-2019
Expand All @@ -35,6 +42,7 @@ jobs:
cmake --build . --config Release
cmake --build . --config Release --target face
cmake --build . --config Release --target swagger
cpack
build:
strategy:
Expand All @@ -47,8 +55,8 @@ jobs:
cxx: g++-10
- os: ubuntu-latest
sanitizer: TSAN
cc: gcc-10
cxx: g++-10
cc: gcc-12
cxx: g++-12
fail-fast: false
runs-on: ${{matrix.os}}
env:
Expand Down Expand Up @@ -116,8 +124,8 @@ jobs:
test: 'GO'
# - os: ubuntu-latest
# sanitizer: TSAN
# cc: gcc-10
# cxx: g++-10
# cc: gcc-12
# cxx: g++-12
# test: 'C++'
- os: ubuntu-latest
sanitizer: TSAN
Expand Down Expand Up @@ -230,3 +238,4 @@ jobs:
run: |
cd pyreindexer
../.github/workflows/test.sh
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(reindexer)
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)
enable_testing()
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
37 changes: 17 additions & 20 deletions bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
modeDelete = bindings.ModeDelete
)

func (db *reindexerImpl) modifyItem(ctx context.Context, namespace string, ns *reindexerNamespace, item interface{}, json []byte, mode int, precepts ...string) (count int, err error) {
func (db *reindexerImpl) modifyItem(ctx context.Context, namespace string, ns *reindexerNamespace, item interface{}, mode int, precepts ...string) (count int, err error) {

if ns == nil {
ns, err = db.getNS(namespace)
Expand All @@ -38,11 +38,11 @@ func (db *reindexerImpl) modifyItem(ctx context.Context, namespace string, ns *r
format := 0
stateToken := 0

if format, stateToken, err = packItem(ns, item, json, ser); err != nil {
if format, stateToken, err = packItem(ns, item, nil, ser); err != nil {
return
}

out, err := db.binding.ModifyItem(ctx, ns.nsHash, ns.name, format, ser.Bytes(), mode, precepts, stateToken)
out, err := db.binding.ModifyItem(ctx, ns.name, format, ser.Bytes(), mode, precepts, stateToken)

if err != nil {
rerr, ok := err.(bindings.Error)
Expand Down Expand Up @@ -80,7 +80,6 @@ func (db *reindexerImpl) modifyItem(ctx context.Context, namespace string, ns *r
}

func packItem(ns *reindexerNamespace, item interface{}, json []byte, ser *cjson.Serializer) (format int, stateToken int, err error) {

if item != nil {
json, _ = item.([]byte)
}
Expand Down Expand Up @@ -142,6 +141,7 @@ func unpackItem(bin bindings.RawBinding, ns *nsArrayEntry, rqparams *rawResultQu
} else {
item = reflect.New(ns.rtype).Interface()
dec := ns.localCjsonState.NewDecoder(item, bin)
defer dec.Finalize()
if params.cptr != 0 {
err = dec.DecodeCPtr(params.cptr, item)
} else if params.data != nil {
Expand All @@ -166,6 +166,7 @@ func unpackItem(bin bindings.RawBinding, ns *nsArrayEntry, rqparams *rawResultQu
item = reflect.New(ns.rtype).Interface()
}
dec := ns.localCjsonState.NewDecoder(item, bin)
defer dec.Finalize()
if params.cptr != 0 {
err = dec.DecodeCPtr(params.cptr, item)
} else if params.data != nil {
Expand Down Expand Up @@ -244,14 +245,16 @@ func (db *reindexerImpl) rawResultToJson(rawResult []byte, jsonName string, tota
}

func (db *reindexerImpl) prepareQuery(ctx context.Context, q *Query, asJson bool) (result bindings.RawBuffer, err error) {

// Ordering in q.nsArray is matter ad must correspond to the ordering in C++
if ns, err := db.getNS(q.Namespace); err == nil {
q.nsArray = append(q.nsArray, nsArrayEntry{ns, ns.cjsonState.Copy()})
} else {
return nil, err
}

ser := q.ser
ser.PutVarCUInt(queryEnd)

for _, sq := range q.mergedQueries {
if ns, err := db.getNS(sq.Namespace); err == nil {
q.nsArray = append(q.nsArray, nsArrayEntry{ns, ns.cjsonState.Copy()})
Expand All @@ -266,20 +269,7 @@ func (db *reindexerImpl) prepareQuery(ctx context.Context, q *Query, asJson bool
} else {
return nil, err
}
}

for _, mq := range q.mergedQueries {
for _, sq := range mq.joinQueries {
if ns, err := db.getNS(sq.Namespace); err == nil {
q.nsArray = append(q.nsArray, nsArrayEntry{ns, ns.cjsonState.Copy()})
} else {
return nil, err
}
}
}

ser.PutVarCUInt(queryEnd)
for _, sq := range q.joinQueries {
ser.PutVarCUInt(sq.joinType)
ser.Append(sq.ser)
ser.PutVarCUInt(queryEnd)
Expand All @@ -289,7 +279,14 @@ func (db *reindexerImpl) prepareQuery(ctx context.Context, q *Query, asJson bool
ser.PutVarCUInt(merge)
ser.Append(mq.ser)
ser.PutVarCUInt(queryEnd)

for _, sq := range mq.joinQueries {
if ns, err := db.getNS(sq.Namespace); err == nil {
q.nsArray = append(q.nsArray, nsArrayEntry{ns, ns.cjsonState.Copy()})
} else {
return nil, err
}

ser.PutVarCUInt(sq.joinType)
ser.Append(sq.ser)
ser.PutVarCUInt(queryEnd)
Expand Down Expand Up @@ -386,7 +383,7 @@ func (db *reindexerImpl) deleteQuery(ctx context.Context, q *Query) (int, error)
return 0, err
}

result, err := db.binding.DeleteQuery(ctx, ns.nsHash, q.ser.Bytes())
result, err := db.binding.DeleteQuery(ctx, q.ser.Bytes())
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -426,7 +423,7 @@ func (db *reindexerImpl) updateQuery(ctx context.Context, q *Query) *Iterator {
return errIterator(err)
}

result, err := db.binding.UpdateQuery(ctx, ns.nsHash, q.ser.Bytes())
result, err := db.binding.UpdateQuery(ctx, q.ser.Bytes())
if err != nil {
return errIterator(err)
}
Expand Down
39 changes: 36 additions & 3 deletions bindings/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (binding *Builtin) awaitLimiter(ctx context.Context) (withLimiter bool, err
return
}

func (binding *Builtin) ModifyItem(ctx context.Context, nsHash int, namespace string, format int, data []byte, mode int, precepts []string, stateToken int) (bindings.RawBuffer, error) {
func (binding *Builtin) ModifyItem(ctx context.Context, namespace string, format int, data []byte, mode int, precepts []string, stateToken int) (bindings.RawBuffer, error) {
if withLimiter, err := binding.awaitLimiter(ctx); err != nil {
return nil, err
} else if withLimiter {
Expand Down Expand Up @@ -463,6 +463,29 @@ func (binding *Builtin) DropIndex(ctx context.Context, namespace, index string)
return err2go(C.reindexer_drop_index(binding.rx, str2c(namespace), str2c(index), ctxInfo.cCtx))
}

func (binding *Builtin) EnumMeta(ctx context.Context, namespace string) ([]string, error) {
ctxInfo, err := binding.StartWatchOnCtx(ctx)
if err != nil {
return nil, err
}
defer binding.ctxWatcher.StopWatchOnCtx(ctxInfo)

data, err := ret2go(C.reindexer_enum_meta(binding.rx, str2c(namespace), ctxInfo.cCtx))
if err != nil {
return nil, err
}
defer data.Free()

ser := cjson.NewSerializer(data.GetBuf())

keyCnt := ser.GetVarUInt()
keys := make([]string, keyCnt)
for i := 0; i < int(keyCnt); i++ {
keys[i] = ser.GetVString()
}
return keys, nil
}

func (binding *Builtin) PutMeta(ctx context.Context, namespace, key, data string) error {
ctxInfo, err := binding.StartWatchOnCtx(ctx)
if err != nil {
Expand All @@ -483,6 +506,16 @@ func (binding *Builtin) GetMeta(ctx context.Context, namespace, key string) (bin
return ret2go(C.reindexer_get_meta(binding.rx, str2c(namespace), str2c(key), ctxInfo.cCtx))
}

func (binding *Builtin) DeleteMeta(ctx context.Context, namespace, key string) error {
ctxInfo, err := binding.StartWatchOnCtx(ctx)
if err != nil {
return err
}
defer binding.ctxWatcher.StopWatchOnCtx(ctxInfo)

return err2go(C.reindexer_delete_meta(binding.rx, str2c(namespace), str2c(key), ctxInfo.cCtx))
}

func (binding *Builtin) Select(ctx context.Context, query string, asJson bool, ptVersions []int32, fetchCount int) (bindings.RawBuffer, error) {
if withLimiter, err := binding.awaitLimiter(ctx); err != nil {
return nil, err
Expand Down Expand Up @@ -553,7 +586,7 @@ func (binding *Builtin) SelectQuery(ctx context.Context, data []byte, asJson boo
return ret2go(C.reindexer_select_query(binding.rx, buf2c(data), bool2cint(asJson), (*C.int32_t)(unsafe.Pointer(&ptVersions[0])), C.int(len(ptVersions)), ctxInfo.cCtx))
}

func (binding *Builtin) DeleteQuery(ctx context.Context, nsHash int, data []byte) (bindings.RawBuffer, error) {
func (binding *Builtin) DeleteQuery(ctx context.Context, data []byte) (bindings.RawBuffer, error) {
if withLimiter, err := binding.awaitLimiter(ctx); err != nil {
return nil, err
} else if withLimiter {
Expand All @@ -569,7 +602,7 @@ func (binding *Builtin) DeleteQuery(ctx context.Context, nsHash int, data []byte
return ret2go(C.reindexer_delete_query(binding.rx, buf2c(data), ctxInfo.cCtx))
}

func (binding *Builtin) UpdateQuery(ctx context.Context, nsHash int, data []byte) (bindings.RawBuffer, error) {
func (binding *Builtin) UpdateQuery(ctx context.Context, data []byte) (bindings.RawBuffer, error) {
if withLimiter, err := binding.awaitLimiter(ctx); err != nil {
return nil, err
} else if withLimiter {
Expand Down
20 changes: 14 additions & 6 deletions bindings/builtinserver/builtinserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func (server *BuiltinServer) DropIndex(ctx context.Context, namespace, index str
return server.builtin.DropIndex(ctx, namespace, index)
}

func (server *BuiltinServer) EnumMeta(ctx context.Context, namespace string) ([]string, error) {
return server.builtin.EnumMeta(ctx, namespace)
}

func (server *BuiltinServer) PutMeta(ctx context.Context, namespace, key, data string) error {
return server.builtin.PutMeta(ctx, namespace, key, data)
}
Expand All @@ -184,8 +188,12 @@ func (server *BuiltinServer) GetMeta(ctx context.Context, namespace, key string)
return server.builtin.GetMeta(ctx, namespace, key)
}

func (server *BuiltinServer) ModifyItem(ctx context.Context, nsHash int, namespace string, format int, data []byte, mode int, percepts []string, stateToken int) (bindings.RawBuffer, error) {
return server.builtin.ModifyItem(ctx, nsHash, namespace, format, data, mode, percepts, stateToken)
func (server *BuiltinServer) DeleteMeta(ctx context.Context, namespace, key string) error {
return server.builtin.DeleteMeta(ctx, namespace, key)
}

func (server *BuiltinServer) ModifyItem(ctx context.Context, namespace string, format int, data []byte, mode int, percepts []string, stateToken int) (bindings.RawBuffer, error) {
return server.builtin.ModifyItem(ctx, namespace, format, data, mode, percepts, stateToken)
}

func (server *BuiltinServer) BeginTx(ctx context.Context, namespace string) (bindings.TxCtx, error) {
Expand Down Expand Up @@ -225,12 +233,12 @@ func (server *BuiltinServer) SelectQuery(ctx context.Context, rawQuery []byte, a
return server.builtin.SelectQuery(ctx, rawQuery, asJson, ptVersions, fetchCount)
}

func (server *BuiltinServer) DeleteQuery(ctx context.Context, nsHash int, rawQuery []byte) (bindings.RawBuffer, error) {
return server.builtin.DeleteQuery(ctx, nsHash, rawQuery)
func (server *BuiltinServer) DeleteQuery(ctx context.Context, rawQuery []byte) (bindings.RawBuffer, error) {
return server.builtin.DeleteQuery(ctx, rawQuery)
}

func (server *BuiltinServer) UpdateQuery(ctx context.Context, nsHash int, rawQuery []byte) (bindings.RawBuffer, error) {
return server.builtin.UpdateQuery(ctx, nsHash, rawQuery)
func (server *BuiltinServer) UpdateQuery(ctx context.Context, rawQuery []byte) (bindings.RawBuffer, error) {
return server.builtin.UpdateQuery(ctx, rawQuery)
}

func (server *BuiltinServer) Commit(ctx context.Context, namespace string) error {
Expand Down
2 changes: 1 addition & 1 deletion bindings/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package bindings

const CInt32Max = int(^uint32(0) >> 1)

const ReindexerVersion = "v4.14.0"
const ReindexerVersion = "v4.15.0"

// public go consts from type_consts.h and reindexer_ctypes.h
const (
Expand Down
1 change: 1 addition & 0 deletions bindings/cproto/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const (
cmdSelectSQL = 49
cmdFetchResults = 50
cmdCloseResults = 51
cmdDeleteMeta = 63
cmdGetMeta = 64
cmdPutMeta = 65
cmdEnumMeta = 66
Expand Down
24 changes: 21 additions & 3 deletions bindings/cproto/cproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func (binding *NetCProto) UpdateQueryTx(txCtx *bindings.TxCtx, rawQuery []byte)
return netBuffer.conn.rpcCallNoResults(txCtx.UserCtx, cmdUpdateQueryTx, uint32(binding.timeouts.RequestTimeout/time.Second), rawQuery, int64(txCtx.Id))
}

func (binding *NetCProto) ModifyItem(ctx context.Context, nsHash int, namespace string, format int, data []byte, mode int, precepts []string, stateToken int) (bindings.RawBuffer, error) {
func (binding *NetCProto) ModifyItem(ctx context.Context, namespace string, format int, data []byte, mode int, precepts []string, stateToken int) (bindings.RawBuffer, error) {

var packedPercepts []byte
if len(precepts) != 0 {
Expand Down Expand Up @@ -557,6 +557,20 @@ func (binding *NetCProto) DropIndex(ctx context.Context, namespace, index string
return binding.rpcCallNoResults(ctx, opWr, cmdDropIndex, namespace, index)
}

func (binding *NetCProto) EnumMeta(ctx context.Context, namespace string) ([]string, error) {
buf, err := binding.rpcCall(ctx, opRd, cmdEnumMeta, namespace)
if err != nil {
return nil, err
}
defer buf.Free()

keys := make([]string, len(buf.args))
for i, item := range buf.args {
keys[i] = string(item.([]byte))
}
return keys, nil
}

func (binding *NetCProto) PutMeta(ctx context.Context, namespace, key, data string) error {
return binding.rpcCallNoResults(ctx, opWr, cmdPutMeta, namespace, key, data)
}
Expand All @@ -565,6 +579,10 @@ func (binding *NetCProto) GetMeta(ctx context.Context, namespace, key string) (b
return binding.rpcCall(ctx, opRd, cmdGetMeta, namespace, key)
}

func (binding *NetCProto) DeleteMeta(ctx context.Context, namespace, key string) error {
return binding.rpcCallNoResults(ctx, opWr, cmdDeleteMeta, namespace, key)
}

func (binding *NetCProto) Select(ctx context.Context, query string, asJson bool, ptVersions []int32, fetchCount int) (bindings.RawBuffer, error) {
flags := 0
if asJson {
Expand Down Expand Up @@ -611,11 +629,11 @@ func (binding *NetCProto) SelectQuery(ctx context.Context, data []byte, asJson b
return buf, err
}

func (binding *NetCProto) DeleteQuery(ctx context.Context, nsHash int, data []byte) (bindings.RawBuffer, error) {
func (binding *NetCProto) DeleteQuery(ctx context.Context, data []byte) (bindings.RawBuffer, error) {
return binding.rpcCall(ctx, opWr, cmdDeleteQuery, data)
}

func (binding *NetCProto) UpdateQuery(ctx context.Context, nsHash int, data []byte) (bindings.RawBuffer, error) {
func (binding *NetCProto) UpdateQuery(ctx context.Context, data []byte) (bindings.RawBuffer, error) {
return binding.rpcCall(ctx, opWr, cmdUpdateQuery, data)
}

Expand Down
8 changes: 5 additions & 3 deletions bindings/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ type RawBinding interface {
DeleteQueryTx(txCtx *TxCtx, rawQuery []byte) error
UpdateQueryTx(txCtx *TxCtx, rawQuery []byte) error

EnumMeta(ctx context.Context, namespace string) ([]string, error)
PutMeta(ctx context.Context, namespace, key, data string) error
GetMeta(ctx context.Context, namespace, key string) (RawBuffer, error)
ModifyItem(ctx context.Context, nsHash int, namespace string, format int, data []byte, mode int, percepts []string, stateToken int) (RawBuffer, error)
DeleteMeta(ctx context.Context, namespace, key string) error
ModifyItem(ctx context.Context, namespace string, format int, data []byte, mode int, percepts []string, stateToken int) (RawBuffer, error)
Select(ctx context.Context, query string, asJson bool, ptVersions []int32, fetchCount int) (RawBuffer, error)
SelectQuery(ctx context.Context, rawQuery []byte, asJson bool, ptVersions []int32, fetchCount int) (RawBuffer, error)
DeleteQuery(ctx context.Context, nsHash int, rawQuery []byte) (RawBuffer, error)
UpdateQuery(ctx context.Context, nsHash int, rawQuery []byte) (RawBuffer, error)
DeleteQuery(ctx context.Context, rawQuery []byte) (RawBuffer, error)
UpdateQuery(ctx context.Context, rawQuery []byte) (RawBuffer, error)
Commit(ctx context.Context, namespace string) error
EnableLogger(logger Logger)
DisableLogger()
Expand Down
Loading

0 comments on commit d372adf

Please sign in to comment.