I am new to Spark. Can anyone help me to understand why SparkSession creation follows builder design pattern when Scala has other recommended design pattern (with a case class) to handle same situation?
mardi 2 juillet 2019
One vs Multiple Datastore in NeDB
I'm new in NoSQL and more in NeDB so maybe this is a noob question.
From the docs (https://github.com/louischatriot/nedb#creatingloading-a-database):
One datastore is the equivalent of a MongoDB collection
Suppose I have 3 types of documents: user (documents saving user info), order (documents saving orders, I have a userId reference here) and log (documents saving errors etc)
Should I create a different datastore for every type? or is better to save everything inside a single datastore with a "type" fieldname?
I've read the collections in MongoDB are the equivalent to tables in RDBMS, so I guess I should use 3 DataStores in NeDB but not sure what is the best approach.
which architecture is suitable for realtime chat application like what's app
I want to develop a real-time chat application in androids like what's app or telegram for the all-purpose client should connect to the server via WebSockets and even offline or online has to works fine I decided to use android architecture like MVP, MVVM, mvi but I'm confusing which one is suitable for my app may anyone help me to choose one of them? and my second question is it ok to use WebSockets for all APIs or it should better use WebSockets and rest APIs together? thanks for your help
Pytest, choosing scope for fixture according to input parameter per test class
I've got several test classes that are using the same fixtures, with the exception that on some classes I need the fixtures to be in class scope while in other Classes the scope should be per test function.
How can I select the fixture scope according to test class name or some other input parameter ?
here's a pseudo-code illustration :
#if class=='classA'
@pytest.fixture(scope='class')
#else
@pytest.fixture(scope='function')
#endif
def myfix(request):
#fixture implementation
Finding last occurence of _sre.SRE_Pattern in a text file
I want to search for last occurence of a pattern "frame(some variable number)())" like frame1(), frame2(), frame3().... (it is not exactly a string). I'm interested in getting the variable number which will keep increasing with every occurence.
i did it by using this code
regex = re.compile('frame*[0-9]*\(\)') NoOfFrames = len(regex.findall(s))
But i think there may be more efficient way of finding it rather than listing all the occurrences and then counting it. like if we can start from last line of text file then the first occurence will be the answer. I also tried using this
m = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) i = m.rfind(regex) # search for last occurrence of 'word' print(i) m.seek(i) # seek to the location line = m.readline() # read to the end of the line print(line)
but this will not work because what i'm searching is not exactly a string. My text file is pretty big like in gigabytes and more efficient solution will be appreciated.
Thanks!
How to Design a go game using design patterns by Creational Structural design Behavioral patterns
I want to design a go game using design patterns, which Behavioral Creational Structural design patterns should I using
Go is an abstract strategy board game for two players, in which the aim is to surround more territory than the opponent. The game was invented in China more than 2,500 years ago and is believed to be the oldest board game continuously played to the present day.
A suitable design pattern
I am facing a design issue, where i have to find a suitable design pattern for my small library, which should be easy to understand by the user of my library.
I have a base class and the derived classes from the base class are A,B and C
The requirements consist of the following:
- the User can create an object of type A
- the User can create an object of type B
- The User can create an object that has the type A and B at the same Time
- The user can create an object of type C
- The User can create an object that has the type C and B at the same Time
- The base class can have the type C as well.
I was thikning about using the decorator design pattern, but it seems like i ened up making it look so complex.
So is there any other better design patterns to work with.