« first day (1649 days earlier)      last day (3296 days later) » 

5:00 PM
@LuiggiMendoza This has been a request for spoonfeeding from an hour ago til now.
 
@Unihedron one more request won't hurt @rubin.kazan :P
 
~brb deploying
 
@LuiggiMendoza How would i approach sorting the arrays??
hang on
ill show u
 
@LuiggiMendoza I'm not sure if you're taking me incorrectly, but the user has been asking for their code to be written since an hour ago, "one more request" doesn't apply here. :P
 
@rubin.kazan do you know how to sort an array?
 
5:03 PM
@LuiggiMendoza ill give it a try and post code here
 
@Unihedron yes, I misread your comment, sorry. And my request was about @rubin.kazan please provide any code you have used to sort the arrays in order to help you, we won't write all the code from scratch for you, that's not how this site works and if we do that we're not helping you to learn, it will be the other way around: we will be hurting you and stopping you from learn
part of the learning process of programming (as in many other fields, not IT related) is the trial-and-error
 
I'm curious - why don't you have a github profile?
 
Hello all! Back from my vacation at the "Happiest Place On Earth(™)"
 
@Kylar Hello hello!
 
I DO have a github profile. With hardly anything on it. ;)
Hi Uni!
 
5:04 PM
Hi @Kylar
 
Hi @LuiggiMendoza
 
Okayso
Here is my shot at sorting the linked arrays
not sure how I would implement it in my code
 
Hi @Kylar
 
Hi @ItachiUchiha!
 
@Kylar Not really targeted towards you, but most of the high reputation users I find likely have contributed something to OSS development; I'm surprised that Luiggi wasn't one, which was the essence of the question :p
 
5:06 PM
@Kylar what is the so called "Happiest Place On Earth(™)" ?
 
@ItachiUchiha ask wolfram alpha
 
@rubin.kazan that will work if the number of elements in both arrays is less than 5
 
@Unihedron lolz
 
@Unihedron That's a pretty good baseline. I've got a couple forked repos, but I'm forbidden by Work to contribute to them externally. If you're very good, you can occasionally find places where I've found breakages in the JDK or Apache libraries and asked for fixes :)
 
5:07 PM
@ItachiUchiha: Disneyland
 
@ItachiUchiha ^
@Kylar omg seriously?
 
@Unihedron I have 3 kids :)
 
@LuiggiMendoza is it correct then?, do i just change the for loop to be like 99999999
 
When I was a kid, I heard good things about disneyland - going to one was a huge let-down
 
@rubin.kazan You should know the length of your array. Set the upper bound of the loop to that.
 
5:09 PM
@Kylar ah
@Kylar I understand now, once I use this sorting technique how do I apply it to my main question to display the corresponding users marks with their name
 
@rubin.kazan you should change it to n, where n is the number of elements in the array. And n is not array.length
 
@rubin.kazan If you are keeping the same index in the array for both (as it appears you are) - then you could just loop through a second time and print out each one.
 
@Kylar how would i perform this?
 
That's the simplest (from a logic) stand point
 
@rubin.kazan By writing code that does it.
 
5:11 PM
@rubin.kazan you already have a loop, right? You're looping through the arrays.
 
@Kylar I don't get your point
 
@LuiggiMendoza Sorry, what point is that?
 
@Kylar what do you mean by loop through a second time and print out each one?
@Kylar OP's problem is to sort both arrays at the same time
 
^^
I can show an example input/output
 
anyway
 
5:12 PM
@LuiggiMendoza He just asked how to display the users with their marks. He's already sorting them at the same time
He's keeping consistent indexing in both arrays, assuming they're set up properly before hand
 
input:
rubin 42
jake 27
oliver 13
lucy 99
output:
lucy 99
rubin 42
jake 27
oliver 13
 
@rubin.kazan if you need descending order, then use > rather than < in your sort method.
oh no, keep the code like that
I though you were comparing array[j] against array[i]
 
i have a String array and an Int array
 
compare ints by using >,< or =
compare Strings by using compareTo method
 
@LuiggiMendoza Don't compare strings.
 
5:15 PM
why would i need to compare the strings?
 
it will depend on what field you need to sort
@rubin.kazan I don't know, it depends on your task
 
if I'm sorting the marks? surely the marks will be linked to the names?
 
@rubin.kazan again, you code should work fine
as is
 
Yes, that's right based on your code
 
it will sort both arrays based on the marks
 
5:16 PM
And then he needs to print them out which is what he was asking before.
 
How would i display this
@Kylar correct
 
as @Kylar explained
 
this is some code i have i mind
 
traverse one of the arrays
 
@rubin.kazan do another loop (the for...) that you did the first time. Then for each one, call the print function for both the name and the mark.
 
5:17 PM
and print the elements of both arrays at the same index
 
@rubin.kazan yes
 
so do i create a separate button to sort the code
and a separate button to print the code?
 
uhm
I think you should do it for now
but it depends on the task
I guess you can do that for testing purposes
 
where would i insert that line of code though?
inside the for loop of the sorting algorithim>
 
5:19 PM
@rubin.kazan you could just sort it and then print it out. You don't need two separate buttons.
 
@Kylar how would I perform this?
 
@rubin.kazan how are you performing it now?
 
@Kylar I've tried to include it into the sort loop but it just prints the code out 5 times (size of the array)
 
Don't put it in the sort loop
put it after the sort loop
 
5:21 PM
~deploy finished
 
does anybody knows a data structure that supports queries like this: SELECT columnX FROM tableX WHERE columY like '%<parameter>%' ???
 
@LuiggiMendoza JOOQ
 
@rubin.kazan down one more }
 
@Unihedron that's a framework for executing the query
I'm looking to optimize this by doing the search on memory
 
@Kylar i get an error?
 
5:22 PM
@rubin.kazan keep trying. Move things around. google the error.
 
Can't you use a prepared statement?
 
so instead of hitting the database, I would perform the lookup in memory, that's why I'm looking for a data structure that can help me to solve this
@Unihedron the problem is the time response of the query
 
@Kylar the j's inside the [] are just underlined red
 
because it's a LIKE '%<whatever>%' sentence
 
@LuiggiMendoza from what I know you could try to index this column
 
5:23 PM
@LuiggiMendoza Using a LIKE this way isn't performant anyway.
 
the query plan shows it doesn't make use of any index
 
make one
 
@rubin.kazan because you're using j inside the other loop. Try using i, which you're using inside the outer loop
 
@Kylar is this correct then? hastebin.com/uhilikonik.tex
 
additionally in-memory-caching could help
 
5:23 PM
@Unihedron I know all that...
so again, my problem is
the time response for that query is loooong
 
You're doing a pattern match against a varchar?
in what DB?
 
I know SE runs some of these queries against their databases regularly
 
@Kylar mysql
 
and their response time is minimal
 
how big is the dataset?
 
5:24 PM
1m records now
 
and what's the column definition?
 
it will increase on time
 
Create an index in your db?
 
for X and Y since you'd need both
 
varchar(100)
 
5:24 PM
@LuiggiMendoza Ditch it. MySQL is the worst DB.
 
@Codeconuts the field is already indexed
 
@Kylar @LuiggiMendoza thank you very much. problem solved
 
+1 for that. Switch to postgres or something
 
@Unihedron it's what I have at the moment, I cannot change that
 
@rubin.kazan Welcome.
 
5:24 PM
@rubin.kazan you're welcome
 
If both are indexed, and you're doing a match against 1M records, your lookup time should be subsecond
 
@Kylar @LuiggiMendoza took me 3 hours to solve, i feel as if I've wasted so much time over a simple bit of code but i also feel as if i have learnt so much
 
@Codeconuts indexes don't work with a LIKE '%<whatever>% query
 
they should...
 
yeah because its like
 
5:25 PM
@rubin.kazan it happens on learning phase, don't be ashamed
 
You can't do fancy matching algorithms with wildcards at both ends of a match
 
@rubin.kazan every programmer had that feel at some time, you're not alone
so that's my problem
 
You need to search every char effectively
 
and I'm thinking on loading the data into memory
and do the lookup there
 
if you can optimize your query you'll get better results.
 
5:26 PM
@Kylar the query cannot be optimized
 
@Kylar With MySQL as the DB in question, that's impossible.
 
@LuiggiMendoza I wouldn't be so sure
 
it will always return that it doesn't make use of an index
 
decentralize your data?
 
@LuiggiMendoza That means basically doing a tuple (Colx->ColY) and doing a regex or incremental character search against everything in ColY
 
5:27 PM
am i allowed to ask u to tick my answer to close the question?
or is that against the rules?
 
@rubin.kazan you can provide an answer to your own question and post the relevant code that helped you to solve it, after two days you may accept your own answer
 
@Kylar yes
 
why was my answer down voted?
 
You posted an answer already?
 
5:29 PM
@Vogel612 well, I'm doing some research on the topic, if you can prove that I'm wrong (and I really hope to be wrong and find a better solution) I will really appreciate it
 
@LuiggiMendoza decentralize your data to your subject? what is the need of your query anyways to use wildcard
 
@Unihedron no need to be a douche
 
@Codeconuts because users like to do that kind of search
 
@rubin.kazan What? @Unihedron didn't say anything that is out of order.
 
@rubin.kazan Wow, that's really rude. I didn't even comment on your issue for all that time, and you just had to bring on a groundless argument.
@Kylar They did. What do you think I'm putting up with for the entire hour?
 
5:30 PM
@LuiggiMendoza if they want speed then they must learn to filter their search :P category then wildcard
 
@rubin.kazan OK, first and last warning - no personal attacks, no name calling.
I'm not as nice as the others.
 
lmao
 
@rubin.kazan To begin with, the formatting is inconsistent (once again) and there's virtually no explanation of your code. This is the type of answer I would flag to have them deleted.
 
@Codeconuts that's not available
 
With little information to how it's a solution, this is not an answer.
 
5:32 PM
ok, let me explain the problem again
 
@rubin.kazan goodbye
 
imagine we have a table like this
 
So many flags :I
 
ohhh the flags again
quick, make a wish!
 
LOL
 
5:33 PM
because some users can't just play nice
 
Do i post my solution in the main question?
 
Welcome everyone ;)
 
CREATE TABLE PERSON(id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100), uniqueidentifierfromexternalsystemwecannotcontrol VARCHAR(100), KEY idx_identifier(uniqueidentifierfromexternalsystemwecannotcontrol));
now, users may need to do a lookup on this table by this field uniqueidentifierfromexternalsystemwecannotcontrol
but using only a part of the value
 
Your database design is all over the place.
 
oh legacy systems...
 
5:36 PM
that's why we have this query: SELECT * FROM person WHERE uniqueidentifierfromexternalsystemwecannotcontrol LIKE '%<whateverTheUserWantsToPutHere>%'
which, obviously, has performance issues
 
is there structure to that string at all? like systemblahblah_user_id_blah
 
@Codeconuts the names are for having a better understanding of the problem
 
@LuiggiMendoza as I said before, if you can't ditch MySQL, you're screwed with this statement - there's nothing you can do
 
the fields are not named like that :P
@Unihedron mysql only
 
Then, you are screwed.
Work on caching the results or something.
 
5:38 PM
Well lunch time, maybe its better to ask this in SQL chats :P
 
@Unihedron again...
 
@Codeconuts No one hangs out there anymore, you won't get any help there.
 
my proposed solution is to load this data into memory
and to the lookup there
in memory rather than against database
 
which is really just a fancier way of saying caching :)
 
so, I'm looking for a data structure that can do a better lookup for this
 
5:39 PM
If you use Guava, there's a thing for caching values
 
@Unihedron caching by using this field as key won't solve the problem :)
 
I forgot what it is.
 
I'm aware of that
 
... use it?
 
@Unihedron the solution will be like List<Person> results = new ArrayList<>(); for (Map.Entry<String, Person> entry : personMapInCache) { if (entry.getKey().contains(userInput)) { results.add(entry.getValue()); } } return results;, which is the same as letting the database do the simple query and returning me the data
@Unihedron and that's what I want to avoid, using a linear search
 
5:41 PM
 
is there any data structure that can do this kind of lookups in less time than O(n)?
 
@LuiggiMendoza You could had just said that earlier.
 
@Unihedron I've said that from the beginning =_=
 
I must have been distracted. :P
@LuiggiMendoza what about hashing directly?
the keys, that is.
 
@LuiggiMendoza Is the piece of the uniqueID that they hand you always consistent?
like, do they always give you N characters
 
5:43 PM
@Unihedron could you explain more of this?
@Kylar the size may vary, it depends form the external system
it can be of length 10, 20, 50, 35...
 
Doesn't that cause collisions?
having the same 10 chars in more than one key?
There's no way to do this more efficiently than O(n) unless you have some way of reducing the problem space
 
for example, if the user naively filters the data by using a single character, like '1'
 
Which may match 500K results
 
the query will make the system explode (and both users and us are aware of that)
yes @Kylar you're correct
 
If the input data is arbitrary and you're doing a wildcard search, then you're screwed.
What you could do
is something like this: Load it into memory and use something like Lucene to index the objects.
 
5:49 PM
@Kylar that's the kind of solution I'm looking for, but I don't know that much of these technologies
a coworker here had the idea to use mongodb but I don't know about it either
 
You're still on your own with keeping the cache up to date. But 200M of data is a fair amount
Wait, you can use other DB's?!?!
 
yes, I can
I never said I cannot
 
Drop MySQL already then
 
So... make a Postgres or Oracle DB and dump all the data into it and use THAT as a cache.
 
@Unihedron that cannot be done, get over it
 
5:52 PM
But you can use 2 DB's
 
@Unihedron it's a technical restriction we have to live with
 
and just sync them
Use one that's optimized for data retrieval, and one that's your canon
 
@Kylar we have postgres available, that can be another solution
so I have lucene and PostgreSQL as alternative solutions to do this lookup
that's great, thanks @Kylar
 
... What?
 
@Unihedron you keep saying drop mysql, that cannot be done for my case (even if I want)
so please stop it
 
5:55 PM
Having two databases in one project as a slave clone isn't any solution to any problem.
@LuiggiMendoza I wasn't even addressing that.
 
@Unihedron Here's a place where I'm going to pull the experience card and say "Sadly, you're wrong."
There are times when you have business decisions that are made for you that you have no choice in the matter about
 
Wait and see.
 
and you have to live with them and make the best solution that you can, given really really bad constraints
 
@Kylar yep, it's part of what we have to do
 
and if that means using one DB as canon and one as a slave to look stuff up...
:(
 
5:56 PM
get the best from crappy systems
 
Then that's what we have to do.
 
thanks for the help
I'll evaluate these technologies
proof of concept, benchmark, and all that funny stuff
performance, memory limitations, high availability, etc etc...
bye guys! see ya on Q/As on SO
 
@Unihedron This is one of those things that will cause you to become more and more jaded as time goes on. when you know what the RIGHT solution is, but "they" will not let you use it because of "reasons"
 
@Kylar It's not a solution at all, that's a workaround. That's what I was pointing out - the precondition is irrelevant.
 
I think it depends on the way that you view the problem.
Luiggi's problem is "These queries are too slow".
if having a slave DB with indexed queries makes his lookups faster, then many people look at that as a solution.
the root of the problem may be that "At some point, someone decided on a DB that we cannot change and is now not the right fit to our data needs", but that's not the problem that he has to solve.
And sadly, this is the kind of problem that most programmers will need to spend at least a few years "solving/working around" in their career.
 
6:04 PM
I discarded my stance because you have the experience card.
Cool cool.
:P
 
There are other choices, of course. You can start your own company. The truth of the matter is that money runs businesses, and solutions cost money.
If replacing the DB entirely costs 6 man months, and a dual DB workaround costs 1 man month, it's easy to know which one they'll likely pick.
:p
 
Hmm...
 
There are many writings about things like this.
 
I've been catching up on a few lately.
... Meh.
 
"Who is more likely to reach the other side of the river? One who dreams of a raft, or one who hitchhikes to the next bridge?"
 
6:10 PM
> Upon hearing this, the programmer was enlightened.
Good for him, I have no idea what the metaphor's supposed to mean.
 
Then you must study. Enlightenment takes time, young padawan.
 
Nah, if enlightenment involves philosophical thinking, I'm not a lucky one.
 
You'll get it :)
 
6:26 PM
There's a lot of stuff in there about the Unix Way
 
um, one day I'll buy it.
 
It's free
You can read it online
He wrote an earlier book called The Cathedral and the Bazaar about how companies build software
it was more or less a Microsoft Vs Unix
 
Meh, all is full of false dichotomy.
 
fge
6:48 PM
Heh, for my work, ideally I'd read the source directly from the database but the client doesn't want that
No sir; you have to fetch XML sources from a TFS server and parse them to generate the source to analyze
hiccup
 
7:01 PM
@Kylar gotta love footnote no. 2
 
@Vogel612 Wut wut?
 
7:24 PM
> 2. This particular footnote is dedicated to Terry Pratchett, whose use of footnotes is quite...inspiring
 
Quick question: I have a excel spreadsheet 2 tabs. One tab with rows of data that I need to add an additional 12 records to each row. Whats a quick method to solving this problem :P
 
7:45 PM
@Codeconuts vba
 
@Vogel612 just gonna use MSACCESS do a simple query :P
 
meh... no need for ACCESS
just use a proper OLEDB connection
 
I dont know vba very well :(
 
umm... it's basically... javascript..
with a little different syntax and keywords.
 
7:55 PM
oh you're back?
 
oh I thought i was ignored
 
just js-based
aka. you're back on page-reload
you're simply not on the level of perm-ignore...
 
kk
whats up
 
akn
8:45 PM
Hello, could someone explain me how to correctly implement strategy pattern in grails? That's my code: hastebin.com/bocivagulo.java. Someone suggest me to use resources.groovy and define there a map [channel : concrete service implementation], but I don't know how to do it.
 
 
3 hours later…

« first day (1649 days earlier)      last day (3296 days later) »