forked from kamba4/sunders
improved performance
All checks were successful
Build (and tag) Images / build (push) Successful in 38s
All checks were successful
Build (and tag) Images / build (push) Successful in 38s
This commit is contained in:
parent
6c8f5cce81
commit
8612798373
3 changed files with 58 additions and 97 deletions
|
|
@ -57,50 +57,6 @@ if (! ($insertTagStmt = $mysqli->prepare("INSERT INTO tag (id, k, v) VALUES (?,
|
|||
}
|
||||
$insertTagStmt->bind_param('dss', $id, $k, $v);
|
||||
|
||||
if (USE_STATISTICS) {
|
||||
if (! ($insertStatsStmt = $mysqli->prepare("INSERT INTO statistics (id, ts, version) VALUES (?, ?, ?)"))) {
|
||||
echo "Error while preparing insert statistics statement : " . $mysqli->error ;
|
||||
exit(1);
|
||||
}
|
||||
$insertStatsStmt->bind_param('dsi', $id, $ts, $version);
|
||||
}
|
||||
|
||||
function printDebug() {
|
||||
global $elementTypes, $count, $countDelete, $countModifyDelete, $countModify, $countCreate;
|
||||
|
||||
echo "== $count ==============================\n";
|
||||
foreach($elementTypes as $k => $v) {
|
||||
echo "$k : $v\n";
|
||||
}
|
||||
echo "++++++ Surveillance nodes : ++++++\n";
|
||||
echo "$countDelete deletions\n";
|
||||
echo "$countModifyDelete modifications --> deletions\n";
|
||||
echo "$countModify modifications\n";
|
||||
echo "$countCreate creations\n";
|
||||
}
|
||||
|
||||
function printDebugCurNode() {
|
||||
global $curNodeAttrs, $curNodeTags, $mode;
|
||||
|
||||
echo "=============\n";
|
||||
echo "$mode : " . $curNodeAttrs['id'] ." (". $curNodeAttrs['lat'] . " x " . $curNodeAttrs['lon'] . ") : " . $curNodeAttrs['user'] . "\n";
|
||||
if (! empty($curNodeAttrs)) {
|
||||
echo " => Attributes :\n";
|
||||
foreach($curNodeAttrs as $k => $v) {
|
||||
echo " $k : $v\n";
|
||||
}
|
||||
} else {
|
||||
echo " => No attributes\n";
|
||||
}
|
||||
if (! empty($curNodeTags)) {
|
||||
echo " => Tags :\n";
|
||||
foreach($curNodeTags as $k => $v) {
|
||||
echo " $k : $v\n";
|
||||
}
|
||||
} else {
|
||||
echo " => No tags\n";
|
||||
}
|
||||
}
|
||||
|
||||
function startElement ($parser, $name, $attrs) {
|
||||
global $elementTypes, $count, $mode, $curNodeAttrs, $curNodeTags;
|
||||
|
|
@ -137,12 +93,6 @@ function endElement ($parser, $name) {
|
|||
if ($mode == 'delete') {
|
||||
$id = $curNodeAttrs['id'];
|
||||
|
||||
if (USE_STATISTICS) {
|
||||
if (! $deleteStatsStmt->execute()) {
|
||||
echo "***** Error : Deleting statistics $id : ". $deleteStatsStmt->error . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (! $deleteTagStmt->execute()) {
|
||||
echo "***** Error : Deleting tags $id : ". $deleteTagStmt->error . "\n";
|
||||
}
|
||||
|
|
@ -151,6 +101,13 @@ function endElement ($parser, $name) {
|
|||
echo "***** Error : Deleting $id : ". $deleteStmt->error . "\n";
|
||||
}
|
||||
if ($deleteStmt->affected_rows > 0) {
|
||||
if (! $deleteTagStmt->execute()) {
|
||||
echo "***** Error : Deleting tags $id : ". $deleteTagStmt->error . "\n";
|
||||
}
|
||||
|
||||
if (! $deleteStmt->execute()) {
|
||||
echo "***** Error : Deleting $id : ". $deleteStmt->error . "\n";
|
||||
}
|
||||
$sql_statement = $sql_statement . "DELETE FROM position WHERE id=$id;\n";
|
||||
$sql_statement = $sql_statement . "DELETE FROM tag WHERE id=$id;\n";
|
||||
}
|
||||
|
|
@ -165,19 +122,14 @@ function endElement ($parser, $name) {
|
|||
$id = $curNodeAttrs['id'];
|
||||
|
||||
if ($mode == 'modify') {
|
||||
|
||||
if (USE_STATISTICS) {
|
||||
if (! $deleteStatsStmt->execute()) {
|
||||
echo "***** Error : Deleting statistics $id for modification : ". $deleteStatsStmt->error . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (! $deleteTagStmt->execute()) {
|
||||
echo "***** Error : Deleting tags $id for modification : ". $deleteTagStmt->error . "\n";
|
||||
}
|
||||
if (! $deleteStmt->execute()) {
|
||||
echo "***** Error : Deleting $id for modification : ". $deleteStmt->error . "\n";
|
||||
}
|
||||
$sql_statement = $sql_statement . "DELETE FROM position WHERE id=$id;\n";
|
||||
$sql_statement = $sql_statement . "DELETE FROM tag WHERE id=$id;\n";
|
||||
} else {
|
||||
}
|
||||
|
||||
|
|
@ -198,57 +150,30 @@ function endElement ($parser, $name) {
|
|||
$k = 'lon';
|
||||
$v = $curNodeAttrs['lon'];
|
||||
$sql_statement = $sql_statement . "INSERT INTO tag (id, k, v) VALUES ($id, '$k', '$v');\n";
|
||||
if (! $insertTagStmt->execute()) {
|
||||
echo "***** Error : inserting longitude $v for $id : ". $insertTagStmt->error . "\n";
|
||||
}
|
||||
|
||||
$k = 'userid';
|
||||
$v = $curNodeAttrs['user'];
|
||||
$sql_statement = $sql_statement . "INSERT INTO tag (id, k, v) VALUES ($id, '$k', '$v');\n";
|
||||
|
||||
if (! $insertTagStmt->execute()) {
|
||||
echo "***** Error : inserting user $v for $id : ". $insertTagStmt->error . "\n";
|
||||
}
|
||||
|
||||
$k = 'version';
|
||||
$v = $curNodeAttrs['version'];
|
||||
$sql_statement = $sql_statement . "INSERT INTO tag (id, k, v) VALUES ($id, '$k', '$v');\n";
|
||||
if (! $insertTagStmt->execute()) {
|
||||
echo "***** Error : inserting version $v for $id : ". $insertTagStmt->error . "\n";
|
||||
}
|
||||
|
||||
|
||||
$k = 'timestamp';
|
||||
$v = $curNodeAttrs['timestamp'];
|
||||
$sql_statement = $sql_statement . "INSERT INTO tag (id, k, v) VALUES ($id, '$k', '$v');\n";
|
||||
if (! $insertTagStmt->execute()) {
|
||||
echo "***** Error : inserting timestamp $v for $id : ". $insertTagStmt->error . "\n";
|
||||
}
|
||||
|
||||
|
||||
foreach($curNodeTags as $k => $v) {
|
||||
$sql_statement = $sql_statement . "INSERT INTO tag (id, k, v) VALUES ($id, '$k', '$v');\n";
|
||||
if (! $insertTagStmt->execute()) {
|
||||
echo "***** Error : inserting tag $k => $v for $id : ". $insertTagStmt->error . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (USE_STATISTICS) {
|
||||
$ts = $curNodeAttrs['timestamp'];
|
||||
$version = $curNodeAttrs['version'];
|
||||
if (! $insertStatsStmt->execute()) {
|
||||
echo "***** Error : inserting ts $ts, version $version for $id : ". $insertStatsStmt->error . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$mysqli->commit();
|
||||
} else if ($mode == 'modify') {
|
||||
// delete former surveillance nodes that were modified to non-surveillance nodes
|
||||
$id = $curNodeAttrs['id'];
|
||||
|
||||
if (USE_STATISTICS) {
|
||||
if (! $deleteStatsStmt->execute()) {
|
||||
echo "***** Error : Deleting statistics $id for non-surveillance node : ". $deleteStatsStmt->error . "\n";
|
||||
}
|
||||
}
|
||||
if (! $deleteTagStmt->execute()) {
|
||||
echo "***** Error : Deleting tags $id for non-surveillance node : ". $deleteTagStmt->error . "\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue