#include <string.h>
#include <fcntl.h>
#include <pthread.h>
+#include <time.h>
#include "result.h"
#include "db_options.h"
int offset = 0;
db_result_t result;
uint8_t success = 0;
+ int curtime;
+ curtime = time(NULL);
+ random_init(curtime);
tree_t *tree = malloc(sizeof(tree_t));
if (tree == NULL) {
DB_LOG_E("DB: Failed to allocate a tree\n");
{
tree_t *tree;
long long_key;
- qnode_t *tmp_node;
tree = (tree_t *)index->opaque_data;
long_key = db_value_to_long(key);
DB_LOG_E("DB: Failed to insert key %ld into a bplus-tree index\n", long_key);
return DB_INDEX_ERROR;
}
+
+ /***************************************************************************************
+ * The following code is to implement write through caching structure.
+ * The write back cache gives better performance as compared to write through cache
+ * and write back is preferred.
+ ***************************************************************************************/
+#ifdef DB_WIP
+ qnode_t *tmp_node;
storage_write_to(tree->tree_storage, tree, 0, sizeof(tree_t));
/* Bucket Cache being flushed */
+
tmp_node = tree->buck_cache->in_cache.head->next;
while (tmp_node != tree->buck_cache->in_cache.tail) {
if ((tmp_node->node_state & NODE_STATE_DIRTY) && (tmp_node->node_state & NODE_STATE_VALID)) {
}
tmp_node = tmp_node->next;
}
-
+#endif
return DB_OK;
}
}
}
list_remove(indices, index);
- res = storage_remove(index->descriptor_file);
- if (DB_ERROR(res)) {
- return res;
+ if (index->descriptor_file[0] != '\0') {
+ res = storage_remove(index->descriptor_file);
+ if (DB_ERROR(res)) {
+ return res;
+ }
}
if (DB_ERROR(storage_remove_index(index->rel, index->attr))) {
return DB_STORAGE_ERROR;
if ((iterator->index->attr->flags & ATTRIBUTE_FLAG_UNIQUE) && iterator->next_item_no == 1) {
min = db_value_to_long(&iterator->min_value);
max = db_value_to_long(&iterator->max_value);
- printf("%d\n", __LINE__);
- sleep(1);
if (min == max) {
/*
* We stop if this is an equivalence search on an attribute
DB_LOG_E("DB: Failed to allocate row\n");
return DB_ALLOCATION_ERROR;
}
-
+#ifdef CONFIG_ARASTORAGE_ENABLE_WRITE_BUFFER
+ storage_flush_insert_buffer();
+#endif
DB_LOG_D("DB: Loading the index for %s.%s...\n", index->rel->name, index->attr->name);
offset = 0;
for (tuple_id = 0; tuple_id < cardinality; tuple_id++) {
memset(row, 0, sizeof(row));
+ DB_LOG_V("DB: Indexing Tuple id %d\n",tuple_id);
result = storage_get_row(rel, &tuple_id, row);
if (DB_ERROR(result)) {
DB_LOG_E("DB: Failed to get a row in relation %s!\n", rel->name);
goto errout;
}
- row += offset;
- result = db_phy_to_value(&value, index->attr, row);
+ result = db_phy_to_value(&value, index->attr, row + offset);
if (DB_ERROR(result)) {
DB_LOG_E("DB: Failed to get value from row\n");
goto errout;