Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
7ff432c9
Commit
7ff432c9
authored
Oct 04, 2001
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. Implemented binary search in array
Oleg Bartunov
parent
720ca220
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
24 deletions
+20
-24
contrib/intarray/README.intarray
contrib/intarray/README.intarray
+2
-0
contrib/intarray/_int.c
contrib/intarray/_int.c
+18
-24
No files found.
contrib/intarray/README.intarray
View file @
7ff432c9
...
@@ -12,6 +12,8 @@ for additional information.
...
@@ -12,6 +12,8 @@ for additional information.
CHANGES:
CHANGES:
October 1, 2001
1. Change search method in array to binary
September 28, 2001
September 28, 2001
1. gist__int_ops now is without lossy
1. gist__int_ops now is without lossy
2. add sort entry in picksplit
2. add sort entry in picksplit
...
...
contrib/intarray/_int.c
View file @
7ff432c9
...
@@ -1741,7 +1741,6 @@ makepol(WORKSTATE *state) {
...
@@ -1741,7 +1741,6 @@ makepol(WORKSTATE *state) {
typedef
struct
{
typedef
struct
{
int4
*
arrb
;
int4
*
arrb
;
int4
*
arre
;
int4
*
arre
;
int4
*
ptr
;
}
CHKVAL
;
}
CHKVAL
;
/*
/*
...
@@ -1749,23 +1748,20 @@ typedef struct {
...
@@ -1749,23 +1748,20 @@ typedef struct {
*/
*/
static
bool
static
bool
checkcondition_arr
(
void
*
checkval
,
int4
val
)
{
checkcondition_arr
(
void
*
checkval
,
int4
val
)
{
#ifdef BS_DEBUG
int4
*
StopLow
=
((
CHKVAL
*
)
checkval
)
->
arrb
;
elog
(
NOTICE
,
"OPERAND %d"
,
val
);
int4
*
StopHigh
=
((
CHKVAL
*
)
checkval
)
->
arre
;
#endif
int4
*
StopMiddle
;
if
(
val
>
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
{
while
(
((
CHKVAL
*
)
checkval
)
->
ptr
<
((
CHKVAL
*
)
checkval
)
->
arre
)
{
/* Loop invariant: StopLow <= val < StopHigh */
((
CHKVAL
*
)
checkval
)
->
ptr
++
;
if
(
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
==
val
)
return
true
;
while
(
StopLow
<
StopHigh
)
{
if
(
val
<
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
return
false
;
StopMiddle
=
StopLow
+
(
StopHigh
-
StopLow
)
/
2
;
}
if
(
*
StopMiddle
==
val
)
}
else
if
(
val
<
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
{
return
(
true
);
while
(
((
CHKVAL
*
)
checkval
)
->
ptr
>
((
CHKVAL
*
)
checkval
)
->
arrb
)
{
else
if
(
*
StopMiddle
<
val
)
((
CHKVAL
*
)
checkval
)
->
ptr
--
;
StopLow
=
StopMiddle
+
1
;
if
(
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
==
val
)
return
true
;
else
if
(
val
>
*
(((
CHKVAL
*
)
checkval
)
->
ptr
)
)
return
false
;
StopHigh
=
StopMiddle
;
}
}
else
{
return
true
;
}
}
return
false
;
return
false
;
}
}
...
@@ -1818,8 +1814,7 @@ execconsistent( QUERYTYPE *query, ArrayType *array, bool calcnot ) {
...
@@ -1818,8 +1814,7 @@ execconsistent( QUERYTYPE *query, ArrayType *array, bool calcnot ) {
CHKVAL
chkval
;
CHKVAL
chkval
;
chkval
.
arrb
=
ARRPTR
(
array
);
chkval
.
arrb
=
ARRPTR
(
array
);
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
array
)
-
1
;
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
array
);
chkval
.
ptr
=
chkval
.
arrb
+
ARRNELEMS
(
array
)
/
2
;
return
execute
(
return
execute
(
GETQUERY
(
query
)
+
query
->
size
-
1
,
GETQUERY
(
query
)
+
query
->
size
-
1
,
(
void
*
)
&
chkval
,
calcnot
,
(
void
*
)
&
chkval
,
calcnot
,
...
@@ -1854,8 +1849,7 @@ boolop(PG_FUNCTION_ARGS) {
...
@@ -1854,8 +1849,7 @@ boolop(PG_FUNCTION_ARGS) {
PREPAREARR
(
val
);
PREPAREARR
(
val
);
chkval
.
arrb
=
ARRPTR
(
val
);
chkval
.
arrb
=
ARRPTR
(
val
);
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
val
)
-
1
;
chkval
.
arre
=
chkval
.
arrb
+
ARRNELEMS
(
val
);
chkval
.
ptr
=
chkval
.
arrb
+
ARRNELEMS
(
val
)
/
2
;
result
=
execute
(
result
=
execute
(
GETQUERY
(
query
)
+
query
->
size
-
1
,
GETQUERY
(
query
)
+
query
->
size
-
1
,
&
chkval
,
true
,
&
chkval
,
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment