Exemplo n.º 1
0
// - Seems like an as_storage_record method, but leaving it here for now.
// - sets rd->bins!
// - for data-in-memory, assumes rd->n_bins is already set!
bool
as_bin_get_and_size_all(as_storage_rd *rd, as_bin *stack_bins)
{
	if (rd->ns->storage_data_in_memory) {
		rd->bins = rd->ns->single_bin ? as_index_get_single_bin(rd->r) :
				safe_bins(rd->r);

		if (! rd->bins) {
			// i.e. multi-bin when record just created.
			return true;
		}

		if (rd->ns->storage_type != AS_STORAGE_ENGINE_SSD) {
			// Not interested in calculating flat-sizing info.
			return true;
		}

		// Calculate starting values for rd->n_bins_to_write and
		// rd->particles_flat_size.

		uint16_t i;

		for (i = 0; i < rd->n_bins; i++) {
			as_bin *b = &rd->bins[i];

			if (! as_bin_inuse(b)) {
				// i.e. single-bin when record just created.
				break;
			}

			size_t flat_size;

			if (0 != as_particle_get_flat_size(b, &flat_size)) {
				return false;
			}

			rd->particles_flat_size += flat_size;
		}

		rd->n_bins_to_write = (uint32_t)i;

		return true;
	}

	// Data NOT in-memory.

	rd->bins = stack_bins;
	as_bin_set_all_empty(rd);

	if (rd->record_on_device && ! rd->ignore_record_on_device) {
		// Sets rd->n_bins_to_write and rd->particles_flat_size:
		if (0 != as_storage_particle_read_and_size_all_ssd(rd)) {
			return false;
		}
	}

	return true;
}
Exemplo n.º 2
0
as_bin *
as_bin_get_all(as_record *r, as_storage_rd *rd, as_bin *stack_bins)
{
	if (rd->ns->storage_data_in_memory) {
		return rd->ns->single_bin ? as_index_get_single_bin(r) : safe_bins(r);
	}

	rd->bins = stack_bins;
	as_bin_set_all_empty(rd);

	if (rd->record_on_device && ! rd->ignore_record_on_device) {
		as_storage_particle_read_all(rd);
	}

	return (stack_bins);
}
Exemplo n.º 3
0
// - Seems like an as_storage_record method, but leaving it here for now.
// - sets rd->bins!
int
as_storage_rd_load_bins(as_storage_rd *rd, as_bin *stack_bins)
{
	if (rd->ns->storage_data_in_memory) {
		rd->bins = rd->ns->single_bin ? as_index_get_single_bin(rd->r) :
				safe_bins(rd->r);
		return 0;
	}

	// Data NOT in-memory.

	rd->bins = stack_bins;
	as_bin_set_all_empty(rd);

	if (rd->record_on_device && ! rd->ignore_record_on_device) {
		int result = as_storage_particle_read_all_ssd(rd);

		if (result < 0) {
			return result;
		}
	}

	return 0;
}