Sagewire Logo

best way to load arrays with large amounts of data?

4 Message(s) by 4 Author(s) originally posted in javascript programming


From: newspost Date:   Saturday, October 27, 2007
I'm working on an application that requires a lot of internal data -
short text s, numbers, switches etc. At the moment the only way I have
of load ing these is long lines of Array[1,2,3 etc]=The Data. In the VB
version I read data in from text file s - is there a similar feature in
JAVAScript - or at least soem thing mroe flaxible than lines and lines
of assignments?

Marshal


From: Thomas PointedEars Lahn Date:   Saturday, October 27, 2007
wrote in message :
I'm working on an application that requires a lot of internal data -
short texts, numbers, switches etc. At the moment the only way I have of
loading these is long lines of Array[1,2,3 etc]=The Data.



No, certainly you do not. However, you may have something like

var a = new Array();
a[0] = ...;
a[1] = ...;

In the VB version I read data in from text files - is there a similar
feature in JAVAScript -



Reading files or rather accessing resources isn't a feature of the
language, but a feature of an API (application programming interface )that can be used by the language.

As for reading text files/resources, you can load the file per URI in an
iframe and read its contents using the DOM , or you can use the
IXMLHTTPRequest interface to make a request and retrieve the response text.

http://en.wikipedia.org/wiki/Document_Object_Model
http://en.wikipedia.org/wiki/AJAX

or at least soem thing mroe flaxible than lines and lines of assignments?



var a1 = new Array(
...,
...
);

Since JAVAScript 1.3:

var a2 = [
...,
...
];PointedEars


From: Evertjan. Date:   Saturday, October 27, 2007
wrote in message on 27 okt 2007 in comp.lang.JAVAscript:

I'm working on an application that requires a lot of internal data -
short texts, numbers, switches etc. At the moment the only way I have
of loading these is long lines of Array[1,2,3 etc]=The Data. In the VB
version I read data in from text files - is there a similar feature in
JAVAScript - or at least soem thing mroe flaxible than lines and lines
of assignments?



I hope you aren't talking client side JAVAscript,
but w/cscript or server side asp/jscript?

var fileContent = 'soem thing\nmroe flaxible\nthan lines';
// the above should be replaced with your file getting routine

var arr = fileContent.split(/\n/);--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


From: Richard Maher Date:   Saturday, October 27, 2007
Hi Marshal,

is there a similar feature in
JAVAScript - or at least soem thing mroe flaxible than lines and lines
of assignments?



One possibility, and my personal preference, is to deploy a TCP/IP Socket
managed by a JAVA Applet. As long as you connect back to the same code base
then no certificate signing is reqd. Server Affinity is completely under
your control , and you can receive any number of rows, or array elements, in
response. Unlike Ajax or a.n.other option, you can achieve a high degree of
parallelism with the client JAVAScript enriching and adding value to rows,
and presenting them, while the server is busy filling the queue with the
rest of the result set. Realtime visual status aids such as a Record Count
or a Diminishing Scrollbar can also help the user to feel that the server
has not forgotten about them. (I'm also quite excited about the prospect of
dynamic/animated chart building with Flash's "Data Binding" and the
streaming of periodic sales figures down the pipe - but I have not worked
that part out yet :-) Anybody with opinions/experiences of
JAVAScript+FABridge -vs- Native ActionScript Getters and Setters?)

Anyway, here is an example of what I'm talking about: -
http://manson.vistech.net/t3$examples/demo _client_web.html

Username: TIER3_DEMO
Password: QUEUE

I will post more demo instructions at the end of this but, to see the bit you
want in action, just enter an asterix "*" for the Queue Name and then click
the green "Get Job Info" button. You will see that the <select> list is
populated from the server, one row/element at a time. I have tested this
with up to 3000 rows and scalability does not seem to be an issue! The one
performance problem I experienced was the tear-down of the old/previous
option-collection before populating the results from the next query. Thanks
to RobG, the problem was solved with DOM Node Cloning and Replacing.

All of the client source code can be found at:-
http://manson.vistech.net/t3$examples/

QUEUE_LOOKUP.HTML contains the code you'd be interested in specifically the
job Lookup() and getResponse() functions, although following the selectRef
and selectClone object s through the code could be worthwhile. The driving
Applet is CornuCopiae.JAVA and the object definition can be found in
ConuCopiae.html. (The main Socket stuff being in Tier3Socket.JAVA) NB: All
Applet JAVA code is application-neutral and completely reusable. No JAVA
coding "need" be done for applications 2 to N.

If you'd prefer someone to have Mugabe(esque) totalitarian control over your
server interaction then I'd suggest Silverlight. (Or Flash's Data Management
Services - "All client-resident data in sync" - Yeah right. But at least
with Flash (and obviously JAVA) you get the choice!)

Although my code is, at present, VMS -specific you could achieve similar
results with simple INETd server process es, if you dropped the authorization
and were happy with one server process per user.

Cheers Richard Maher

PS. The code does not automatically check for versions, but does work on
recent versions of Mac OS X Safari (1.5 JDK), Firefox , Windows Firefox and
IE 6 and 7, Opera, Linux and Firefox. You must have JAVAScript enabled,
Applets enabled and a recent JVM. You also can not be behind a firewall that
bans outgoing connections unless you open up 5255.

Here's some of the functionality-catwalk highlights from the example: -

1) Full, one-time, context-specific, VMS User Authentication. No Cookies,
Session IDs, Password Caching or generic Work-Station or Browser
credentials! When you load the demo_client_web.html page into your browser,
a JAVA Applet is automatically activated that prompts the user for their VMS
Username and Password via a modal dialogue box. If authorization fails, the
"Access Denied" page will be displayed and VMS Intrusion Detection (in
accordance with the policy set out by your System Manager) will be enforced,
and Login-Failures is incremented in SYSUAF. Alternatively, if authorization
is successful (and you left the "Display Logon Confirmation" box ticked)
then a Welcome dialog box will be displayed detailing last login times and
the number of unsuccessful login attempts (if any). Login-Failures is now
set to zero and last non-interactive login time is set to the current time.

If you refresh this page, or move to a different page, then the server
connection is broken and you must be re-authorised before continuing to
access the Demo Queue Manager application.

2) A Hot-Abort button! After you've pressed the "Get Job Info" button
you will notice that the "Abort Request" button becomes active and turns red.
(Actually you probably won't notice 'cos this query completes too quickly
:-) You can edit the DEMO_UARS.COB code and change the value of the
DEBUG_DELAY field if you want to see your 3GL Interrupt routine in action.)
In this case the cancel-flag I have set in the AST routine is picked up in the
mainline code, resulting in the graceful termination of the loop that
controls "next queue" (or "next row") retrieval.

Also, if you look at the getResponse() function in query_lookup.html, you
will see how the chan.setTimeout() method has been deployed to provide an
erstwhile "blocking" socket Read with the ability to surrender the
event-thread for things like processing the Abort button and ticking over
the clock. (all of this, and much more, "infrastructure-code" is already
there and does not have to be re-invented)

3) Predictive text on the Queue Name field so that all matching VMS queues
are retrieved on-demand as the user types. As is now common-place with many
websites, a drop down select list of matching options is automatically
retrieved from the server and made available for the user to select from.

4) Result-set drill-down. Many database queries return a result-set of rows
for the user to scan through and possibly drill-down into for more detail.
I have provided a reasonably generic example of this, where all matching Job
Entries have been populated into a dynamic HTML select list. Once again the
user was able to see the select-list grow, the scroll-bar diminish, and
"Jobs Found" field tick over in real-time, whilst continually being
empowered (by the Abort button) to curtail the results at any time!

If you click on an entry in the Select List then the <frame> changes and the
entry_details.html page appears. See the parent.entry_details.getReady()
call in queue_lookup.html to see how the handover to the new frame takes
place. (Also see goBack() in entry_details.html to see how simply that
operation is reversed.)

The user is now free to move forward, back, first, last, refresh, and delete
queue entries, or return to the previous frame. (Thanks to the deployment of
the VMS Persona functionality, the user is only permitted to see those queue
entries that the Username they signed in under is permitted to see. They can
also *only* delete those entries that this username is allowed to delete.)

5) Floating <div>s. You will see that any queue names are highlighted in bold
and italics; if you mouseover any of these fields when they aren't blank
then the current status information for that queue will be retrieved from
the server and displayed in a quasi-popup DIV.

6) Local Result-Set Sort. If you click on the "header" or "first" row in the
Select List of queues, you'll get a popup prompting you for a sort key. If
you select one, the contents of the Select List are sorted in the chosen
order. (Try enter "*" for the Queue Name and then clicking "Get Job Info" to
wrote in message in
message
I'm working on an application that requires a lot of internal data -
short texts, numbers, switches etc. At the moment the only way I have
of loading these is long lines of Array[1,2,3 etc]=The Data. In the VB
version I read data in from text files - is there a similar feature in
JAVAScript - or at least soem thing mroe flaxible than lines and lines
of assignments?


> Marshal



Next Message: Date field in DD/MM/YYY


Blogs related to best way to load arrays with large amounts of data?

What do you really know…
But this was kind of a one-off, and writing Java code seemed kind \f wasteful. I had experimented with Jython once before, where I was looking for a way to call some Java standalone programs from the command line. ...

basically i have two multiple select box im doing a add button so ...
Leonord, java might be best hosting if you want cross-browser compatibility Leonord, or if the situation allows it, you should implement unzipping as a server-side component is there a way i can measure the extent of some text string in ...

I was learning Drupal and saw it had a db_query function that ...
What's the easiest/best way of finding out if a directory is owned by the webserver, with permissions 0700? Im thinking fileperms, then a call to is_readable() to see if the webserver holds the 7, but i appreciate this wouldnt work for ...

HOWTO: Installing MySQL, PHP and PHPMyAdmin on IIS - Part 1 MySQL ...
If you’re building a system for storing System Logs in a MySQL structure, and this is the database server that you’ll be doing the storage on, then using this option seems acceptable, however, the best way is the middle way, ...

everyone Im jsp having an issue trying to start World of Warcraft ...
A large amount of the first questions asked in this channel start with “Does anyone/anybody…” Why not ask your next question (the real one) and find out? in the same lab, accessing the same server, the new client cannot access because ...

Greetings Question about multiple versions of Java installed on ...
Instead of asking whether anyone works with something you need help with, please save time by asking your actual question. If someone knows and wants/has time to help, perhaps he/she will. define 'best'. also, is there a way to forcibly ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional