Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
openldap
OpenLDAP
Commits
a3bbc8ad
Commit
a3bbc8ad
authored
May 04, 2004
by
Kurt Zeilenga
Browse files
Update substr indexing macros to better separate
initial/final string settings from any string settings.
parent
d7ff03d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
servers/slapd/schema_init.c
View file @
a3bbc8ad
...
...
@@ -405,31 +405,27 @@ octetStringSubstringsIndexer(
for
(
i
=
0
;
values
[
i
].
bv_val
!=
NULL
;
i
++
)
{
/* count number of indices to generate */
if
(
values
[
i
].
bv_len
<
SLAP_INDEX_SUBSTR_MINLEN
)
{
continue
;
}
if
(
flags
&
SLAP_INDEX_SUBSTR_INITIAL
)
{
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_MAXLEN
)
{
nkeys
+=
SLAP_INDEX_SUBSTR_MAXLEN
-
(
SLAP_INDEX_SUBSTR_MINLEN
-
1
);
}
else
{
nkeys
+=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_MINLEN
-
1
);
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
)
{
nkeys
+=
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
-
(
SLAP_INDEX_SUBSTR_
IF_
MINLEN
-
1
);
}
else
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_IF_MINLEN
)
{
nkeys
+=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_
IF_
MINLEN
-
1
);
}
}
if
(
flags
&
SLAP_INDEX_SUBSTR_ANY
)
{
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
MAX
LEN
)
{
nkeys
+=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_
MAX
LEN
-
1
);
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
ANY_
LEN
)
{
nkeys
+=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_
ANY_
LEN
-
1
);
}
}
if
(
flags
&
SLAP_INDEX_SUBSTR_FINAL
)
{
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_MAXLEN
)
{
nkeys
+=
SLAP_INDEX_SUBSTR_MAXLEN
-
(
SLAP_INDEX_SUBSTR_MINLEN
-
1
);
}
else
{
nkeys
+=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_MINLEN
-
1
);
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
)
{
nkeys
+=
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
-
(
SLAP_INDEX_SUBSTR_
IF_
MINLEN
-
1
);
}
else
if
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_IF_MINLEN
)
{
nkeys
+=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_
IF_
MINLEN
-
1
);
}
}
}
...
...
@@ -449,13 +445,11 @@ octetStringSubstringsIndexer(
for
(
i
=
0
;
values
[
i
].
bv_val
!=
NULL
;
i
++
)
{
ber_len_t
j
,
max
;
if
(
values
[
i
].
bv_len
<
SLAP_INDEX_SUBSTR_MINLEN
)
continue
;
if
(
(
flags
&
SLAP_INDEX_SUBSTR_ANY
)
&&
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
MAX
LEN
)
)
(
values
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
ANY_
LEN
)
)
{
char
pre
=
SLAP_INDEX_SUBSTR_PREFIX
;
max
=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_
MAX
LEN
-
1
);
max
=
values
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_
ANY_
LEN
-
1
);
for
(
j
=
0
;
j
<
max
;
j
++
)
{
HASH_Init
(
&
HASHcontext
);
...
...
@@ -472,17 +466,20 @@ octetStringSubstringsIndexer(
(
unsigned
char
*
)
mr
->
smr_oid
,
mlen
);
HASH_Update
(
&
HASHcontext
,
(
unsigned
char
*
)
&
values
[
i
].
bv_val
[
j
],
SLAP_INDEX_SUBSTR_
MAX
LEN
);
SLAP_INDEX_SUBSTR_
ANY_
LEN
);
HASH_Final
(
HASHdigest
,
&
HASHcontext
);
ber_dupbv_x
(
&
keys
[
nkeys
++
],
&
digest
,
ctx
);
}
}
max
=
SLAP_INDEX_SUBSTR_MAXLEN
<
values
[
i
].
bv_len
?
SLAP_INDEX_SUBSTR_MAXLEN
:
values
[
i
].
bv_len
;
/* skip if too short */
if
(
values
[
i
].
bv_len
<
SLAP_INDEX_SUBSTR_IF_MINLEN
)
continue
;
max
=
SLAP_INDEX_SUBSTR_IF_MAXLEN
<
values
[
i
].
bv_len
?
SLAP_INDEX_SUBSTR_IF_MAXLEN
:
values
[
i
].
bv_len
;
for
(
j
=
SLAP_INDEX_SUBSTR_MINLEN
;
j
<=
max
;
j
++
)
{
for
(
j
=
SLAP_INDEX_SUBSTR_
IF_
MINLEN
;
j
<=
max
;
j
++
)
{
char
pre
;
if
(
flags
&
SLAP_INDEX_SUBSTR_INITIAL
)
{
...
...
@@ -526,7 +523,6 @@ octetStringSubstringsIndexer(
}
}
}
if
(
nkeys
>
0
)
{
...
...
@@ -563,8 +559,9 @@ octetStringSubstringsFilter (
sa
=
(
SubstringsAssertion
*
)
assertedValue
;
if
(
flags
&
SLAP_INDEX_SUBSTR_INITIAL
&&
sa
->
sa_initial
.
bv_val
!=
NULL
&&
sa
->
sa_initial
.
bv_len
>=
SLAP_INDEX_SUBSTR_MINLEN
)
if
(
flags
&
SLAP_INDEX_SUBSTR_INITIAL
&&
sa
->
sa_initial
.
bv_val
!=
NULL
&&
sa
->
sa_initial
.
bv_len
>=
SLAP_INDEX_SUBSTR_IF_MINLEN
)
{
nkeys
++
;
}
...
...
@@ -572,16 +569,17 @@ octetStringSubstringsFilter (
if
(
flags
&
SLAP_INDEX_SUBSTR_ANY
&&
sa
->
sa_any
!=
NULL
)
{
ber_len_t
i
;
for
(
i
=
0
;
sa
->
sa_any
[
i
].
bv_val
!=
NULL
;
i
++
)
{
if
(
sa
->
sa_any
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
MAX
LEN
)
{
/* don't bother accounting
for
stepping */
if
(
sa
->
sa_any
[
i
].
bv_len
>=
SLAP_INDEX_SUBSTR_
ANY_
LEN
)
{
/* don't bother accounting
with
stepping */
nkeys
+=
sa
->
sa_any
[
i
].
bv_len
-
(
SLAP_INDEX_SUBSTR_
MAX
LEN
-
1
);
(
SLAP_INDEX_SUBSTR_
ANY_
LEN
-
1
);
}
}
}
if
(
flags
&
SLAP_INDEX_SUBSTR_FINAL
&&
sa
->
sa_final
.
bv_val
!=
NULL
&&
sa
->
sa_final
.
bv_len
>=
SLAP_INDEX_SUBSTR_MINLEN
)
if
(
flags
&
SLAP_INDEX_SUBSTR_FINAL
&&
sa
->
sa_final
.
bv_val
!=
NULL
&&
sa
->
sa_final
.
bv_len
>=
SLAP_INDEX_SUBSTR_IF_MINLEN
)
{
nkeys
++
;
}
...
...
@@ -600,14 +598,15 @@ octetStringSubstringsFilter (
keys
=
slap_sl_malloc
(
sizeof
(
struct
berval
)
*
(
nkeys
+
1
),
ctx
);
nkeys
=
0
;
if
(
flags
&
SLAP_INDEX_SUBSTR_INITIAL
&&
sa
->
sa_initial
.
bv_val
!=
NULL
&&
sa
->
sa_initial
.
bv_len
>=
SLAP_INDEX_SUBSTR_MINLEN
)
if
(
flags
&
SLAP_INDEX_SUBSTR_INITIAL
&&
sa
->
sa_initial
.
bv_val
!=
NULL
&&
sa
->
sa_initial
.
bv_len
>=
SLAP_INDEX_SUBSTR_IF_MINLEN
)
{
pre
=
SLAP_INDEX_SUBSTR_INITIAL_PREFIX
;
value
=
&
sa
->
sa_initial
;
klen
=
SLAP_INDEX_SUBSTR_MAXLEN
<
value
->
bv_len
?
SLAP_INDEX_SUBSTR_MAXLEN
:
value
->
bv_len
;
klen
=
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
<
value
->
bv_len
?
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
:
value
->
bv_len
;
HASH_Init
(
&
HASHcontext
);
if
(
prefix
!=
NULL
&&
prefix
->
bv_len
>
0
)
{
...
...
@@ -630,18 +629,18 @@ octetStringSubstringsFilter (
if
(
flags
&
SLAP_INDEX_SUBSTR_ANY
&&
sa
->
sa_any
!=
NULL
)
{
ber_len_t
i
,
j
;
pre
=
SLAP_INDEX_SUBSTR_PREFIX
;
klen
=
SLAP_INDEX_SUBSTR_
MAX
LEN
;
klen
=
SLAP_INDEX_SUBSTR_
ANY_
LEN
;
for
(
i
=
0
;
sa
->
sa_any
[
i
].
bv_val
!=
NULL
;
i
++
)
{
if
(
sa
->
sa_any
[
i
].
bv_len
<
SLAP_INDEX_SUBSTR_
MAX
LEN
)
{
if
(
sa
->
sa_any
[
i
].
bv_len
<
SLAP_INDEX_SUBSTR_
ANY_
LEN
)
{
continue
;
}
value
=
&
sa
->
sa_any
[
i
];
for
(
j
=
0
;
j
<=
value
->
bv_len
-
SLAP_INDEX_SUBSTR_
MAX
LEN
;
j
+=
SLAP_INDEX_SUBSTR_STEP
)
j
<=
value
->
bv_len
-
SLAP_INDEX_SUBSTR_
ANY_
LEN
;
j
+=
SLAP_INDEX_SUBSTR_
ANY_
STEP
)
{
HASH_Init
(
&
HASHcontext
);
if
(
prefix
!=
NULL
&&
prefix
->
bv_len
>
0
)
{
...
...
@@ -663,14 +662,15 @@ octetStringSubstringsFilter (
}
}
if
(
flags
&
SLAP_INDEX_SUBSTR_FINAL
&&
sa
->
sa_final
.
bv_val
!=
NULL
&&
sa
->
sa_final
.
bv_len
>=
SLAP_INDEX_SUBSTR_MINLEN
)
if
(
flags
&
SLAP_INDEX_SUBSTR_FINAL
&&
sa
->
sa_final
.
bv_val
!=
NULL
&&
sa
->
sa_final
.
bv_len
>=
SLAP_INDEX_SUBSTR_IF_MINLEN
)
{
pre
=
SLAP_INDEX_SUBSTR_FINAL_PREFIX
;
value
=
&
sa
->
sa_final
;
klen
=
SLAP_INDEX_SUBSTR_MAXLEN
<
value
->
bv_len
?
SLAP_INDEX_SUBSTR_MAXLEN
:
value
->
bv_len
;
klen
=
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
<
value
->
bv_len
?
SLAP_INDEX_SUBSTR_
IF_
MAXLEN
:
value
->
bv_len
;
HASH_Init
(
&
HASHcontext
);
if
(
prefix
!=
NULL
&&
prefix
->
bv_len
>
0
)
{
...
...
servers/slapd/slap.h
View file @
a3bbc8ad
...
...
@@ -225,9 +225,21 @@ typedef struct slap_ssf_set {
| SLAP_INDEX_SUBSTR_ANY \
| SLAP_INDEX_SUBSTR_FINAL )
#define SLAP_INDEX_SUBSTR_MINLEN 2
#define SLAP_INDEX_SUBSTR_MAXLEN 4
#define SLAP_INDEX_SUBSTR_STEP 2
/* constants for initial/final substrings indices */
#ifndef SLAP_INDEX_SUBSTR_IF_MINLEN
# define SLAP_INDEX_SUBSTR_IF_MINLEN 2
#endif
#ifndef SLAP_INDEX_SUBSTR_IF_MAXLEN
# define SLAP_INDEX_SUBSTR_IF_MAXLEN 4
#endif
/* constants for any substrings indices */
#ifndef SLAP_INDEX_SUBSTR_ANY_LEN
# define SLAP_INDEX_SUBSTR_ANY_LEN 4
#endif
#ifndef SLAP_INDEX_SUBSTR_ANY_STEP
# define SLAP_INDEX_SUBSTR_ANY_STEP 2
#endif
#define SLAP_INDEX_FLAGS 0xF000UL
#define SLAP_INDEX_NOSUBTYPES 0x1000UL
/* don't use index w/ subtypes */
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment