projects
/
yazpp-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Init member timeout_this in socket manager (valgrind warnig)
[yazpp-moved-to-github.git]
/
src
/
yaz-z-cache.cpp
diff --git
a/src/yaz-z-cache.cpp
b/src/yaz-z-cache.cpp
index
975aee9
..
366d19b
100644
(file)
--- a/
src/yaz-z-cache.cpp
+++ b/
src/yaz-z-cache.cpp
@@
-1,21
+1,24
@@
/*
/*
- * Copyright (c) 2002-2003, Index Data.
+ * Copyright (c) 2002-2004, Index Data.
* See the file LICENSE for details.
*
* See the file LICENSE for details.
*
- * $Id: yaz-z-cache.cpp,v 1.7 2003-10-10 17:58:30 adam Exp $
+ * $Id: yaz-z-cache.cpp,v 1.13 2005-06-08 13:28:06 adam Exp $
*/
#include <yaz/log.h>
*/
#include <yaz/log.h>
-#include <yaz++/proxy.h>
+#include <yaz/proto.h>
+#include <yaz++/record-cache.h>
-struct Yaz_RecordCache_Entry {
+using namespace yazpp_1;
+
+struct yazpp_1::RecordCache_Entry {
int m_offset;
Z_NamePlusRecord *m_record;
Z_RecordComposition *m_comp;
int m_offset;
Z_NamePlusRecord *m_record;
Z_RecordComposition *m_comp;
- Yaz_RecordCache_Entry *m_next;
+ RecordCache_Entry *m_next;
};
};
-Yaz_RecordCache::Yaz_RecordCache ()
+RecordCache::RecordCache ()
{
m_mem = nmem_create();
m_entries = 0;
{
m_mem = nmem_create();
m_entries = 0;
@@
-24,17
+27,17
@@
Yaz_RecordCache::Yaz_RecordCache ()
m_max_size = 200000;
}
m_max_size = 200000;
}
-Yaz_RecordCache::~Yaz_RecordCache ()
+RecordCache::~RecordCache ()
{
nmem_destroy(m_mem);
}
{
nmem_destroy(m_mem);
}
-void Yaz_RecordCache::set_max_size(int sz)
+void RecordCache::set_max_size(int sz)
{
m_max_size = sz;
}
{
m_max_size = sz;
}
-void Yaz_RecordCache::clear ()
+void RecordCache::clear ()
{
nmem_destroy(m_mem);
m_mem = nmem_create();
{
nmem_destroy(m_mem);
m_mem = nmem_create();
@@
-43,7
+46,7
@@
void Yaz_RecordCache::clear ()
m_searchRequest = 0;
}
m_searchRequest = 0;
}
-void Yaz_RecordCache::copy_searchRequest(Z_SearchRequest *sr)
+void RecordCache::copy_searchRequest(Z_SearchRequest *sr)
{
ODR encode = odr_createmem(ODR_ENCODE);
ODR decode = odr_createmem(ODR_DECODE);
{
ODR encode = odr_createmem(ODR_ENCODE);
ODR decode = odr_createmem(ODR_DECODE);
@@
-63,7
+66,7
@@
void Yaz_RecordCache::copy_searchRequest(Z_SearchRequest *sr)
odr_destroy(decode);
}
odr_destroy(decode);
}
-void Yaz_RecordCache::copy_presentRequest(Z_PresentRequest *pr)
+void RecordCache::copy_presentRequest(Z_PresentRequest *pr)
{
ODR encode = odr_createmem(ODR_ENCODE);
ODR decode = odr_createmem(ODR_DECODE);
{
ODR encode = odr_createmem(ODR_ENCODE);
ODR decode = odr_createmem(ODR_DECODE);
@@
-83,14
+86,11
@@
void Yaz_RecordCache::copy_presentRequest(Z_PresentRequest *pr)
odr_destroy(decode);
}
odr_destroy(decode);
}
-void Yaz_RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start,
+void RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start,
int hits)
{
if (nmem_total(m_mem) > m_max_size)
int hits)
{
if (nmem_total(m_mem) > m_max_size)
- {
- yaz_log(LOG_LOG, "cache size");
return;
return;
- }
// Build appropriate compspec for this response
Z_RecordComposition *comp = 0;
if (hits == -1 && m_presentRequest)
// Build appropriate compspec for this response
Z_RecordComposition *comp = 0;
if (hits == -1 && m_presentRequest)
@@
-117,7
+117,7
@@
void Yaz_RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start,
int i;
for (i = 0; i<npr->num_records; i++)
{
int i;
for (i = 0; i<npr->num_records; i++)
{
- Yaz_RecordCache_Entry *entry = (Yaz_RecordCache_Entry *)
+ RecordCache_Entry *entry = (RecordCache_Entry *)
nmem_malloc(m_mem, sizeof(*entry));
entry->m_record = (Z_NamePlusRecord *)
nmem_malloc(m_mem, sizeof(*entry->m_record));
nmem_malloc(m_mem, sizeof(*entry));
entry->m_record = (Z_NamePlusRecord *)
nmem_malloc(m_mem, sizeof(*entry->m_record));
@@
-131,7
+131,7
@@
void Yaz_RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start,
}
}
}
}
-int Yaz_RecordCache::match (Yaz_RecordCache_Entry *entry,
+int RecordCache::match (RecordCache_Entry *entry,
Odr_oid *syntax, int offset,
Z_RecordComposition *comp)
{
Odr_oid *syntax, int offset,
Z_RecordComposition *comp)
{
@@
-170,23
+170,23
@@
int Yaz_RecordCache::match (Yaz_RecordCache_Entry *entry,
oid_to_dotstring(entry->m_record->u.databaseRecord->direct_reference, mstr1);
char mstr2[100];
oid_to_dotstring(syntax, mstr2);
oid_to_dotstring(entry->m_record->u.databaseRecord->direct_reference, mstr1);
char mstr2[100];
oid_to_dotstring(syntax, mstr2);
- yaz_log(LOG_LOG, "match fail 3 d=%s s=%s", mstr1, mstr2);
+ yaz_log(YLOG_LOG, "match fail 3 d=%s s=%s", mstr1, mstr2);
#endif
return 0;
}
#endif
return 0;
}
-int Yaz_RecordCache::lookup (ODR o, Z_NamePlusRecordList **npr,
+int RecordCache::lookup (ODR o, Z_NamePlusRecordList **npr,
int start, int num,
Odr_oid *syntax,
Z_RecordComposition *comp)
{
int i;
int start, int num,
Odr_oid *syntax,
Z_RecordComposition *comp)
{
int i;
- yaz_log(LOG_DEBUG, "cache lookup start=%d num=%d", start, num);
+ yaz_log(YLOG_DEBUG, "cache lookup start=%d num=%d", start, num);
for (i = 0; i<num; i++)
{
for (i = 0; i<num; i++)
{
- Yaz_RecordCache_Entry *entry = m_entries;
+ RecordCache_Entry *entry = m_entries;
for(; entry; entry = entry->m_next)
if (match(entry, syntax, start+i, comp))
break;
for(; entry; entry = entry->m_next)
if (match(entry, syntax, start+i, comp))
break;
@@
-199,7
+199,7
@@
int Yaz_RecordCache::lookup (ODR o, Z_NamePlusRecordList **npr,
odr_malloc(o, num * sizeof(Z_NamePlusRecord *));
for (i = 0; i<num; i++)
{
odr_malloc(o, num * sizeof(Z_NamePlusRecord *));
for (i = 0; i<num; i++)
{
- Yaz_RecordCache_Entry *entry = m_entries;
+ RecordCache_Entry *entry = m_entries;
for(; entry; entry = entry->m_next)
if (match(entry, syntax, start+i, comp))
break;
for(; entry; entry = entry->m_next)
if (match(entry, syntax, start+i, comp))
break;