[tek-cvs] tek/server/data TEKConstants.java,1.14,1.15
Status: Beta
Brought to you by:
billthies
From: Bill T. <bil...@us...> - 2005-10-21 21:01:10
|
Update of /cvsroot/tek/tek/server/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24312/data Modified Files: TEKConstants.java Log Message: - improved page simplification (integrated loband on server) - added pdf-to-html, ps-to-html - you can send and receive searches without registering - server sends exactly 10 pages, unless it overflows ~150K - fewer pages can sometimes appear if search terms not present - URLs and domain names appear properly in the client Index: TEKConstants.java =================================================================== RCS file: /cvsroot/tek/tek/server/data/TEKConstants.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- TEKConstants.java 11 Sep 2003 18:43:47 -0000 1.14 +++ TEKConstants.java 21 Oct 2005 21:01:02 -0000 1.15 @@ -34,19 +34,12 @@ // [it looks like Google will only let us retrieve 20 at a time; to // get more, we have to issue multiple queries (with a different // "start" tag, maybe) and concatanate the results ourselves.] - private static final int NumURLs_DEFAULT = 20; - private static final int NumURLs_LOW_BANDWIDTH = 12; - // returns whether or not the given email address represents a - // low-bandwidth user, for which fewer results should be obtained. - private static final boolean isLowBandwidth(String email) { - // anything from solomon islands, or bill's test account - return (email.endsWith(".sb") || - email.equals("thi...@ca...") || - email.equals("thi...@ca...") || - email.equals("thi...@ca...") || - email.equals("thi...@ca...") || - email.equals("thi...@ca...") - ); + private static final int NumURLs_DEFAULT = 10; + private static final int NumURLs_LOW_BANDWIDTH = 10; + // returns whether or not the given email address is from the + // solomon islands + private static final boolean isSolomonIslands(String email) { + return email.endsWith(".sb"); } public static final int NumURLs(String SQID) { // get email address of <SQID> to see if we should use default @@ -57,12 +50,37 @@ } catch (TEKDBFailureException e) { return NumURLs_DEFAULT; } - if (isLowBandwidth(email)) { + if (isSolomonIslands(email)) { System.err.println("Detected low-bandwidth user; getting " + NumURLs_LOW_BANDWIDTH + " URLs instead of " + NumURLs_DEFAULT); - return NumURLs_LOW_BANDWIDTH; + // return NumURLs_LOW_BANDWIDTH; + // now pruned in terms of size + return NumURLs_DEFAULT; } else { return NumURLs_DEFAULT; } } + + // right now there is an unexplained expansion of about 1.5X from + // the compressed bytes to the actual attachement size. So the + // actual email ends up being 1.3X bigger than this. (Maybe Base64?) + public static final int DEFAULT_DOWNLOAD_SIZE() { return 120000; } + private static final int SOLOMON_ISLANDS_DOWNLOAD_SIZE = 50000; + // returns size of results to send for given user (in bytes) + public static final int MaxDownloadSize(String SQID) { + // get email address of <SQID> to see if we should use default + // or low-bandwidth num urls + String email; + try { + email = TEKProtocolDB.get_client_email(TEKAppDB.getClientID(SQID)).trim(); + } catch (TEKDBFailureException e) { + return DEFAULT_DOWNLOAD_SIZE(); + } + + if (isSolomonIslands(email)) { + return SOLOMON_ISLANDS_DOWNLOAD_SIZE; + } else { + return DEFAULT_DOWNLOAD_SIZE(); + } + } } |