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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
teaching
dunixir
Commits
48df36a4
Commit
48df36a4
authored
4 years ago
by
x18zhan2
Browse files
Options
Downloads
Patches
Plain Diff
implements:
#73
parent
d689ee06
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#1320
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/local_augmentation_example.ex
+20
-2
20 additions, 2 deletions
lib/local_augmentation_example.ex
test/block/augmentation/head_unitbase_test.exs
+36
-0
36 additions, 0 deletions
test/block/augmentation/head_unitbase_test.exs
with
56 additions
and
2 deletions
lib/local_augmentation_example.ex
+
20
−
2
View file @
48df36a4
...
...
@@ -122,8 +122,7 @@ defmodule Index.Augmentation do
end
def
currency
(
global_bindex
,
local_bindex
)
do
key
=
:ets
.
first
(
local_bindex
)
[{
key
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
key
)
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
if
head
.
number
>
0
do
[[
currency
]]
=
...
...
@@ -135,6 +134,25 @@ defmodule Index.Augmentation do
end
end
## BR_G12
def
unitBaseBR_G12
(
global_bindex
,
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
if
head
.
number
==
0
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
unitBase:
0
})})
else
[[
unitBase
]]
=
:dets
.
match
(
global_bindex
,
{
:_
,
%{
number:
head
.
number
-
1
,
unitBase:
:"$1"
}})
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
unitBase:
unitBase
})})
end
end
def
find_first_local_bindex_entry
(
local_bindex
)
do
key
=
:ets
.
first
(
local_bindex
)
:ets
.
lookup
(
local_bindex
,
key
)
end
def
membersCount
(
local_iindex
,
global_bindex
,
local_bindex
)
do
key
=
:ets
.
first
(
local_bindex
)
[{
key
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
key
)
...
...
This diff is collapsed.
Click to expand it.
test/block/augmentation/head_unitbase_test.exs
0 → 100644
+
36
−
0
View file @
48df36a4
defmodule
Block
.
Augmentation
.
Head
.
UnitBaseTest
do
use
ExUnit
.
Case
doctest
Index
.
Augmentation
.
BIndex
setup_all
do
# create a local_bindex table
local_bindex
=
:ets
.
new
(
:local_bindex
,
[
:set
,
:protected
])
:ets
.
insert
(
local_bindex
,
{
0
,
%{
number:
0
}})
# create an empty global_bindex table
:file
.
delete
(
"test/global_bindex"
)
{
:ok
,
global_bindex
}
=
:dets
.
open_file
(
:"test/global_bindex"
,
type:
:set
)
Index
.
Augmentation
.
BIndex
.
unitBaseBR_G12
(
global_bindex
,
local_bindex
)
[{
0
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
0
)
unit_base0
=
head
.
unitBase
:ets
.
insert
(
local_bindex
,
{
0
,
%{
number:
1
}})
:dets
.
insert
(
global_bindex
,
{
0
,
%{
number:
0
,
unitBase:
5
}})
Index
.
Augmentation
.
BIndex
.
unitBaseBR_G12
(
global_bindex
,
local_bindex
)
[{
0
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
0
)
unit_base1
=
head
.
unitBase
:dets
.
close
(
global_bindex
)
:file
.
delete
(
"test/global_bindex"
)
{
:ok
,
unit_base0:
unit_base0
,
unit_base1:
unit_base1
}
end
test
"check unitBase BR_G12"
,
state
do
assert
state
.
unit_base0
==
0
assert
state
.
unit_base1
==
5
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