Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
At this link here it says that the basic unit of oracle storage is a data block.
"One data block corresponds to a specific number of bytes of physical database space on disk."
Is it wrong to say that a data block is a like a .txt file?
A database block is a unit of organisation. So it really isn't very like a .txt file. In fact, it is more like processed cheese.
Perhaps a museum specimen cabinet is a better metaphor. It is a storage device, with a specific location (a table) and broken up into smaller units (rows).
Although, as the data block is actually a unit of I/O we can think of it as a train carriage.
Ultimately, it is best to read the Concepts Guide. Metaphors make for great poetry, but a poor one can confuse more than it enlightens. Find out more.
Off hand, I suspect that a data block has more in common with a file system block. Database files on disk are binary; they can hold anything in whatever representation the database wants. They could even hold parts of things and the rest be scattered across the file. One would almost never try to interact with their content directly. We let the database worry about what is in those files and stay out of its way, much like you would stay out of your OS's way when it's handling your disk drives.
So in short, you shouldn't care. Don't touch the content in those files unless you really, really, really, really know what you're doing. Based on the fact you're even asking this question, you don't know enough about what you're doing to mess with them.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
File data example line:
Sicilia 005 frenkco mastro 202020kkk 3 11-23-2155 12-44-6666
I want to overwrite that line with another same line copied but with some changed values:
Calabria 006 frenkco mastro 202020kkk 3 11-23-2155 12-44-6666
That's the result i want, but if I change values and then use "fprintf", it prints a new line without deleting the first one.
You cannot overwrite a specific line, because lines are just conventions related to \n bytes. Please read more about C programming and consider reading the n1570 C standard.
You either want to copy the source file to a target one (this is how sed(1) works on Linux; study its source code since it is free software) or use higher-level approaches such as gdbm or sqlite or databases.
For small amount of data practically fitting in RAM (e.g. less than a gigabyte) or in your page cache, a common approach is to generate a new textual file entirely. It might be a temporary file that you'll rename (e.g. using atexit(3) or simply later on)
You could want to read a textbook on operating systems and/or learn to use databases (perhaps MongoDB or PostGreSQL, but there are many other approaches too) or indexed files.
In some cases, you might consider serialization and parsing techniques, perhaps using textual formats like JSON or YAML (for which many open source libraries are available, and worth studying).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have a disagreement with my colleague about sending/receiving a data structure between two machines (Also with different compilers) by UART.
Our data structure has several simple variable types as its fields (like int32, uint8 and etc).
In his opinion, to have a data structure with the same sequence and alignment in their fields, we have to use serializer and deserializer. Otherwise, Our code has the potential of different struct layout between two sides.
But I did it without using serializer/deserializer many times and never saw any problem.
I think using from the #pragma pack(...), guarantee our purpose. Because of most differences in each compiler (In data structures compiling) occurs in fields alignment due to padding for speedup or size optimization. (Ignore the different of endianness).
For more details, We want to send/receive a struct between a Cortex-M4 (IAR) and PC (Qt in windows) by UART currently.
Am I in a wrong way? Or my friend?!
This is, I'm afraid, fundamentally a question of opinion, that can never be fully resolved.
For what it's worth, I am adamantly, vociferously with your colleague. I believe in writing explicit serializers and deserializers. I don't believe in blatting out an in-memory data structure and hoping that the other side can slurp it down without error. I don't believe in ignoring endianness differences. I believe that "blatting it out" will inevitably fail, in the end, somewhere, and I don't want to run that risk. I believe that although the explicit de/serializers may seem to be more trouble to write up front, they save time in the long run because of all the fussing and debugging you don't have to do later.
But there are also huge swaths of programmers (I suspect a significant majority) who agree entirely with you: that given enough hacking, and suitable pragmas and packing directives, you can get the "blat it out" technique to work at least most of the time, and it may be more efficient, to boot. So you're in good company, and with as many people as there are out there who obviously agree with you, I can't tell you that you're wrong.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What does a file handling mean? What is the difference between them in different languages?, for example perl or c. I'm unable to get a grasp on the concept.
I'm posting an example from perl suggested by #jeegar patel.
open(DATA, " <file.txt");
if you see in this piece of snippet, DATA acts as a file handle, so what exactly is the function/purpose of "DATA" here.
PS: I apologize if this is such a lame question, but I'm trying to get the basics right! Appreciate if anybody could acknowledge this.
In Any programming language, to perform any file operation in programming way it will have some own APIs.
Like C programming has.
http://www.w3schools.in/c/file-handling/
Like perl has
http://www.tutorialspoint.com/perl/perl_files.htm
What is the difference between them in different languages?
You can read file handlings APIs for different programing language and came to know what are different in them..
In fact your program does not get direct access to physical hardware and devices. Your program has to request these as services from the operating system. In each language there is a "run time model" of what a pralooks like, things like where the stack, heap and program memory are. The file system provided by the language is contains the routines needed to coordinate with the operating system, convert data types to the format required by your program and ways to find out the status of the file or even where to put things so the OS will actually write them out
This is complex stuff and each language and language design team has approached the problems somewhat differently.
Trust me they used to be a lot less standardized...
There are many functions on various level of file system hierarchy in the word "File handling".
An example of file system hierarchy and functions in each level:
Handle file systems:
Device/Disk/Directory(Folder)
create/delete/rename/move
Handle a file:
create/delete/rename
Handle a contents of a file:
open/close/read/write
etc.
Each languages have corresponding functions and/or libraries/APIs for "file handling".
When you focused in certain level of hierarchy, "a contents of a file" for example, functions of that level may be comprehensible for you.
Don't to try to see broad functions in all levels at once.
That is not the way of human kind, but of god.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
What are the advantages/disadvantages of mapping a whole file once vs. mapping large blocks when needed in an algorithm?
Intuitively, I would say it makes most sense just to map the whole file and then let the OS take care of reading/writing to disk when needed instead of making a lot of system calls since the OS is not actually reading the mapped file before accessed. At least on a 64 bit system where the address space isn't an issue.
Some context:
This is for an external priority heap developed during a course on I/O algorithms. Our measurements shows that is slightly better to just map the whole underlying file instead of mapping blocks (nodes in a tree) when needed. However, our professor does not trust our measurements and says that he didn't expect that behaviour. Is there anything we are missing?
We are using mmap with PROT_READ | PROT_WRITE and MAP_SHARED.
Thanks,
Lasse
If you have the VM space, just map the whole file. As others have already said, this allows the OS the maximum flexibility to do read-aheads, or even if it doesn't it will bring in the data as required through page faults which are much more efficient than system calls as they're being made when the system is already in the right kernel context.
Not sure why your professor doesn't expect that behaviour, but would be good to understand his rationale?
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Just out of curiosity, assuming there exists a software life form. How would you detect him/her? What are your criteria of figuring out if something/someone is intelligent or not?
It seems to me that it should be quite simple to create such software once you set the right target (not just following a naive "mimic human->pass Turing Test" way).
When posting an answer try also finding a counter example. I have real difficuly inventing anything consistent which I myself agree with.
Warmup
First we need to understand what a life form is.
Take this explanation, for example:
An entity which exists and tries to continue its existence through nourishment or procreation.
If we accept this explanation then in fact many programs represent a life form.
They exist, that's obvious. They attempt to continue their existence through opening child processes, surviving in persistent data storages and continuing the next day.
So, here we are, among digital life forms around us.
On the other hand, there's the idea of evolving and being sentient.
With evolving, it's easy. Many programs have been written to be able to modify their body to adapt to certain scenarios. Computer viruses are first examples of that.
With sentience, it is a different story. An entity needs to be aware of its existence, understand itself and the environment around it, also take active decisions on its life activities.
A computer program has nothing of that kind. In fact, if it still applies, the scientists haven't figured out the definition of "being aware of itself" and consciousness. So until we know what that means, we can't attribute that quality to an entity or the other way around, to take it away.
The bottom line is, you can argue a computer program to be a life form, but it does not qualify for a sentient being.
Thinks humanly, acts humanly.
OR
Thinks rationally, acts rationally.