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
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 (for a while)
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 takes advantage of Cassandra's Architecture to build a powerful set of data structure that manages information between memory and disk as well.
SSTable
starts writing
SSTable
ends writing
SASI
creates structures in memory
flushes structures to disk
SASI
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