Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
teaching
dunixir
Commits
e9dd18f2
Commit
e9dd18f2
authored
4 years ago
by
x18zhan2
Browse files
Options
Downloads
Patches
Plain Diff
implemented:
#86
BR_G11
- udTime and udReevalTime
parent
9a272d1c
No related branches found
No related tags found
No related merge requests found
Pipeline
#1326
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/local_augmentation_example.ex
+35
-0
35 additions, 0 deletions
lib/local_augmentation_example.ex
test/block/augmentation/udTime_test.exs
+58
-0
58 additions, 0 deletions
test/block/augmentation/udTime_test.exs
with
93 additions
and
0 deletions
lib/local_augmentation_example.ex
+
35
−
0
View file @
e9dd18f2
...
...
@@ -134,6 +134,41 @@ defmodule Index.Augmentation do
end
end
## BR_G11
def
udTime
(
global_bindex
,
local_bindex
)
do
# UD production
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
conf
=
ConfDTO
.
mockConfDTO
()
if
head
.
number
==
0
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
conf
.
udTime0
})})
else
[[
head_1_id
]]
=
:dets
.
match
(
global_bindex
,
{
:"$1"
,
%{
number:
head
.
number
-
1
}})
[{
_key_1
,
head_1
}]
=
:dets
.
lookup
(
global_bindex
,
head_1_id
)
if
head_1
.
udTime
<=
head
.
medianTime
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
head_1
.
udTime
+
conf
.
dt
})})
else
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
head_1
.
udTime
})})
end
end
udReevalTime
(
global_bindex
,
local_bindex
)
end
def
udReevalTime
(
global_bindex
,
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
conf
=
ConfDTO
.
mockConfDTO
()
if
head
.
number
==
0
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
conf
.
udReevalTime0
})})
else
[[
head_1_id
]]
=
:dets
.
match
(
global_bindex
,
{
:"$1"
,
%{
number:
head
.
number
-
1
}})
[{
_key_1
,
head_1
}]
=
:dets
.
lookup
(
global_bindex
,
head_1_id
)
if
head_1
.
udReevalTime
<=
head
.
medianTime
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
head_1
.
udReevalTime
+
conf
.
dtReeval
})})
else
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
head_1
.
udReevalTime
})})
end
end
end
## BR_G12
def
unitBaseBR_G12
(
global_bindex
,
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
...
...
This diff is collapsed.
Click to expand it.
test/block/augmentation/udTime_test.exs
0 → 100644
+
58
−
0
View file @
e9dd18f2
defmodule
Block
.
Augmentation
.
UdTimeTest
do
use
ExUnit
.
Case
doctest
Index
.
Augmentation
.
BIndex
setup_all
do
local_bindex
=
:ets
.
new
(
:local_bindex
,
[
:set
,
:protected
])
:file
.
delete
(
"test/global_bindex"
)
{
:ok
,
global_bindex
}
=
:dets
.
open_file
(
:"test/global_bindex"
,
type:
:set
)
# :dets.insert(global_bindex, {2, %{number: 2, udTime: 4, udReevalTime: 3}})
:dets
.
insert
(
global_bindex
,
{
1
,
%{
number:
1
,
udTime:
10
,
udReevalTime:
15
}})
:dets
.
insert
(
global_bindex
,
{
0
,
%{
number:
0
,
udTime:
3
,
udReevalTime:
1
}})
:ets
.
insert
(
local_bindex
,
{
4
,
%{
number:
0
}})
Index
.
Augmentation
.
BIndex
.
udTime
(
global_bindex
,
local_bindex
)
[{
4
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
4
)
udTimeNumber0
=
head
.
udTime
udReevalTime0
=
head
.
udReevalTime
:ets
.
insert
(
local_bindex
,
{
4
,
%{
number:
1
,
medianTime:
4
}})
Index
.
Augmentation
.
BIndex
.
udTime
(
global_bindex
,
local_bindex
)
[{
4
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
4
)
udTime1
=
head
.
udTime
udReevalTime1
=
head
.
udReevalTime
:ets
.
insert
(
local_bindex
,
{
4
,
%{
number:
2
,
medianTime:
3
}})
Index
.
Augmentation
.
BIndex
.
udTime
(
global_bindex
,
local_bindex
)
[{
4
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
4
)
udTime2
=
head
.
udTime
udReevalTime2
=
head
.
udReevalTime
:dets
.
close
(
global_bindex
)
:file
.
delete
(
"test/global_bindex"
)
{
:ok
,
udTimeNumber0:
udTimeNumber0
,
udTime1:
udTime1
,
udTime2:
udTime2
,
udReevalTime0:
udReevalTime0
,
udReevalTime1:
udReevalTime1
,
udReevalTime2:
udReevalTime2
}
end
test
"check udTime"
,
state
do
assert
state
.
udTimeNumber0
==
ConfDTO
.
mockConfDTO
()
.
udTime0
assert
state
.
udTime1
==
3
+
ConfDTO
.
mockConfDTO
()
.
dt
assert
state
.
udTime2
==
10
end
test
"check udReevalTime"
,
state
do
assert
state
.
udReevalTime0
==
ConfDTO
.
mockConfDTO
()
.
udReevalTime0
assert
state
.
udReevalTime1
==
1
+
ConfDTO
.
mockConfDTO
()
.
dtReeval
assert
state
.
udReevalTime2
==
15
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment