ID | name | |
---|---|---|
110 | "Foo" | "foo@foo.com" |
111 | "Bar" | "bar@bar.com" |
ID
x
y
y
x
Inverse function
ID | |
---|---|
110 | "foo@foo.com" |
111 | "bar@bar.com" |
ID | |
---|---|
"foo@foo.com" | 110 |
"bar@bar.com" | 111 |
ID | |
---|---|
110 | "foo@foo.com" |
111 | "bar@bar.com" |
ID | |
---|---|
"foo@foo.com" | 110 |
"bar@bar.com" | 111 |
Regular Index
Form Input
ID | name | |
---|---|---|
110 | "Foo" | "foo@foo.com" |
111 | "Bar" | "bar@bar.com" |
Regular index (key)
Secondary index (on column)
https://github.com/xedin/sasi
"Cassandra 3.4 and beyond" - Jon Haddad
cqlsh> CREATE KEYSPACE foo
WITH replication = {
'class': 'SimpleStrategy',
'replication_factor': '1'
};
cqlsh> USE foo;
CREATE TABLE bar (
id uuid, fname text,
lname text,
age int,
created_at bigint,
primary key (id))
WITH COMPACT STORAGE;
NOTE: COMPACT STORAGE IS MANDATORY!!11!!111 (at least until now)
CREATE CUSTOM INDEX ON bar (fname)
USING 'org.apache.cassandra.db.index.SSTableAttachedSecondaryIndex'
WITH OPTIONS = {
'analyzer_class':
'org.apache.cassandra.db.index.sasi.analyzer.NonTokenizingAnalyzer',
'case_sensitive': 'false'
};
https://github.com/xedin/sasi/blob/master/src/java/org/apache/cassandra/db/index/sasi/analyzer/StandardAnalyzer.java
CREATE CUSTOM INDEX ON bar (lname)
USING 'org.apache.cassandra.db.index.SSTableAttachedSecondaryIndex'
WITH OPTIONS = {'mode': 'SUFFIX'};
Analyses by suffix.
CREATE CUSTOM INDEX ON bar (created_at)
USING 'org.apache.cassandra.db.index.SSTableAttachedSecondaryIndex'
WITH OPTIONS = {'mode': 'SPARSE'};
Analyses ranges of time by timestamp
SASI builds it's data structures without messing up with Cassandra Architecture. It follows the flow of the events that happen at the SSTable.
SSTable
starts writing
SSTable
ends writing
SASI
creates structures in memory
flushes structures to disk
SASI
SSTableFlushObserver was added into Cassandra source code, to handle with SASI
CommitLog
CommitLog
CommitLog
MemTable
MemTable
Cassandra
IndexMemTable
SASI
IndexMemTable
SSTable
Indexed columns
Index files by SASI
MEMORY
OnDiskIndexBuilder
Indexed columns
Index files by SASI
MEMORY
OnDiskIndexBuilder
Disk
OnDiskIndex
Index files by SASI
Optimised data structures (List<ByteBuffer> and custom iterators)
Information o SSTable is turned into these structures
Index files by SASI
QueryPlan
Analysis
Execution
RangeUnionIterator
RangeIntersectionIterator
Questions?
hannelita@gmail.com
@hannelita
@planetcassandra
@datastax