Ben
Ben
CC#
Created by Ben on 5/7/2023 in #help
❔ Naming Conventions N-Tier architecture, conflicts?
If thats an a-ok practice I'll keep it as is and write the namespaces explcity when needed. In regards to your structure, I don't feel comfortable enough to put all my trust on the namespace 😅 Thanks!
8 replies
CC#
Created by KidKai25 on 3/5/2023 in #help
❔ Must read books!?
How about audible? fk reading is hard lol
51 replies
CC#
Created by Ben on 2/2/2023 in #help
❔ MongoDB Update nested elements
same result 😦
15 replies
CC#
Created by Ben on 2/2/2023 in #help
❔ MongoDB Update nested elements
Well just doing {Events:{$ne: []}} covers both 😅 Anyways the select query isn't the issue, its just when I run the update command with the set that it says - matchedCount:0
15 replies
CC#
Created by Ben on 2/2/2023 in #help
❔ MongoDB Update nested elements
Are you sure? Iv'e just tested - { "Events": { $exists: true } And it returns documents where Events is empty.
15 replies
CC#
Created by Ben on 2/2/2023 in #help
❔ MongoDB Update nested elements
Your query will return all the documents. As Events always exists (might be an empty array though). What I did was - Events:{$ne: []} Which basically search for all the documents where events not equal to an empty array. meaning it has nested elements
15 replies
CC#
Created by Ben on 9/13/2022 in #help
Download file, decompress and keep in memory
@kaleb Got it! Thanks a lot kaleb
17 replies
CC#
Created by Ben on 9/13/2022 in #help
Download file, decompress and keep in memory
Updating my database using batches of lets say 1000 rows at a time from the file. It shouldn't be over 10mb, so I don't really have an issue (this is why initially I wanted to avoid saving to disk etc.)
17 replies
CC#
Created by Ben on 9/13/2022 in #help
Download file, decompress and keep in memory
can you show me a pseudo example ?
17 replies
CC#
Created by Ben on 9/13/2022 in #help
Download file, decompress and keep in memory
And by that to only decompress parts of the stream every time?
17 replies
CC#
Created by Ben on 9/13/2022 in #help
Download file, decompress and keep in memory
@IcyPhoenix @kaleb Yep your ideas worked, understood kaleb explanation. Never worked with streams before, I'll do some reading on the subject, ty! This is what I did -
var data= await _client.GetByteArrayAsync(url + fileName);

using (var fileStream = new MemoryStream(data))
{
fileStream.Seek(0, SeekOrigin.Begin);

using (var gzStream = new GZipStream(fileStream, CompressionMode.Decompress))
{
using (var outputStream = new MemoryStream())
{
gzStream.CopyTo(outputStream);
byte[] outputBytes = outputStream.ToArray();

var result = Encoding.ASCII.GetString(outputBytes);
}
}
}
var data= await _client.GetByteArrayAsync(url + fileName);

using (var fileStream = new MemoryStream(data))
{
fileStream.Seek(0, SeekOrigin.Begin);

using (var gzStream = new GZipStream(fileStream, CompressionMode.Decompress))
{
using (var outputStream = new MemoryStream())
{
gzStream.CopyTo(outputStream);
byte[] outputBytes = outputStream.ToArray();

var result = Encoding.ASCII.GetString(outputBytes);
}
}
}
17 replies
CC#
Created by Ben on 9/13/2022 in #help
Download file, decompress and keep in memory
coach
17 replies
CC#
Created by Ben on 8/29/2022 in #help
LeetCode - Clone Graph [Answered]
I'll close this, thanks Pobiega
6 replies
CC#
Created by Ben on 8/29/2022 in #help
LeetCode - Clone Graph [Answered]
fml... found the issue. I needed to add the initial clone variable to the hashmap before going into the dfs logic.
6 replies
CC#
Created by surwren on 8/16/2022 in #help
differentiating use cases- Enum vs Tuple vs Array
When would you use records over tuples?
16 replies
CC#
Created by Ben on 8/16/2022 in #help
How to locally loadbalance threadsafe [Answered]
Got it. ok makes sense now. Thanks mate! I'll close this topic
19 replies
CC#
Created by Ben on 8/16/2022 in #help
How to locally loadbalance threadsafe [Answered]
Saying that an atomic operation is having a lock on the hardware level is a correct statement?
19 replies
CC#
Created by Ben on 8/16/2022 in #help
How to locally loadbalance threadsafe [Answered]
Ok so queue is out. I'm not sure what atomic operation actually is, not sure how it achieves that without a lock. I'll be googling for a few minutes and come back afterwards 😅
19 replies
CC#
Created by Ben on 8/16/2022 in #help
How to locally loadbalance threadsafe [Answered]
Ok so instead of reseting the indexCounter you modulo it with the length of the array. makes sense, not really worried about overflow each instance won't be surpassing the 1-2 million. Using Interlocked.Increment means that a lock is in place on every update so it makes the indexCounter incremental thread-safe, correct? It shouldn't affect performance as such a basic operation won't hold the lock? That being said, I can abandon the index counter and use concurrent queue to manage that for me if I dequeue and enqueue before awating the request? Something like -
ConcurrentQueue<string> _endpoints;
public MyClass(List<string> endpoints)
{
_endpoints = new ConcurrentQueue<string>(endpoints);
}

public Task SendRequest()
{
var endpoint = _endpoints.Dequeue();
_endpoints.Enqueue(endpoint);

await client.Request(endpoint);
}
ConcurrentQueue<string> _endpoints;
public MyClass(List<string> endpoints)
{
_endpoints = new ConcurrentQueue<string>(endpoints);
}

public Task SendRequest()
{
var endpoint = _endpoints.Dequeue();
_endpoints.Enqueue(endpoint);

await client.Request(endpoint);
}
What do you think? @Xymanek
19 replies
CC#
Created by surwren on 8/16/2022 in #help
differentiating use cases- Enum vs Tuple vs Array
I'll start off by reading what each type is. As all 3 do not serve the same purpose at all. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum I'm sure that after reading the doc of each type you'll have a better understanding or a more specific question to follow up with.
16 replies