Creating timeuuid for cassandra inserts with apache curvature

I play with apache spark and apache cassandra for data analysis, and I struggle with pasting back into cassandra with timeuuid fields.

I have the following table

CREATE TABLE leech_seed_report.daily_sessions (
    id timeuuid PRIMARY KEY,
    app int,
    count int,
    date bigint,
    offline boolean,
    vendor text,
    version text
) WITH bloom_filter_fp_chance = 0.01
    AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
    AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99.0PERCENTILE';
CREATE INDEX daily_sessions_app_idx ON leech_seed_report.daily_sessions (app);
CREATE INDEX daily_sessions_date_idx ON leech_seed_report.daily_sessions (date);
CREATE INDEX daily_sessions_offline_idx ON leech_seed_report.daily_sessions (offline);
CREATE INDEX daily_sessions_vendor_idx ON leech_seed_report.daily_sessions (vendor);
CREATE INDEX daily_sessions_version_idx ON leech_seed_report.daily_sessions (version);

and I insert rows using

rows.saveToCassandra("leech_seed_report", "daily_sessions", SomeColumns("id", "date", "app", "vendor", "version", "offline", "count"))

and my strings consist of format tuples

([timmuuid_will_be_here], BigInt, Int, String, String, Boolean, Int)

I played with the insert in the same table without the timeuuid field, and everything works fine, but I can't let my life work on how to create timeuuid for each row

Any help would be greatly appreciated, im new for spark, cassandra and scala and feel me bang my head against a brick wall.

Thanks Matt.

+4
source share
2 answers

UUIDGen, zero323 , , , - , scala, . , , , , /.

timeuuid gfc-timeuuid, , build.sbt

libraryDependencies += "com.gilt" %% "gfc-timeuuid" % "0.0.5"

scala script

import com.gilt.timeuuid._

val tuuid = TimeUuid()
+2

com.datastax.driver.core.utils.UUIDs UUIDs.timeBased(), timeuuid.

:

rows.saveToCassandra("leech_seed_report", "daily_sessions", SomeColumns(UUIDS.timeBased(),
"date", "app", "vendor", "version", "offline", "count"))
+1

Source: https://habr.com/ru/post/1609952/


All Articles