-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
**WIP** feat(cass): add shardKey to partKey table #1361
base: develop
Are you sure you want to change the base?
Conversation
5aa7797
to
69ab230
Compare
def records(ds: Dataset, readerSeq: Seq[RowReader]): SomeData = { | ||
val builder = new RecordBuilder(MemFactory.onHeapFactory) | ||
readerSeq.foreach { row => builder.addFromReader(row, ds.schema) } | ||
builder.allContainers.zipWithIndex.map { case (container, i) => SomeData(container, i) }.head | ||
} | ||
|
||
def partKeyFromRecords(ds: Dataset, records: SomeData, builder: Option[RecordBuilder] = None): Seq[Long] = { | ||
val partKeyBuilder = builder.getOrElse(new RecordBuilder(TestData.nativeMem)) | ||
records.records.map { case (base, offset) => | ||
ds.comparator.buildPartKeyFromIngest(base, offset, partKeyBuilder) | ||
}.toVector | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Almost) mirror the same methods in GdeltTestData
.
val partKeyTablesInit = Observable.fromIterable(0.until(numShards)).map { s => | ||
getOrCreatePartitionKeysTable(dataset, s) | ||
}.mapEval(t => Task.fromFuture(t.initialize())).toListL | ||
val shardKeyToPartKeyTableInit = Observable.fromIterable(0.until(numShards)).map { s => | ||
getOrCreateShardKeyToPartKeyTable(dataset, s) | ||
}.mapEval(t => Task.fromFuture(t.initialize())).toListL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every PartKeyTable
init/insert/delete has a counterpart ShardKeyToPartKeyTable
call.
val shardKeyToPartKeyTableCache = concurrentCache[DatasetRef, | ||
ConcurrentLinkedHashMap[Int, ShardKeyToPartKeyTable]](tableCacheSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a table per shard (like PartitionKeysTable
)?
def scanPartKeysByShardKey(ref: DatasetRef, shard: Int, shardKey: Array[Byte]): Observable[Array[Byte]] = { | ||
val table = getOrCreateShardKeyToPartKeyTable(ref, shard) | ||
table.scanPartKeys(shardKey) | ||
// TODO(a_theimer): figure out if token ranges apply here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will only apply if we add extra values to the PK to prevent hot-spotting, right?
|
||
val suffix = s"shardKeyToPartKey_$shard" | ||
|
||
// TODO(a_theimer): compression settings okay? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left the same as PartitionKeyTable
// TODO(a_theimer): probably need to prevent hot-spotting on a single node | ||
// (i.e. add more fields to [Cassandra's] partition key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't do this until benchmark tests indicate we need it (or one of you already knows we'll need it).
Adds a Cassandra table that maps shard keys to partition keys.
Now, all time-series partition keys for a given shard key can be efficiently scanned.