break;
case OSL_MAPPED_STORAGE:
t->num_mapped_columns++;
- col->index_offset = t->index_entry_size;
- t->index_entry_size += 8;
+ col->index_offset = t->row_index_size;
+ t->row_index_size += 8;
break;
case OSL_NO_STORAGE:
col->volatile_num = t->num_volatile_columns;
if (!t->num_rbtrees)
goto err;
/* success */
- PARA_DEBUG_LOG("OK. Index entry size: %u\n", t->index_entry_size);
+ PARA_DEBUG_LOG("OK. Index entry size: %u\n", t->row_index_size);
ret = init_column_descriptions(t);
if (ret < 0)
goto err;
struct osl_column *col = &t->columns[col_num];
uint32_t offset;
char *header;
- char *index_entry;
+ char *cell_index;
int ret;
if (t->num_rows <= row_num)
return -E_BAD_ID;
- ret = get_index_entry(t, row_num, col_num, &index_entry);
+ ret = get_cell_index(t, row_num, col_num, &cell_index);
if (ret < 0)
return ret;
- offset = read_u32(index_entry);
- obj->size = read_u32(index_entry + 4) - 1;
+ offset = read_u32(cell_index);
+ obj->size = read_u32(cell_index + 4) - 1;
header = col->data_map.data + offset;
obj->data = header + 1;
if (read_u8(header) == 0xff) {
*/
int row_is_invalid(struct osl_table *t, uint32_t row_num)
{
- char *index_entry;
- int i, ret = get_index_entry_start(t, row_num, &index_entry);
+ char *row_index;
+ int i, ret = get_row_index(t, row_num, &row_index);
if (ret < 0)
return ret;
- for (i = 0; i < t->index_entry_size; i++) {
- if ((unsigned char)index_entry[i] != 0xff)
+ for (i = 0; i < t->row_index_size; i++) {
+ if ((unsigned char)row_index[i] != 0xff)
return 0;
}
PARA_INFO_LOG("row %d is invalid\n", row_num);
*/
int mark_row_invalid(struct osl_table *t, uint32_t row_num)
{
- char *index_entry;
- int i, ret = get_index_entry_start(t, row_num, &index_entry);
+ char *row_index;
+ int ret = get_row_index(t, row_num, &row_index);
- PARA_INFO_LOG("marking row %d as invalid\n", row_num);
if (ret < 0)
return ret;
- for (i = 0; i < t->index_entry_size; i++)
- index_entry[i] = 0xff;
+ PARA_INFO_LOG("marking row %d as invalid\n", row_num);
+ memset(row_index, 0xff, t->row_index_size);
return 1;
}
return ret;
}
-static int append_index_entry(const struct osl_table *t, char *new_index_entry)
+static int append_row_index(const struct osl_table *t, char *row_index)
{
char *filename;
int ret;
if (!t->num_mapped_columns)
return 1;
filename = index_filename(t->desc);
-// PARA_DEBUG_LOG("appending %u bytes\n", t->index_entry_size);
- ret = append_file(filename, NULL, 0, new_index_entry,
- t->index_entry_size, NULL);
+ ret = append_file(filename, NULL, 0, row_index,
+ t->row_index_size, NULL);
free(filename);
return ret;
}
int i, ret;
char *ds_name = NULL;
struct rb_node **rb_parents = NULL, ***rb_links = NULL;
- char *new_index_entry = NULL;
+ char *new_row_index = NULL;
struct osl_object *volatile_objs = NULL;
const struct osl_column_description *cd;
rb_parents = para_malloc(t->num_rbtrees * sizeof(struct rn_node*));
rb_links = para_malloc(t->num_rbtrees * sizeof(struct rn_node**));
if (t->num_mapped_columns)
- new_index_entry = para_malloc(t->index_entry_size);
+ new_row_index = para_malloc(t->row_index_size);
/* pass 1: sanity checks */
// PARA_DEBUG_LOG("sanity tests: %p:%p\n", objects[0].data,
// objects[1].data);
ret = append_map_file(t, i, objects + i, &new_size);
if (ret < 0)
goto rollback;
- update_index_entry(new_index_entry, col, new_size,
+ update_cell_index(new_row_index, col, new_size,
objects[i].size);
continue;
}
if (ret < 0)
goto rollback;
}
- ret = append_index_entry(t, new_index_entry);
+ ret = append_row_index(t, new_row_index);
if (ret < 0)
goto rollback;
ret = map_table(t, MAP_TBL_FL_VERIFY_INDEX);
if (ret < 0) { /* truncate index and rollback changes */
char *filename = index_filename(t->desc);
- para_truncate(filename, t->index_entry_size);
+ para_truncate(filename, t->row_index_size);
free(filename);
goto rollback;
}
/* ignore error and return previous error value */
map_table(t, MAP_TBL_FL_VERIFY_INDEX);
out:
- free(new_index_entry);
+ free(new_row_index);
free(ds_name);
free(rb_parents);
free(rb_links);
memcpy(old_obj.data, obj->data, cd->data_size);
else { /* TODO: if the size doesn't change, use old space */
uint32_t new_data_map_size;
- char *index_entry;
- ret = get_index_entry_start(t, r->id, &index_entry);
+ char *row_index;
+ ret = get_row_index(t, r->id, &row_index);
if (ret < 0)
return ret;
ret = mark_mapped_object_invalid(t, r->id, col_num);
ret = map_column(t, col_num);
if (ret < 0)
return ret;
- update_index_entry(index_entry, col, new_data_map_size,
+ update_cell_index(row_index, col, new_data_map_size,
obj->size);
}
}
*/
unsigned disk_storage_name_column;
/** The number of bytes of an index entry of a row. */
- unsigned index_entry_size;
+ unsigned row_index_size;
/** Pointer to the internal representation of the columns. */
struct osl_column *columns;
};
_static_inline_ unsigned table_num_rows(const struct osl_table *t)
{
return (t->index_map.size - t->index_header_size)
- / t->index_entry_size;
+ / t->row_index_size;
}
/**
*
* \param t Pointer to a table which has been mapped.
* \param row_num The number of the row whose index entry should be retrieved.
- * \param index_entry Result is returned here.
+ * \param row_index Result pointer.
*
* \return Positive on success, \p -E_INDEX_CORRUPTION otherwise.
*
- * \sa get_index_entry().
+ * \sa get_cell_index().
*/
-_static_inline_ int get_index_entry_start(const struct osl_table *t, uint32_t row_num,
- char **index_entry)
+_static_inline_ int get_row_index(const struct osl_table *t, uint32_t row_num,
+ char **row_index)
{
uint32_t index_offset;
- index_offset = t->index_header_size + t->index_entry_size * row_num;
+ index_offset = t->index_header_size + t->row_index_size * row_num;
if (index_offset + 8 > t->index_map.size) {
- *index_entry = NULL;
+ *row_index = NULL;
return -E_INDEX_CORRUPTION;
}
- *index_entry = (char *)(t->index_map.data) + index_offset;
+ *row_index = (char *)(t->index_map.data) + index_offset;
return 1;
}
* \param t Pointer to a table which has been mapped.
* \param row_num The number of the row whose index entry should be retrieved.
* \param col_num The number of the column whose index entry should be retrieved.
- * \param index_entry Result pointer.
+ * \param cell_index Result pointer.
*
* \return Positive on success, \p -E_INDEX_CORRUPTION otherwise.
*
- * \sa get_index_entry_start().
+ * \sa get_row_index().
*/
-_static_inline_ int get_index_entry(const struct osl_table *t, uint32_t row_num,
- uint32_t col_num, char **index_entry)
+_static_inline_ int get_cell_index(const struct osl_table *t, uint32_t row_num,
+ uint32_t col_num, char **cell_index)
{
- int ret = get_index_entry_start(t, row_num, index_entry);
+ int ret = get_row_index(t, row_num, cell_index);
if (ret < 0)
return ret;
- *index_entry += t->columns[col_num].index_offset;
+ *cell_index += t->columns[col_num].index_offset;
return ret;
}
/**
* Change an index entry of a column after object was added.
*
- * \param index_entry_start This determines the row.
+ * \param row_index Pointer to the index of the row to update.
* \param col Pointer to the column.
* \param map_size The new size of the data file.
* \param object_size The size of the object just appended to the data file.
* This is called right after an object was appended to the data file for a
* mapped column.
*
- * \sa get_index_entry_start().
+ * \sa get_row_index().
*/
-_static_inline_ void update_index_entry(char *index_entry_start, struct osl_column *col,
+_static_inline_ void update_cell_index(char *row_index, struct osl_column *col,
uint32_t map_size, uint32_t object_size)
{
- write_u32(index_entry_start + col->index_offset, map_size - object_size - 1);
- write_u32(index_entry_start + col->index_offset + 4, object_size + 1);
+ write_u32(row_index + col->index_offset, map_size - object_size - 1);
+ write_u32(row_index + col->index_offset + 4, object_size + 1);
}
/**