Firestore write data missing [closed] - swift

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have this code, and it is supposed to write to Firestore. However, when it does the function, in the back end, it shows highlighted as red and then disappears.
db.collection("jokes").document("Dad Jokes").setData(["\(dadJokeNum + 1)": Joke.text!])
Please help.

Using SetData without Merge will delete existing values - it is suggested that if the document exists prior, you should always be using merge: true. Firestore also has a limited 1 write per second each, you should be managing writes together as it is most likely similar writes will conflict and potentially resolve out of order.

Related

How to fetch subcollections using streambuilder in firestore [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 days ago.
Improve this question
I have subcollections in firestore database and I want to fetch data from subcollections using streambuilder also use Listview.builder to show.
I have database like this
- Collection ->doc1->collection->doc->data
->doc2->collection->doc->data
->doc3->collection->doc->data
->doc4->collection->doc->data
->doc5->collection->doc->data
->doc6->collection->doc->data
Please write a query to fetch the data from database like this
For Future call:
you could use something like, if you don't know the next value for the document.
For streambuilder:
Would be to much heavy for encapsulated querys to make it.
One way to get values from a "col>doc>col>doc>data" is to get it directly like:
Stream<UserData?>? get data {
if(uid != null)
return collectionsT.doc(uid).collection("col1").doc("doc2").snapshots().map(_dataFromSnapShot);
return null;
}
Replicating that data in a diferent shorter path collection.
Or saving the path in some kind of a "static" path Table> staticPath="doc/col/doc/col"
Normally "doc>col" structures are created in a way to have all the information that will be used in that screen that is designed to show, even if the information is replicated.
A trick is to calculate if the reads that will be done to that document with replicated information is lower than the updates. If that is the case, is needed a way to sync that information on the specific document. That is the information that google gives, by the video tutorials.

Is Swift string count included in string storage? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
My app involves repeated equality comparisons of many megabytes of an array of strings. I was (naively?) surprised that such comparisons became immensely faster when I added a shadow array of the count of each string; if the counts are not equal, the strings cannot be equal.
I would have thought that the Swift compiler could easily and efficiently maintain a string's count in the internal representation, and short-circuit string equality comparisons if the counts differ. The initial creation of each string would provide the opportunity to initialize the count, and each manipulation would then know the count of each participant. But it seems not so. If only some applications would benefit from a stored count, a compiler switch to turn it on could help them.
Would this be a reasonable standard library refinement?
The problem with String is that it is not stored always in the same way. There are different types of storage and for them to be properly compared, they have to be converted to the same representation first.
Looking into the source code here: StringComparison.swift, I think you are right and count should be compared first when checking equality.
I recommend filing a bug.

Drools LHS How to update map [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Sorry for my bad expression. Actually I asked one of my friends who majored in English but knew little about programming to revise my posting. And it turns out that the problem makes less sense, though. I've conducted some research and realized that I should learn more about Drools for my next asking. Thanks for your patience, and the question will be deleted.
I've created a simple reproducer to understand better what's happening. You can find the project that fires both rules here. I always suggest trying to create a simple reproducer with the Drools archetype because it's easier to understand what's happening.
Having said that, your second rule is not firing because the condition this["ISELSE"] != "TRUE" is not satisfied. In fact you can see you put the value of the map to true in the first consequence.
$map.put("ISELSE", "TRUE");
A few other details:
You shouldn't do pattern matching on such a generic type such as java.util.Map. Use a specific type that wraps a Map. Be as specific as possible in your pattern matching constraints.
Also why using string booleans instead of java booleans? Drools supports all Java type system, and it's probably better to use better data types.
In the video you'll find some other suggestion such as using DebugAgendaEventListener to understand rules evaluation
Rules matching is indeterministic process, you can't predict LHS matching order.
Once matching process finished, rules are added to agenda queue for execution.
RHS execution order is indeterministic unless you use salience. Rules with bigger salience will be executed first.
If a rule changes state of the object while execution, next queued rule will be removed from agenda queue if LHS no longer matches.
If I understood you right, you need salience 1 for rule-2

ObserveSingleEventOfType(ChildAdded) only return one snapshot Firebase [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have 3 FirDataSnapshot. When I am using observeEventType(.ChildAdded,..), it returns 3 item. When I use observeSingeEventTypeOf, it returns only 1 snapshot. I don't know why.
observeSingleEventType returns single value means it observe .childAdded only once ... the block is immediately canceled after the initial data is returned.
If you are using observeEventType than it gets all values from database ..

What distance metric for project source code makes sense? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to compare the changes of the source code of two project stages, e.g. the web application source code before it was scalable, and the scalable one.
For me it is interesting to show how many lines needed to be changed, removed or added to get from one to the other stage. I'm searching for a good distance metric that rewards less code and little code changes - the one I imagine would output a relative value:
0% = "Both projects are the same"
50% = "Half of the source code has been changed"
100% = "Both projects have nothing in common"
Intentionally I came up with a few solutions:
diff: Maybe concat all files to a single source code file and run a diff against them. Problem here is that less code is better, but with this solution is counted as a plain change therefore punishing code removal.
Levenshtein Distance: Calculates the changes needed to transform source code a to source code b. The result is a number of changes in characters. Problem here again is, that code removal is not rewarded but punished.
Unified Code Count: Sets up rules how to consistently count lines of code, but is no descriptive distance metric between projects.
So I'm searching for a metric that is descriptive, rewards code removal and only counts in code changes or additions. It doesn't have to be source code specific, both projects use the same language. My personal feeling goes into the diff direction but I did not come up with a satisfactory descriptive metric.
What would you propose?
If you want, you can make this into a really difficult research problem:
http://gate.ac.uk/sale/dd/related-work/tao-related/2007+Kagdi+Survey+for+mining+software+repositories.pdf
This approach: http://www.cs.kent.edu/~jmaletic/papers/icsm04.pdf looks like it's under active development here: http://www.srcml.org/ .
There's other, more general, code metrics tools listed here http://www.aniche.com.br/wp-content/uploads/2013/04/scam2013.pdf (though it looks like the tool advertised by the paper is down now). Apparently Sonar has the ability to look at metrics over time: https://en.wikipedia.org/wiki/SonarQube