blob: 1b1e085ed167ba0c779bd627752538c19c7f44b0 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "large_array_buffer_type.h"
#include "small_array_buffer_type.h"
namespace vespalib::datastore {
/**
* This class provides a 1-to-1 mapping between type ids and array sizes for small arrays in an array store.
*
* This means that buffers for type id 1 stores arrays of size 1, buffers for type id 2 stores arrays of size 2, and so on.
* Type id 0 is always reserved for large arrays allocated on the heap.
*
* A more complex mapping can be used by creating a custom mapper and BufferType implementations.
*/
template <typename EntryT>
class ArrayStoreTypeMapper {
public:
using SmallBufferType = SmallArrayBufferType<EntryT>;
using LargeBufferType = LargeArrayBufferType<EntryT>;
uint32_t get_type_id(size_t array_size) const { return array_size; }
size_t get_array_size(uint32_t type_id) const { return type_id; }
static uint32_t get_max_small_array_type_id(uint32_t max_small_array_type_id) noexcept { return max_small_array_type_id; }
};
}
|