-
Notifications
You must be signed in to change notification settings - Fork 0
First implementation of new SI API #2
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
3aa431d
97bcf90
1b10d64
d9db397
c54018c
047e27d
85c54a4
11c0289
ac12836
2c94bd7
e340da7
a094f81
3b118b8
ab625ac
5ac4a8c
e6baec2
b922709
1874a7c
eb59000
664e7dc
d15c6c6
3bb74ad
ef80838
b12d4d6
2ce51aa
c179dc8
42619d7
25730b9
01220cf
e30da07
ab1c815
8c88c1a
3b57ef1
f024f3a
074028b
5bf46d9
4458616
881f4bd
32320de
f6a9603
101aff6
8a321d9
d380af8
5a40baa
a2a55ac
7917538
25f310f
c4b0781
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| using FASTER.core; | ||
|
|
||
| namespace FASTER.benchmark | ||
| { | ||
| class NullKeyIndex<Key> : ISecondaryKeyIndex<Key> | ||
| { | ||
| public string Name => "KeyIndex"; | ||
|
|
||
| public bool IsMutable => true; | ||
|
|
||
| public void Delete(ref Key key) { } | ||
|
|
||
| public void Insert(ref Key key) { } | ||
|
|
||
| public void Upsert(ref Key key, bool isMutable) { } | ||
| } | ||
|
|
||
| class NullValueIndex<Value> : ISecondaryValueIndex<Value> | ||
| { | ||
| public string Name => "ValueIndex"; | ||
|
|
||
| public bool IsMutable => true; | ||
|
|
||
| public void Delete(ref Value value, long recordId) { } | ||
|
|
||
| public void Insert(ref Value value, long recordId) { } | ||
|
|
||
| public void Upsert(ref Value value, long recordId, bool isMutable) { } | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -922,7 +922,7 @@ protected override bool RetrievedFullRecord(byte* record, ref AsyncIOContext<Key | |
| /// <returns></returns> | ||
| public override bool KeyHasObjects() | ||
| { | ||
| return SerializerSettings.keySerializer != null; | ||
| return SerializerSettings?.keySerializer != null; | ||
|
||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -931,7 +931,7 @@ public override bool KeyHasObjects() | |
| /// <returns></returns> | ||
| public override bool ValueHasObjects() | ||
| { | ||
| return SerializerSettings.valueSerializer != null; | ||
| return SerializerSettings?.valueSerializer != null; | ||
| } | ||
| #endregion | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -737,15 +737,54 @@ public void ConcurrentReader(ref Key key, ref Input input, ref Value value, ref | |
|
|
||
| public bool ConcurrentWriter(ref Key key, ref Value src, ref Value dst, long address) | ||
| { | ||
| return _clientSession.functions.ConcurrentWriter(ref key, ref src, ref dst, address); | ||
| if (!_clientSession.fht.SupportsMutableIndexes) | ||
|
||
| return _clientSession.functions.ConcurrentWriter(ref key, ref src, ref dst, address); | ||
|
|
||
| ref RecordInfo recordInfo = ref _clientSession.fht.RecordAccessor.SpinLockRecordInfo(address); | ||
| try | ||
| { | ||
| if (!recordInfo.Tombstone && _clientSession.functions.ConcurrentWriter(ref key, ref src, ref dst, address)) | ||
| { | ||
| // KeyIndexes do not need notification of in-place updates because the key does not change. | ||
| if (_clientSession.fht.SecondaryIndexBroker.MutableValueIndexCount > 0) | ||
| _clientSession.fht.SecondaryIndexBroker.Upsert(ref dst, address); | ||
| return true; | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| recordInfo.Unlock(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public bool ConcurrentDeleter(ref Key key, ref Value value, long address) | ||
| { | ||
| if (!_clientSession.fht.SupportsMutableIndexes) | ||
| return _clientSession.functions.ConcurrentDeleter(ref key, ref value, address); | ||
|
|
||
| ref RecordInfo recordInfo = ref _clientSession.fht.RecordAccessor.SpinLockRecordInfo(address); | ||
| try | ||
| { | ||
| if (_clientSession.fht.SecondaryIndexBroker.MutableKeyIndexCount > 0) | ||
| _clientSession.fht.SecondaryIndexBroker.Delete(ref key); | ||
| if (_clientSession.fht.SecondaryIndexBroker.MutableValueIndexCount > 0) | ||
| _clientSession.fht.SecondaryIndexBroker.Delete(ref value, address); | ||
| return _clientSession.functions.ConcurrentDeleter(ref key, ref value, address); | ||
| } | ||
| finally | ||
| { | ||
| recordInfo.Unlock(); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| public bool NeedCopyUpdate(ref Key key, ref Input input, ref Value oldValue) | ||
| => _clientSession.functions.NeedCopyUpdate(ref key, ref input, ref oldValue); | ||
|
|
||
| public void CopyUpdater(ref Key key, ref Input input, ref Value oldValue, ref Value newValue, long oldAddress, long newAddress) | ||
| public void CopyUpdater(ref Key key, ref Input input, ref Value oldValue, ref Value newValue, long address) | ||
| { | ||
| _clientSession.functions.CopyUpdater(ref key, ref input, ref oldValue, ref newValue, oldAddress, newAddress); | ||
| _clientSession.functions.CopyUpdater(ref key, ref input, ref oldValue, ref newValue, address); | ||
| } | ||
|
|
||
| public void DeleteCompletionCallback(ref Key key, Context ctx) | ||
|
|
@@ -770,7 +809,25 @@ public void InitialUpdater(ref Key key, ref Input input, ref Value value, long a | |
|
|
||
| public bool InPlaceUpdater(ref Key key, ref Input input, ref Value value, long address) | ||
| { | ||
| return _clientSession.functions.InPlaceUpdater(ref key, ref input, ref value, address); | ||
| if (!_clientSession.fht.SupportsMutableIndexes) | ||
| return _clientSession.functions.InPlaceUpdater(ref key, ref input, ref value, address); | ||
|
|
||
| ref RecordInfo recordInfo = ref _clientSession.fht.RecordAccessor.SpinLockRecordInfo(address); | ||
| try | ||
| { | ||
| if (!recordInfo.Tombstone && _clientSession.functions.InPlaceUpdater(ref key, ref input, ref value, address)) | ||
| { | ||
| // KeyIndexes do not need notification of in-place updates because the key does not change. | ||
| if (_clientSession.fht.SecondaryIndexBroker.MutableValueIndexCount > 0) | ||
| _clientSession.fht.SecondaryIndexBroker.Upsert(ref value, address); | ||
| return true; | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| recordInfo.Unlock(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public void ReadCompletionCallback(ref Key key, ref Input input, ref Output output, Context ctx, Status status, RecordInfo recordInfo) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -747,13 +747,53 @@ public void ConcurrentReader(ref Key key, ref Input input, ref Value value, ref | |
|
|
||
| public bool ConcurrentWriter(ref Key key, ref Value src, ref Value dst, long address) | ||
| { | ||
| return _clientSession.functions.ConcurrentWriter(ref key, ref src, ref dst); | ||
| if (!_clientSession.fht.SupportsMutableIndexes) | ||
| return _clientSession.functions.ConcurrentWriter(ref key, ref src, ref dst); | ||
|
|
||
| ref RecordInfo recordInfo = ref _clientSession.fht.RecordAccessor.SpinLockRecordInfo(address); | ||
|
||
| try | ||
| { | ||
| if (!recordInfo.Tombstone && _clientSession.functions.ConcurrentWriter(ref key, ref src, ref dst)) | ||
| { | ||
| // KeyIndexes do not need notification of in-place updates because the key does not change. | ||
|
||
| if (_clientSession.fht.SecondaryIndexBroker.MutableValueIndexCount > 0) | ||
|
||
| _clientSession.fht.SecondaryIndexBroker.Upsert(ref dst, address); | ||
| return true; | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| recordInfo.Unlock(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public bool ConcurrentDeleter(ref Key key, ref Value value, long address) | ||
| { | ||
| // Non-Advanced IFunctions has no ConcurrentDeleter | ||
| if (!_clientSession.fht.SupportsMutableIndexes) | ||
| return false; | ||
|
|
||
| ref RecordInfo recordInfo = ref _clientSession.fht.RecordAccessor.SpinLockRecordInfo(address); | ||
|
||
| try | ||
| { | ||
| if (_clientSession.fht.SecondaryIndexBroker.MutableKeyIndexCount > 0) | ||
| _clientSession.fht.SecondaryIndexBroker.Delete(ref key); | ||
| if (_clientSession.fht.SecondaryIndexBroker.MutableValueIndexCount > 0) | ||
| _clientSession.fht.SecondaryIndexBroker.Delete(ref value, address); | ||
| _clientSession.fht.SetRecordDeleted(ref recordInfo, ref value); | ||
| } | ||
| finally | ||
| { | ||
| recordInfo.Unlock(); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| public bool NeedCopyUpdate(ref Key key, ref Input input, ref Value oldValue) | ||
| => _clientSession.functions.NeedCopyUpdate(ref key, ref input, ref oldValue); | ||
|
|
||
| public void CopyUpdater(ref Key key, ref Input input, ref Value oldValue, ref Value newValue, long oldAddress, long newAddress) | ||
| public void CopyUpdater(ref Key key, ref Input input, ref Value oldValue, ref Value newValue, long address) | ||
| { | ||
| _clientSession.functions.CopyUpdater(ref key, ref input, ref oldValue, ref newValue); | ||
| } | ||
|
|
@@ -780,7 +820,25 @@ public void InitialUpdater(ref Key key, ref Input input, ref Value value, long a | |
|
|
||
| public bool InPlaceUpdater(ref Key key, ref Input input, ref Value value, long address) | ||
| { | ||
| return _clientSession.functions.InPlaceUpdater(ref key, ref input, ref value); | ||
| if (!_clientSession.fht.SupportsMutableIndexes) | ||
| return _clientSession.functions.InPlaceUpdater(ref key, ref input, ref value); | ||
|
|
||
| ref RecordInfo recordInfo = ref _clientSession.fht.RecordAccessor.SpinLockRecordInfo(address); | ||
| try | ||
| { | ||
| if (!recordInfo.Tombstone && _clientSession.functions.InPlaceUpdater(ref key, ref input, ref value)) | ||
| { | ||
| // KeyIndexes do not need notification of in-place updates because the key does not change. | ||
| if (_clientSession.fht.SecondaryIndexBroker.MutableValueIndexCount > 0) | ||
| _clientSession.fht.SecondaryIndexBroker.Upsert(ref value, address); | ||
| return true; | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| recordInfo.Unlock(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public void ReadCompletionCallback(ref Key key, ref Input input, ref Output output, Context ctx, Status status, RecordInfo recordInfo) | ||
|
|
||
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.
There is a variant here that takes in the address as well. In that case, we need to update the index whenever addresses changes, even if the key does not change. Like an Upsert call here in addition to Insert.