Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
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
Container registry
Model registry
Operate
Environments
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
Jakob Huber
postgres-lambda-diff
Commits
7ff432c9
Commit
7ff432c9
authored
23 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
1. Implemented binary search in array
Oleg Bartunov
parent
720ca220
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
contrib/intarray/README.intarray
+2
-0
2 additions, 0 deletions
contrib/intarray/README.intarray
contrib/intarray/_int.c
+18
-24
18 additions, 24 deletions
contrib/intarray/_int.c
with
20 additions
and
24 deletions
contrib/intarray/README.intarray
+
2
−
0
View file @
7ff432c9
...
...
@@ -12,6 +12,8 @@ for additional information.
CHANGES:
October 1, 2001
1. Change search method in array to binary
September 28, 2001
1. gist__int_ops now is without lossy
2. add sort entry in picksplit
...
...
This diff is collapsed.
Click to expand it.
contrib/intarray/_int.c
+
18
−
24
View file @
7ff432c9
...
...
@@ -1741,7 +1741,6 @@ makepol(WORKSTATE *state) {
typedef
struct
{
int4
*
arrb
;
int4
*
arre
;
int4
*
ptr
;
}
CHKVAL
;
/*
...
...
@@ -1749,23 +1748,20 @@ typedef struct {
*/
static
bool
checkcondition_arr
(
void
*
checkval
,
int4
val
)
{
#ifdef BS_DEBUG
elog
(
NOTICE
,
"OPERAND %d"
,
val
);
#endif
if
(
val
>
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
{
while
(
((
CHKVAL
*
)
checkval
)
->
ptr
<
((
CHKVAL
*
)
checkval
)
->
arre
)
{
((
CHKVAL
*
)
checkval
)
->
ptr
++
;
if
(
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
==
val
)
return
true
;
if
(
val
<
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
return
false
;
}
}
else
if
(
val
<
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
{
while
(
((
CHKVAL
*
)
checkval
)
->
ptr
>
((
CHKVAL
*
)
checkval
)
->
arrb
)
{
((
CHKVAL
*
)
checkval
)
->
ptr
--
;
if
(
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
==
val
)
return
true
;
if
(
val
>
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
return
false
;
}
}
else
{
return
true
;
int4
*
StopLow
=
((
CHKVAL
*
)
checkval
)
->
arrb
;
int4
*
StopHigh
=
((
CHKVAL
*
)
checkval
)
->
arre
;
int4
*
StopMiddle
;
/* Loop invariant: StopLow <= val < StopHigh */
while
(
StopLow
<
StopHigh
)
{
StopMiddle
=
StopLow
+
(
StopHigh
-
StopLow
)
/
2
;
if
(
*
StopMiddle
==
val
)
return
(
true
);
else
if
(
*
StopMiddle
<
val
)
StopLow
=
StopMiddle
+
1
;
else
StopHigh
=
StopMiddle
;
}
return
false
;
}
...
...
@@ -1818,8 +1814,7 @@ execconsistent( QUERYTYPE *query, ArrayType *array, bool calcnot ) {
CHKVAL
chkval
;
chkval
.
arrb
=
ARRPTR
(
array
);
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
array
)
-
1
;
chkval
.
ptr
=
chkval
.
arrb
+
ARRNELEMS
(
array
)
/
2
;
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
array
);
return
execute
(
GETQUERY
(
query
)
+
query
->
size
-
1
,
(
void
*
)
&
chkval
,
calcnot
,
...
...
@@ -1854,8 +1849,7 @@ boolop(PG_FUNCTION_ARGS) {
PREPAREARR
(
val
);
chkval
.
arrb
=
ARRPTR
(
val
);
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
val
)
-
1
;
chkval
.
ptr
=
chkval
.
arrb
+
ARRNELEMS
(
val
)
/
2
;
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
val
);
result
=
execute
(
GETQUERY
(
query
)
+
query
->
size
-
1
,
&
chkval
,
true
,
...
...
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