source: gs2-extensions/tdb/trunk/perllib/DBDrivers/GDBMTXTGZ.pm@ 30339

Last change on this file since 30339 was 30339, checked in by jmt12, 8 years ago

Interim commit due to unexplained hardlock and subsequent 'failed command: READ FPDMA QUEUED' errors on restart

  • Property svn:executable set to *
File size: 3.8 KB
Line 
1###############################################################################
2#
3# GDBMTXTGZ.pm -- utility functions for writing to gdbm-txtgz databases
4#
5# A component of the Greenstone digital library software from the New Zealand
6# Digital Library Project at the University of Waikato, New Zealand.
7#
8# Copyright (C) 1999-2015 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify it under
11# the terms of the GNU General Public License as published by the Free Software
12# Foundation; either version 2 of the License, or (at your option) any later
13# version.
14#
15# This program is distributed in the hope that it will be useful, but WITHOUT
16# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18# more details.
19#
20# You should have received a copy of the GNU General Public License along with
21# this program; if not, write to the Free Software Foundation, Inc., 675 Mass
22# Ave, Cambridge, MA 02139, USA.
23#
24###############################################################################
25
26package DBDrivers::GDBMTXTGZ;
27
28# Pragma
29use strict;
30
31# Libraries
32use util;
33use FileUtils;
34# - OO inheritence
35use parent 'DBDrivers::GDBM';
36
37
38sub new
39{
40 my $class = shift(@_);
41 my $self = DBDrivers::GDBM->new();
42 # Default TDB file extension
43 $self->{'default_file_extension'} = 'txt.gz';
44 # note: file separator agnostic
45 $self->{'executable_path'} = $ENV{'GSDLHOME'} . '/bin/' . $ENV{'GSDLOS'};
46 $self->{'read_executable'} = 'gzip --decompress --to-stdout';
47 $self->{'keyread_executable'} = $self->{'read_executable'};
48 $self->{'write_executable'} = 'gzip -';
49 bless ($self, $class);
50 return $self;
51}
52
53# -----------------------------------------------------------------------------
54# GDBM TXT-GZ IMPLEMENTATION
55# -----------------------------------------------------------------------------
56
57# Handled by BaseDBDriver
58# sub get_infodb_file_path(string, string)
59
60# Handled by 70HyphenFormat
61# sub close_infodb_write_handle(filehandle) => void
62# sub delete_infodb_entry(filehandle, string) => void
63# sub read_infodb_file(string, hashmap) => void
64# sub read_infodb_keys(string, hashmap) => void
65# sub write_infodb_entry(filehandle, string, hashmap) => void
66# sub write_infodb_rawentry(filehandle, string, string) => void
67
68
69## @function open_infodb_write_handle(string)
70#
71# Keep infodb in GDBM neutral form => save data as compressed text file, read
72# for txt2db to be run on it later (i.e. by the runtime system, first time the
73# collection is ever accessed). This makes it easier distribute pre-built
74# collections to various architectures.
75#
76# NB: even if two architectures are little endian (e.g. Intel and ARM procesors)
77# GDBM does *not* guarantee that the database generated on one will work on the
78# other
79#
80# All this function does now is turn the optional 'append' argument into the
81# appropriate operator for either appending to or clobbering gzip file.
82#
83sub open_infodb_write_handle
84{
85 my $self = shift(@_);
86 my $infodb_file_path = shift(@_);
87 my $opt_append = shift(@_);
88 my $infodb_file_handle;
89 if (defined $opt_append) {
90 my $output_operator = '>'; # clobber
91 if ($opt_append eq "append") {
92 $output_operator = '>>'; # append
93 }
94 $infodb_file_handle = $self->open_infodb_write_handle($infodb_file_path, $output_operator);
95 }
96 else {
97 $infodb_file_handle = $self->open_infodb_write_handle($infodb_file_path);
98 }
99 return $infodb_file_handle;
100}
101## open_infodb_write_handle(string) => filehandle ##
102
103
104## @function set_infodb_entry(string, string, hashmap)
105#
106sub set_infodb_entry
107{
108 my $self = shift(@_);
109 print STDERR "***** gdbmtxtgz::set_infodb_entry() not implemented yet!\n";
110}
111## set_infodb_entry(string, string, hashmap) => void ##
112
1131;
Note: See TracBrowser for help on using the repository browser.