mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
DataManager.SetFilterIndexes with cacheID and itemIDPrefix
This commit is contained in:
@@ -1112,8 +1112,9 @@ func (dm *DataManager) GetFilterIndexes(cacheID, itemIDPrefix, filterType string
|
||||
return dm.DataDB().GetFilterIndexesDrv(cacheID, itemIDPrefix, filterType, fldNameVal)
|
||||
}
|
||||
|
||||
func (dm *DataManager) SetFilterIndexes(dbKey string, indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
return dm.DataDB().SetFilterIndexesDrv(dbKey, indexes, commit, transactionID)
|
||||
func (dm *DataManager) SetFilterIndexes(cacheID, itemIDPrefix string,
|
||||
indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
return dm.DataDB().SetFilterIndexesDrv(cacheID, itemIDPrefix, indexes, commit, transactionID)
|
||||
}
|
||||
|
||||
func (dm *DataManager) RemoveFilterIndexes(dbKey string) (err error) {
|
||||
|
||||
@@ -126,8 +126,8 @@ func (rfi *FilterIndexer) cacheRemItemType() { // ToDo: tune here by removing pe
|
||||
// StoreIndexes handles storing the indexes to dataDB
|
||||
func (rfi *FilterIndexer) StoreIndexes(commit bool, transactionID string) (err error) {
|
||||
if err = rfi.dm.SetFilterIndexes(
|
||||
GetDBIndexKey(rfi.itemType, rfi.dbKeySuffix, false),
|
||||
rfi.indexes, commit, transactionID); err != nil {
|
||||
utils.PrefixToIndexCache[rfi.itemType], rfi.dbKeySuffix,
|
||||
rfi.indexes, commit, utils.NonTransactional); err != nil {
|
||||
return
|
||||
}
|
||||
if err = rfi.dm.SetFilterReverseIndexes(
|
||||
@@ -196,7 +196,7 @@ func (rfi *FilterIndexer) RemoveItemFromIndex(itemID string) (err error) {
|
||||
}
|
||||
rfi.reveseIndex[itemID] = make(utils.StringMap) //Force deleting in driver
|
||||
if err = rfi.dm.SetFilterIndexes(
|
||||
GetDBIndexKey(rfi.itemType, rfi.dbKeySuffix, false),
|
||||
utils.PrefixToIndexCache[rfi.itemType], rfi.dbKeySuffix,
|
||||
rfi.indexes, false, utils.NonTransactional); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -120,8 +120,8 @@ type DataDB interface {
|
||||
AddLoadHistory(*utils.LoadInstance, int, string) error
|
||||
GetFilterIndexesDrv(cacheID, itemIDPrefix, filterType string,
|
||||
fldNameVal map[string]string) (indexes map[string]utils.StringMap, err error)
|
||||
SetFilterIndexesDrv(dbKey string, indexes map[string]utils.StringMap,
|
||||
commit bool, transactionID string) (err error)
|
||||
SetFilterIndexesDrv(cacheID, itemIDPrefix string,
|
||||
indexes map[string]utils.StringMap, commit bool, transactionID string) (err error)
|
||||
RemoveFilterIndexesDrv(id string) (err error)
|
||||
GetFilterReverseIndexesDrv(dbKey string,
|
||||
fldNameVal map[string]string) (indexes map[string]utils.StringMap, err error)
|
||||
|
||||
@@ -1267,12 +1267,13 @@ func (ms *MapStorage) GetFilterIndexesDrv(cacheID, itemIDPrefix, filterType stri
|
||||
}
|
||||
|
||||
//SetFilterIndexesDrv stores Indexes into DataDB
|
||||
func (ms *MapStorage) SetFilterIndexesDrv(originKey string, indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
func (ms *MapStorage) SetFilterIndexesDrv(cacheID, itemIDPrefix string,
|
||||
indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
ms.mu.Lock()
|
||||
defer ms.mu.Unlock()
|
||||
dbKey := originKey
|
||||
dbKey := utils.CacheInstanceToPrefix[cacheID] + itemIDPrefix
|
||||
if transactionID != "" {
|
||||
dbKey = "tmp_" + utils.ConcatenatedKey(originKey, transactionID)
|
||||
dbKey = "tmp_" + utils.ConcatenatedKey(dbKey, transactionID)
|
||||
}
|
||||
if commit && transactionID != "" {
|
||||
delete(ms.dict, dbKey)
|
||||
@@ -1280,7 +1281,7 @@ func (ms *MapStorage) SetFilterIndexesDrv(originKey string, indexes map[string]u
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ms.dict[originKey] = result
|
||||
ms.dict[dbKey] = result
|
||||
return nil
|
||||
} else {
|
||||
for key, strMp := range indexes {
|
||||
|
||||
@@ -1976,13 +1976,14 @@ func (ms *MongoStorage) GetFilterIndexesDrv(cacheID, itemIDPrefix, filterType st
|
||||
}
|
||||
|
||||
// SetFilterIndexesDrv stores Indexes into DataDB
|
||||
func (ms *MongoStorage) SetFilterIndexesDrv(originKey string,
|
||||
func (ms *MongoStorage) SetFilterIndexesDrv(cacheID, itemIDPrefix string,
|
||||
indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
session, col := ms.conn(colRFI)
|
||||
defer session.Close()
|
||||
originKey := utils.CacheInstanceToPrefix[cacheID] + itemIDPrefix
|
||||
dbKey := originKey
|
||||
if transactionID != "" {
|
||||
dbKey = "tmp_" + utils.ConcatenatedKey(originKey, transactionID)
|
||||
dbKey = "tmp_" + utils.ConcatenatedKey(dbKey, transactionID)
|
||||
}
|
||||
if commit && transactionID != "" {
|
||||
oldKey := "tmp_" + utils.ConcatenatedKey(originKey, transactionID)
|
||||
@@ -1993,8 +1994,8 @@ func (ms *MongoStorage) SetFilterIndexesDrv(originKey string,
|
||||
pairs := []interface{}{}
|
||||
for key, itmMp := range indexes {
|
||||
param := fmt.Sprintf("value.%s", key)
|
||||
pairs = append(pairs, bson.M{"key": originKey})
|
||||
pairs = append(pairs, bson.M{"$set": bson.M{"key": originKey, param: itmMp.Slice()}})
|
||||
pairs = append(pairs, bson.M{"key": dbKey})
|
||||
pairs = append(pairs, bson.M{"$set": bson.M{"key": dbKey, param: itmMp.Slice()}})
|
||||
}
|
||||
if len(pairs) != 0 {
|
||||
bulk := col.Bulk()
|
||||
|
||||
@@ -1408,8 +1408,9 @@ func (rs *RedisStorage) GetFilterIndexesDrv(cacheID, itemIDPrefix, filterType st
|
||||
}
|
||||
|
||||
//SetFilterIndexesDrv stores Indexes into DataDB
|
||||
func (rs *RedisStorage) SetFilterIndexesDrv(originKey string, indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
dbKey := originKey
|
||||
func (rs *RedisStorage) SetFilterIndexesDrv(cacheID, itemIDPrefix string,
|
||||
indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
dbKey := utils.CacheInstanceToPrefix[cacheID] + itemIDPrefix
|
||||
if transactionID != "" {
|
||||
dbKey = "tmp_" + utils.ConcatenatedKey(dbKey, transactionID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user