Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8591
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: DataInputStream |
| Date | 2011-10-06 00:11 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <356220fa-e842-4ba0-9f63-d66f80c2262a@n15g2000vbn.googlegroups.com> (permalink) |
| References | (2 earlier) <6cf66421-77a9-4088-b810-3bcc958cc8ca@i28g2000yqn.googlegroups.com> <2ec7550a-a3d9-40a9-bca1-e1fd2586429d@g33g2000yqc.googlegroups.com> <02b9b80f-ff02-499d-8f33-056080b114bb@s9g2000yql.googlegroups.com> <64b13101-4846-42d7-bc75-458eb326f73f@n8g2000yqd.googlegroups.com> <20878450.465.1317851548409.JavaMail.geo-discussion-forums@prcs9> |
On Oct 5, 11:52 pm, Lew <lewbl...@gmail.com> wrote: > Robert Klemme wrote: > > bob wrote: > >> The issue is that it's too slow. > > How slow is that, and how fast should it be? > > How much faster could it be, and what makes you think that's possible? > > > Ah, now we're getting closer to the point. I'd first test whether the > > slowness is caused by the underlying stream or the reading procedure. > > If it's the stream (e.g. because you read unbuffered from a socket) > > then you might want to add buffering or you need a faster NIC. If > > it's in the reading then look at Mark's suggestion. > > The OS could also be a factor. So could other loads on the system, particularly the I/O subsystem. Given that we don't know what speed is "too slow" and what speed is acceptable, nor the system configuration, nor the load profile, nor anything else, there's nothing we can say to affect the "too slow" evaluation. Absolutely. I just wanted to partition the problem space in "float reading and parsing" and "general IO" because that information is needed to decide whether the approach to reading floats is wrong because it's too slow. OS then falls into "general IO". > >> What I'm hoping for is something like this: > > >> byte[] b = new byte[numfloats*4]; > > Did you indent enough there? > > >> dis.read(b, 0, numfloats*4); > >> float[] f = (float[]) b; > >> return f; > > >> I don't know why, but it won't let me do the cast. Any ideas? > > > See Patricia's reply. Java works fundamentally different from C or C+ > > +. For example, there are no pointers into memory. I seriously > > Well, there are, actually. I can see why you say that (because eventually every reference of any kind points to a place in memory). But for the sake of this discussion and the general concept of Java I'd rather stick with "no pointers into memory in Java" because that makes it crystal clear that there is not that free access to memory cells as in C/C++. Actually objects can even move in memory so an unchanged reference can point to different locations throughout its lifetime, while an unchanged C pointer always references the same memory addresses. > In the case of the OP's code, they're 'b' and 'f'. However, the pointers in Java are rigidly typed, unlike those in C, so you cannot cast a pointer to 'byte[]' into a pointer to 'float[]'. That's why I prefer the term "object reference" which is also what the JLS uses (even though there are some occurrences of "pointer" and we have "NullPointerException"). Kind regards robert
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
DataInputStream bob <bob@coolgroups.com> - 2011-10-04 22:34 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-05 08:02 +0200
Re: DataInputStream bob <bob@coolgroups.com> - 2011-10-04 23:17 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-05 00:07 -0700
Re: DataInputStream bob <bob@coolgroups.com> - 2011-10-05 07:17 -0700
Re: DataInputStream markspace <-@.> - 2011-10-05 08:27 -0700
Re: DataInputStream Patricia Shanahan <pats@acm.org> - 2011-10-05 08:38 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-05 08:58 -0700
Re: DataInputStream Lew <lewbloch@gmail.com> - 2011-10-05 14:52 -0700
Re: DataInputStream Patricia Shanahan <pats@acm.org> - 2011-10-05 15:15 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-06 00:11 -0700
Re: DataInputStream Lew <lewbloch@gmail.com> - 2011-10-06 07:08 -0700
Re: DataInputStream Patricia Shanahan <pats@acm.org> - 2011-10-06 07:49 -0700
Re: DataInputStream Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-05 21:16 -0400
Re: DataInputStream Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-10-05 08:12 +0000
Re: DataInputStream bob <bob@coolgroups.com> - 2011-10-05 07:12 -0700
Re: DataInputStream Roedy Green <see_website@mindprod.com.invalid> - 2011-10-06 02:48 -0700
csiph-web