Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
isochrone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Institut für Informatik
dbis
dbis-isochrone
isochrone
Commits
f83bc549
Commit
f83bc549
authored
10 years ago
by
User expired
Browse files
Options
Downloads
Patches
Plain Diff
fixed problem in placeHolder caching
parent
fda86fb3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/unibz/inf/isochrone/db/Database.java
+39
-26
39 additions, 26 deletions
src/main/java/it/unibz/inf/isochrone/db/Database.java
with
39 additions
and
26 deletions
src/main/java/it/unibz/inf/isochrone/db/Database.java
+
39
−
26
View file @
f83bc549
...
...
@@ -74,7 +74,7 @@ public class Database {
final
int
preachingLength
=
10
;
PRECACHED_PLACEHOLDERS
=
new
String
[
preachingLength
];
for
(
int
i
=
0
;
i
<
preachingLength
;
++
i
)
{
PRECACHED_PLACEHOLDERS
[
i
]
=
prepar
ePlaceHolders
(
i
);
PRECACHED_PLACEHOLDERS
[
i
]
=
calculat
ePlaceHolders
(
i
);
}
}
...
...
@@ -743,31 +743,6 @@ public class Database {
// Private static methods
/**
* Prepares a number of place holders for a prepared statement.
*
* @param length The number of placeholders that is needed
* @return a string with the placeholders plugged in to a statement.
*/
private
static
String
preparePlaceHolders
(
final
int
length
)
{
if
(
length
<=
0
)
{
return
""
;
}
if
(
length
<
PRECACHED_PLACEHOLDERS
.
length
)
{
return
PRECACHED_PLACEHOLDERS
[
length
];
}
final
StringBuilder
builder
=
new
StringBuilder
((
2
*
length
)
-
1
);
builder
.
append
(
"?"
);
final
int
max
=
length
-
1
;
for
(
int
i
=
0
;
i
<
max
;
++
i
)
{
builder
.
append
(
",?"
);
}
return
builder
.
toString
();
}
/**
* Adds a node to the network.
*
...
...
@@ -800,6 +775,25 @@ public class Database {
}
}
/**
* Calculates a number of place holders for a prepared statement.
* In difference to @see {@link #preparePlaceHolders(int)} this does not use any caching approach at all.
*
* @param length The number of placeholders that is needed
* @return a string with the placeholders plugged in to a statement.
*/
private
static
String
calculatePlaceHolders
(
final
int
length
)
{
final
StringBuilder
builder
=
new
StringBuilder
((
2
*
length
)
-
1
);
builder
.
append
(
"?"
);
final
int
max
=
length
-
1
;
for
(
int
i
=
0
;
i
<
max
;
++
i
)
{
builder
.
append
(
",?"
);
}
return
builder
.
toString
();
}
/**
* Transforms the day into something machine-readable.
*
...
...
@@ -827,6 +821,25 @@ public class Database {
}
}
/**
* Prepares a number of place holders for a prepared statement.
* In difference to @see {@link #calculatePlaceHolders(int)} this uses a caching approach for small lengths
*
* @param length The number of placeholders that is needed
* @return a string with the placeholders plugged in to a statement.
*/
private
static
String
preparePlaceHolders
(
final
int
length
)
{
if
(
length
<=
0
)
{
return
""
;
}
if
(
length
<
PRECACHED_PLACEHOLDERS
.
length
)
{
return
PRECACHED_PLACEHOLDERS
[
length
];
}
return
calculatePlaceHolders
(
length
);
}
private
static
String
subQuery
(
final
Node
[]
loaded
,
final
int
idx
,
final
int
srid
)
{
if
(
idx
==
0
)
{
return
"st_buffer(st_pointfromtext('POINT("
+
loaded
[
idx
].
getCoordinates
().
getX
()
+
" "
...
...
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