Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
12504881
Commit
12504881
authored
5 years ago
by
Vivek Naik
Browse files
Options
Downloads
Patches
Plain Diff
fix: fdb delete record
parent
4146b076
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!127
Mep release 13Nov2019
,
!126
fix: fdb delete record
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dalmdl/corefdb/bucket.go
+19
-17
dalmdl/corefdb/bucket.go
dalmdl/corefdb/bucket_test.go
+8
-0
dalmdl/corefdb/bucket_test.go
with
27 additions
and
17 deletions
dalmdl/corefdb/bucket.go
+
19
−
17
View file @
12504881
...
...
@@ -824,11 +824,11 @@ func deleteDataFromNormalBucket(fdbPath string, index *Index, paths []string) (r
index
.
indexObj
.
Update
(
func
(
tx
*
buntdb
.
Tx
)
error
{
for
_
,
path
:=
range
paths
{
// delete index entry
_
,
err
:=
tx
.
Delete
(
path
)
if
err
!=
nil
{
errList
=
append
(
errList
,
errormdl
.
Wrap
(
"unable to delete index :"
+
path
+
err
.
Error
()))
continue
}
//
_, err := tx.Delete(path)
//
if err != nil {
//
errList = append(errList, errormdl.Wrap("unable to delete index :"+path+err.Error()))
//
continue
//
}
filePath
:=
filepath
.
Join
(
fdbPath
,
path
)
// dirPath, _ := filepath.Split(path)
...
...
@@ -848,7 +848,7 @@ func deleteDataFromNormalBucket(fdbPath string, index *Index, paths []string) (r
// }
// delete file
err
=
deleteNormalFile
(
filePath
)
err
:
=
deleteNormalFile
(
filePath
)
if
err
!=
nil
{
errList
=
append
(
errList
,
errormdl
.
Wrap
(
"unable to delete file : "
+
filePath
+
err
.
Error
()))
...
...
@@ -891,7 +891,7 @@ func deleteDataFromInFileIndexBucket(fdbPath string, bucket *Bucket, paths []str
continue
}
if
err
!=
nil
{
errList
=
append
(
errList
,
errormdl
.
Wrap
(
"fail to delete records
from: "
+
path
+
"
: "
+
err
.
Error
()))
errList
=
append
(
errList
,
errormdl
.
Wrap
(
"fail to delete records: "
+
err
.
Error
()))
continue
}
dataDeletedFromPath
=
append
(
dataDeletedFromPath
,
filePath
)
...
...
@@ -1184,17 +1184,19 @@ func DeleteDataFromFDB(dbName string, indexID string, rs *gjson.Result, queries
}
else
{
return
recordsDeleted
,
[]
error
{
errormdl
.
Wrap
(
"Operation not allowed on bucket type: "
+
bucket
.
BucketType
)}
}
index
.
indexObj
.
Update
(
func
(
tx
*
buntdb
.
Tx
)
error
{
// optimization : if data not changed then dont update
for
_
,
path
:=
range
dataDeletedFromPaths
{
_
,
err
=
tx
.
Delete
(
path
)
if
err
!=
nil
{
errList
=
append
(
errList
,
err
)
// loggermdl.LogError("dataDeletedFromPaths", dataDeletedFromPaths)
if
bucket
.
BucketType
==
BucketTypeSimple
{
index
.
indexObj
.
Update
(
func
(
tx
*
buntdb
.
Tx
)
error
{
// optimization : if data not changed then dont update
for
_
,
path
:=
range
dataDeletedFromPaths
{
_
,
err
=
tx
.
Delete
(
path
)
if
err
!=
nil
{
errList
=
append
(
errList
,
err
)
}
}
}
return
nil
}
)
return
nil
})
}
if
isLazyWriterEnabled
{
...
...
This diff is collapsed.
Click to expand it.
dalmdl/corefdb/bucket_test.go
+
8
−
0
View file @
12504881
...
...
@@ -251,6 +251,10 @@ func TestDeleteDataFromNormalBucket(t *testing.T) {
if
len
(
errList
)
>
0
{
loggermdl
.
LogError
(
errList
)
}
err
=
LogFDBIndexFile
(
indexFilePath
,
i
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
loggermdl
.
LogDebug
(
"recordsDeletedCnt"
,
recordsDeletedCnt
)
}
...
...
@@ -609,6 +613,10 @@ func TestDeleteDataFromPackBucket(t *testing.T) {
if
len
(
errList
)
>
0
{
loggermdl
.
LogError
(
errList
)
}
err
=
LogFDBIndexFile
(
indexFilePath
,
i
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
loggermdl
.
LogDebug
(
"recordsDeleted"
,
recordsDeleted
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets