|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
A silly SQL issue popped up in the last 15 minutes of work, I didn't solve it and it's driving me nuts thinking about it. Anybody got any ideas?
SELECT ev.id, user.name, floor((timestamp - <starttime>)/10000) as bin, ev.details FROM Events ev LEFT JOIN Users user ON ev.userId = user.id WHERE user.id = <userid> AND timestamp > <starttime> AND timestamp < <endtime>
Returns a pretty list of events (for the test user I was checking: 736 in total. Among them, nothing in bin 278.
SELECT user.name, floor((timestamp - <starttime>)/10000) as bin, COUNT(*) as eventsinbin FROM Events ev LEFT JOIN Users user ON ev.userId = user.id WHERE user.id = <userid> AND timestamp > <starttime> AND timestamp < <endtime> GROUP BY bin
Returns a pretty list of bins and counts of events in them. Bin 278 has 43 events in it
WHY?!
|
Events.id is an identity key or can it be NULL?
Edit: Nevermind, you're not joining on Events.id anyway. Does the second SELECT actually work? user.name isn't in the aggregate.
|
On February 20 2018 07:04 WolfintheSheep wrote: Events.id is an identity key or can it be NULL? Primary key for the events table
|
On February 20 2018 07:46 Acrofales wrote:Show nested quote +On February 20 2018 07:04 WolfintheSheep wrote: Events.id is an identity key or can it be NULL? Primary key for the events table See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it.
Are you still getting back 736 total events with the second query?
|
On February 20 2018 07:51 WolfintheSheep wrote:Show nested quote +On February 20 2018 07:46 Acrofales wrote:On February 20 2018 07:04 WolfintheSheep wrote: Events.id is an identity key or can it be NULL? Primary key for the events table See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it. Are you still getting back 736 total events with the second query? Because I select only one user name it works.
I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin.
|
On February 20 2018 08:03 Acrofales wrote:Show nested quote +On February 20 2018 07:51 WolfintheSheep wrote:On February 20 2018 07:46 Acrofales wrote:On February 20 2018 07:04 WolfintheSheep wrote: Events.id is an identity key or can it be NULL? Primary key for the events table See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it. Are you still getting back 736 total events with the second query? Because I select only one user name it works. I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin. Well, without a set ORDER BY results are sorted by retrieval time, which by data is entirely arbitrary. Definitely don't assume one ID is blank by default return order.
|
On February 19 2018 19:26 nunez wrote:Show nested quote +On February 18 2018 12:48 phar wrote:On February 15 2018 19:33 nunez wrote:
in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.
The gcc AST tends to be a less exact representation of the actual source code compared to clang. So if you're e.g. building a tool to refactor all of a given thing, gcc might yield you some missing pieces. Not a big deal for most use cases. you are comparing gcc / clang as compiler front-ends in the context of writing a compiler. spinesheath was comparing compilers in the context of using a compiler. the former is not a use-case in a discussion of the latter, it's irrelevant, and so is the level of abstraction in the AST. in any case: can you give examples of how GCC 'completely fucked with' the AST and caused you pain? what kind of tool did you try to write? I'm not talking about writing a compiler, I know almost nothing about that area.
My specific case in mind is various types of refactoring on a codebase that is ~O(hundred million) LoC.
It simply is not possible to do in gcc. Gcc's ast is not complete, and it removes references to variables on occasion. For a trivial example, see the (obviously hella biased) clang/llvm page on comparison: https://clang.llvm.org/comparison.html.
See here for some similar discussion:
https://lwn.net/Articles/629316/
Again, not really a concern for most use-cases.
|
On February 20 2018 10:45 WolfintheSheep wrote:Show nested quote +On February 20 2018 08:03 Acrofales wrote:On February 20 2018 07:51 WolfintheSheep wrote:On February 20 2018 07:46 Acrofales wrote:On February 20 2018 07:04 WolfintheSheep wrote: Events.id is an identity key or can it be NULL? Primary key for the events table See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it. Are you still getting back 736 total events with the second query? Because I select only one user name it works. I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin. Well, without a set ORDER BY results are sorted by retrieval time, which by data is entirely arbitrary. Definitely don't assume one ID is blank by default return order. I knew that, but from what I was looking at in the list they seemed incremental. Turns out they were not, and the events I was looking for were hidden somewhere else. Crisis resolved
|
On February 20 2018 20:02 Acrofales wrote:Show nested quote +On February 20 2018 10:45 WolfintheSheep wrote:On February 20 2018 08:03 Acrofales wrote:On February 20 2018 07:51 WolfintheSheep wrote:On February 20 2018 07:46 Acrofales wrote:On February 20 2018 07:04 WolfintheSheep wrote: Events.id is an identity key or can it be NULL? Primary key for the events table See edit. Wouldn't you get an error back about user.name? Or are you grouping by that as well and just missed it. Are you still getting back 736 total events with the second query? Because I select only one user name it works. I didn't have time to sum the counts before leaving work. It was the first thing I was going to check tomorrow. That, and make sure there isn't something funky with the event ordering by making absolutely sure I'm not messing up, and order the first query by bin. Well, without a set ORDER BY results are sorted by retrieval time, which by data is entirely arbitrary. Definitely don't assume one ID is blank by default return order. I knew that, but from what I was looking at in the list they seemed incremental. Turns out they were not, and the events I was looking for were hidden somewhere else. Crisis resolved I've found that half my issues are resolved by assuming I'm a dumbass.
|
On February 20 2018 11:39 phar wrote:Show nested quote +On February 19 2018 19:26 nunez wrote:On February 18 2018 12:48 phar wrote:On February 15 2018 19:33 nunez wrote:
in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.
The gcc AST tends to be a less exact representation of the actual source code compared to clang. So if you're e.g. building a tool to refactor all of a given thing, gcc might yield you some missing pieces. Not a big deal for most use cases. you are comparing gcc / clang as compiler front-ends in the context of writing a compiler. spinesheath was comparing compilers in the context of using a compiler. the former is not a use-case in a discussion of the latter, it's irrelevant, and so is the level of abstraction in the AST. in any case: can you give examples of how GCC 'completely fucked with' the AST and caused you pain? what kind of tool did you try to write? I'm not talking about writing a compiler, I know almost nothing about that area. My specific case in mind is various types of refactoring on a codebase that is ~O(hundred million) LoC. It simply is not possible to do in gcc. Gcc's ast is not complete, and it removes references to variables on occasion. For a trivial example, see the (obviously hella biased) clang/llvm page on comparison: https://clang.llvm.org/comparison.html. See here for some similar discussion: https://lwn.net/Articles/629316/Again, not really a concern for most use-cases. i referred to your hypothetical code transformation tool as a compiler. did you try to write this tool yourself?
|
Let's say I was doing vectorized operations with large arrays. My output goes into another, bigger array.
Sometimes the output creates a duplicate, but according to some secondary criteria I will only want to save one of each given output - I don't want duplicates. But i have to discern which to keep. It's probable there will be many duplicates for each output.
So which would be more efficient
1) do all vectorized operations, storing all my output in the huge array. Then sort the array, then filter out the bad duplicates.
2.) save all outputs to a map, along with their index in the array, and check every new output against the map. if it's a duplicate, only keep it if it is the one I want, and if so - remove the old one.
If I was using lists I would go with 2.....
|
Depends on lots of things, your data, the programming language, the compiler, your hardware, what you do afterwards with your outcomes, etc.
I'd do whatever is easiest. If that runs into tractability problems, then start optimizing.
|
On February 21 2018 16:05 travis wrote: Let's say I was doing vectorized operations with large arrays. My output goes into another, bigger array.
Sometimes the output creates a duplicate, but according to some secondary criteria I will only want to save one of each given output - I don't want duplicates. But i have to discern which to keep. It's probable there will be many duplicates for each output.
So which would be more efficient
1) do all vectorized operations, storing all my output in the huge array. Then sort the array, then filter out the bad duplicates.
2.) save all outputs to a map, along with their index in the array, and check every new output against the map. if it's a duplicate, only keep it if it is the one I want, and if so - remove the old one.
If I was using lists I would go with 2.....
The function is called unique. You should have some built-in matrix function that does that.
|
On February 21 2018 04:16 nunez wrote:Show nested quote +On February 20 2018 11:39 phar wrote:On February 19 2018 19:26 nunez wrote:On February 18 2018 12:48 phar wrote:On February 15 2018 19:33 nunez wrote:
in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.
The gcc AST tends to be a less exact representation of the actual source code compared to clang. So if you're e.g. building a tool to refactor all of a given thing, gcc might yield you some missing pieces. Not a big deal for most use cases. you are comparing gcc / clang as compiler front-ends in the context of writing a compiler. spinesheath was comparing compilers in the context of using a compiler. the former is not a use-case in a discussion of the latter, it's irrelevant, and so is the level of abstraction in the AST. in any case: can you give examples of how GCC 'completely fucked with' the AST and caused you pain? what kind of tool did you try to write? I'm not talking about writing a compiler, I know almost nothing about that area. My specific case in mind is various types of refactoring on a codebase that is ~O(hundred million) LoC. It simply is not possible to do in gcc. Gcc's ast is not complete, and it removes references to variables on occasion. For a trivial example, see the (obviously hella biased) clang/llvm page on comparison: https://clang.llvm.org/comparison.html. See here for some similar discussion: https://lwn.net/Articles/629316/Again, not really a concern for most use-cases. i referred to your hypothetical code transformation tool as a compiler. did you try to write this tool yourself?
Ah gotcha, no it's definitely not a compiler. It relies on AST info extracted from the compiler but can't itself compile code. There's ~dozens of people working on this at my place. Aside from a few of the tools nobody writes them by themselves, it's always a team effort.
I wish I was smart enough to write this by myself lol, maybe I would be able to employ myself ha.
Also it is not a hypothetical tool lol, it works and is in active use. We're still mucking with it always, and will be using it or a similar tool more in the future, but we do use it now too.
It will become a tricky problem if we ever start supporting codebases that explicitly use gcc, icc etc. We'll see what happens then, idk.
|
our compiler-concepts differ.
|
So i have two parts of my test Application. One written in C# the other (main) in Python. Whats the best way to exchange data between them? I need both parts of app to talk to each other in "close" to real time conditions (the max delay i can allow i think is around 1s).
|
On February 22 2018 18:22 Silvanel wrote: So i have two parts of my test Application. One written in C# the other (main) in Python. Whats the best way to exchange data between them? I need both parts of app to talk to each other in "close" to real time conditions (the max delay i can allow i think is around 1s). The easiest alternative I can think of is to simply open a socket-based connection between the two processes: it's not the fastest form of communication, but 1s is an eternity.
|
So (I might have mentioned this earlier) our firm doesn't really have any testing policy. Our only testing is done in the form of manually checking that shit works after coding. While this will work to some extent, it's not a super good practice.
So one of my colleagues came up with the idea to run a workshop with everyone to teach people how to set up proper tests and to apply some good practices. The conversation with the boss went as follows:
"No". "Why not?" "We don't have time right now". "When will we have time for this?" "Well everything is a bit unstable at the moment. If we get everything more stable then we'll have ti-" "DO YOU NOT SEE THE PROBLEM HERE?!"
|
On February 22 2018 08:42 nunez wrote: our compiler-concepts differ. Ok sure, possibly because I know almost nothing about building an actual compiler.
|
On February 22 2018 23:04 Excludos wrote: So (I might have mentioned this earlier) our firm doesn't really have any testing policy. Our only testing is done in the form of manually checking that shit works after coding. While this will work to some extent, it's not a super good practice.
So one of my colleagues came up with the idea to run a workshop with everyone to teach people how to set up proper tests and to apply some good practices. The conversation with the boss went as follows:
"No". "Why not?" "We don't have time right now". "When will we have time for this?" "Well everything is a bit unstable at the moment. If we get everything more stable then we'll have ti-" "DO YOU NOT SEE THE PROBLEM HERE?!" Aaaahhh, I remember having a similar conversation once. Good times....
|
|
|
|