You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because I use github.com/buger/jsonparser, which can search through JSON bytes without memory-overhead I had to make an extra method to just get the bytes back. I was thinking if it might be suitable for the tiedot package itself too. Maybe jsonparser can also be used for lookup stuff under the hood to speed things up even more?
This is the method :
// Find and retrieve bytes of a document by ID.
func (col *Col) ReadBytes(id int) (docB []byte, err error) {
col.db.schemaLock.RLock()
part := col.parts[id%col.db.numParts]
part.Lock.RLock()
docB, err = part.Read(id)
part.Lock.RUnlock()
col.db.schemaLock.RUnlock()
return
}
It gave me a 1.6x speed boost when just wanting to lookup one field from the result-set (eg password), which was really significant in my API, easily upping requests p/second by hundreds.
Would love to hear your feedback.
Example loop comparison:
k := ""
for id := range queryResult {
// user, err := App.Cols["Users"].Read(id)
// if nil != err {
// panic(err)
// }
//
// k = user[DBFieldUserPassword].(string)
user, err := App.Cols["Users"].ReadBytes(id)
if nil != err {
panic(err)
}
k, err = jsonparser.GetUnsafeString(user, DBFieldUserPassword)
if nil != err {
panic(err)
}
}
The text was updated successfully, but these errors were encountered:
Because I use
github.com/buger/jsonparser
, which can search through JSON bytes without memory-overhead I had to make an extra method to just get the bytes back. I was thinking if it might be suitable for the tiedot package itself too. Maybejsonparser
can also be used for lookup stuff under the hood to speed things up even more?This is the method :
It gave me a
1.6x
speed boost when just wanting to lookup one field from the result-set (eg password), which was really significant in my API, easily upping requests p/second by hundreds.Would love to hear your feedback.
Example loop comparison:
The text was updated successfully, but these errors were encountered: