473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

seekg Concerns On Fragmented File

Tom
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file. I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever. Maybe
fragmentation is no worse than changing tracks on the drive?

If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?

Any thoughts on the topic?

Please, no OT police comments. Thanks.

-- Tom
Feb 8 '06 #1
6 1714
Tom wrote:
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file.
There is no concept of "fragmentation" in C++ (or C) streams. The
continuity of the stream is ensured by the host system.
I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever.
Could be. Do you feel being watched?
Maybe
fragmentation is no worse than changing tracks on the drive?
"Tracks on the drive" concept is absent from C++ as well.
If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?
Could be. Impossible to tell without clocking them both.
Any thoughts on the topic?
Beyond what I've just typed, not really. Seeking ahead in a file
that allows direct access is often faster than reading out all of
the intermediate bytes. But if the stream is truly sequential, then
seeking forward is _exactly_ like reading out all extraneous bytes,
at least that's IME.
Please, no OT police comments. Thanks.
You've just made one. Why should others be deprived of that right?

-- Tom


V
--
Please remove capital As from my address when replying by mail
Feb 8 '06 #2
"Tom" <Th********@earthlink.net> wrote in message
news:4q********************************@4ax.com...
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file. I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever. Maybe
fragmentation is no worse than changing tracks on the drive?

If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?

Any thoughts on the topic?

Please, no OT police comments. Thanks.

-- Tom


Fragmentation and reading fragmentation happens at the OS level. Unless
you're writing your own disk driver you shouldn't have to worry about it.
As such, seekg is safe for fragmented files. If it wasn't safe, the OS
would be a piece of... well, you know, and unusable.

The OS itself is going to buffer the file read/writes independant of the
..exe's buffers in whatever language.

In other words, don't worry about it.
Feb 8 '06 #3

"Tom" <Th********@earthlink.net> wrote in message
news:4q********************************@4ax.com...
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file. I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever. Maybe
fragmentation is no worse than changing tracks on the drive?

If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?

Any thoughts on the topic?

Please, no OT police comments. Thanks.


A (compliant) C++ implementation will ensure that all
stream operations treat a stream as a contiguous sequence
of characters, whether or not this is true at a 'lower level'
(e.g. OS, hardware, etc).

'File fragmentation' is an operating system issue,
not part of the 'abstract machine' defined by the
language.

-Mike
Feb 8 '06 #4
Tom
Victor, Jim, Mike -- thank you each for your input.

I've never been accused of being afraid to ask a question. I also have
zero fear of asking a dumb one, because I am so darn use to it by now.
:)

Every single day in this newsgroup I have learned. It's a very good
thing too.

There are many experts in here. Those who have more answers than
questions I salute you. I wonder ... is there some way to prompt the
gurus to just blog away in here about their C++ skills? Time is
precious and I am not trying to infringe on anyone's time ... but I
know I am not the only newb who'd be reading those blogs and
benefitting as well. hmmm, blog sounds a bit mundane. How about a
snazzy name: "C_log<xxx>"? Where "xxx" is the topic of your choice.
Easily identified and avoided by those so inclined, and also
highlighted for those who are anxious to read them. Excuse me,
sometimes I dream ..... Thanks again & good night.

- Tom
Feb 8 '06 #5
Tom wrote:

There are many experts in here. Those who have more answers than
questions I salute you. I wonder ... is there some way to prompt the
gurus to just blog away in here about their C++ skills?

I think the experts answering questions is more likely to result in
infodumps on topics that people are actually interested in. That's why
the question was asked in the first place.

Brian
Feb 8 '06 #6
On Wed, 08 Feb 2006 06:23:14 GMT, Tom <Th********@earthlink.net>
wrote:
I've never been accused of being afraid to ask a question. I also have
zero fear of asking a dumb one, because I am so darn use to it by now.
:)
"Keep on raging - to stop the aging." - Dale Carnegie :-)
Every single day in this newsgroup I have learned. It's a very good
thing too.
I used to do the same. It's harder nowadays with the clueless academic
NetCops.There used to be a lot more dicussion of C++ programming
instead of the same robotic answers repeated over and over. I can't
tell you how many "little gems" fell out of what would now be called
off-topic discussions. Not to say their wasn't a few egotistical
netcops around, but most just ignored them.
There are many experts in here. Those who have more answers than
questions I salute you. I wonder ... is there some way to prompt the
gurus to just blog away in here about their C++ skills?


This has happened from time to time. Herb Sutter used to do a, umm,
what was it called, Gotw: Gotcha of the Week? A little exercise
everyone could play with. He made a name for himself and now slaves
for the Evil Empire. "C++"/CLI... I don't know how he sleeps at night.
Oh wait, I guess I do: very, very richly that's how. I guess everyone
has their price. And no, I've never been offered mine yet. :-)

Plauger would/does reveal stuff on occasion while selling his wares. I
found Joseph Newcomer an absolute hoot. (Good Thing.) He was a
pragmatic Real Programmer (r)(tm) and didn't suffer the ludicrous
exercises of the Topic Nazis. (Probably why he doesn't come round
anymore.) Anyway...

I'm not sure there is anyone left here with the breadth of experience
and character that could do such a thing, and be the least bit
interesting. Most of the regulars here now are narrowly trained myopic
academics with little practical experience as far as I can tell. The
fact they can't figure out how to *skip a thread* they don't like
tells me all I need to know.

I think most of the people that could do it are now writing books or
are doing actual blogs. It is a great idea Tom. I don't want to be the
pessimist... anything could happen I guess.:-)

Behold! in Liberty's unclouded blaze, We lift our heads, a race of
other days. - Charles Sprague
Feb 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kapil Khosla | last post by:
Hi, I am trying to move the file pointer back to the original location, but not able to using seekg, can someone help ? Thanks, Kapil #include "stdafx.h" using std::cerr; using std::endl;...
1
by: wtnt | last post by:
Hello. I've searched all over and haven't seen another thread with this problem. Please bear with me as I try to explain. thanks. :) I have some programs that need to be cross-platform...
2
by: Brian Ronk | last post by:
I'm having a strange error. I have a Debian stable server and I'm using gcc 3.3, but it looks like I have 3.4 installed as well. I recently made a change to a program that takes data from two...
2
by: Assertor | last post by:
Hi, All. (VC++6.0) I found some strange thins when using getline() and seekg() of std::ifstream. After the file position of an open file was shift to the end of the file, seekg() did not...
3
by: nomad5000 | last post by:
Hi I'm trying to read a textfile and print it's content twice to the std::cout but it won't work the second time. I think it has something to do with the seekg(0) command but I don't know. here is...
1
by: greek | last post by:
Hi I have to write a prg for the following question.. A file carsale_june.txt stores the number of small and medium-sized of cars sold in the month of June by a car company. The first line of...
12
by: Julian | last post by:
Hi, I am having problems with a function that I have been using in my program to read sentences from a 'command file' and parse them into commands. the surprising thing is that the program works...
1
by: fmufti | last post by:
I would like to check if the f_count is a valid position for seekg in the file or not. What I mean is if I pass a position to seekg and that does not exist in the file then e.g if...
33
by: Aaron Watters | last post by:
Why is the migration to py3k a concern? For example I have libraries which use string%dictionary substitution where the dictionary is actually an object which emulates a dictionary. The...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.