-# $Id: Makefile.am,v 1.11 2007-04-20 13:03:22 marc Exp $
+# $Id: Makefile.am,v 1.12 2007-04-20 14:37:17 marc Exp $
bin_PROGRAMS = pazpar2
check_PROGRAMS = test_config test_relevance test_sel_thread
libpazpar2_a_SOURCES = config.c config.h eventl.c eventl.h \
http.c http_command.c http_command.h http.h \
logic.c pazpar2.h \
- record.h reclists.c reclists.h \
+ record.h record.c reclists.c reclists.h \
relevance.c relevance.h termlists.c termlists.h \
util.c util.h zeerex.c zeerex.h database.c database.h \
settings.h settings.c sel_thread.c sel_thread.h
-/* $Id: config.c,v 1.27 2007-04-20 11:00:29 marc Exp $
+/* $Id: config.c,v 1.28 2007-04-20 14:37:17 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
02111-1307, USA.
*/
-/* $Id: config.c,v 1.27 2007-04-20 11:00:29 marc Exp $ */
+/* $Id: config.c,v 1.28 2007-04-20 14:37:17 marc Exp $ */
#include <string.h>
struct conf_service * conf_service_create(NMEM nmem,
int num_metadata, int num_sortkeys)
{
- struct conf_service * service
- = nmem_malloc(nmem, sizeof(struct conf_service));
+ struct conf_service * service = 0;
+
+ //assert(nmem);
+
+ service = nmem_malloc(nmem, sizeof(struct conf_service));
+
service->num_metadata = num_metadata;
service->metadata = 0;
if (service->num_metadata)
--- /dev/null
+/* $Id: record.c,v 1.1 2007-04-20 14:37:17 marc Exp $
+ Copyright (c) 2006-2007, Index Data.
+
+This file is part of Pazpar2.
+
+Pazpar2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Pazpar2; see the file LICENSE. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+ */
+
+/* $Id: record.c,v 1.1 2007-04-20 14:37:17 marc Exp $ */
+
+
+#include <string.h>
+
+#include <yaz/yaz-util.h>
+#include <yaz/nmem.h>
+
+#if HAVE_CONFIG_H
+#include <cconfig.h>
+#endif
+
+//#define CONFIG_NOEXTERNS
+#include "config.h"
+#include "record.h"
+
+
+struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys)
+{
+ struct record * record = 0;
+
+ // assert(nmem);
+
+ record = nmem_malloc(nmem, sizeof(struct record));
+
+ record->next = 0;
+ // which client should I use for record->client = cl; ??
+ record->client = 0;
+
+ record->metadata
+ = nmem_malloc(nmem,
+ sizeof(struct record_metadata*) * num_metadata);
+ memset(record->metadata, 0,
+ sizeof(struct record_metadata*) * num_metadata);
+
+ record->sortkeys
+ = nmem_malloc(nmem,
+ sizeof(union data_types*) * num_sortkeys);
+ memset(record->metadata, 0,
+ sizeof(union data_types*) * num_sortkeys);
+
+
+ return record;
+}
+
+
+struct record_metadata * record_add_metadata_fieldno(NMEM nmem,
+ struct record * record,
+ int fieldno,
+ union data_types data)
+{
+ struct record_metadata * rmd = 0;
+
+ if (!record || fieldno < 0
+ || !record->metadata || !record->metadata[fieldno] )
+ return 0;
+
+ // construct new record_metadata
+ rmd = nmem_malloc(nmem, sizeof(struct record_metadata));
+ rmd->data = data;
+ rmd->next = 0;
+
+ // still needs to be assigned ..
+
+ return rmd;
+
+};
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
-/* $Id: record.h,v 1.1 2007-04-20 13:03:22 marc Exp $
+/* $Id: record.h,v 1.2 2007-04-20 14:37:17 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
struct record *next; // Next in cluster of merged records
};
+
+struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys);
+
+struct record_metadata * record_add_metadata_fieldno(NMEM nmem,
+ struct record * record,
+ int fieldno,
+ union data_types data);
+
struct record_cluster
{
struct record_metadata **metadata; // Array mirrors list of metadata fields in config
-/* $Id: test_relevance.c,v 1.4 2007-04-19 19:42:30 marc Exp $
+/* $Id: test_relevance.c,v 1.5 2007-04-20 14:37:17 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
//#include "pazpar2.h"
#include "config.h"
#include "relevance.h"
-
+#include "record.h"
+#include "pazpar2.h"
void test_relevance(int argc, char **argv)
{"abe", "fisk", 0};
// {"ål", "økologi", "æble", 0};
- struct record_cluster *cluster = 0;
+ //struct record_cluster *cluster = 0;
struct conf_service *service = 0;
struct reclist *list = 0;
struct record *record = 0;
- const char *mergekey = "amergekey";
- int total = 0;
+ //const char *mergekey = "amergekey";
+ //int total = 0;
struct relevance *rel = 0;
+ struct client *client = 0;
+
rel = relevance_create(nmem, queryterms, numrecs);
list = reclist_create(nmem, numrecs);
1, 1, 1, 0);
-#if 0
- // preparing one record
- // this should have been done by a nice record_create function
- // why the heck does the record know which client it belongs to ??
-
-
- record = nmem_malloc(nmem, sizeof(struct record));
- record->next = 0;
- // which client should I use for record->client = cl; ??
- record->client = 0;
- // and which sortkeys data_types list should I use ??
- record->sortkeys = 0;
- record->metadata
- = nmem_malloc(nmem,
- sizeof(struct record_metadata*) * service->num_metadata);
- memset(record->metadata, 0,
- sizeof(struct record_metadata*) * service->num_metadata);
-#endif
+ // testing record things
+ record = record_create(nmem, 4, 1);
+ YAZ_CHECK(record);
+
+ // why on earth do we have a client dangeling from the record ??
+ record->client = client;
+
+ //union data_types data;
+ //data.text = "sometext";
+
+ char * bla = "blabla";
+ union data_types data;
+ data.text = bla;
+
+
+ union data_types data2;
+ data.number.min = 2;
+ data.number.max = 5;
+
+ record_add_metadata_fieldno(nmem, record, 0, data);
+ record_add_metadata_fieldno(nmem, record, 0, data2);
+
+ //record_add_metadata_text(nmem, record, 0, bla);
+
// now we need to put some actual data into the record ... how ??
// there is a hell of a lot spagetti code in logic.c ingest_record()