System keyspace is used for things like keyspace and table metadata.
Initialize it in database constructor so that they're always available.
Needed for CQL create keyspace test case, for example.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
This adds a set_cell() variant which accepts a column name and a
boost::any value and does column definition lookup and decomposition
under the hood. Simplifies code that manipulates system tables directly
in db/legacy_schema_tables.cc.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
By the time being, compression info is the unique component being
written by store(). Changes introduced by this patch are generic,
so as to make it easier writing other components as well.
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Test sstable::data_read(pos, len), for both compressed and uncompressed
data files. We already have compressed and uncompressed sstables in our
test tree with identical data, we read from them in a particular position
and expect to find the string "gustaf" there.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
This patch implements sstable::data_read(pos, len) to do random-access
read of a specific byte range from the data file. Later we'll determine
the byte range needed to read a specific row, using the summary and index
files.
This function works for either a compressed or uncompressed data file.
To support the compressed data file, we need to determine when opening
the sstable also the data file's size, and then make a compression_metadata
object using the data we read from the compression file and the data
file's size.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
It turns out that Cassandra's LZ4Compressor doesn't use the LZ4
compressor directly - instead it prepends the uncompressed length,
in 4-byte little-endian (!) encoding, to the compressed chunk.
We don't need this extra information - we already know the expected
uncompressed chunk length, so we need to just skip it.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Move compress.{cc,hh} from db/ to sstables/. This makes more sense, as
this code is only used for sstables (un)compression.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Now that the code for sstable metadata is ready, we can read it when we are
loading the keyspaces.
At this moment, only the system tables are processed. This is because we will
require the schema to be already determined in order to properly read the
sstables. The system schema is known at compile time. The others will have to
be derived when we are able to read it from the system tables themselves.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
While reading the TOC, we are given a string and then transverse the components
map in the search of a key of that corresponding value. This behavior will also
be necessary when we are parsing the filename, for version and format.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
From Pekka:
This patch series adds support for _parsing_ CQL create table
statements. Changes to underlying schema are done by the migration
manager which is not implemented yet.
This patch adds compressed_file_input_stream, which is a
"random_access_reader" subclass just like the existing file_input_stream.
Changed all the parsers to take a reference to random_access_reader (the
base class) instead of file_input_stream.
The code is now ready (sort of) for compressed-file reading, but it doesn't
actually do that: sstable::read_simple() still always uses file_input_stream
for now.
Note: despite all the layers of classes holding our input streams, we
actually pay surprisingly little cost for virtual function calls or pointer
dereferencing: random_access_reader::read_exactly is *not* a virtual function -
it always calls _in.read_exactly(). This is input_stream::read_exactly(),
which again is not a virtual function (the rarely called get() is a virtual
function is virtual, but input_stream::read_exactly() usually just reads reads
from an already available buffer.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
This patch adds a make_compressed_file_input_stream - our futuristic version
of cassandra.io.compress.CompressedRandomAccessReader, and compression_metadata
(parallel of CompressionMetadata). It will allow us to read chunk-compressed
SSTable files.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Needed by the cf_prop_defs class to modify a schema object in the
apply_to_cf_metadata() function.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>