Skip to content

Commit

Permalink
dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
shacharPash committed Sep 10, 2023
1 parent 36d32dd commit bff96ca
Show file tree
Hide file tree
Showing 42 changed files with 225 additions and 233 deletions.
2 changes: 1 addition & 1 deletion src/NRedisStack/CuckooFilter/ICuckooCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ bool Reserve(RedisKey key, long capacity,
/// <param name="iterator">Iterator value; either 0 or the iterator from a previous invocation of this command.</param>
/// <returns>Tuple of iterator and data.</returns>
/// <remarks><seealso href="https://redis.io/commands/cf.scandump"/></remarks>
Tuple<long,Byte[]> ScanDump(RedisKey key, long iterator);
Tuple<long, Byte[]> ScanDump(RedisKey key, long iterator);
}
}
2 changes: 1 addition & 1 deletion src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ Task<bool> ReserveAsync(RedisKey key, long capacity,
/// <param name="iterator">Iterator value; either 0 or the iterator from a previous invocation of this command.</param>
/// <returns>Tuple of iterator and data.</returns>
/// <remarks><seealso href="https://redis.io/commands/cf.scandump"/></remarks>
Task<Tuple<long,Byte[]>> ScanDumpAsync(RedisKey key, long iterator);
Task<Tuple<long, Byte[]>> ScanDumpAsync(RedisKey key, long iterator);
}
}
12 changes: 6 additions & 6 deletions src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ namespace NRedisStack.CuckooFilter.Literals
{
internal class CuckooArgs
{
public const string CAPACITY = "CAPACITY";
public const string EXPANSION = "EXPANSION";
public const string NOCREATE = "NOCREATE";
public const string ITEMS = "ITEMS";
public const string BUCKETSIZE = "BUCKETSIZE";
public const string MAXITERATIONS = "MAXITERATIONS";
public const string CAPACITY = "CAPACITY";
public const string EXPANSION = "EXPANSION";
public const string NOCREATE = "NOCREATE";
public const string ITEMS = "ITEMS";
public const string BUCKETSIZE = "BUCKETSIZE";
public const string MAXITERATIONS = "MAXITERATIONS";
}
}
2 changes: 1 addition & 1 deletion src/NRedisStack/Gears/GearsCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static SerializedCommand TFunctionList(bool withCode = false, int verbose
public static SerializedCommand TFCall(string libraryName, string functionName, string[]? keys = null, string[]? args = null, bool async = false)
{
string command = async ? RG.TFCALLASYNC : RG.TFCALL;
var commandArgs = new List<object>() {$"{libraryName}.{functionName}"};
var commandArgs = new List<object>() { $"{libraryName}.{functionName}" };

if (keys != null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Gears/GearsCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static Dictionary<string, RedisResult>[] TFunctionList(this IDatabase db,
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks>
public static RedisResult TFCall_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false));
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: false));
}

/// <summary>
Expand All @@ -72,7 +72,7 @@ public static RedisResult TFCall_(this IDatabase db, string libraryName, string
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks>
public static RedisResult TFCallAsync_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true));
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: true));
}
}
}
4 changes: 2 additions & 2 deletions src/NRedisStack/Gears/GearsCommandsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static async Task<Dictionary<string, RedisResult>[]> TFunctionListAsync(t
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks>
public async static Task<RedisResult> TFCall_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false));
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: false));
}

/// <summary>
Expand All @@ -71,7 +71,7 @@ public async static Task<RedisResult> TFCall_Async(this IDatabase db, string lib
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks>
public async static Task<RedisResult> TFCallAsync_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true));
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: true));
}
}
}
2 changes: 1 addition & 1 deletion src/NRedisStack/Graph/DataTypes/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override int GetHashCode()
{
int hash = 17;

foreach(var label in Labels)
foreach (var label in Labels)
{
hash = hash * 31 + label.GetHashCode();
}
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Graph/DataTypes/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace NRedisStack.Graph.DataTypes
/// </summary>
public class Path
{
public ReadOnlyCollection<Node> Nodes { get;}
public ReadOnlyCollection<Edge> Edges { get;}
public ReadOnlyCollection<Node> Nodes { get; }
public ReadOnlyCollection<Edge> Edges { get; }

public Path(IList<Node> nodes, IList<Edge> edges)
{
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Graph/RedisGraphUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static string ValueToString(object value)

foreach (var val in valueList)
{
objectValueList.Add((object) val);
objectValueList.Add((object)val);
}

return ArrayToString(objectValueList.ToArray());
Expand Down Expand Up @@ -90,7 +90,7 @@ private static string ArrayToString(object[] array)
{
if (x.GetType().IsArray)
{
return ArrayToString((object[]) x);
return ArrayToString((object[])x);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/NRedisStack/Graph/ResultSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private Dictionary<string, object> DeserializeDictionary(RedisResult rawPath)
for (int i = 0; i < size; i += 2)
{
string key = keyTypeValueEntries[i].ToString();
object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i+1]);
object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i + 1]);
dict.Add(key, value);
}
return dict;
Expand Down
40 changes: 20 additions & 20 deletions src/NRedisStack/Graph/Statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ internal Statistics(Dictionary<string, string> statistics)
{
_statistics = statistics;

NodesCreated = GetIntValue("Nodes created");
NodesDeleted = GetIntValue("Nodes deleted");
IndicesAdded = GetIntValue("Indices added");
IndicesCreated = GetIntValue("Indices created");
IndicesDeleted = GetIntValue("Indices deleted");
LabelsAdded = GetIntValue("Labels added");
RelationshipsDeleted = GetIntValue("Relationships deleted");
RelationshipsCreated = GetIntValue("Relationships created");
PropertiesSet = GetIntValue("Properties set");
QueryInternalExecutionTime = GetStringValue("Query internal execution time");
GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time");
CachedExecution = (GetIntValue("Cached execution") == 1);
NodesCreated = GetIntValue("Nodes created");
NodesDeleted = GetIntValue("Nodes deleted");
IndicesAdded = GetIntValue("Indices added");
IndicesCreated = GetIntValue("Indices created");
IndicesDeleted = GetIntValue("Indices deleted");
LabelsAdded = GetIntValue("Labels added");
RelationshipsDeleted = GetIntValue("Relationships deleted");
RelationshipsCreated = GetIntValue("Relationships created");
PropertiesSet = GetIntValue("Properties set");
QueryInternalExecutionTime = GetStringValue("Query internal execution time");
GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time");
CachedExecution = (GetIntValue("Cached execution") == 1);

}
}

/// <summary>
/// Retrieves the relevant statistic.
/// </summary>
/// <param name="label">The requested statistic label.</param>
/// <returns>A string representation of the specific statistic or null</returns>
public string? GetStringValue(string label) =>
_statistics.TryGetValue(label, out string? value) ? value : null;
/// <summary>
/// Retrieves the relevant statistic.
/// </summary>
/// <param name="label">The requested statistic label.</param>
/// <returns>A string representation of the specific statistic or null</returns>
public string? GetStringValue(string label) =>
_statistics.TryGetValue(label, out string? value) ? value : null;


private int GetIntValue(string label)
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Json/JsonCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public static SerializedCommand MSet(KeyPathValue[] KeyPathValueList)
if (KeyPathValueList.Length < 1)
throw new ArgumentOutOfRangeException(nameof(KeyPathValueList));

var args = KeyPathValueList.SelectMany(x => x.ToArray()).ToArray();
return new SerializedCommand(JSON.MSET, args);
var args = KeyPathValueList.SelectMany(x => x.ToArray()).ToArray();
return new SerializedCommand(JSON.MSET, args);
}

public static SerializedCommand Merge(RedisKey key, RedisValue path, RedisValue json)
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Json/JsonCommandsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public async Task<bool> SetFromFileAsync(RedisKey key, RedisValue path, string f
throw new FileNotFoundException($"File {filePath} not found.");
}

string fileContent = File.ReadAllText(filePath);
string fileContent = File.ReadAllText(filePath);
return await SetAsync(key, path, fileContent, when);
}

Expand All @@ -181,7 +181,7 @@ public async Task<int> SetFromDirectoryAsync(RedisValue path, string filesPath,
foreach (var filePath in files)
{
key = filePath.Substring(0, filePath.IndexOf("."));
if(await SetFromFileAsync(key, path, filePath, when))
if (await SetFromFileAsync(key, path, filePath, when))
{
inserted++;
}
Expand Down
6 changes: 3 additions & 3 deletions src/NRedisStack/ResponseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public static List<string> ToStringList(this RedisResult result)
return new[] { (long?)result };
}

return ((RedisResult[])result!).Select(x=>(long?)x).ToArray();
return ((RedisResult[])result!).Select(x => (long?)x).ToArray();
}

public static IEnumerable<HashSet<string>> ToHashSets(this RedisResult result)
Expand Down Expand Up @@ -626,7 +626,7 @@ public static Dictionary<string, Dictionary<string, double>> ToFtSpellCheckResul

string termValue = rawElements[1].ToString()!;

var list = (RedisResult[]) rawElements[2]!;
var list = (RedisResult[])rawElements[2]!;
Dictionary<string, double> entries = new Dictionary<string, double>(list.Length);
foreach (var entry in list)
{
Expand All @@ -653,7 +653,7 @@ public static List<Tuple<string, double>> ToStringDoubleTupleList(this RedisResu
}
return list;
}

public static Dictionary<string, RedisResult> ToStringRedisResultDictionary(this RedisResult value)
{
var res = (RedisResult[])value!;
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Search/AggregationRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class AggregationRequest

// Params:
private Dictionary<string, object> nameValue = new Dictionary<string, object>();
public int? dialect {get; private set;} = null;
public int? dialect { get; private set; } = null;

public AggregationRequest(string query, int? defaultDialect = null)
{
Expand All @@ -57,7 +57,7 @@ public AggregationRequest Verbatim(bool verbatim = true)

private void Verbatim()
{
if(verbatim == true)
if (verbatim == true)
args.Add("VERBATIM");
}

Expand Down
8 changes: 5 additions & 3 deletions src/NRedisStack/Search/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace NRedisStack.Search
public class Document
{
public string Id { get; }
public double Score { get; set;}
public double Score { get; set; }
public byte[] Payload { get; }
public string[] ScoreExplained { get; private set; } // TODO: check if this is needed (Jedis does not have it)
internal readonly Dictionary<string, RedisValue> _properties;
Expand All @@ -35,10 +35,12 @@ public static Document Load(string id, double score, byte[] payload, RedisValue[
for (int i = 0; i < fields.Length; i += 2)
{
string fieldName = (string)fields[i];
if (fieldName == "$") {
if (fieldName == "$")
{
ret["json"] = fields[i + 1];
}
else {
else
{
ret[fieldName] = fields[i + 1];
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/NRedisStack/Search/FTSpellCheckParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ private void Dialect()

private void Terms()
{
foreach (var term in terms)
{
args.Add(SearchArgs.TERMS);
args.Add(term.Value);
args.Add(term.Key);
}
foreach (var term in terms)
{
args.Add(SearchArgs.TERMS);
args.Add(term.Value);
args.Add(term.Key);
}
}

private void Distance()
Expand Down
16 changes: 8 additions & 8 deletions src/NRedisStack/Search/Limit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public Limit(int offset, int count)
_count = count;
}

// public void addArgs(List<String> args) {
// if (count == 0) {
// return;
// }
// args.add("LIMIT");
// args.add(Integer.toString(offset));
// args.add(Integer.toString(count));
// }
// public void addArgs(List<String> args) {
// if (count == 0) {
// return;
// }
// args.add("LIMIT");
// args.add(Integer.toString(offset));
// args.add(Integer.toString(count));
// }

internal void SerializeRedisArgs(List<object> args)
{
Expand Down
2 changes: 1 addition & 1 deletion src/NRedisStack/Search/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public HighlightTags(string open, string close)
// public bool ExplainScore { get; set; } // TODO: Check if this is needed because Jedis doesn't have it

private Dictionary<string, object> _params = new Dictionary<string, object>();
public int? dialect { get; private set;} = null;
public int? dialect { get; private set; } = null;
private int _slop = -1;
private long _timeout = -1;
private bool _inOrder = false;
Expand Down
10 changes: 5 additions & 5 deletions src/NRedisStack/Search/SearchCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,18 @@ public static SerializedCommand ProfileSearch(string IndexName, Query q, bool li
{
var args =
(limited)
? new List<object>(){IndexName, SearchArgs.SEARCH, SearchArgs.LIMITED, SearchArgs.QUERY}
: new List<object>(){IndexName, SearchArgs.SEARCH, SearchArgs.QUERY};
? new List<object>() { IndexName, SearchArgs.SEARCH, SearchArgs.LIMITED, SearchArgs.QUERY }
: new List<object>() { IndexName, SearchArgs.SEARCH, SearchArgs.QUERY };

q.SerializeRedisArgs(args);
return new SerializedCommand(FT.PROFILE, args);
}

public static SerializedCommand ProfileAggregate(string IndexName, AggregationRequest query, bool limited = false)
{
var args = (limited)
? new List<object>{IndexName, SearchArgs.AGGREGATE, SearchArgs.LIMITED, SearchArgs.QUERY}
: new List<object>{IndexName, SearchArgs.AGGREGATE, SearchArgs.QUERY};
var args = (limited)
? new List<object> { IndexName, SearchArgs.AGGREGATE, SearchArgs.LIMITED, SearchArgs.QUERY }
: new List<object> { IndexName, SearchArgs.AGGREGATE, SearchArgs.QUERY };

query.SerializeRedisArgs();
args.AddRange(query.GetArgs());
Expand Down
4 changes: 2 additions & 2 deletions src/NRedisStack/Search/SearchCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public SearchCommands(IDatabase db, int? defaultDialect) : base(db)

public void SetDefaultDialect(int? defaultDialect)
{
if(defaultDialect == 0)
if (defaultDialect == 0)
{
throw new System.ArgumentOutOfRangeException("DIALECT=0 cannot be set.");
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public bool Create(string indexName, FTCreateParams parameters, Schema schema)
/// <inheritdoc/>
public bool Create(string indexName, Schema schema)
{
return Create(indexName, new FTCreateParams(), schema);
return Create(indexName, new FTCreateParams(), schema);
}

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion src/NRedisStack/Search/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal SearchResult(RedisResult[] resp, bool hasContent, bool hasScores, bool
// }
//else
//{
score = (double)resp[i + scoreOffset];
score = (double)resp[i + scoreOffset];
//}
}
if (hasPayloads)
Expand Down
2 changes: 1 addition & 1 deletion src/NRedisStack/Tdigest/TdigestCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public double Max(RedisKey key)
public double Min(RedisKey key)
{
var cmd = TdigestCommandBuilder.Min(key);
var res =_db.Execute(cmd);
var res = _db.Execute(cmd);
return res.ToDouble();
}

Expand Down
Loading

0 comments on commit bff96ca

Please sign in to comment.