RDB 2
Main Page
Related Pages
Namespaces
Classes
Files
Examples
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
rdb-example-09-cleanup-database.py
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
#
4
#*******************************************************************************
5
#
6
# Copyright 2023 RIEGL Laser Measurement Systems
7
#
8
# Licensed under the Apache License, Version 2.0 (the "License");
9
# you may not use this file except in compliance with the License.
10
# You may obtain a copy of the License at
11
#
12
# http://www.apache.org/licenses/LICENSE-2.0
13
#
14
# Unless required by applicable law or agreed to in writing, software
15
# distributed under the License is distributed on an "AS IS" BASIS,
16
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
# See the License for the specific language governing permissions and
18
# limitations under the License.
19
#
20
# SPDX-License-Identifier: Apache-2.0
21
#
22
#*******************************************************************************
23
#
24
"""
25
rdb-example-09-cleanup-database.py
26
27
This example shows how to open an existing database and how to dismiss
28
the database history, i.e. to delete all transactions except the first
29
(database creation) and the current transaction (last committed or
30
restored).
31
32
Afterwards we vacuum the database which reorganizes the data blocks in
33
the database file so that there are no (or as few as possible) unused
34
blocks (gaps).
35
36
Please note, that both database operations cannot be reverted!
37
"""
38
39
import
riegl.rdb
40
41
# Access existing database
42
with riegl.rdb.rdb_open(
"pointcloud.rdbx"
)
as
rdb:
43
# First we delete the history (see comments in header)
44
rdb.management.finalize()
45
46
#____________________________________________________________________#
47
# #
48
# At this point, there might be many unused data blocks in the #
49
# database file which were occupied by the transactions we have #
50
# just deleted. These data blocks will be re-used when we create #
51
# new transactions to insert, update or remove points or make #
52
# other changes to e.g. meta data items. #
53
# So the following vacuum step is optional but might be a good #
54
# idea before archiving or transferring the database file. #
55
#____________________________________________________________________#
56
# #
57
58
# Now we reorganize and shrink the database file:
59
rdb.management.vacuum(
60
# As this might be a lengthy operation, vacuum() accepts
61
# an optional callback function to notify the user about
62
# the (coarse) progress. However there is no function to
63
# cancel this process.
64
lambda
progress: print(
"progress:"
, progress)
65
)
Generated on Thu Nov 30 2023 13:50:36 for RDB 2 by
1.8.6