Repository navigation
Add JSON.SET FPHA support (8.8) #467
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
Changes from 1 commit
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using NRedisStack.Json.DataTypes; | ||
| using System.ComponentModel; | ||
| using NRedisStack.Json.DataTypes; | ||
| using StackExchange.Redis; | ||
| using System.Text.Json; | ||
| using System.Text.Json.Nodes; | ||
|
|
@@ -20,19 +21,28 @@ public RedisResult[] Resp(RedisKey key, string? path = null) | |
| return (RedisResult[])result!; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] | ||
| public bool Set(RedisKey key, RedisValue path, object obj, When when, JsonSerializerOptions? serializerOptions) | ||
| => Set(key, path, JsonSerializer.Serialize(obj, serializerOptions), when, JsonNumericArrayStorage.NotSpecified); | ||
|
|
||
| /// <inheritdoc/> | ||
| [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] | ||
| public bool Set(RedisKey key, RedisValue path, RedisValue json, When when) | ||
| => Set(key, path, json, when, JsonNumericArrayStorage.NotSpecified); | ||
|
Comment on lines
+25
to
+32
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will keep these until major release, right ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't a good idea to mark them obsolete, as that will cause unnecessary build warnings/failures (depending on build settings) when the exact combination is specified; I try to avoid drama if at all possible. |
||
|
|
||
| /// <inheritdoc/> | ||
| public bool Set(RedisKey key, RedisValue path, object obj, When when = When.Always, | ||
| JsonSerializerOptions? serializerOptions = default) | ||
| JsonSerializerOptions? serializerOptions = default, JsonNumericArrayStorage fpha = JsonNumericArrayStorage.NotSpecified) | ||
| { | ||
| string json = JsonSerializer.Serialize(obj, options: serializerOptions); | ||
| return Set(key, path, json, when); | ||
| return Set(key, path, json, when, fpha); | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public bool Set(RedisKey key, RedisValue path, RedisValue json, When when = When.Always) | ||
| { | ||
| return db.Execute(JsonCommandBuilder.Set(key, path, json, when)).OKtoBoolean(); | ||
| } | ||
| public bool Set(RedisKey key, RedisValue path, RedisValue json, When when = When.Always, JsonNumericArrayStorage fpha = JsonNumericArrayStorage.NotSpecified) | ||
| => db.Execute(JsonCommandBuilder.Set(key, path, json, when, fpha)).OKtoBoolean(); | ||
|
|
||
|
|
||
| /// <inheritdoc/> | ||
| public bool MSet(KeyPathValue[] KeyPathValueList) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| namespace NRedisStack; | ||
|
|
||
| /// <summary> | ||
| /// Specifies the storage type for numeric values when used in a JSON array. | ||
| /// </summary> | ||
| public enum JsonNumericArrayStorage | ||
| { | ||
| /// <summary> | ||
| /// Default behaviour, no FPHA usage. | ||
| /// </summary> | ||
| NotSpecified = 0, | ||
|
|
||
| /// <summary> | ||
| /// "Brain" floating-point 16-bit. | ||
| /// </summary> | ||
| BF16 = 1, | ||
|
|
||
| /// <summary> | ||
| /// IEEE 754 16-bit. | ||
| /// </summary> | ||
| FP16 = 2, | ||
|
|
||
| /// <summary> | ||
| /// IEEE 754 32-bit. | ||
| /// </summary> | ||
| FP32 = 3, | ||
|
|
||
| /// <summary> | ||
| /// IEEE 754 64-bit. | ||
| /// </summary> | ||
| FP64 = 4, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,4 @@ public enum JsonType | |
| STRING = 5, | ||
| ARRAY = 6, | ||
| OBJECT = 7 | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.