You are viewing a plain text version of this content. The canonical link for it is here.
Posted to triplesoup-commits@incubator.apache.org by le...@apache.org on 2007/04/13 16:13:59 UTC
svn commit: r528543 - in /incubator/triplesoup/code/trunk/libraries/b: b.h
b_internal.h
Author: leosimons
Date: Fri Apr 13 09:13:57 2007
New Revision: 528543
URL: http://svn.apache.org/viewvc?view=rev&rev=528543
Log:
Merge relevant parts of revisions r528519 and r528537 (updates to the libb
contribution) into code/trunk (commit r528542 left out the header files).
Modified:
incubator/triplesoup/code/trunk/libraries/b/b.h
incubator/triplesoup/code/trunk/libraries/b/b_internal.h
Modified: incubator/triplesoup/code/trunk/libraries/b/b.h
URL: http://svn.apache.org/viewvc/incubator/triplesoup/code/trunk/libraries/b/b.h?view=diff&rev=528543&r1=528542&r2=528543
==============================================================================
--- incubator/triplesoup/code/trunk/libraries/b/b.h (original)
+++ incubator/triplesoup/code/trunk/libraries/b/b.h Fri Apr 13 09:13:57 2007
@@ -1,10 +1,17 @@
-/* (c) 2007 Satis Superque Merce B.V. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#ifndef __B_H__
@@ -15,15 +22,15 @@
#include <string.h>
#ifndef WIN32
-#include <sys/mman.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/time.h>
+# include <sys/mman.h>
+# include <unistd.h>
+# include <errno.h>
+# include <sys/time.h>
#else
-#include <Windows.h>
-#include <Winbase.h>
-#include <Winsock2.h>
-#include <sys/timeb.h>
+# include <Windows.h>
+# include <Winbase.h>
+# include <Winsock2.h>
+# include <sys/timeb.h>
#endif
#include <sys/types.h>
@@ -36,7 +43,7 @@
/**
* b_t:
*
- * The principal data struct. You must have 1 for any B storage.
+ * The principal data struct. You must have one of this for any B storage.
**/
typedef struct b_t b_t;
@@ -98,7 +105,8 @@
*
* The list of errors for this library.
**/
-typedef enum {
+typedef enum
+{
B_OK = 0,
B_ERROR_MEMORY,
@@ -120,7 +128,8 @@
*
* The types of simple elements.
*/
-typedef enum {
+typedef enum
+{
B_TYPE_URI,
B_TYPE_PROPERTY,
B_TYPE_LITERAL,
@@ -152,7 +161,8 @@
*
* This struct describes a RDF triple.
*/
-typedef struct {
+typedef struct
+{
unsigned char * subject_uri;
b_uint64 subject_uri_len;
@@ -180,6 +190,8 @@
unsigned char * lang;
b_uint64 lang_len;
} b_triple_t;
+
+/* List of functions */
b_error_t b_new (b_t ** data,
unsigned char * path);
Modified: incubator/triplesoup/code/trunk/libraries/b/b_internal.h
URL: http://svn.apache.org/viewvc/incubator/triplesoup/code/trunk/libraries/b/b_internal.h?view=diff&rev=528543&r1=528542&r2=528543
==============================================================================
--- incubator/triplesoup/code/trunk/libraries/b/b_internal.h (original)
+++ incubator/triplesoup/code/trunk/libraries/b/b_internal.h Fri Apr 13 09:13:57 2007
@@ -1,10 +1,17 @@
-/* (c) 2007 Satis Superque Merce B.V. All rights reserved.
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#ifndef __B_INTERNAL_H__
@@ -17,6 +24,7 @@
#define B_PATH_CONTEXTS_DATA "_contexts.data"
#define B_PATH_DATATYPES_DATA "_datatypes.data"
#define B_PATH_TRIPLES_DATA "_triples.data"
+#define B_PATH_JOURNALING_DATA ".journaling"
#define B_HASH_SIZE 16
#define B_TRIPLE_SIZE (sizeof(b_tmap_item_t) * 9)
@@ -130,7 +138,8 @@
b_uint64 size,
void * data);
-struct b_cache_t {
+struct b_cache_t
+{
unsigned char hash[B_HASH_SIZE];
unsigned char * what;
@@ -139,7 +148,8 @@
b_uint64 pointer;
};
-struct b_tcache_t {
+struct b_tcache_t
+{
b_uint64 tmap_pointer;
unsigned char tmap_index;
@@ -161,7 +171,8 @@
b_tcache_t * next;
};
-struct b_t {
+struct b_t
+{
b_uint64 max_cache;
b_hash_t * hashes_cache;
@@ -181,9 +192,13 @@
b_tempty_t * triples_empty;
b_uint64 triples_empty_size;
+
+ unsigned char * journaling_file;
+ b_io_t * journaling_io;
};
-struct b_hash_t {
+struct b_hash_t
+{
unsigned char hash[B_HASH_SIZE];
unsigned char * what;
b_uint64 len;
@@ -192,7 +207,8 @@
b_hash_t * prev;
};
-struct b_string_t {
+struct b_string_t
+{
unsigned char * string;
b_uint64 size;
@@ -202,7 +218,8 @@
b_int64 callback_ret;
};
-struct b_io_t {
+struct b_io_t
+{
void * fd;
b_uint64 size;
@@ -212,12 +229,14 @@
unsigned char *data;
};
-struct b_el_t {
+struct b_el_t
+{
b_tcache_t * cache;
b_el_t * next;
};
-struct b_iterator_type_t {
+struct b_iterator_type_t
+{
b_t * data;
b_type_t type;
@@ -227,7 +246,8 @@
b_uint64 pointer;
};
-struct b_iterator_compare_t {
+struct b_iterator_compare_t
+{
char subject_uri_exists;
unsigned char subject_uri[B_HASH_SIZE];
char subject_bnode_exists;
@@ -252,7 +272,8 @@
unsigned char lang[B_HASH_SIZE];
};
-struct b_iterator_triple_t {
+struct b_iterator_triple_t
+{
b_t * data;
char status;
b_iterator_compare_t *compare;
@@ -261,9 +282,10 @@
b_el_t * results;
};
-struct b_map_t {
+struct b_map_t
+{
/* This 2 elements must be in the top: */
- unsigned char hash[16];
+ unsigned char hash[B_HASH_SIZE];
b_uint64 len;
/* how many triples linked with this item? */
@@ -274,18 +296,21 @@
b_uint64 parent;
};
-struct b_timer_t {
+struct b_timer_t
+{
struct timeval start;
struct timeval stop;
char stopped;
};
-struct b_tempty_t {
+struct b_tempty_t
+{
b_uint64 pointer;
b_tempty_t * next;
};
-struct b_tmap_t {
+struct b_tmap_t
+{
/* Maybe tomorrow a single bit: */
unsigned char map[B_TMAP_NUMB];
@@ -304,11 +329,19 @@
unsigned char langs[B_TMAP_NUMB];
};
-struct b_tmap_item_t {
+struct b_tmap_item_t
+{
unsigned char hash[B_HASH_SIZE];
b_uint64 pointer;
};
+typedef enum
+{
+ B_JOURNALING_CACHE_EMPTY,
+ B_JOURNALING_END_WRITE,
+ B_JOURNALING_WRITE
+} b_journaling_type_t;
+
/* b_string: */
b_error_t b_string_new (b_string_t ** string);
@@ -416,7 +449,6 @@
b_error_t b_tcache_copy_easy (b_tcache_t * src,
b_tcache_t ** dest);
-/* copy: */
/* triple: */
b_error_t b_triple_check (b_triple_t * triple);
@@ -489,6 +521,25 @@
b_error_t b_remove_type_cache (b_t * data,
b_io_t * io,
b_cache_t * cache);
+
+/* journaling: */
+void b_journaling_new (b_t * data,
+ b_io_t * io,
+ b_journaling_type_t type,
+ ...);
+
+b_error_t b_journaling_recover (b_t * data);
+
+void b_journaling_destroy (b_t * data);
+
+/* b_el_t functions: */
+
+b_error_t b_el_new (b_tcache_t * cache,
+ b_el_t ** list);
+
+b_tcache_t * b_el_first (b_el_t ** list);
+
+void b_el_free (b_el_t ** list);
#endif