Beispiel #1
0
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
}
Beispiel #2
0
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
}
Beispiel #3
0
func (op *ObjectPath) EntryPath() string {
	return dbutil.ObjectPathClean(op.FoldName + "/" + op.FieldName)
}
Beispiel #4
0
func ObjectNsMetaFoldKey(path string) []byte {
	return RawNsKeyConcat(NsObjectMeta, stringToHashBytes(dbutil.ObjectPathClean(path), ObjectFoldLength))
}
Beispiel #5
0
func ObjectDocFoldKey(fold string) []byte {
	return stringToHashBytes(dbutil.ObjectPathClean(fold), ObjectFoldLength)
}