From 01651e17689984a48a46c6a979a303788c27da1b Mon Sep 17 00:00:00 2001 From: tonnesen Date: Wed, 22 May 2002 16:00:51 +0000 Subject: [PATCH] First attempt at a perl data structure for marc records --- marc/benchmarks/benchmarkschema | 3 ++- marc/perlmarcstructure | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 marc/perlmarcstructure diff --git a/marc/benchmarks/benchmarkschema b/marc/benchmarks/benchmarkschema index 7c10aeb42d..c5894f8a6b 100644 --- a/marc/benchmarks/benchmarkschema +++ b/marc/benchmarks/benchmarkschema @@ -17,6 +17,7 @@ CREATE TABLE marc_2XX_subfield_table ( subfieldvalue varchar(255) default NULL, valuebloblink bigint(20) default NULL, PRIMARY KEY (subfieldid), - KEY (bibid,tagid,tag,subfieldcode) + KEY (bibid,tagid,tag,subfieldcode), + KEY (bibid,tag,subfieldcode,subfieldvalue) ) TYPE=MyISAM; diff --git a/marc/perlmarcstructure b/marc/perlmarcstructure new file mode 100644 index 0000000000..fef700a57e --- /dev/null +++ b/marc/perlmarcstructure @@ -0,0 +1,45 @@ + +A proposed perl data structure for storing marc info + + +$record is a hash reference + +$record->{leader}= +$record->{bibid}=58973 +$record->{tags}=$tags + +$tags is a hash reference + +$tags->{1}=$tag +$tags->{2}=$tag +$tags->{3}=$tag + +$tag->{tag}=110 +$tag->{indicator}='04' +$tag->{tagid}=573498 +$tag->{subfields}=$subfields + + +$subfields->{1}=$subfield +$subfields->{2}=$subfield +$subfields->{3}=$subfield + +$subfield is a hash reference + +$subfield->{mark}='a' +$subfield->{value}='MacDonald, John A.' + +This takes care of possible repeating tags and subfields as well as ordering of +tags and subfields, but it makes it difficult to look up specific tags and +subfields without looping through every time. It might be an idea to add an +index to the structure to aid these lookups. + +$record->{index}->{110}->{tags}=\(3,4) <-- array ref shows that tags 3 and 4 + are 110 tags + +This still needs more work. This will also require an API for accessing or +modifying this structure, as it is non-trivial to parse the data. I'm also +starting to wonder how difficult it is going to be to develop templates using +this kind of structure. HTML::Template has no facility for parsing this kind +of data structure. We might need an alternate (or completely different) data +structure that is parseable by HTML::Template. -- 2.39.2