• Brian Boorman (google)

    SET bitnum = frist

  • True (unregistered)

    Yes, Jane looks like someone opposed to healthy diet - wondered why the hate...

  • someone (unregistered)

    Forgive me if I'm wrong, but would using a version control system with branches prevent the issue of _NEW, _PROD and _DEV?

  • LCrawford (unregistered)

    But wait, how can they do clever combination searches without creating a big-big-hugeint from an array of byte first?

  • someone else (unregistered) in reply to someone

    You're correct in theory. The "prc_" prefix indicates a stored procedure (think of this as a custom method attached to the database object) which makes things a bit trickier

    Far as I'm aware, the ideal solution would be something like: stored procedure definitions held as text files, controlled by a source control system, with a bunch of clever scripts to roll the repository contents out to the relevant database. Extra cleverness is required to handle any table layout changes, as you can't just store all your data in the CVS.

    The additional effort required to set up such an arrangement, and to get one's head around version control in general and database version control in particular, means that a lot of companies basically do their version control on the honour system. Situations like the one here are distressingly common.

  • Pjrz (unregistered) in reply to someone

    You're giving the original developers far too much credit.

    In my own inherited codebase, which now uses source control by never used to (though at least they kept backups of main builds), there were tons of functions called SomeFunction_old, SomeFunction_old2, etc.

    They remained there for quite some time until they bugged me enough that I decided it was time to purge!

  • not me (unregistered)

    Paranoid hippies? Harsh.

  • RLB (unregistered) in reply to not me

    Harsh, but deserved.

  • (nodebb)

    "with a bunch of clever scripts to roll the repository contents out to the relevant database. Extra cleverness is required to handle any table layout changes, as you can't just store all your data in the CVS."

    Proper tooling to handle this has been around for about a decade.....

  • someone (unregistered) in reply to Pjrz

    Well, sure. Hence my inclusion of "using", not "having" :)

  • (nodebb)

    Later, these numbers are added together so that groups of technical functions effectively have a distinct number, allowing them to be used as a bitmask to search for the additives. "Clever" at its finest.

    And this would be searched with a database engine, how? No database engine I'm aware of provides any predicates for searching by bit mask. This is a WTF's WTF, a second-order WTF.

  • Kashim (unregistered) in reply to Pjrz

    I just left a place that believed that the methods that they wrote should be named _v1 and _v2 if they wanted a new method with the same name and different behavior. Thus "GetAbsolutePath_v1" would get the absolute path to a file, but if the path was on another drive, would throw an error and die. Thus, this warranted "GetAbsolutePath_v2" which would properly parse addtional drives.

    We had version control. CVS, but still version control. Someone copy and pasted v1 to make v2, then added 3 lines of exception handling at the top. Why? They "didn't want to break the functionality for anyone who was relying on v1 throwing an error." The end result? I find it 3 years later, and v2 has become abandonware, because someone renamed v1 back to "GetAbsolutePath", and everyone used it without worrying about it.

    This is along the same lines as wanting to keep old, buggy code in the codebase by commenting out huge blocks of code and then never cleaning them up.

  • Trust Me I'm Not a Robot (unregistered) in reply to someone

    Ha ha ha ha! Ha ha ha ha ha ha ha! Ho ho ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha!

  • (nodebb)

    That was more "Brilliant" than "Clever"

  • 04012018 (unregistered)

    Trust me folks, space aids is real.

    https://bit.ly/2HnUd2o

    I'm going to walk around the block and stand on the corner. Just kill me if it's a problem. Please know that I only did this not for any personal gain or profit, not for any malevolence or ignorance, but for hope for Planet Earth.

    For further questions regarding the philosophical or theological ramifications or debate of this Dungeons and Dragons game, and I really do mean that, game, G-A-M-E, culminating in the following:

    • March Madness Chinese Prom (dry hump PMS Olympics to promote sportswear fashions)
    • Clean Cut Free the NIP Activity Summer 2018
    • Advancements in medicine for the human brain to provide invincible human immortality
    • A new elementary model utilizing the Laplace Equation
    • Send your children to Geh... I mean the Gannon!

    For questions, please contact my "colleague", fellow graduate of Gannon University Mechanical Engineering 2004, Gerard Pawlowski. He will happily assist on any theological, philosophical or mathematical questions:

    https://www.facebook.com/gerard.pawlowski

    Please also inform him that the meta-exorcism may continue, as long as he proscribes by the Hippocratic oath regarding myself and my family, and he and his brother, who I think is a Monsignor now, is having fun!

    Satan must flap his wings, I guess. Probably not. But I'm not Satan, no, and neither is my family.

    But for all intentions, Satan works for me now! He may work for you too, if you go to the Gannon! If not, send your kids, especially if they are problem childs! The Diocese of Erie knows how to handle many devil worshipers. Just sell them off to the navy at $5 a head and turn them into drunken sailors!

    please consult my colleague, friend and fellow graduate

  • CowgirlNelly (unregistered)

    Yes, everything that's added to food is added for one reason: profit.

  • 04012018 (unregistered)

    https://www.linkedin.com/in/gerard-pawlowski-413428aa/

  • 04012018 (unregistered)

    If it's too much, we could also discuss the McBride Viaduct here:

    https://www.facebook.com/Rethink-the-Mcbride-Viaduct-1436971393204864/

    Maybe rename it, and give hospitals a say in what makes ambulances run faster?

  • 🤷 (unregistered)

    Nice. The spam posts still get through. The moderation should be held, until those comments have been cleared up.

  • ooOOooGa (unregistered)

    "Paranoid hippies" Seriously? That is ad hominem of the darkest stripe.

    Yes. There are many people who don't think that the FDA and other government agencies actually have the public's best interest at heart. Given the track record of recent years I am inclined to agree with them. My aunt suffers from short term memory problems caused by some new drug that her doctor gave her, and my mother-in-law died for several minutes from something her doctor gave her.

    How many drugs have been recalled in recent years due to health concerns?

    "Paranoid hippies" indeed. Just because people are paranoid doesn't mean that they are wrong.

  • Kashim (unregistered) in reply to 04012018

    Lol, the Singularity will come in the form of a spam bot that we cannot tell is a spam bot. Does it count as passing the turing test when even humans cannot tell anymore which ones are the spam bots, and which are the real posters?

  • Yep (unregistered) in reply to 🤷

    In the meanwhile, less than half of my comments are coming through without passing the moderation queue.

    Even if my comments were spam, at least I'm not a robot.

  • W (unregistered) in reply to 🤷

    Evil thought: Could it be that the spammer is an insider that controls the moderation? If this comment is held for moderation at least I will know.

  • Oliver Jones (google)

    Gödel-numbering combinations of food additives? Wow. Just wow.

  • I Am A Robot (unregistered)

    "the bitNum was never used" probably should be "the bitNum was no longer used" - I'll bet anything that someone removed the use of the value while leaving the calculation.

  • I Am A Robot (unregistered)

    And adding DEV, QA, PROD, etc to the end of versions. I'll bet after an incident where development code was run in production someone made a rule saying that all code must have an identifier to say which environment it can run in.

  • Pedro (unregistered)

    I think the moderation detection code is missing a "!" ...

  • Pedro (unregistered)

    edit: I think the SPAM detection code is missing a "!" ...

  • John (unregistered)

    https://en.wikipedia.org/wiki/The_Elements_of_Programming_Style Lesson 1.

  • tbo (unregistered) in reply to CoyneTheDup

    MySQL has ENUM and SET types, which act behind the scenes as bitmasks, but they have limits.

    Really, this information probably should've been in a separate table (or two, if additives can have many functions).

  • William F (unregistered) in reply to TheCPUWizard

    I'm sure there's a lot of WTF fodder in the hand-rolled stored-procedure-management code that's out there...

  • Jeremy Hannon (google) in reply to CoyneTheDup

    Microsoft SQL Sever has supported bitwise operators since the 2008 version. You can use operators such as &, |, &=, |=, ^, ^=, and ~ to perform bitwise queries against integer fields. I have not used them much, so I don't know how efficient they are, but it is possible.

  • (nodebb) in reply to Jeremy Hannon

    Oh, sure, bitwise operators are in many database engines. But those are not search predicates. Say I want VI bit from the right set to 1, I would need to do something like:

    where (col & 64) > 0
    

    But that requires evaluating every row in the table, there is no indexability for performance.

    Addendum 2018-04-10 00:18: "6th bit", not "VI bit". It is truly amazing what Chrome thinks dictated text should be translated to.

  • Abe Z. (unregistered)

    Why is this "feature" article and not CodeSOD?

  • (nodebb) in reply to CoyneTheDup

    There are DBMSs that provide for indexing on expressions, and/or computed columns. Of course, you would still need to declare separate indexes for "col & 1", "col & 2", "col & 3".... though you could skip the last one if you asked for "where (col & 1) > 0 AND (col & 2) > 0".

  • bobcat (unregistered) in reply to I Am A Robot

    I think you've hit the nail on the head. It USED to be set up that way, several revisions and probably even programming languages ago, when the architecture couldn't handle a fancier setup. Someone realized it wasn't necessary, and set up the newer and better method, but never trimmed out the function. Possibly in case they needed to fall back to it.

    Just imagining an ancient system that has been clunking along on COBOL since dirt was invented, where that bitmap was a lifesaver in terms of searchable data... Oy.

  • Just a fan (unregistered)

    WTFs from Jane Bailey are my favorite ^_^

  • 04012018 (unregistered)

    There needs to be a conversation for it to count as passing the turing test.

  • Si (unregistered)

    I don't see the code doing what it's claimed to do. The exponent is the dense_rank() of any given row within each TechFunctionId partition, with the partition ordered by RowId (which will give the same result as row_number() if RowId is unique across the table or even just each TechFunctionId). So there could be billions of different functions, but >= 63 (int and bigint are signed) RowIds within a function will result in an overflow.

    If RowIds represent additives, then I can't figure out what bitNum is meant to be useful for (though it apparently wasn't found in the code...).

    From a brief shitty test I just tried, I'd also say that updating a CTE with the result of the power() results in about a 300% increase in memory grant, though I'm guessing at the table definition :s

  • (nodebb)

    Reminds me of setting up custom processing attributes in a major application from a certain company that we love to hate (but which I might get into trouble for naming explicitly). No joke, for each one you had to assign a unique prime number (starting from enough after the predefined ones to leave room for future predefined ones), and when you set up a processing rule using them, it would compute the product of all the attributes used and store this on the rule. Since prime decomposition is unique, it could then reverse this to identify which attributes were being used.

    The UI has been improved to the point that you don't have to physically select the prime numbers yourself now, but it still behaves this way behind the scenes.

    It still boggles me that anyone would think this is a good idea. Clever, yes, even ingenious, but GOOD? No.

  • Si (unregistered) in reply to Scarlet_Manuka

    the phrase I have to come out with more often than I'd like to is "you can build Tetris in Excel if you really want to, but if you actually wanted to play a round of it you'd pick up a fucking Game Boy"

  • (nodebb) in reply to Scarlet_Manuka

    I'm guessing the decomposition routine wasn't anything special: even if it did verify that the user-selected "prime numbers" really were prime before using them, I'd still be specifying numbers like 123456791 and 9876543211 and 1073741827.

  • (nodebb) in reply to Scarlet_Manuka

    Prime number decomposition is only useful if you need to store an indefinite number of integers as an integer; your use case sounds as if the OP's bitmask approach would have sufficed.

  • (nodebb) in reply to urkerab

    Prime number decomposition is only useful if you need to store an indefinite multiple of each selection as an integer: e.g. five of the first selection, none of the second selection, eight thousand of the third selection, etc. If it's a simple matter of on or off then bitmasks will suffice, and they are always more compact.

    This makes a difference in a world where integers have fixed length. With 16-bit integers, bitmasks allow for 16 variables. With prime decomposition, the most you can have is 6, since 2 * 3 * 5 * 7 * 11 * 13 * 17 > 65535.

    Addendum 2018-04-18 09:50: Actually,my first sentence is false. Prime number decomposition can only be used for on or off. Five of the first selection ("2") is indistinguishable from two of the third selection ("5"), or for that matter one of each--the result in all cases is 10. So yeah, they really don't have any advantage over bitmasks.

  • Bl1ngBl1ng (unregistered) in reply to CoyneTheDup

    Oh, but they do my friend, they do. I've seen this level of clever by a former programmer at my place of work, consider a table with keys that are powers of two:

    ID DESCRIPTION

    1 Frist 2 Brillant 4 True 8 False 16 FILE_NOT_FOUND

    Now lets say you have the value 19 which would be 1-Frist + 2-Brillant + 16-FILE_NOT_FOUND. You have, at least in Oracle, the function BITAND at your disposal, so ...

    SELECT * FROM table t WHERE BITAND(t.id,19) = t.id;

    Et voila, it will return those 3 rows. I don't condone this, the obvious problem of only being able to handle 32 items with an unsigned 32-bit integer, and no, casting to a float when there are more than 32 items will not fix the problem, sure it won't overflow but you won't get the right answer. Why casting to a float isn't a solution is left as an exercise for the reader, understanding how floating point arithmetic works is a handy skill. Hint, float loses integer precision around 2^23, so you can now handle 23 items instead of 32 if you cast first, not the direction one would hope to head towards.

  • (nodebb) in reply to jkshapiro

    "Actually,my first sentence is false. Prime number decomposition can only be used for on or off. Five of the first selection ("2") is indistinguishable from two of the third selection ("5")"

    Well, actually your first sentence is correct. You just don't multiply the prime with the n, you put it to the n'th power. Five of the first is 2^5 = 32 and very distinguishable from two of the third 5^2 = 25.

  • Dr. λ the Creator of Variables, Binder of Variables, Applicator of Terms and β-Converter of Redexes (unregistered)

    "Someone has to maintain, for example, the database that keeps track of every legal additive to food so that paranoid hippies can call them liars and insist they all cause cancer and autism."

    Yet many of those "paranoid hippies" are slim and healthy while you are fat and unhealthy. So clearly they are doing it right and you are doing it wrong. Who's opinions on dieting should people take more seriously? Those of the people who fail at dieting or those of the people who succeed in dieting?

Leave a comment on “Another Bitmask Fail”

Log In or post as a guest

Replying to comment #495097:

« Return to Article