projects
/
pazpar2-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into paz-927
[pazpar2-moved-to-github.git]
/
src
/
record.c
diff --git
a/src/record.c
b/src/record.c
index
874a0a2
..
84da2c8
100644
(file)
--- a/
src/record.c
+++ b/
src/record.c
@@
-1,5
+1,5
@@
/* This file is part of Pazpar2.
/* This file is part of Pazpar2.
- Copyright (C) 2006-2011 Index Data
+ Copyright (C) Index Data
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
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
@@
-27,10
+27,11
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
#include "pazpar2_config.h"
#endif
#include "pazpar2_config.h"
+#include "client.h"
#include "record.h"
#include "record.h"
-union data_types * data_types_assign(NMEM nmem,
- union data_types ** data1,
+union data_types * data_types_assign(NMEM nmem,
+ union data_types ** data1,
union data_types data2)
{
// assert(nmem);
union data_types data2)
{
// assert(nmem);
@@
-44,7
+45,7
@@
union data_types * data_types_assign(NMEM nmem,
else
*data1 = nmem_malloc(nmem, sizeof(union data_types));
}
else
*data1 = nmem_malloc(nmem, sizeof(union data_types));
}
-
+
**data1 = data2;
return *data1;
}
**data1 = data2;
return *data1;
}
@@
-55,7
+56,9
@@
struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys,
{
struct record * record = 0;
int i = 0;
{
struct record * record = 0;
int i = 0;
-
+ const char *name = client_get_id(client);
+ unsigned h = position;
+
// assert(nmem);
record = nmem_malloc(nmem, sizeof(struct record));
// assert(nmem);
record = nmem_malloc(nmem, sizeof(struct record));
@@
-63,26
+66,31
@@
struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys,
record->next = 0;
record->client = client;
record->next = 0;
record->client = client;
- record->metadata
- = nmem_malloc(nmem,
+ record->metadata
+ = nmem_malloc(nmem,
sizeof(struct record_metadata*) * num_metadata);
for (i = 0; i < num_metadata; i++)
record->metadata[i] = 0;
sizeof(struct record_metadata*) * num_metadata);
for (i = 0; i < num_metadata; i++)
record->metadata[i] = 0;
-
- record->sortkeys
- = nmem_malloc(nmem,
+
+ record->sortkeys
+ = nmem_malloc(nmem,
sizeof(union data_types*) * num_sortkeys);
for (i = 0; i < num_sortkeys; i++)
record->sortkeys[i] = 0;
record->position = position;
sizeof(union data_types*) * num_sortkeys);
for (i = 0; i < num_sortkeys; i++)
record->sortkeys[i] = 0;
record->position = position;
-
+
+ for (i = 0; name[i]; i++)
+ h = h * 65509 + ((unsigned char *) name)[i];
+
+ record->checksum = h;
+
return record;
}
struct record_metadata * record_metadata_create(NMEM nmem)
{
return record;
}
struct record_metadata * record_metadata_create(NMEM nmem)
{
- struct record_metadata * rec_md
+ struct record_metadata * rec_md
= nmem_malloc(nmem, sizeof(struct record_metadata));
rec_md->next = 0;
rec_md->attributes = 0;
= nmem_malloc(nmem, sizeof(struct record_metadata));
rec_md->next = 0;
rec_md->attributes = 0;
@@
-98,7
+106,7
@@
int record_compare(struct record *r1, struct record *r2,
{
struct conf_metadata *ser_md = &service->metadata[i];
enum conf_metadata_type type = ser_md->type;
{
struct conf_metadata *ser_md = &service->metadata[i];
enum conf_metadata_type type = ser_md->type;
-
+
struct record_metadata *m1 = r1->metadata[i];
struct record_metadata *m2 = r2->metadata[i];
while (m1 && m2)
struct record_metadata *m1 = r1->metadata[i];
struct record_metadata *m2 = r2->metadata[i];
while (m1 && m2)
@@
-106,6
+114,7
@@
int record_compare(struct record *r1, struct record *r2,
switch (type)
{
case Metadata_type_generic:
switch (type)
{
case Metadata_type_generic:
+ case Metadata_type_skiparticle:
if (strcmp(m1->data.text.disp, m2->data.text.disp))
return 0;
break;
if (strcmp(m1->data.text.disp, m2->data.text.disp))
return 0;
break;
@@
-115,6
+124,12
@@
int record_compare(struct record *r1, struct record *r2,
m1->data.number.max != m2->data.number.max)
return 0;
break;
m1->data.number.max != m2->data.number.max)
return 0;
break;
+ case Metadata_type_float:
+ if (m1->data.fnumber != m2->data.fnumber)
+ return 0;
+ case Metadata_type_position:
+ case Metadata_type_relevance:
+ break;
}
m1 = m1->next;
m2 = m2->next;
}
m1 = m1->next;
m2 = m2->next;