Commit a39d32d7 authored by Akshay Bharambe's avatar Akshay Bharambe
Browse files

Add: FDB query to fetch all data

1. Add: FDB query to fetch all data
parent ff2d11ad
Branches
No related merge requests found
Showing with 18 additions and 0 deletions
...@@ -55,6 +55,8 @@ const ( ...@@ -55,6 +55,8 @@ const (
IndexKeyValSeperator = "=" IndexKeyValSeperator = "="
// FileType - represents key for type of file. Used whenever we need to set file type field in json // FileType - represents key for type of file. Used whenever we need to set file type field in json
FileType = "fileType" FileType = "fileType"
// GetAll - wraper gjson query to return all results.
GetAll = "#[*]"
) )
// ErrNoDataFound - This error describes that the required data might be deleted and not found. Kidly ignore this error in caller. // ErrNoDataFound - This error describes that the required data might be deleted and not found. Kidly ignore this error in caller.
...@@ -848,6 +850,10 @@ func updateDataWithInFileIndex(filePath string, bucket *Bucket, rs *gjson.Result ...@@ -848,6 +850,10 @@ func updateDataWithInFileIndex(filePath string, bucket *Bucket, rs *gjson.Result
indexRows := gjson.Parse(indexDataString) indexRows := gjson.Parse(indexDataString)
indexRecordsToUpdate := indexRows indexRecordsToUpdate := indexRows
for _, query := range infileIndexQueries { for _, query := range infileIndexQueries {
if query == GetAll {
// return all results
break
}
indexRecordsToUpdate = indexRecordsToUpdate.Get(query + "#") indexRecordsToUpdate = indexRecordsToUpdate.Get(query + "#")
} }
loggermdl.LogError("indexRecordsToUpdate - ", indexRecordsToUpdate) loggermdl.LogError("indexRecordsToUpdate - ", indexRecordsToUpdate)
...@@ -1265,6 +1271,10 @@ func getFileDataUsingInFileIndex(filePath string, bucket *Bucket, requestedFileT ...@@ -1265,6 +1271,10 @@ func getFileDataUsingInFileIndex(filePath string, bucket *Bucket, requestedFileT
indexData := gjson.Parse(indexDataString) indexData := gjson.Parse(indexDataString)
indexRows := indexData.Get(`#[fileType==` + requestedFileType + `]#`) indexRows := indexData.Get(`#[fileType==` + requestedFileType + `]#`)
for i := 0; i < len(inFileIndexQuery); i++ { for i := 0; i < len(inFileIndexQuery); i++ {
if inFileIndexQuery[i] == GetAll {
// return all results
break
}
indexRows = indexRows.Get(inFileIndexQuery[i] + "#") indexRows = indexRows.Get(inFileIndexQuery[i] + "#")
} }
sb := strings.Builder{} sb := strings.Builder{}
...@@ -1784,6 +1794,10 @@ func ReadDataFromFDB(dbName, indexID string, rs *gjson.Result, query []string, i ...@@ -1784,6 +1794,10 @@ func ReadDataFromFDB(dbName, indexID string, rs *gjson.Result, query []string, i
rsJSON := gjson.Parse("[" + value + "]") rsJSON := gjson.Parse("[" + value + "]")
for i := 0; i < len(query); i++ { for i := 0; i < len(query); i++ {
loggermdl.LogError(query[i]) loggermdl.LogError(query[i])
if query[i] == GetAll {
// return all results
break
}
rsJSON = rsJSON.Get(query[i] + "#") rsJSON = rsJSON.Get(query[i] + "#")
} }
if rsJSON.Value() != nil { if rsJSON.Value() != nil {
...@@ -1867,6 +1881,10 @@ func UpdateDataInFDB(dbName, indexID string, rs *gjson.Result, query []string, i ...@@ -1867,6 +1881,10 @@ func UpdateDataInFDB(dbName, indexID string, rs *gjson.Result, query []string, i
loggermdl.LogError("key = ", key, " val = ", value) loggermdl.LogError("key = ", key, " val = ", value)
rsJSON := gjson.Parse("[" + value + "]") rsJSON := gjson.Parse("[" + value + "]")
for i := 0; i < len(query); i++ { for i := 0; i < len(query); i++ {
if query[i] == GetAll {
// return all results
break
}
rsJSON = rsJSON.Get(query[i] + "#") rsJSON = rsJSON.Get(query[i] + "#")
} }
if rsJSON.Value() != nil { if rsJSON.Value() != nil {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment