Skip to content

Commit

Permalink
Update to version v2.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
olegator77 committed Sep 30, 2019
1 parent 672d145 commit ec24739
Show file tree
Hide file tree
Showing 48 changed files with 837 additions and 758 deletions.
12 changes: 12 additions & 0 deletions bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,18 @@ func (db *reindexerImpl) updateQuery(ctx context.Context, q *Query) *Iterator {
return newIterator(ctx, q, result, q.nsArray, nil, nil, nil)
}

// Execute query
func (db *reindexerImpl) updateQueryTx(ctx context.Context, q *Query, tx *Tx) *Iterator {
err := db.binding.UpdateQueryTx(&tx.ctx, q.ser.Bytes())
return errIterator(err)
}

// Execute query
func (db *reindexerImpl) deleteQueryTx(ctx context.Context, q *Query, tx *Tx) (int, error) {
err := db.binding.DeleteQueryTx(&tx.ctx, q.ser.Bytes())
return 0, err
}

func (db *Reindexer) ResetCaches() {
db.impl.resetCachesCtx(db.ctx)
}
Expand Down
8 changes: 8 additions & 0 deletions bindings/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ func (binding *Builtin) ModifyItemTx(txCtx *bindings.TxCtx, format int, data []b
return err2go(C.reindexer_modify_item_packed_tx(binding.rx, C.uintptr_t(txCtx.Id), buf2c(packedArgs), buf2c(data)))
}

func (binding *Builtin) DeleteQueryTx(txCtx *bindings.TxCtx, rawQuery []byte) error {
return err2go(C.reindexer_delete_query_tx(binding.rx, C.uintptr_t(txCtx.Id), buf2c(rawQuery)))
}
func (binding *Builtin) UpdateQueryTx(txCtx *bindings.TxCtx, rawQuery []byte) error {

return err2go(C.reindexer_update_query_tx(binding.rx, C.uintptr_t(txCtx.Id), buf2c(rawQuery)))
}

// ModifyItemTxAsync is not implemented for builtin binding
func (binding *Builtin) ModifyItemTxAsync(txCtx *bindings.TxCtx, format int, data []byte, mode int, precepts []string, stateToken int, cmpl bindings.RawCompletion) {
err := binding.ModifyItemTx(txCtx, format, data, mode, precepts, stateToken)
Expand Down
7 changes: 7 additions & 0 deletions bindings/builtinserver/builtinserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ func (server *BuiltinServer) ModifyItemTxAsync(txCtx *bindings.TxCtx, format int
err := server.builtin.ModifyItemTx(txCtx, format, data, mode, precepts, stateToken)
cmpl(nil, err)
}
func (server *BuiltinServer) DeleteQueryTx(txCtx *bindings.TxCtx, rawQuery []byte) error {
return server.builtin.DeleteQueryTx(txCtx, rawQuery)
}

func (server *BuiltinServer) UpdateQueryTx(txCtx *bindings.TxCtx, rawQuery []byte) error {
return server.builtin.UpdateQueryTx(txCtx, rawQuery)
}

func (server *BuiltinServer) Select(ctx context.Context, query string, asJson bool, ptVersions []int32, fetchCount int) (bindings.RawBuffer, error) {
return server.builtin.Select(ctx, query, asJson, ptVersions, fetchCount)
Expand Down
2 changes: 2 additions & 0 deletions bindings/cproto/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const (
cmdCommitTx = 27
cmdRollbackTx = 28
cmdStartTransaction = 29
cmdDeleteQueryTx = 30
cmdUpdateQueryTx = 31
cmdCommit = 32
cmdModifyItem = 33
cmdDeleteQuery = 34
Expand Down
26 changes: 26 additions & 0 deletions bindings/cproto/cproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ func (binding *NetCProto) ModifyItemTxAsync(txCtx *bindings.TxCtx, format int, d
netBuffer.conn.rpcCallAsync(txCtx.UserCtx, cmdAddTxItem, uint32(binding.timeouts.RequestTimeout/time.Second), cmpl, format, data, mode, packedPercepts, stateToken, int64(txCtx.Id))
}

func (binding *NetCProto) DeleteQueryTx(txCtx *bindings.TxCtx, rawQuery []byte) error {
netBuffer := txCtx.Result.(*NetBuffer)
txBuf, err := netBuffer.conn.rpcCall(txCtx.UserCtx, cmdDeleteQueryTx, uint32(binding.timeouts.RequestTimeout/time.Second), rawQuery, int64(txCtx.Id))

defer txBuf.Free()
if err != nil {
netBuffer.close()
return err
}

return nil
}

func (binding *NetCProto) UpdateQueryTx(txCtx *bindings.TxCtx, rawQuery []byte) error {
netBuffer := txCtx.Result.(*NetBuffer)
txBuf, err := netBuffer.conn.rpcCall(txCtx.UserCtx, cmdUpdateQueryTx, uint32(binding.timeouts.RequestTimeout/time.Second), rawQuery, int64(txCtx.Id))

defer txBuf.Free()
if err != nil {
netBuffer.close()
return err
}

return nil
}

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

var packedPercepts []byte
Expand Down
2 changes: 2 additions & 0 deletions bindings/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ type RawBinding interface {
RollbackTx(tx *TxCtx) error
ModifyItemTx(txCtx *TxCtx, format int, data []byte, mode int, percepts []string, stateToken int) error
ModifyItemTxAsync(txCtx *TxCtx, format int, data []byte, mode int, percepts []string, stateToken int, cmpl RawCompletion)
DeleteQueryTx(txCtx *TxCtx, rawQuery []byte) error
UpdateQueryTx(txCtx *TxCtx, rawQuery []byte) error

PutMeta(ctx context.Context, namespace, key, data string) error
GetMeta(ctx context.Context, namespace, key string) (RawBuffer, error)
Expand Down
34 changes: 27 additions & 7 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,65 @@
# Version 2.2.4 (30.09.2019)

## Core

- [fix] Idset cache invalidation on upsert/delete null values to indexes
- [fix] Possibe crash if sort orders disabled
- [fix] Wrong lowercasing field name on SQL UPDATE query
- [fea] Delete & Update queries in transactions

## Reindexer tool

- [fea] Add command `databases` for operating with databases
- [fea] Add suggestions for commands and databases names
- [fix] Replxx dependency reverted to stable version
- [fea] Using default dsn cproto:://127.0.0.1:6534/

## go connector

- [fea] Delete & Update queries in transactions

# Version 2.2.3 (18.09.2019)

# Core
## Core

- [fix] Fulltext queries sort by another field
- [fea] Number of bacground threads for sort optimization can be changed from #config namespace
- [fix] Sort optimization choose logic is improoved

# go connectpr
## go connectpr

- [fix] leak seq from chan
- [fix] check ctx.Done while waiting on cgo limiter


# Version 2.2.2 (15.09.2019)

# Core
## Core

- [fea] More effective usage of btree index for GT/LT and sort in concurent read write operations
- [fix] Potential crash on index update or deletion
- [fea] Timeout of background indexes optimization can be changed from #config namespace

# Reindexer server
## Reindexer server

- [fea] User list moved from users.json to users.yml
- [fea] Hash is used insead of plain password in users.yml file
- [fix] Pass operation timeout from cproto client to core

# Version 2.2.1 (07.09.2019)

# Core
## Core

- [fea] Updated behaviour of Or InnerJoin statement
- [fea] Store backups of system records in storage
- [fix] Replicator can start before db initalization completed
- [fix] Search prefixes if enabled only postfixes

# Reindexer server
## Reindexer server

- [fea] Added prometheus /metrics handler

# Face
## Face

- [fea] Fulltext config editor
- [fea] Quick copy item's JSON from list view
Expand Down
2 changes: 1 addition & 1 deletion cpp_src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ option (ENABLE_LIBUNWIND "Enable libunwind" ON)
option (ENABLE_TCMALLOC "Enable tcmalloc extensions" ON)
option (ENABLE_JEMALLOC "Enable jemalloc extensions" ON)
option (ENABLE_ROCKSDB "Enable rocksdb storage" ON)
set (REINDEXER_VERSION_DEFAULT "2.2.3")
set (REINDEXER_VERSION_DEFAULT "2.2.4")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
Expand Down
1 change: 1 addition & 0 deletions cpp_src/client/reindexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Error Reindexer::AddIndex(string_view nsName, const IndexDef& idx) { return impl
Error Reindexer::UpdateIndex(string_view nsName, const IndexDef& idx) { return impl_->UpdateIndex(nsName, idx, ctx_); }
Error Reindexer::DropIndex(string_view nsName, const IndexDef& index) { return impl_->DropIndex(nsName, index, ctx_); }
Error Reindexer::EnumNamespaces(vector<NamespaceDef>& defs, bool bEnumAll) { return impl_->EnumNamespaces(defs, bEnumAll, ctx_); }
Error Reindexer::EnumDatabases(vector<string>& dbList) { return impl_->EnumDatabases(dbList, ctx_); }
Error Reindexer::SubscribeUpdates(IUpdatesObserver* observer, bool subscribe) { return impl_->SubscribeUpdates(observer, subscribe); }
Error Reindexer::GetSqlSuggestions(const string_view sqlQuery, int pos, vector<string>& suggests) {
return impl_->GetSqlSuggestions(sqlQuery, pos, suggests);
Expand Down
3 changes: 3 additions & 0 deletions cpp_src/client/reindexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Reindexer {
/// @param defs - std::vector of NamespaceDef of available namespaves
/// @param bEnumAll - Also include currenty not opened, but exists on disk namespaces
Error EnumNamespaces(vector<NamespaceDef> &defs, bool bEnumAll);
/// Gets a list of available databases for a certain server.
/// @param dbList - list of DB names
Error EnumDatabases(vector<string> &dbList);
/// Insert new Item to namespace. If item with same PK is already exists, when item.GetID will
/// return -1, on success item.GetID() will return internal Item ID
/// May be used with completion
Expand Down
40 changes: 32 additions & 8 deletions cpp_src/client/rpcclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "gason/gason.h"
#include "tools/errors.h"
#include "tools/logger.h"
#include "vendor/gason/gason.h"

using std::string;
using std::vector;
Expand Down Expand Up @@ -463,6 +464,26 @@ Error RPCClient::EnumNamespaces(vector<NamespaceDef>& defs, bool bEnumAll, const
return Error(errParseJson, "EnumNamespaces: %s", err.what());
}
}

Error RPCClient::EnumDatabases(vector<string>& dbList, const InternalRdxContext& ctx) {
try {
auto ret = getConn()->Call(cproto::kCmdEnumDatabases, config_.RequestTimeout, ctx.execTimeout(), 0);
if (ret.Status().ok()) {
gason::JsonParser parser;
auto json = ret.GetArgs(1)[0].As<string>();
auto root = parser.Parse(giftStr(json));
for (auto& elem : root["databases"]) {
dbList.emplace_back(elem.As<string>());
}
}
return ret.Status();
} catch (const Error& err) {
return err;
} catch (const gason::Exception& err) {
return Error(errParseJson, "EnumDatabases: %s", err.what());
}
}

Error RPCClient::SubscribeUpdates(IUpdatesObserver* observer, bool subscribe) {
if (subscribe) {
observers_.Add(observer);
Expand All @@ -485,6 +506,7 @@ Error RPCClient::SubscribeUpdates(IUpdatesObserver* observer, bool subscribe) {
}
return err;
}

Error RPCClient::GetSqlSuggestions(string_view query, int pos, std::vector<std::string>& suggests) {
try {
auto ret = getConn()->Call(cproto::kCmdGetSQLSuggestions, config_.RequestTimeout, milliseconds(0), query, pos);
Expand Down Expand Up @@ -587,14 +609,16 @@ void RPCClient::onUpdates(net::cproto::RPCAnswer& ans, cproto::ClientConnection*
delayedUpdates_.emplace_back(std::move(ans));

QueryResults* qr = new QueryResults;
Select(Query(string(nsName)).Limit(0), *qr, InternalRdxContext([=](const Error& err) {
delete qr;
// If there are delayed updates, then send them to client
auto uq = std::move(delayedUpdates_);
delayedUpdates_.clear();
if (err.ok())
for (auto& a1 : uq) onUpdates(a1, conn);
}).cmpl(),
Select(Query(string(nsName)).Limit(0), *qr,
InternalRdxContext([=](const Error& err) {
delete qr;
// If there are delayed updates, then send them to client
auto uq = std::move(delayedUpdates_);
delayedUpdates_.clear();
if (err.ok())
for (auto& a1 : uq) onUpdates(a1, conn);
})
.cmpl(),
conn);
return;
} else {
Expand Down
1 change: 1 addition & 0 deletions cpp_src/client/rpcclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RPCClient {
Error UpdateIndex(string_view nsName, const IndexDef &index, const InternalRdxContext &ctx);
Error DropIndex(string_view nsName, const IndexDef &index, const InternalRdxContext &ctx);
Error EnumNamespaces(vector<NamespaceDef> &defs, bool bEnumAll, const InternalRdxContext &ctx);
Error EnumDatabases(vector<string> &dbList, const InternalRdxContext &ctx);
Error Insert(string_view nsName, client::Item &item, const InternalRdxContext &ctx);
Error Update(string_view nsName, client::Item &item, const InternalRdxContext &ctx);
Error Upsert(string_view nsName, client::Item &item, const InternalRdxContext &ctx);
Expand Down
2 changes: 1 addition & 1 deletion cpp_src/cmd/reindexer_tool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (NOT ReplXX_LIBRARY OR NOT ReplXX_INCLUDE_DIR)
ExternalProject_Add(
replxx_lib
GIT_REPOSITORY "https://github.com/Restream/replxx"
GIT_TAG "master"
GIT_TAG "b50b7b7a8c2835b45607cffabc18e4742072e9e6"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
Expand Down
Loading

0 comments on commit ec24739

Please sign in to comment.