Skip to content

Commit 5e510fa

Browse files
authored
Merge pull request #2 from shacharPash/AddModuls
Arranging & adding files to the modules
2 parents 79e77ba + 9e0b71d commit 5e510fa

File tree

7 files changed

+235
-1
lines changed

7 files changed

+235
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NRedisStack.Core.Bloom
2+
{
3+
public class RedisBloomCommands
4+
{
5+
//ADD COMMANDS
6+
}
7+
}

src/NRedisStack.Core/RedisJsonCommands.cs renamed to src/NRedisStack.Core/Json/RedisJsonCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using StackExchange.Redis;
22
using System.Text.Json;
33
using System.Text.Json.Serialization;
4-
namespace NRedisStack.Core;
4+
namespace NRedisStack.Core.Json;
55

66
public static class RedisJsonCommands
77
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NRedisStack.Core.Search
2+
{
3+
public class RedisSearchCommands
4+
{
5+
//ADD COMMANDS
6+
}
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace NRedisStack.Core.TimeSeries.Commands
2+
{
3+
internal class CommandArgs
4+
{
5+
public static string RETENTION => "RETENTION";
6+
public static string LABELS => "LABELS";
7+
public static string UNCOMPRESSED => "UNCOMPRESSED";
8+
public static string COUNT => "COUNT";
9+
public static string AGGREGATION => "AGGREGATION";
10+
public static string ALIGN => "ALIGN";
11+
public static string FILTER => "FILTER";
12+
public static string WITHLABELS => "WITHLABELS";
13+
public static string SELECTEDLABELS => "SELECTED_LABELS";
14+
public static string TIMESTAMP => "TIMESTAMP";
15+
public static string CHUNK_SIZE => "CHUNK_SIZE";
16+
public static string DUPLICATE_POLICY => "DUPLICATE_POLICY";
17+
public static string ON_DUPLICATE => "ON_DUPLICATE";
18+
public static string GROPUBY => "GROUPBY";
19+
public static string REDUCE => "REDUCE";
20+
public static string FILTER_BY_TS => "FILTER_BY_TS";
21+
public static string FILTER_BY_VALUE => "FILTER_BY_VALUE";
22+
}
23+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
using NRedisStack.Core.TimeSeries.Commands;
2+
3+
namespace NRedisStack.Core.TimeSeries
4+
{
5+
/*public static partial class TimeSeriesCommands
6+
{
7+
private static void AddRetentionTime(this IList<object> args, long? retentionTime)
8+
{
9+
if (retentionTime.HasValue)
10+
{
11+
args.Add(CommandArgs.RETENTION);
12+
args.Add(retentionTime);
13+
}
14+
}
15+
16+
private static void AddChunkSize(this IList<object> args, long? chunkSize)
17+
{
18+
if (chunkSize.HasValue)
19+
{
20+
args.Add(CommandArgs.CHUNK_SIZE);
21+
args.Add(chunkSize);
22+
}
23+
}
24+
25+
private static void AddLabels(this IList<object> args, IReadOnlyCollection<TimeSeriesLabel> labels)
26+
{
27+
if (labels != null)
28+
{
29+
args.Add(CommandArgs.LABELS);
30+
foreach (var label in labels)
31+
{
32+
args.Add(label.Key);
33+
args.Add(label.Value);
34+
}
35+
}
36+
}
37+
38+
private static void AddUncompressed(this IList<object> args, bool? uncompressed)
39+
{
40+
if (uncompressed.HasValue)
41+
{
42+
args.Add(CommandArgs.UNCOMPRESSED);
43+
}
44+
}
45+
46+
private static void AddCount(this IList<object> args, long? count)
47+
{
48+
if (count.HasValue)
49+
{
50+
args.Add(CommandArgs.COUNT);
51+
args.Add(count.Value);
52+
}
53+
}
54+
55+
private static void AddDuplicatePolicy(this IList<object> args, TsDuplicatePolicy? policy)
56+
{
57+
if (policy.HasValue)
58+
{
59+
args.Add(CommandArgs.DUPLICATE_POLICY);
60+
args.Add(policy.Value.AsArg());
61+
}
62+
}
63+
64+
65+
private static void AddOnDuplicate(this IList<object> args, TsDuplicatePolicy? policy)
66+
{
67+
if (policy.HasValue)
68+
{
69+
args.Add(CommandArgs.ON_DUPLICATE);
70+
args.Add(policy.Value.AsArg());
71+
}
72+
}
73+
74+
private static void AddAlign(this IList<object> args, TimeStamp align)
75+
{
76+
if(align != null)
77+
{
78+
args.Add(CommandArgs.ALIGN);
79+
args.Add(align.Value);
80+
}
81+
}
82+
83+
private static void AddAggregation(this IList<object> args, TsAggregation? aggregation, long? timeBucket)
84+
{
85+
if(aggregation != null)
86+
{
87+
args.Add(CommandArgs.AGGREGATION);
88+
args.Add(aggregation.Value.AsArg());
89+
if (!timeBucket.HasValue)
90+
{
91+
throw new ArgumentException("RANGE Aggregation should have timeBucket value");
92+
}
93+
args.Add(timeBucket.Value);
94+
}
95+
}
96+
97+
private static void AddFilters(this List<object> args, IReadOnlyCollection<string> filter)
98+
{
99+
if(filter == null || filter.Count == 0)
100+
search
101+
102+
prsearch {
103+
args.Add(CommandArgs.FILTER_BY_VALUE);
104+
args.Add(filter.Value.Item1);
105+
args.Add(filter.Value.Item2);
106+
}
107+
}
108+
search
109+
if(selectLabels != null){
110+
args.Add(CommandArgs.SELECTEDLABELS);
111+
foreach(string label in selectLabels){
112+
args.Add(label);
113+
}
114+
}
115+
}
116+
117+
private static void AddGroupby(this IList<object> args, (string groupby, TsReduce reduce)? groupbyTuple)
118+
{
119+
if (groupbyTuple.HasValue)
120+
{
121+
args.Add(CommandArgs.GROPUBY);
122+
args.Add(groupbyTuple.Value.groupby);
123+
args.Add(CommandArgs.REDUCE);
124+
args.Add(groupbyTuple.Value.reduce.AsArg());
125+
}
126+
}
127+
128+
private static void AddTimeStamp(this IList<object> args, TimeStamp timeStamp)
129+
{
130+
if(timeStamp != null)
131+
{
132+
args.Add(CommandArgs.TIMESTAMP);
133+
args.Add(timeStamp.Value);
134+
}
135+
}
136+
137+
private static void AddRule(this IList<object> args, TimeSeriesRule rule)
138+
{
139+
args.Add(rule.DestKey);
140+
args.Add(CommandArgs.AGGREGATION);
141+
args.Add(rule.Aggregation.AsArg());
142+
args.Add(rule.TimeBucket);
143+
}
144+
145+
private static List<object> BuildTsCreateArgs(string key, long? retentionTime, IReadOnlyCollection<TimeSeriesLabel> labels, bool? uncompressed,
146+
long? chunkSizeBytes, TsDuplicatePolicy? policy)
147+
{
148+
var args = new List<object> {key};
149+
args.AddRetentionTime(retentionTime);
150+
args.AddChunkSize(chunkSizeBytes);
151+
args.AddLabels(labels);
152+
args.AddUncompressed(uncompressed);
153+
args.AddDuplicatePolicy(policy);
154+
return args;
155+
}
156+
157+
private static List<object> BuildTsAlterArgs(string key, long? retentionTime, IReadOnlyCollection<TimeSeriesLabel> labels)
158+
{
159+
var args = new List<object> {key};
160+
args.AddRetentionTime(retentionTime);
161+
args.AddLabels(labels);
162+
return args;
163+
}
164+
165+
private static List<object> BuildTsAddArgs(string key, TimeStamp timestamp, double value, long? retentionTime,
166+
IReadOnlyCollection<TimeSeriesLabel> labels, bool? uncompressed, long? chunkSizeBytes, TsDuplicatePolicy? policy)
167+
{
168+
var args = new List<object> {key, timestamp.Value, value};
169+
args.AddRetentionTime(retentionTime);
170+
args.AddChunkSize(chunkSizeBytes);
171+
args.AddLabels(labels);
172+
args.AddUncompressed(uncompressed);
173+
args.AddOnDuplicate(policy);
174+
return args;
175+
}
176+
177+
private static List<object> BuildTsIncrDecrByArgs(string key, double value, TimeStamp timestamp, long? retentionTime,
178+
IReadOnlyCollection<TimeSeriesLabel> labels, bool? uncompressed, long? chunkSizeBytes)
179+
{
180+
var args = new List<object> {key, value};
181+
args.AddTimeStamp(timestamp);
182+
args.AddRetentionTime(retentionTime);
183+
args.AddChunkSize(chunkSizeBytes);
184+
args.AddLabels(labels);
185+
args.AddUncompressed(uncompressed);
186+
return args;
187+
}
188+
}*/
189+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NRedisStack.Core.TimeSeries
2+
{
3+
public class TimeSeriesCommands
4+
{
5+
//ADD COMMANDS
6+
}
7+
}

tests/NRedisStack.Tests/JsonTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.IO;
77
using NRedisStack.Core;
8+
using NRedisStack.Core.Json;
89
using Moq;
910

1011
using System.Text.Json;

0 commit comments

Comments
 (0)