Faster string search options

Hi
I am an intern at a mobile technology firm assigned the job of enhancing the search performance of a tool, which is coded completely in java. This tool, along with other features basically searches for the substring in a string array by using the string.indexof() method which is very slow, since i am dealing with vast amount of data..
Now the last two weeks all I did was try and understand the massive code. These are the alternatives I came up with. I could do with suggestions about the feasibilities of these ideas.. or any new suggestions are welcome..
1. are there any faster ways instead of string.indexof() that i can use to do my string search?
2. How about replacing this indexof() method with a faster search algorithm? something like boyer-moore for example??
3. will using a the .nio package instead of .io package work???
4. how about completely scrapping this string search and taking in the data from input stream as integer format.. and then doing the comparisons??
thanks
mahima

yumjay wrote:
1. are there any faster ways instead of string.indexof() that i can use to do my string search?You seem to have found one in section 2.
2. How about replacing this indexof() method with a faster search algorithm? something like boyer-moore for example?? Well obviously you can't override or replace String's indexOf, but you could certainly change the code to use a different algorithm. What's stopping you?
3. will using a the .nio package instead of .io package work??? Not sure, there may be virtue in some of the memory mapping additions, but I don't really know your requirements or situation.
4. how about completely scrapping this string search and taking in the data from input stream as integer format.. and then doing the comparisons?? The string search is essentially doing integer comparisons on data 16 bits at a time (that's the width of a char). So first, remember that the int returned by InputStream.read() isn't really an int but a byte stuffed into an int (so they can return -1 on EOS). That said, you might experience a performance gain if you put the data into ints or longs (depending on your computer architecture) and then use something like boyer-moore, because your computer can likely do comparisons of two bytes, chars, shorts, ints (and perhaps even longs on a 64-bit architecture) in the exact same amount of time. They're probably even the same machine instruction. You also wouldn't therefore have to decode the input data into a string either. But you'd have to encode your search string into integers. So yeah you could potentially squeeze a bit more speed, not likely more than 50% though.

Similar Messages

  • Why is there no "SEARCH OPTION" in the Windows Store? Apps missing be nice if I could find them !

    Since on this journey from Win 8 consumer preview to Win 8 retail preview   ..And no currently trying out Win 8 Pro...It verified if it was gonna give me back ( allowed to re-download ) the apps I was used/had in previous editions. The Store gives you
    a selection of YOU APPS from previous versions of the OS preview of apps you installed and currently would want to reinstall. Various versions of the Consumer preview I installed 2 out the 4 times i installed the OS seen I had installed the app Comixology.
    When the first time I installed Retail preview it didn't have it in my list nor was it listed in the store!  Same goes with Iheart Radio and Slacker Radio though numerous installments of the OS. Now trying out the Win 8 Pro 9200 version It showed I at
    one point no matter what PC I used ( I own a few and bought a new one recently ) It showed at one point I installed Comixology. Yet it didn't show Iheart Radio or Slacker in my install list of old to reinstall nor was it even in the Store!!!!   \\\So
    what the hell gives ?????   I mean If there was a SEARCH Option it would make it easier to track these Metro ( whatever they are calling it now -personally I think they should call it FRAMES as in Window Frames  :P  When you go on these
    programs sites they only offer up Apple or Android app downloads and nothing mentioning of Metro or Win 8 -which is understandable due to not being released yet but still if the Store can't comply with your history of app install base ( paid or free ) and
    you can't have the ability to retrieves said apps you once installed how can that be trusted if and when paid apps are bought if you are only to reinstall the entire OS and find that your app is not obtainable via offered through the main store or even in
    your downloads app install history. I hope they fix this issue as it's been pissing me off since this whole testing thing!!  

    Sorry if I offended you by using an anecdote - the actions of kids are simply an easy way to explore the actions of adults.  Growing up doesn't change base instincts.  Most people (myself included) tend to have an immediate distrust of change when
    it is not change that they are instigating, when it is forced upon them.  What better example is there than a child, where many big decisions are made for them?
    As for the new interface, I didn't catch on until it was revealed to me (or I hit my head against the wall, can't remember), so I'm not saying it is easy.  Better education is needed, but going back to the old way doesn't help.  The five or six
    questions I have answered today are questions that I myself had, and wished someone had answered for me.  This is a
    drastic change from old versions of Windows.  I even told my boss yesterday that I can't see his company (I'm a contractor) switching any time soon - too much new stuff to learn.  That being said, once there are some good training tools available,
    I do believe that this OS will be a good choice - it does feel more intuitive after only a few days of use.  A training course is likely necessary for new users, however my guess is that this will wind up being a beneficial change (long-run)
    for IT departments, because the system does feel more aimed towards the casual user.  No matter what program you use, the search and settings are in one easy place.
    I admittedly do not have a lot of files in my Skydrive, however the file that is there is purple, while the folders are blue.  Not sure if all files are like that, and I really do not have the time to explore those differences.  That being said,
    the number in the bottom-right seems pretty self-explanatory, the number of child elements in the container.  I barely remember the old Skydrive interface, however I do remember it felt clunky.  Whether or not the changes are a true
    improvement, it does feel more streamlined.
    Metro (or whatever it is called now) is confusing.  It is scary.  (My word, not yours, nor am I trying to imply it.)  It is definitely
    different from the past.  But it makes sense.  Same interface on every MS product: Xbox, Windows, and Phone.  Microsoft didn't exactly
    pioneer this idea, either.  Apple has been creeping in that direction for a while now.  As I said previously, I can move around faster in the new Start menu than I could in the old, and I can actually do
    more without ever putting a hand on the mouse - for anyone that is waist-deep in computers, regardless of their specific job, that tends to be a
    good thing.
    There are a lot of growing pains here, for both Microsoft and the consumer.  Has MS gotten it right?  Not yet, not entirely, but the goal is clear.
    If your complaint is on broken
    functionality, then I wouldn't disagree with you.  There is plenty of that, and I think it was a bit foolish of Microsoft not to have a Connect site up for such things.  (If I'm wrong on that, and there is one, please point me that way.  I'm
    still stuck with Explorer.exe crashing from click-scrolling.)
    As for disliking the big changes, well, I can't agree with you on that at all.  Again, it wasn't an easy transition, but now that I'm here, I don't want to go back.  I want the true
    bugs fixed, but not having a search bar seems more like being stuck on old ways of doing things than a real problem.  That kind of thing can even lead to puking.

  • I'm not able to do the DELETE and the SEARCH options on my list ( HELP!! )

    import java.io.*;
    public class StudentContactManager
    public static void main(String[] args) throws IOException
    char userSelection;
    final int maxStudents = 10;
    String [] Lname = new String [maxStudents];//LName= Last Name
    String [] FName= new String [maxStudents];//FName=First Name
    String [] En= new String [maxStudents];//En = Enrolment Number
    String [] PhoneNo= new String [maxStudents];
    int activeEntries = 0;
    boolean found = false;
    //================================
    System.out.println ( "1 - Initialise contact detail list" );
    System.out.println ( "2 - Display contact details list" );
    System.out.println ( "3 - Insert new entry into cotact detail list" );
    System.out.println ( "4 - Delete entry from contact detail list" );
    System.out.println ( "5 - Search cotact detail list" );
    System.out.println ( "Q - Quit" );
    System.out.print ( "Option : " );
    userSelection = Text.readChar ( "Enter option" );
    while ( userSelection != 'Q' & userSelection != 'q' )
    switch ( userSelection )
    case '1': activeEntries=0 ;
    break;
    case '2': if (activeEntries > 0)//IF contact detail list contains entries
    System.out.println("\tEnrolment Number\tFirst Name\tSecond Name\tTelephone Number");
    for (int i = 0; i<activeEntries; i ++)//FOR each stored contact
    {//DO
    System.out.println();
    System.out.println("\t"+En[i]+"\t"+"\t"+FName[i]+ Lname[i]+"\t"+"\t"+PhoneNo);//Display one/current contact detail
    }//END-FOR
    else
    {// ELSE
    System.out.println("Contact detail list empty");//Display �Contact detail list empty� message
    }//END-IF
    break;
    case '3': if(activeEntries<maxStudents)
    En[activeEntries]= Text.readString("Enter enrolment number");
    found = false;
    int i = 0;
    while ( !found && i < activeEntries)
    if (En[i].equals(En[activeEntries]) )
    found = true;
    else
    i++;
    }//end-if
    }//end-while
    if (found == false)
    FName[activeEntries]=Text.readString("Enter first name");
    Lname[activeEntries]=Text.readString("Enter last name");
    PhoneNo[activeEntries]=Text.readString("Enter telephone number");
    // Insert new contact details into contact detail list
    activeEntries++;
    else
    System.out.println("Enrolment number already exists");
    else
    System.out.println("Contact detail list full");
    break;
    case '4': Text.showMessage("Selected Option 4");
    break;
    case '5':Text.showMessage("Selected option 5");
    default: Text.showMessage("invalid selection, Please input a valid option");
    break;
    }//switch
    userSelection = Text.readChar ( "Enter option" );
    }//while
    System.exit(0);
    }//main
    }//StudentContactManager
    //===============================================================================
    I need help with case 4 and case 5...the search option should include while statement. and the 5th case is the delete option
    Thanks guys =).

    Please use the code tags when posting code (there is a button on the posting page for them). It would also help if you told us what you are trying to do, what error you are getting, and what you expect to get.
    If you are just asking us to write the code for you, then you are in the wrong place.

  • Search option in tracklist/playlist in nokia 5310 ...

    Hi,
    I am having nokia 5310 xpress music.
    I am looking for the search option in playlist. sometimes playlist is too long and you are looking for a particular song to be player then I need to scroll down the whole list to find the related song.
    I am having nokia E51 also and I found that search option is there in that.
    I dont think it has any dependency over s40 or s60. and it can be provided with just firmware update..
    Please confirm and suggest.
    -Anchal

    If you disable the Search Entire Library option (available in the dropdown to the left of the search box) iTunes 12 will not show the search results in a dropdown but will immediately go to a filtered version of your current view.  With the Search Entire Library option enabled, you can still get to this filtered view by clicking on the first entry in the drop down, which will say "Show <search string> in Library" or "Show <search string> in <playlist>" depending on where you start the search from.
    There are some inconsistencies in the search behavior, most notably that where you have the Search Entire Library option enabled and search within a playlist the dropdown will show all matches in you complete library (whether in your playlist or not), whereas the first entry in the dropdown just takes you to the filtered playlist view.
    You can use https://www.apple.com/feedback/itunesapp.html to provide input to developers about bugs, enhancement requests, etc.

  • Why String Search in not working in ADF.?

    Hi,
        I've created application in ADF with Search Options. Search Operation is working for all the Integer Values in that page but its not working for String Values.
    I dont know why its not able to search String Values.
    My AppModule bean Code :
                    package model.portfolio.portfolio.am;
    import model.portfolio.portfolio.am.common.PortfolioAppModuleAM;
    import model.portfolio.portfolio.view.ResourceViewChildObjImpl;
    import oracle.jbo.VariableValueManager;
    import oracle.jbo.ViewCriteria;
    import oracle.jbo.server.ApplicationModuleImpl;
    import oracle.jbo.server.ViewLinkImpl;
    import oracle.jbo.server.ViewObjectImpl;
    public class PortfolioAppModuleAMImpl extends ApplicationModuleImpl implements PortfolioAppModuleAM {
         * This is the default constructor (do not remove).
        public PortfolioAppModuleAMImpl() {
        public void applyVCforGlobalSearchPortfolios(String theString){
            ViewObjectImpl vo = getPortfolio1();
            ViewCriteria vc = vo.getViewCriteria("PortfolioVOCriteria");
            System.out.println("On Criteria");
            vc.resetCriteria();
            VariableValueManager vvm = vc.ensureVariableManager();
            System.out.println("On String");
            vvm.setVariableValue("globalSearchString", theString);
            System.out.println("After String");
            vo.applyViewCriteria(vc,true);
            vo.executeQuery();
    *All Getters and Setter of all VO and VLs****
    My Query created in View Criteria :
    ( (UPPER(SHORTNAME) LIKE UPPER( :globalSearchString || '%') ) OR (UPPER(DESCRIPTION) LIKE UPPER( :globalSearchString || '%') ) AND (PROGRAMMES_COUNT = :globalSearchString ) OR (KK_COUNT = :globalSearchString ) OR (KPI_KRA_VALUE = :globalSearchString ) )
    One more interesting thing in After Creating the View Criteria If i try to Test this Query, Its giving me error msg as
    "Cannot complete query to determine the view attributes.  Either the query is invalid or timeout occurs.  Please revise the query or create the view attributes manually.
    "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':globalSearchString || '%') ) OR (UPPER(QRSLT.DESCRIPTION) LIKE UPPER( :globalSe' at line 1"
    I don know why... Can somebody please help me?
    Im using Jdev 12C

    Binding variables will be different from oracle database and My Sql database.
    Oracle database use this (:) for defining bindVariable but in My Sql use this (?)
    Try to remove the view criteria which you define in View Object and you can make it programmatically like this:
        ViewObject vo = getPortfolio1();
        ViewCriteria vc = vo.createViewCriteria();
        ViewCriteriaRow vcr = vc.createViewCriteriaRow();
        vcr.setAttribute("Attribute1", value);
        vcr.setAttribute("Attribute2", value);
        vc.add(vcr);
        vo.applyViewCriteria(vc);
        vo.executeQuery();

  • Search option for multiple lines in iPad for fixed layout ePub is not working. Is there any alternate way to search multiple lines in ePub?

    Search option for multiple lines in iPad for fixed layout ePub is not working. Is there any alternate way to search multiple lines in ePub?

    Hi SAP Gurus
    I need a big favour, I am trying to map serach string with internal order, my search string is MV-38610573 which I have mapped with posting rule 'GENT' which  debits bank account and credit revanue accounts but this revanue account requires assignment with internal order, so I have created another 3 search string with same search string 'MV-38610573' and mapped with BSEG-ASUFNR,60000LC ( internal order),3 (bdc account type) respectively, also maintained three entries in search string use which is for BDC FIELD NAME1, BDC FIELD VALUE 1 & BDC ACCOUNT TYPE 1,
    But this is not working it gives me following error,                                                                 
    > Error: (KI 235) Account 4421 requires an assignment to a CO object
    Your help will be highly appreciated,

  • Allow indexing service to index this disk for fast file searching

    Hello,
    I'm using Oracle on Win 2000, I have lately found out that the option "Compress drive to save disk space"
    is not supported in Oracle.
    When I've opened the drive specifications on the properties dialog, I found also another option called "Allow indexing service to index this disk for fast file searching".
    My question are;
    1. Should I turn it off?
    2. Same question when the indexed directories does not include Oracle files?
    3. Same question, when the indexing service is set to off?
    Thanks,
    Tal Olier ([email protected])

    If this is a production machine, I'd definitely turn this off. Hopefully, no one is going to be searching for particular files on a production server-- they'll know where to go. You probably don't want any unnecessary background processes using up CPU or RAM either.
    If this is a development machine, the developer may be searching for files with some frequency. If that's the case, it may be worth it to keep this service enabled.
    I'm not aware of any Oracle issues when this service is running, but I'm paranoid enough not to trust it on a production box. If you're running on a dev box, you shouldn't have problems, particularly if you're not indexing Oracle files.
    Justin

  • Workspace Search Option Issue....

    Hi All,
    The Search option in the Workspaces is not returning proper results. It always gives the same result output.
    Even if i use the proper File Name / Discussion Name / Meeting Name also..
    What might be the Issue here..?
    Best Regards
    Message was edited by:
    ark_505

    Here are some details of how searching various content works:
    Files: file name, file content for text files (10.1.2.3: does not search content)
    Discussions: message subject, message body
    Meetings: meeting subject, meeting location, meeting description
    You can use * as a wildcard character.
    Can you give a specific example of a search that is failing for each content type? For example: what is the filename, what is the search string? What is the meeting subject, what is the search string? And what results are you seeing?
    Finally, what version of workspaces are you using?
    regards,
    -Neil.

  • How is "Fast Browser Search" engine PERMANENTLY REMOVED (and I mean wiped), from the search engines that were included by default with recent Mozilla update?

    Fast Browser Search (FBS) emgine is now being included in all the Mozilla Updates.
    This concerns me because the company that provides it is a known malware distributor.
    When Mozilla toolbar "Manage Search Engines" option is selected, I can choose to remove FBS, move FBS to the bottom of the list, move Yahoo to top as preferred, and FBS always comes back when Mozilla is closed & restarted.
    If this browser search is used, malware is automatically downloaded onto my computer. My ISP has verified this as fact.
    MalwareBytes Anti-Malware (mbam) catches malware stemming from "Fast Browser Search" every time I scan.
    I want this removed forever. I love using Mozilla, but if this doesn't go, Mozilla will have to go. I'll have to return to IE (which I don't want to do).
    I cannot believe that Firefox Mozilla would knowingly include "Fast Browser Search" in their list of browsers installed by default. And setting the configuration for it constantly trump Google or Yahoo, when I move them to preferred, is ridiculous.
    If I go the the Fast Browser Search website and follow the uninstall directions, more malware is slapped on my system. I read your recommendation to use that very process in your forum.
    Please Help,
    annie

    Ahh, the toolbar is still on system. I thought ComboFix got it. I think I'll uninstall Mozilla prior to initiating the fix procedures you linked. The extracare service tech support I'm paying Frontier (ISP) isn't worth a lick. After I thought I had removed, I called them and had my system scoured by them. May need to cancel that $14.90/month service...seems to have been a waste.
    Thank you so much.
    I will be back with an update. Cross your fingers for me.

  • No search option in music player Nokia N8

    there is no search option in music player of nokia N8 like other nokia phone (N82 N72)
    if we are in all song list and we want to play a song  how to search that song?
    i have 14 GB songs in my N8  so it is very difficult to search a single song in vast list
    plzz fix this issu in next firmware update

    no offense, dude, but that was a stupid comment. obviously you are the one who has no clue and  doesn't know how to use the phone. everybody knows there's search widget that can do that, but it's just plain ridiculous.  it is as if you're suggesting that whevenever we want to text  a sms, we need to open "message" app, then go to main menu and open another "keyboard" app so that we could finally type something.
    the feature of being able to find the song by typing the alphabet was there since N73. and it's so so so convenient.  it was fast and efficient.  another feature is the abilily to edit the songs details. it' makes selecting song and creating playlist like a breeze. i love nokia musica player because of this. these useful and practical features is something that other phone manufacturers still fail to offer. that's why nokia stood out. now in N8, all these were taken away. it's a major loss.
    stop acting like a smart **bleep**, and make a fool out of yourself.
    to Nokia, please solve this issue.  if this is the price that i have to pay to have the cover flow feature, i'd rather not have it. the cover flow is uselss to me, beside being eye candy

  • Streaming PDF With Search Option

    Hi All,
    I want to open the Streamed PDF with Search Option.
    My PDF is searchable so if i use the URL like http://servername/abc.pdf#search=test then its working fine
    but when I stream the PDF then i m not able to pass the path like \\Servername\abc.pdf#search=test as it says that the file not found.
    Here is the code
      Response.Clear()
            Response.ContentType = "application/pdf"
            Response.AddHeader("Content-Disposition", "inline; filename=abc.pdf")
            Dim myStream As System.IO.Stream
            Dim buffer() As Byte
            Dim BytesRead As Integer
            myStream = New System.IO.FileStream("\\servername\new\abc.pdf", System.IO.FileMode.Open, _
                                                IO.FileAccess.Read, IO.FileShare.Read)
            BuffSize = 102400
            Response.AddHeader("Content-Length", myStream.Length)
            ReDim buffer(BuffSize)
            BytesRead = myStream.Read(Buffer, 0, BuffSize)
            Do While (BytesRead > 0)
                Response.OutputStream.Write(Buffer, 0, BytesRead)
                Response.Flush()
                BytesRead = myStream.Read(Buffer, 0, BuffSize)
            Loop
            Response.End()
    I want abc.pdf to be opened w/ search option but when i pass the seach option with the file name its not working.
    Is there any other way to Stream PDF with Search option?
    Regards
    JD

    Hello, (please tell us your first name)
    As you didn't mention how exactly you are using your search field in your report, I'm assuming it is part of a where clause. If this is the case, you need to understand that APEX is running your report query each time you are changing your search string value.
    "I added a search item and a go button…if I enter a value in the search that will take me 5 or 6 pages deep …It is not like you have a master result set, and you are browsing it with your search string. The go button actually submit your page. The report engine build a new result set, based on your query where clause, and reset the pagination, as it is a new report.
    Regards,
    Arie.

  • How to use auto-increment and search option for MS Access DB

    Dear All,
               I have configured our invoice in Adobe Livecycle and connected it to MS Acess 2007 as per http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/.
    All is working fine, I can insert, retrieve data from DB to invoice and vice versa.
    Now I want few things to be implemented on our invoice.
    When ever I open our invoice, it populate the first entry from DB, Is it possible to populate the last entry ?
    Auto increment invoice number from MS Access DB every time we open our invoice after save.
    How to implement search option from DB for invoice number ?
    Please let me know if someone can provide me help on my scenario, so that I can share more stuff related to invoice and DB.
    Look forward to hearing soon from experts and other team members.
    Thanks & Regards
    Riyad...

    As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
    CREATE SEQUENCE Test_Sequence ;
    CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
    ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
    INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ;

  • Error using 'Search' option in Planning.

    Hi,
    when i expand my webforms list on the left side of the Planning interface i am able to see all the folders expected.
    on selecting one of those folders say 'x' i get a list of forms under 'x' which is fine .
    But when i type the name of webform which is placed under folder 'x' in Search option which at bottom right side of the planning interface,
    I get an the error ' exception occured. you dod not have sufficient access to view this page'.
    But the point over here is if i am able to see and access the webform while searching for same webform why i am i getting this error.
    can anybody help me on this?
    Thanks
    NJ

    Hi,
    when i expand my webforms list on the left side of the Planning interface i am able to see all the folders expected.
    on selecting one of those folders say 'x' i get a list of forms under 'x' which is fine .
    But when i type the name of webform which is placed under folder 'x' in Search option which at bottom right side of the planning interface,
    I get an the error ' exception occured. you dod not have sufficient access to view this page'.
    But the point over here is if i am able to see and access the webform while searching for same webform why i am i getting this error.
    can anybody help me on this?
    Thanks
    NJ

  • I can't see the 'search' option on this site. Am I the only one?

    I'm having an issue with DVDSP and I can't see the 'search' option on this site. Is Apple cutting down on bandwidth for this so they can sell their phones?!
    Anyone else having the same issue?

    frmrt wrote:
    http://discussions.apple.com/ann.jspa?annID=639
    frmrt wrote:
    http://discussions.apple.com/ann.jspa?annID=639
    +Good afternoon,+
    +We have temporarily disabled search and status levels to improve performance of Apple Discussions. We expect this to be a temporary measure.+
    Regards,
    Mark
    +Apple Discussions+
    What the **** does this mean? The performance was just fine! Now, I am unable to efficiently search for information and the performance therefore is awful. How long will this go on?

  • Can no longer simultaneously stream an mp3 in Safari when using fast user switching option.

    After updating to ios 5, I can no longer stream an mp3 in Safari when I use the fast user switching option.  For instance, if you are listening to streaming content in a Safari tab and want to reference another app as soon as you switch from the Safari stream pauses.
    This was not the case with previous versions of ios.  Any ideas on a work around to restore this functionality to keep Safarr streaming content in the background?

    User switching problems is the very first thing I noticed with SL. I have a host of other problems with SL but this is one of the most frustrating. The user switching did not work on 10.6 very well either but was wicked fast in 10.5.x
    Apple rewrote the Kernel so this type of thing is expected, still the test crew missed this very noticable problem. Hopefully 10.6.2 has a fix.

Maybe you are looking for