[server] Switch to using efficient binary headers encoding; other minor updates.
This commit is contained in:
parent
9f0f14bd56
commit
c8bf6ee056
3 changed files with 14 additions and 12 deletions
|
@ -418,7 +418,8 @@ func archiveReference (_context *context, _namespace string, _pathInArchive stri
|
||||||
}
|
}
|
||||||
_context.archivedReferences += 1
|
_context.archivedReferences += 1
|
||||||
|
|
||||||
_key := fmt.Sprintf ("%s:%s", _namespace, _pathInArchive)
|
_namespacePrefix := KeyNamespacePrefix (_namespace)
|
||||||
|
_key := fmt.Sprintf ("%c:%s", _namespacePrefix, _pathInArchive)
|
||||||
|
|
||||||
var _keyMeta, _keyContent uint64
|
var _keyMeta, _keyContent uint64
|
||||||
if _key_0, _error := prepareKeyUint (_context, NamespaceDataMetadata, _fingerprintMeta); _error == nil {
|
if _key_0, _error := prepareKeyUint (_context, NamespaceDataMetadata, _fingerprintMeta); _error == nil {
|
||||||
|
@ -721,7 +722,7 @@ func prepareDataContent (_context *context, _pathResolved string, _pathInArchive
|
||||||
func prepareDataMeta (_context *context, _dataMeta map[string]string) (string, []byte, error) {
|
func prepareDataMeta (_context *context, _dataMeta map[string]string) (string, []byte, error) {
|
||||||
|
|
||||||
var _dataMetaRaw []byte
|
var _dataMetaRaw []byte
|
||||||
if _dataMetaRaw_0, _error := MetadataEncode (_dataMeta); _error == nil {
|
if _dataMetaRaw_0, _error := MetadataEncodeBinary (_dataMeta); _error == nil {
|
||||||
_dataMetaRaw = _dataMetaRaw_0
|
_dataMetaRaw = _dataMetaRaw_0
|
||||||
} else {
|
} else {
|
||||||
return "", nil, _error
|
return "", nil, _error
|
||||||
|
@ -752,7 +753,6 @@ func prepareKeyUint (_context *context, _namespace string, _fingerprint string)
|
||||||
} else {
|
} else {
|
||||||
return 0, _error
|
return 0, _error
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareKeyString (_context *context, _namespace string, _fingerprint string) (string, error) {
|
func prepareKeyString (_context *context, _namespace string, _fingerprint string) (string, error) {
|
||||||
|
|
|
@ -182,13 +182,13 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () {
|
||||||
|
|
||||||
if _server.cachedReferences != nil {
|
if _server.cachedReferences != nil {
|
||||||
_key := _keyBufferLarge[:0]
|
_key := _keyBufferLarge[:0]
|
||||||
|
_key = append (_key, KeyNamespacePrefix (_namespace), ':')
|
||||||
_key = append (_key, _path ...)
|
_key = append (_key, _path ...)
|
||||||
_key = append (_key, _pathSuffix ...)
|
_key = append (_key, _pathSuffix ...)
|
||||||
_referencesValues, _referencesFound = _server.cachedReferences[BytesToString (*NoEscapeBytes (&_key))]
|
_referencesValues, _referencesFound = _server.cachedReferences[BytesToString (*NoEscapeBytes (&_key))]
|
||||||
} else {
|
} else {
|
||||||
_key := _keyBufferLarge[:0]
|
_key := _keyBufferLarge[:0]
|
||||||
_key = append (_key, _namespace ...)
|
_key = append (_key, KeyNamespacePrefix (_namespace), ':')
|
||||||
_key = append (_key, ':')
|
|
||||||
_key = append (_key, _path ...)
|
_key = append (_key, _path ...)
|
||||||
_key = append (_key, _pathSuffix ...)
|
_key = append (_key, _pathSuffix ...)
|
||||||
if _value, _error := _server.cdbReader.GetWithCdbHash (_key); _error == nil {
|
if _value, _error := _server.cdbReader.GetWithCdbHash (_key); _error == nil {
|
||||||
|
@ -226,13 +226,13 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () {
|
||||||
|
|
||||||
if _server.cachedReferences != nil {
|
if _server.cachedReferences != nil {
|
||||||
_key := _keyBufferLarge[:0]
|
_key := _keyBufferLarge[:0]
|
||||||
|
_key = append (_key, NamespaceFilesContentPrefix, ':')
|
||||||
_key = append (_key, _path[: _pathLimit] ...)
|
_key = append (_key, _path[: _pathLimit] ...)
|
||||||
_key = append (_key, "/*" ...)
|
_key = append (_key, "/*" ...)
|
||||||
_referencesValues, _referencesFound = _server.cachedReferences[BytesToString (*NoEscapeBytes (&_key))]
|
_referencesValues, _referencesFound = _server.cachedReferences[BytesToString (*NoEscapeBytes (&_key))]
|
||||||
} else {
|
} else {
|
||||||
_key := _keyBufferLarge[:0]
|
_key := _keyBufferLarge[:0]
|
||||||
_key = append (_key, NamespaceFilesContent ...)
|
_key = append (_key, NamespaceFilesContentPrefix, ':')
|
||||||
_key = append (_key, ':')
|
|
||||||
_key = append (_key, _path[: _pathLimit] ...)
|
_key = append (_key, _path[: _pathLimit] ...)
|
||||||
_key = append (_key, "/*" ...)
|
_key = append (_key, "/*" ...)
|
||||||
if _value, _error := _server.cdbReader.GetWithCdbHash (_key); _error == nil {
|
if _value, _error := _server.cdbReader.GetWithCdbHash (_key); _error == nil {
|
||||||
|
@ -353,7 +353,7 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _error := MetadataDecodeIterate (_dataMetaRaw, _handleHeader); _error != nil {
|
if _error := MetadataDecodeBinaryIterate (_dataMetaRaw, _handleHeader); _error != nil {
|
||||||
_server.ServeError (_context, http.StatusInternalServerError, _error, false)
|
_server.ServeError (_context, http.StatusInternalServerError, _error, false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1276,8 +1276,7 @@ func main_0 () (error) {
|
||||||
var _fileReferences []byte
|
var _fileReferences []byte
|
||||||
{
|
{
|
||||||
_key := _keyBuffer[:0]
|
_key := _keyBuffer[:0]
|
||||||
_key = append (_key, NamespaceFilesContent ...)
|
_key = append (_key, NamespaceFilesContentPrefix, ':')
|
||||||
_key = append (_key, ':')
|
|
||||||
_key = append (_key, _filePath ...)
|
_key = append (_key, _filePath ...)
|
||||||
if _references_0, _error := _cdbReader.GetWithCdbHash (_key); _error == nil {
|
if _references_0, _error := _cdbReader.GetWithCdbHash (_key); _error == nil {
|
||||||
if _references_0 != nil {
|
if _references_0 != nil {
|
||||||
|
@ -1297,7 +1296,10 @@ func main_0 () (error) {
|
||||||
AbortError (_error, "[7d1a366f] [cdb.....] failed indexing archive!")
|
AbortError (_error, "[7d1a366f] [cdb.....] failed indexing archive!")
|
||||||
}
|
}
|
||||||
if _indexPaths {
|
if _indexPaths {
|
||||||
_cachedReferences[BytesToString (_filePath)] = [2]uint64 { _keyDataMeta, _keyDataContent }
|
_key := _keyBuffer[:0]
|
||||||
|
_key = append (_key, NamespaceFilesContentPrefix, ':')
|
||||||
|
_key = append (_key, _filePath ...)
|
||||||
|
_cachedReferences[string (_key)] = [2]uint64 { _keyDataMeta, _keyDataContent }
|
||||||
}
|
}
|
||||||
if _indexDataMeta {
|
if _indexDataMeta {
|
||||||
if _, _wasCached := _cachedDataMeta[_keyDataMeta]; !_wasCached {
|
if _, _wasCached := _cachedDataMeta[_keyDataMeta]; !_wasCached {
|
||||||
|
|
|
@ -43,7 +43,7 @@ func EncodeKeyToBytes_0 (_namespace string, _key uint64, _buffer []byte) (error)
|
||||||
}
|
}
|
||||||
_prefix := KeyNamespacePrefix (_namespace)
|
_prefix := KeyNamespacePrefix (_namespace)
|
||||||
if _prefix == 0 {
|
if _prefix == 0 {
|
||||||
return fmt.Errorf ("[feece73b] invalid key namespace `%s`!", _namespace)
|
return fmt.Errorf ("[8c6ba154] invalid key namespace `%s`!", _namespace)
|
||||||
}
|
}
|
||||||
_keyPrefix := byte (_key >> 56)
|
_keyPrefix := byte (_key >> 56)
|
||||||
if _keyPrefix != _prefix {
|
if _keyPrefix != _prefix {
|
||||||
|
|
Loading…
Reference in a new issue