Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22fa00199
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
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
Summer2022
22fa00199
Commits
22ea6761
Unverified
Commit
22ea6761
authored
Jul 22, 2022
by
chenmingsong
Committed by
GitHub
Jul 22, 2022
Browse files
Options
Downloads
Patches
Plain Diff
add ut for intHashMap and fix intHashMap bugs (#4155)
parent
35848d72
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/common/hashmap/inthashmap.go
+3
-0
3 additions, 0 deletions
pkg/common/hashmap/inthashmap.go
pkg/common/hashmap/inthashmap_test.go
+52
-0
52 additions, 0 deletions
pkg/common/hashmap/inthashmap_test.go
pkg/common/hashmap/iterator.go
+3
-1
3 additions, 1 deletion
pkg/common/hashmap/iterator.go
with
58 additions
and
1 deletion
pkg/common/hashmap/inthashmap.go
+
3
−
0
View file @
22ea6761
...
@@ -27,8 +27,11 @@ var wrongUseOfIntHashTable = errors.New(errno.InternalError, "wrong use of IntHa
...
@@ -27,8 +27,11 @@ var wrongUseOfIntHashTable = errors.New(errno.InternalError, "wrong use of IntHa
var
zeroUint64
[]
uint64
var
zeroUint64
[]
uint64
var
zeroUint32
[]
uint32
func
init
()
{
func
init
()
{
zeroUint64
=
make
([]
uint64
,
UnitLimit
)
zeroUint64
=
make
([]
uint64
,
UnitLimit
)
zeroUint32
=
make
([]
uint32
,
UnitLimit
)
}
}
// IntHashMap key is int64, value is an uint64 (start from 1)
// IntHashMap key is int64, value is an uint64 (start from 1)
...
...
This diff is collapsed.
Click to expand it.
pkg/common/hashmap/inthashmap_test.go
0 → 100644
+
52
−
0
View file @
22ea6761
// Copyright 2021 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
hashmap
import
(
"github.com/matrixorigin/matrixone/pkg/container/batch"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/testutil"
"github.com/matrixorigin/matrixone/pkg/vm/mheap"
"github.com/matrixorigin/matrixone/pkg/vm/mmu/guest"
"github.com/matrixorigin/matrixone/pkg/vm/mmu/host"
"github.com/stretchr/testify/require"
"testing"
)
func
TestIntHashMap_Iterator
(
t
*
testing
.
T
)
{
mp
:=
NewIntHashMap
(
false
)
m
:=
mheap
.
New
(
guest
.
New
(
1
<<
30
,
host
.
New
(
1
<<
30
)))
rowCount
:=
10
bat
:=
&
batch
.
Batch
{
Cnt
:
1
,
Vecs
:
[]
*
vector
.
Vector
{
testutil
.
NewVector
(
rowCount
,
types
.
T_int32
.
ToType
(),
m
,
false
,
[]
int32
{
-
1
,
-
1
,
-
1
,
2
,
2
,
2
,
3
,
3
,
3
,
4
,
}),
testutil
.
NewVector
(
rowCount
,
types
.
T_uint32
.
ToType
(),
m
,
false
,
[]
uint32
{
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
4
,
}),
},
Zs
:
testutil
.
MakeBatchZs
(
rowCount
,
false
),
}
itr
:=
mp
.
NewIterator
()
vs
,
_
:=
itr
.
Insert
(
0
,
rowCount
,
bat
.
Vecs
,
make
([]
int32
,
rowCount
))
require
.
Equal
(
t
,
[]
uint64
{
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
4
},
vs
)
vs
,
_
=
itr
.
Find
(
0
,
rowCount
,
bat
.
Vecs
,
make
([]
int32
,
rowCount
))
require
.
Equal
(
t
,
[]
uint64
{
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
4
},
vs
)
bat
.
Clean
(
m
)
require
.
Equal
(
t
,
int64
(
0
),
mheap
.
Size
(
m
))
}
This diff is collapsed.
Click to expand it.
pkg/common/hashmap/iterator.go
+
3
−
1
View file @
22ea6761
...
@@ -52,6 +52,7 @@ func (itr *intHashMapIterator) Find(start, count int, vecs []*vector.Vector, _ [
...
@@ -52,6 +52,7 @@ func (itr *intHashMapIterator) Find(start, count int, vecs []*vector.Vector, _ [
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
itr
.
mp
.
keys
[
i
]
=
0
itr
.
mp
.
keys
[
i
]
=
0
}
}
copy
(
itr
.
mp
.
keyOffs
[
:
count
],
zeroUint32
)
}()
}()
if
err
:=
itr
.
mp
.
encodeHashKeys
(
vecs
,
start
,
count
);
err
!=
nil
{
if
err
:=
itr
.
mp
.
encodeHashKeys
(
vecs
,
start
,
count
);
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
@@ -66,9 +67,10 @@ func (itr *intHashMapIterator) Insert(start, count int, vecs []*vector.Vector, _
...
@@ -66,9 +67,10 @@ func (itr *intHashMapIterator) Insert(start, count int, vecs []*vector.Vector, _
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
itr
.
mp
.
keys
[
i
]
=
0
itr
.
mp
.
keys
[
i
]
=
0
}
}
copy
(
itr
.
mp
.
keyOffs
[
:
count
],
zeroUint32
)
}()
}()
if
itr
.
mp
.
hasNull
{
if
!
itr
.
mp
.
hasNull
{
copy
(
itr
.
mp
.
zValues
[
:
count
],
OneInt64s
[
:
count
])
copy
(
itr
.
mp
.
zValues
[
:
count
],
OneInt64s
[
:
count
])
}
}
if
err
:=
itr
.
mp
.
encodeHashKeys
(
vecs
,
start
,
count
);
err
!=
nil
{
if
err
:=
itr
.
mp
.
encodeHashKeys
(
vecs
,
start
,
count
);
err
!=
nil
{
...
...
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