File: rdf_storage_tstore.c

package info (click to toggle)
redland 1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 27,592 kB
  • ctags: 12,328
  • sloc: ansic: 79,017; xml: 25,115; sh: 10,162; yacc: 5,985; lex: 3,682; makefile: 3,260; perl: 2,814; cpp: 59
file content (745 lines) | stat: -rw-r--r-- 23,204 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
/* -*- Mode: c; c-basic-offset: 2 -*-
 *
 * rdf_storage_tstore.c - RDF Storage using 3store
 *
 * $Id: rdf_storage_tstore.c 11930 2007-02-25 19:46:53Z dajobe $
 *
 * Copyright (C) 2003-2006, David Beckett http://purl.org/net/dajobe/
 * Copyright (C) 2003-2004, University of Bristol, UK http://www.bristol.ac.uk/
 * 
 * This package is Free Software and part of Redland http://librdf.org/
 * 
 * It is licensed under the following three licenses as alternatives:
 *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
 *   2. GNU General Public License (GPL) V2 or any newer version
 *   3. Apache License, V2.0 or any newer version
 * 
 * You may not use this file except in compliance with at least one of
 * the above three licenses.
 * 
 * See LICENSE.html or LICENSE.txt at the top of this package for the
 * complete terms and further detail along with the license texts for
 * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
 * 
 * 
 */


#ifdef HAVE_CONFIG_H
#include <rdf_config.h>
#endif

#ifdef WIN32
#include <win32_rdf_config.h>
#endif

#include <stdio.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h> /* for abort() as used in errors */
#endif
#include <sys/types.h>

#include <redland.h>

#include <rdfsql/rdfsql.h>

typedef struct
{
  /* Tstore args for connecting */
  const char *host;
  const char *db;
  const char *user;
  const char *password;
  const char *model;
  
  RDFSQL* rdfsql;
  
} librdf_storage_tstore_context;


/* prototypes for local functions */
static int librdf_storage_tstore_init(librdf_storage* storage, const char *name, librdf_hash* options);
static int librdf_storage_tstore_open(librdf_storage* storage, librdf_model* model);
static int librdf_storage_tstore_close(librdf_storage* storage);
static int librdf_storage_tstore_size(librdf_storage* storage);
static int librdf_storage_tstore_add_statement(librdf_storage* storage, librdf_statement* statement);
static int librdf_storage_tstore_remove_statement(librdf_storage* storage, librdf_statement* statement);
static int librdf_storage_tstore_contains_statement(librdf_storage* storage, librdf_statement* statement);
static librdf_stream* librdf_storage_tstore_serialise(librdf_storage* storage);
static librdf_stream* librdf_storage_tstore_find_statements(librdf_storage* storage, librdf_statement* statement);

/* serialising implementing functions */
static int librdf_storage_tstore_serialise_end_of_stream(void* context);
static int librdf_storage_tstore_serialise_next_statement(void* context);
static void* librdf_storage_tstore_serialise_get_statement(void* context, int flags);
static void librdf_storage_tstore_serialise_finished(void* context);

/* find implementing functions */
static int librdf_storage_tstore_find_end_of_stream(void* context);
static int librdf_storage_tstore_find_next_statement(void* context);
static void* librdf_storage_tstore_find_get_statement(void* context, int flags);
static void librdf_storage_tstore_find_finished(void* context);


/* context functions */
static int librdf_storage_tstore_context_add_statement(librdf_storage* storage, librdf_node* context_node, librdf_statement* statement);
static int librdf_storage_tstore_context_remove_statement(librdf_storage* storage, librdf_node* context_node, librdf_statement* statement);
static librdf_stream* librdf_storage_tstore_context_serialise(librdf_storage* storage, librdf_node* context_node);

/* context list statement stream methods */
#if 0
static int librdf_storage_tstore_context_serialise_end_of_stream(void* context);
static int librdf_storage_tstore_context_serialise_next_statement(void* context);
static void* librdf_storage_tstore_context_serialise_get_statement(void* context, int flags);
static void librdf_storage_tstore_context_serialise_finished(void* context);
#endif

static librdf_statement* librdf_storage_tstore_statement_from_rs_triple(librdf_world* world, rs_triple *triple);
static rs_triple* librdf_storage_tstore_statement_as_rs_triple(librdf_statement *statement);

static void librdf_storage_tstore_register_factory(librdf_storage_factory *factory);



/* functions implementing storage api */
static int
librdf_storage_tstore_init(librdf_storage* storage, const char *name,
                           librdf_hash* options)
{
  librdf_storage_tstore_context *context=(librdf_storage_tstore_context*)storage->context;
  
  context->host=librdf_hash_get_del(options, "host");
  context->db=librdf_hash_get_del(options, "database");
  context->user=librdf_hash_get_del(options, "user");
  context->password=librdf_hash_get_del(options, "password");
  context->model=librdf_hash_get_del(options, "model");

  /* no more options, might as well free them now */
  if(options)
    librdf_free_hash(options);

  return 0;
}


static void
librdf_storage_tstore_terminate(librdf_storage* storage)
{
  /* nop */  
}



static int
librdf_storage_tstore_open(librdf_storage* storage, librdf_model* model)
{
  librdf_storage_tstore_context *context=(librdf_storage_tstore_context*)storage->context;

  if(context->host)
    context->rdfsql=rs_connect_remote(context->host,
                                      context->db, context->user, 
                                      context->password, context->model);
  else
    context->rdfsql=rs_connect(context->db, context->user, 
                               context->password, context->model);
  if(!context->rdfsql)
    return 1;

  return 0;
}


/**
 * librdf_storage_tstore_close:
 * @storage: the storage
 *
 * .
 * 
 * Close the storage list storage, and free all content since there is no 
 * persistance.
 * 
 * Return value: non 0 on failure
 **/
static int
librdf_storage_tstore_close(librdf_storage* storage)
{
  /* librdf_storage_tstore_context* context=(librdf_storage_tstore_context*)storage->context; */

  return 0;
}


static int
librdf_storage_tstore_size(librdf_storage* storage)
{
  return -1;
}


static int
librdf_storage_tstore_add_statement(librdf_storage* storage, librdf_statement* statement)
{
  /* FIXME - cannot check for adding duplicate statements */

  return librdf_storage_tstore_context_add_statement(storage, NULL, statement);
}



static int
librdf_storage_tstore_remove_statement(librdf_storage* storage, librdf_statement* statement)
{
  return librdf_storage_tstore_context_remove_statement(storage, NULL, statement);
}


static int
librdf_storage_tstore_contains_statement(librdf_storage* storage, librdf_statement* statement)
{
  /*librdf_storage_tstore_context* context=(librdf_storage_tstore_context*)storage->context; */
  /* FIXME */
  return 0;
}


static librdf_statement*
librdf_storage_tstore_statement_from_rs_triple(librdf_world* world,
                                               rs_triple *triple)
{
  librdf_node *subject_node;
  librdf_node *predicate_node;
  librdf_node *object_node;

  if(triple->subject) {
    if(!strncmp(triple->subject, "_:",2))
      subject_node=librdf_new_node_from_blank_identifier(world, 
                                                         (const unsigned char *)triple->subject+2);
    else
      subject_node=librdf_new_node_from_uri_string(world, 
                                                   (const unsigned char *)triple->subject);

    if(!subject_node)
      return NULL;

  } else
    subject_node=NULL;
  
  if(triple->predicate) {
    predicate_node=librdf_new_node_from_uri_string(world,
                                                   (const unsigned char *)triple->predicate);

    if(!predicate_node) {
      librdf_free_node(subject_node);
      return NULL;
    }
  } else
    predicate_node=NULL;
  
  if(triple->object) {
    if(triple->literal)
      object_node=librdf_new_node_from_typed_literal(world, 
                                                     (const unsigned char *)triple->object,
                                                     NULL, NULL);
    else if(!strncmp(triple->object, ":", 2))
      object_node=librdf_new_node_from_blank_identifier(world, 
                                                        (const unsigned char *)triple->object+2);
    else
      object_node=librdf_new_node_from_uri_string(world, 
                                                  (const unsigned char *)triple->object);

    if(!object_node) {
      librdf_free_node(subject_node);
      librdf_free_node(predicate_node);
      return NULL;
    }
  } else
    object_node=NULL;  
  
  return librdf_new_statement_from_nodes(world, subject_node, predicate_node, object_node);
}


/* FIXME returns an alloced triple pointing to shared strings */
static rs_triple*
librdf_storage_tstore_statement_as_rs_triple(librdf_statement *statement)
{
  librdf_node *subject_node=statement->subject;
  librdf_node *predicate_node=statement->predicate;
  librdf_node *object_node=statement->object;
  rs_triple* triple=LIBRDF_MALLOC(rs_triple, sizeof(rs_triple));

  if(subject_node) {
    if(librdf_node_is_blank(subject_node))
      triple->subject=(char*)librdf_node_get_blank_identifier(subject_node);
    else
      triple->subject=(char*)librdf_uri_as_string(librdf_node_get_uri(subject_node));
  } else
    triple->subject=NULL;

  if(predicate_node)
    triple->predicate=(char*)librdf_uri_as_string(librdf_node_get_uri(predicate_node));
  else
    triple->predicate=NULL;
  
  /* Assumptions - FIXME */
  triple->literal = 0;
  if(object_node) {
    if(librdf_node_is_literal(object_node)) {
      triple->object=(char*)librdf_node_get_literal_value(object_node);
      triple->literal = 1;
    } else if(librdf_node_is_blank(object_node)) {
      triple->object=(char*)librdf_node_get_blank_identifier(object_node);
    } else {
      triple->object=(char*)librdf_uri_as_string(librdf_node_get_uri(object_node));
    }
  } else
    triple->object=NULL;
  
  return triple;
}


typedef struct {
  librdf_storage* storage;
  rs_result *result;
  rs_triple *triple;
} librdf_storage_tstore_serialise_stream_context;


static librdf_stream*
librdf_storage_tstore_serialise(librdf_storage* storage)
{
  librdf_storage_tstore_context* context=(librdf_storage_tstore_context*)storage->context;
  librdf_storage_tstore_serialise_stream_context* scontext;
  librdf_stream* stream;
  
  scontext=(librdf_storage_tstore_serialise_stream_context*)LIBRDF_CALLOC(librdf_storage_tstore_serialise_stream_context, 1, sizeof(librdf_storage_tstore_serialise_stream_context));
  if(!scontext)
    return NULL;
  
  scontext->storage=storage;
  librdf_storage_add_reference(scontext->storage);

  scontext->result=rs_find_all_resources(context->rdfsql, 0, context->model);
  if(!scontext->result)
    /* empty */
    scontext->triple=NULL;
  else
    scontext->triple=rs_next_triple(scontext->result);

  stream=librdf_new_stream(storage->world,
                           (void*)scontext,
                           &librdf_storage_tstore_serialise_end_of_stream,
                           &librdf_storage_tstore_serialise_next_statement,
                           &librdf_storage_tstore_serialise_get_statement,
                           &librdf_storage_tstore_serialise_finished);
  if(!stream) {
    librdf_storage_tstore_serialise_finished((void*)scontext);
    return NULL;
  }
  
  return stream;  
}


static int
librdf_storage_tstore_serialise_end_of_stream(void* context)
{
  librdf_storage_tstore_serialise_stream_context* scontext=(librdf_storage_tstore_serialise_stream_context*)context;

  return scontext->triple == NULL;

}

static int
librdf_storage_tstore_serialise_next_statement(void* context)
{
  librdf_storage_tstore_serialise_stream_context* scontext=(librdf_storage_tstore_serialise_stream_context*)context;

  if(!scontext->triple)
    return 1;

  scontext->triple=rs_next_triple(scontext->result);

  return scontext->triple == NULL;
}


static void*
librdf_storage_tstore_serialise_get_statement(void* context, int flags)
{
  librdf_storage_tstore_serialise_stream_context* scontext=(librdf_storage_tstore_serialise_stream_context*)context;

  switch(flags) {
    case LIBRDF_ITERATOR_GET_METHOD_GET_OBJECT:
      {
        librdf_statement* statement=librdf_storage_tstore_statement_from_rs_triple(scontext->storage->world, scontext->triple);
        return statement;
      }
    case LIBRDF_ITERATOR_GET_METHOD_GET_CONTEXT:
      return NULL;
    default:
      librdf_log(scontext->storage->world,
                 0, LIBRDF_LOG_ERROR, LIBRDF_FROM_STORAGE, NULL,
                 "Unknown iterator method flag %d", flags);
      return NULL;
  }
}


static void
librdf_storage_tstore_serialise_finished(void* context)
{
  librdf_storage_tstore_serialise_stream_context* scontext=(librdf_storage_tstore_serialise_stream_context*)context;

  if(scontext->triple) {
    /* The docs say about rs_find_triples:[[
     *   NB Once rs_find_triples has been called, all the triples
     *   /must/ be fetched with rs_next_triple(), even if they are
     *   not required.
     * ]]
     * but let's assume it applies to rs_find_all_resources
     */
    while(rs_next_triple(scontext->result))
      ;
  }

  if(scontext->result)
    rs_free_result(scontext->result);

  if(scontext->storage)
    librdf_storage_remove_reference(scontext->storage);

  LIBRDF_FREE(librdf_storage_tstore_serialise_stream_context, scontext);
}


typedef struct {
  librdf_storage* storage;
  rs_result *result;
  rs_triple *triple;
  rs_triple *search_triple;
} librdf_storage_tstore_find_stream_context;


/**
 * librdf_storage_tstore_find_statements:
 * @storage: the storage
 * @statement: the statement to match
 *
 * .
 * 
 * Return a stream of statements matching the given statement (or
 * all statements if NULL).  Parts (subject, predicate, object) of the
 * statement can be empty in which case any statement part will match that.
 * Uses #librdf_statement_match to do the matching.
 * 
 * Return value: a #librdf_stream or NULL on failure
 **/
static librdf_stream*
librdf_storage_tstore_find_statements(librdf_storage* storage, librdf_statement* statement)
{
  librdf_storage_tstore_context* context=(librdf_storage_tstore_context*)storage->context;
  librdf_storage_tstore_find_stream_context* scontext;
  librdf_stream* stream;
  rs_triple* triple;
  rs_obj_type type;

  statement=librdf_new_statement_from_statement(statement);
  if(!statement)
    return NULL;

  scontext=(librdf_storage_tstore_find_stream_context*)LIBRDF_CALLOC(librdf_storage_tstore_find_stream_context, 1, sizeof(librdf_storage_tstore_find_stream_context));
  if(!scontext)
    return NULL;
  
  scontext->storage=storage;
  librdf_storage_add_reference(scontext->storage);

  triple=librdf_storage_tstore_statement_as_rs_triple(statement);
  scontext->search_triple=triple;

  if(triple->object)
    type=(triple->literal ? ObjLiteral: ObjURI);
  else
    type=ObjAny;

  scontext->result=rs_find_triples(context->rdfsql,
                                   triple->subject, 
                                   triple->predicate,
                                   triple->object,
                                   type,
                                   0, 
                                   context->model);
  if(!scontext->result)
    /* empty */
    scontext->triple=NULL;
  else
    scontext->triple=rs_next_triple(scontext->result);

  stream=librdf_new_stream(storage->world,
                           (void*)scontext,
                           &librdf_storage_tstore_find_end_of_stream,
                           &librdf_storage_tstore_find_next_statement,
                           &librdf_storage_tstore_find_get_statement,
                           &librdf_storage_tstore_find_finished);
  if(!stream) {
    librdf_storage_tstore_find_finished((void*)scontext);
    return NULL;
  }
  
  return stream;  

}


static int
librdf_storage_tstore_find_end_of_stream(void* context)
{
  librdf_storage_tstore_find_stream_context* scontext=(librdf_storage_tstore_find_stream_context*)context;

  return scontext->triple == NULL;

}

static int
librdf_storage_tstore_find_next_statement(void* context)
{
  librdf_storage_tstore_find_stream_context* scontext=(librdf_storage_tstore_find_stream_context*)context;

  if(!scontext->triple)
    return 1;

  scontext->triple=rs_next_triple(scontext->result);

  return scontext->triple == NULL;
}


static void*
librdf_storage_tstore_find_get_statement(void* context, int flags)
{
  librdf_storage_tstore_find_stream_context* scontext=(librdf_storage_tstore_find_stream_context*)context;

  switch(flags) {
    case LIBRDF_ITERATOR_GET_METHOD_GET_OBJECT:
      {
        librdf_statement* statement=librdf_storage_tstore_statement_from_rs_triple(scontext->storage->world, scontext->triple);
        return statement;
      }
    case LIBRDF_ITERATOR_GET_METHOD_GET_CONTEXT:
      return NULL;
    default:
      librdf_log(scontext->storage->world,
                 0, LIBRDF_LOG_ERROR, LIBRDF_FROM_STORAGE, NULL,
                 "Unknown iterator method flag %d", flags);
      return NULL;
  }
}


static void
librdf_storage_tstore_find_finished(void* context)
{
  librdf_storage_tstore_find_stream_context* scontext=(librdf_storage_tstore_find_stream_context*)context;

  if(scontext->triple) {
    /* The docs say about rs_find_triples:[[
     *   NB Once rs_find_triples has been called, all the triples
     *   /must/ be fetched with rs_next_triple(), even if they are
     *   not required.
     * ]]
     */
    while(rs_next_triple(scontext->result))
      ;
  }

  if(scontext->result)
    rs_free_result(scontext->result);


  /* FIXME: as alloced in librdf_storage_tstore_statement_as_rs_triple */
  if(scontext->search_triple)
    LIBRDF_FREE(rs_triple, scontext->search_triple);

  if(scontext->storage)
    librdf_storage_remove_reference(scontext->storage);

  LIBRDF_FREE(librdf_storage_tstore_find_stream_context, scontext);
}

/**
 * librdf_storage_tstore_context_add_statement:
 * @storage: #librdf_storage object
 * @context_node: #librdf_node object
 * @statement: #librdf_statement statement to add
 *
 * Add a statement to a storage context.
 * 
 * Return value: non 0 on failure
 **/
static int
librdf_storage_tstore_context_add_statement(librdf_storage* storage,
                                            librdf_node* context_node,
                                            librdf_statement* statement) 
{
  librdf_storage_tstore_context* context=(librdf_storage_tstore_context*)storage->context;
  librdf_node *subject_node=statement->subject;
  librdf_node *predicate_node=statement->predicate;
  librdf_node *object_node=statement->object;
  char *subject;
  char *predicate;
  char *object;
  rs_obj_type type;

  
  if(librdf_node_is_blank(subject_node)) {
    subject=(char*)librdf_node_get_blank_identifier(subject_node);
  } else
    subject=(char*)librdf_uri_as_string(librdf_node_get_uri(subject_node));
  

  predicate=(char*)librdf_uri_as_string(librdf_node_get_uri(predicate_node));
  
  /* Assumptions - FIXME */
  if(librdf_node_is_literal(object_node)) {
    object=(char*)librdf_node_get_literal_value(object_node);
    type = ObjLiteral;
  } else if(librdf_node_is_blank(object_node)) {
    object=(char*)librdf_node_get_blank_identifier(object_node);
    type = ObjURI;
  } else {
    object=(char*)librdf_uri_as_string(librdf_node_get_uri(object_node));
    type = ObjURI;
  }
  

  if(rs_assert_triple(context->rdfsql, subject, predicate, object, type))
    return 1;

  return 0;
}


/**
 * librdf_storage_tstore_context_remove_statement:
 * @storage: #librdf_storage object
 * @context_node: #librdf_node object
 * @statement: #librdf_statement statement to remove
 *
 * Remove a statement from a storage context.
 * 
 * Return value: non 0 on failure
 **/
static int
librdf_storage_tstore_context_remove_statement(librdf_storage* storage, 
                                             librdf_node* context_node,
                                             librdf_statement* statement) 
{
  /* librdf_storage_tstore_context* context=(librdf_storage_tstore_context*)storage->context; */

  /* FIXME */

  return 0;
}


typedef struct {
  librdf_iterator* iterator;
  librdf_hash_datum *key;
  librdf_hash_datum *value;
  librdf_statement current; /* static, shared statement */
} librdf_storage_tstore_context_serialise_stream_context;


/**
 * librdf_storage_tstore_context_serialise:
 * @storage: #librdf_storage object
 * @context_node: #librdf_node object
 *
 * List all statements in a storage context.
 * 
 * Return value: #librdf_stream of statements or NULL on failure or context is empty
 **/
static librdf_stream*
librdf_storage_tstore_context_serialise(librdf_storage* storage,
                                      librdf_node* context_node) 
{
  return NULL;
}


#if 0
static int
librdf_storage_tstore_context_serialise_end_of_stream(void* context)
{
  /* librdf_storage_tstore_context_serialise_stream_context* scontext=(librdf_storage_tstore_context_serialise_stream_context*)context; */

  return 1;
}


static int
librdf_storage_tstore_context_serialise_next_statement(void* context)
{
  /* librdf_storage_tstore_context_serialise_stream_context* scontext=(librdf_storage_tstore_context_serialise_stream_context*)context; */

  return 1;
}


static void*
librdf_storage_tstore_context_serialise_get_statement(void* context, int flags)
{
  /* librdf_storage_tstore_context_serialise_stream_context* scontext=(librdf_storage_tstore_context_serialise_stream_context*)context; */
  
  return NULL;
}


static void
librdf_storage_tstore_context_serialise_finished(void* context)
{
  librdf_storage_tstore_context_serialise_stream_context* scontext=(librdf_storage_tstore_context_serialise_stream_context*)context;
  
  LIBRDF_FREE(librdf_storage_tstore_context_serialise_stream_context, scontext);
}
#endif


/* local function to register list storage functions */

static void
librdf_storage_tstore_register_factory(librdf_storage_factory *factory) 
{
  factory->context_length     = sizeof(librdf_storage_tstore_context);
  
  factory->init               = librdf_storage_tstore_init;
  factory->terminate          = librdf_storage_tstore_terminate;
  factory->open               = librdf_storage_tstore_open;
  factory->close              = librdf_storage_tstore_close;
  factory->size               = librdf_storage_tstore_size;
  factory->add_statement      = librdf_storage_tstore_add_statement;
  factory->remove_statement   = librdf_storage_tstore_remove_statement;
  factory->contains_statement = librdf_storage_tstore_contains_statement;
  factory->serialise          = librdf_storage_tstore_serialise;
  factory->find_statements    = librdf_storage_tstore_find_statements;
  factory->context_add_statement    = librdf_storage_tstore_context_add_statement;
  factory->context_remove_statement = librdf_storage_tstore_context_remove_statement;
  factory->context_serialise        = librdf_storage_tstore_context_serialise;
}


/**
 * librdf_init_storage_tstore:
 * @world: world object
 * 
 * INTERNAL - initialise the storage_tstore module.
 **/
void
librdf_init_storage_tstore(librdf_world *world)
{
  librdf_storage_register_factory(world, "tstore", "AKT triplestore",
                                  &librdf_storage_tstore_register_factory);
}