Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTFS
提交
c0312e42
Y
YTFS
项目概览
YottaChain
/
YTFS
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTFS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c0312e42
编写于
8月 18, 2020
作者:
X
xiaojianming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ytfs write position
上级
dc152b0d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
14 deletion
+28
-14
db.go
db.go
+1
-0
indexDB.go
indexDB.go
+4
-0
rocksDB_linux.go
rocksDB_linux.go
+11
-10
storage/indexfile.go
storage/indexfile.go
+5
-4
ytfs.go
ytfs.go
+7
-0
未找到文件。
db.go
浏览文件 @
c0312e42
...
...
@@ -7,6 +7,7 @@ type DB interface {
Get
(
key
ydcommon
.
IndexTableKey
)
(
ydcommon
.
IndexTableValue
,
error
)
Put
(
key
ydcommon
.
IndexTableKey
,
value
ydcommon
.
IndexTableValue
)
error
BatchPut
(
kvPairs
[]
ydcommon
.
IndexItem
)
(
map
[
ydcommon
.
IndexTableKey
]
byte
,
error
)
UpdateMeta
(
account
uint64
)
error
Len
()
uint64
TotalSize
()
uint64
BlockSize
()
uint32
...
...
indexDB.go
浏览文件 @
c0312e42
...
...
@@ -94,6 +94,10 @@ func (db *IndexDB) Put(key ydcommon.IndexTableKey, value ydcommon.IndexTableValu
return
err
}
func
(
db
*
IndexDB
)
UpdateMeta
(
accout
uint64
)
error
{
return
db
.
indexFile
.
UpdateMeta
(
accout
)
}
// BatchPut add a set of new key value pairs to db.
func
(
db
*
IndexDB
)
BatchPut
(
kvPairs
[]
ydcommon
.
IndexItem
)
(
map
[
ydcommon
.
IndexTableKey
]
byte
,
error
)
{
// sorr kvPair by hash entry to make sure write in sequence.
...
...
rocksDB_linux.go
浏览文件 @
c0312e42
...
...
@@ -215,9 +215,19 @@ func initializeHeader( config *opt.Options) (*ydcommon.Header, error) {
return
&
header
,
nil
}
func
(
rd
*
KvDB
)
UpdateMeta
(
account
uint64
)
error
{
fmt
.
Println
(
"[rockspos] BatchPut PosIdx="
,
rd
.
PosIdx
,
"account="
,
account
)
rd
.
PosIdx
=
ydcommon
.
IndexTableValue
(
uint32
(
rd
.
PosIdx
)
+
uint32
(
account
))
binary
.
LittleEndian
.
PutUint32
(
valbuf
,
uint32
(
rd
.
PosIdx
))
err
:=
rd
.
Rdb
.
Put
(
rd
.
wo
,
rd
.
PosKey
[
:
],
valbuf
)
if
err
!=
nil
{
fmt
.
Println
(
"update write pos to db error:"
,
err
)
}
return
err
}
func
(
rd
*
KvDB
)
BatchPut
(
kvPairs
[]
ydcommon
.
IndexItem
)
(
map
[
ydcommon
.
IndexTableKey
]
byte
,
error
)
{
// keyValue:=make(map[ydcommon.IndexTableKey]ydcommon.IndexTableValue,len(batch))
i
:=
0
valbuf
:=
make
([]
byte
,
4
)
for
_
,
value
:=
range
kvPairs
{
HKey
:=
value
.
Hash
[
:
]
...
...
@@ -229,17 +239,8 @@ func (rd *KvDB) BatchPut(kvPairs []ydcommon.IndexItem) (map[ydcommon.IndexTableK
fmt
.
Println
(
"[rocksdb]put dnhash to rocksdb error:"
,
err
)
return
nil
,
err
}
i
++
}
fmt
.
Println
(
"[rockspos] BatchPut PosIdx="
,
rd
.
PosIdx
,
"i="
,
i
)
rd
.
PosIdx
=
ydcommon
.
IndexTableValue
(
uint32
(
rd
.
PosIdx
)
+
uint32
(
i
))
binary
.
LittleEndian
.
PutUint32
(
valbuf
,
uint32
(
rd
.
PosIdx
))
err
:=
rd
.
Rdb
.
Put
(
rd
.
wo
,
rd
.
PosKey
[
:
],
valbuf
)
if
err
!=
nil
{
fmt
.
Println
(
"update write pos to db error:"
,
err
)
return
nil
,
err
}
//fmt.Printf("[noconflict] write success batch_write_time: %d ms, batch_len %d", time.Now().Sub(begin).Milliseconds(), bufCnt)
return
nil
,
nil
}
...
...
storage/indexfile.go
浏览文件 @
c0312e42
...
...
@@ -345,7 +345,7 @@ func (indexFile *YTFSIndexFile) BatchPut(kvPairs []ydcommon.IndexItem) (map[ydco
locker
,
_
:=
indexFile
.
store
.
Lock
()
defer
locker
.
Unlock
()
dataWritten
:=
uint64
(
0
)
//
dataWritten := uint64(0)
conflicts
:=
map
[
ydcommon
.
IndexTableKey
]
byte
{}
for
_
,
kvPair
:=
range
kvPairs
{
err
:=
indexFile
.
updateTable
(
kvPair
.
Hash
,
kvPair
.
OffsetIdx
)
...
...
@@ -356,15 +356,16 @@ func (indexFile *YTFSIndexFile) BatchPut(kvPairs []ydcommon.IndexItem) (map[ydco
return
conflicts
,
err
}
}
dataWritten
++
//dataWritten++
}
//if len(conflicts) != 0 {
// return conflicts, errors.ErrConflict
//}
return
conflicts
,
indexFile
.
updateMeta
(
dataWritten
)
//pos metadata has been updated before this func
return
conflicts
,
nil
//return conflicts, indexFile.updateMeta(dataWritten)
}
func
(
indexFile
*
YTFSIndexFile
)
UpdateMeta
(
dataWritten
uint64
)
error
{
...
...
ytfs.go
浏览文件 @
c0312e42
...
...
@@ -343,6 +343,13 @@ func (ytfs *YTFS) BatchPut(batch map[ydcommon.IndexTableKey][]byte) (map[ydcommo
return
nil
,
err
}
//update the write position to db
err
=
ytfs
.
db
.
UpdateMeta
(
uint64
(
bufCnt
))
if
err
!=
nil
{
fmt
.
Println
(
"update position error:"
,
err
)
return
nil
,
err
}
for
i
:=
uint32
(
0
);
i
<
uint32
(
bufCnt
);
i
++
{
batchIndexes
[
i
]
=
ydcommon
.
IndexItem
{
Hash
:
batchIndexes
[
i
]
.
Hash
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录