func NewObjectPathParse(path string) *ObjectPath { op := &ObjectPath{} is_fold := false if len(path) > 0 && path[len(path)-1] == '/' { is_fold = true } path = dbutil.ObjectPathClean(path) if is_fold { op.FoldName, op.FieldName = path, "" } else { if i := strings.LastIndex(path, "/"); i > 0 { op.FoldName, op.FieldName = path[:i], path[i+1:] } else { op.FoldName, op.FieldName = "", path } } op.Fold = stringToHashBytes(op.FoldName, ObjectFoldLength) op.Field = stringToHashBytes(op.FieldName, ObjectFieldLength) return op }
func NewObjectPathKey(fold, key string) *ObjectPath { op := &ObjectPath{ FoldName: dbutil.ObjectPathClean(fold), } op.Fold = stringToHashBytes(op.FoldName, ObjectFoldLength) klen := len(key) if klen > 32 { klen = 32 } if v := dbutil.HexStringToBytes(key[:klen]); len(v) > 0 { op.Field = v op.FieldName = key[:klen] } return op }
func (op *ObjectPath) EntryPath() string { return dbutil.ObjectPathClean(op.FoldName + "/" + op.FieldName) }
func ObjectNsMetaFoldKey(path string) []byte { return RawNsKeyConcat(NsObjectMeta, stringToHashBytes(dbutil.ObjectPathClean(path), ObjectFoldLength)) }
func ObjectDocFoldKey(fold string) []byte { return stringToHashBytes(dbutil.ObjectPathClean(fold), ObjectFoldLength) }