Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Help Needed : File comparision irrespective of the order

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Frnds

This is my 1st post on javaranch.

This is what i need.

I have different sql files generated as dumps.
Now one machine has TOAD 8 installed on it and it generates queries.
same way another has TOAD 9 installed on it and this also generates many queries.

The issue is that these generate queries in different order.
But the requirement is that both versions should generate equal sql queries
irrespective of the order in which they are generated !!

This boils down to

I have two files , having queries in random order
Now i need to validate that both files have the same content(queries)
even though not in the same order.

Ex: File1

select * from emp;
select * from dept;

drop table emp;

Ex: File2

drop table emp;
select * from emp;
select * from dept;

Now the output should show that both files File1 and File2 have same content
though the order is different.

I am thinking of using a Hashtable ( with a key generated for each query in each file )

In that way i should assign

1=select * from emp;
2=select * from dept;
3=drop table emp;

in File1 and also in File2 for the same query.

Then compare the keys generated for both the files

like

if(aHashDataofFile1.keySet().equals(aHashDataofFile2.keySet()))
{
System.out.println("The two files have same data in them !!");
}

else
{
System.out.println("The two files have different data in them");
}


Anyone who can help me with this issue .......

Thanks

Sandeep
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Sandeep This is SCJP forum, better you post this question in the
related forum of this site. Possibility of getting answer will be more.


Interesting issue though

If I get the solution, I will post that ASAP.





Thanks,
 
sandeepz putrevu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks 4 d quick fire reply Chandra

Posted this in I/O Streams Section too....

Thanks
Sandeep
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
One idea:

1- You store one file in the ArrayList line by line.
2- Take an array as marker, (mark the line which has be read, see next)
3- Now take another file and pick one line and find the match
in the ArrayList and it match found, mark the marker array element.
You wont use the arraylist element that has been used, use the marker array.
I am using marker if one query exists more than one time in the file.

Gotcha:
Whitespaces!!!

Remove all the whitespaces in between words first before you put the lines of the file in the ArrayList.


Thanks,
 
sandeepz putrevu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Chandra

Hi gave those queries just for example.

The real queries are much longer and bigger in expand to 10 lines also

The only way I though was to index as key each query ( as each query is delimited by a / in the dumps generated)

and then compare keys for both the files.

Also there are inserts , deletes , grants , etc etc in the files
that are quite bigger.

Thanks
Sandeep
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Originally posted by sandeepz putrevu:
Thanks 4 d quick fire reply Chandra

Posted this in I/O Streams Section too....

Thanks
Sandeep



In the future, please don't crosspost. It wastes people's time and effort. If you feel that a post is in the wrong location, just ask a bartender/sheriff to move it for you.

Anyway, in this case, I'll just close this topic. And ask that anyone with a potential answer to please go to the I/O forum.

Henry
 
They weren't very bright, but they were very, very big. Ad contrast:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
    Bookmark Topic Watch Topic
  • New Topic