Results 1 to 16 of 16
- 03-14-2009, 07:01 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
[SOLVED] Making a new folder, reading an entire file in one block read
Hello,
I am working on a new database indexing structure (to index a heap file). I have a need to create folders in which to store various index files.
Secondly, I need to be able to read my files (files, NOT folders) in as few hard disk head movements as possible. I need to pull them into memory and then execute a linear search on them, but I do not want to read them line by line if this would cause n reads for a file containing n lines.
Thanks,
- 03-15-2009, 04:39 AM #2
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Use
to solve that problemnew File("");
- 03-15-2009, 07:58 AM #3
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Use a FileInputStream as the source object of a Buffered InputStream.
Java Code:BufferedInputStream in = new BufferedInputStream(new FileInputStream(...yoiur file name...));
- 03-15-2009, 08:45 AM #4
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
- 03-15-2009, 08:46 AM #5
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
- 03-16-2009, 07:26 AM #6
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
try it...
Java Code:File f=new File("folder_1"); f.mkdir();
- 03-17-2009, 01:51 AM #7
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
OK, I will, for sure.
Another question: does anyone know how to make a "folder" structure within a single file ("single file" as in one .dat file in windows, for example) that can be accessed one "file" at a time? Is there a module to do something like that?
Cheers,~fogus
- 03-17-2009, 02:07 AM #8
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
You can create zip and jar files in Java. These can have an embedded directory structure. Is that what you mean?
- 03-17-2009, 02:15 AM #9
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 03-17-2009, 03:32 AM #10
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
Well, what I am trying to do is create a new indexing method for a database (where records are stored in an unordered fashion in a heap file). My new structure is a mix between a hash table and a tree. It is extremely simple, easy to implement, and (I believe) efficient.
Perhaps all I need is more control over how my files are read and written. I need some kind of way to write to a file without having to shift all the contents around. My index file has to persist on the hard drive through program restarts.
Imagine this: you have a B+ tree index and you want to write it to the hard drive. How do you do it? I becha that if you can answer that question with sufficient detail, I will be able to figure out how to make my new structure persist.
Cheers,~fogus
- 03-17-2009, 04:56 PM #11
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
you can put all resources right into your jar file in a folder structure you need and then sinply get out the recources you need to. But there may cause a problem with jar in the case you need to input the data (as db may should) :(
What client you want to use. Is it an applet or an dt application?
- 03-17-2009, 05:04 PM #12
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
- 03-17-2009, 09:27 PM #13
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
"Serialize in memory"
That sounds cool, but I don't know how to do it. (sorry, I'm a beginner)~fogus
- 03-17-2009, 10:12 PM #14
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Rather than writing directly to a file, write to a byte array. Then write the byte array to the file. If you explain a little more about how you're doing it with files, we can explain how to do it in memory.
- 03-18-2009, 12:09 AM #15
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
I think my problem is not that I cannot build the objects that I need in memory; it is that I do not know how to make those objects persist across program restarts.
I need to have my index structure (think B+ tree) saved to a file so that it does not vaporise when I shutdown my program.
I have made a binary tree before, and that was all well and good, but every time I needed to use it for an index I would have to rebuild it (because it disappeared last time I shut the program down).
The other thing is, I can only assume an arbitrarily large hard drive, not RAM. I would much rather store my index structure on the hard disk (hence the similar structure to B+ trees, structures designed for a minimum of disk reads). Does anyone know how to make a B+ index in Java? I can't think of a way to make one persist. Where do I store the leaves? Do I need a lot of separate files or can I use one single large file?~fogus
- 03-18-2009, 10:59 PM #16
Member
- Join Date
- Mar 2008
- Posts
- 43
- Rep Power
- 0
Similar Threads
-
How to read pdf files from the folder using java?
By hnj81 in forum New To JavaReplies: 2Last Post: 02-20-2009, 07:13 AM -
how to read openproj(Projity) file i.e. ,POD file(Project Management file)
By mahendra.athneria in forum New To JavaReplies: 0Last Post: 02-11-2009, 09:53 AM -
java.io.IOException: Unable to read entire block; 493 bytes read before EOF; expected
By kushagra in forum New To JavaReplies: 5Last Post: 10-17-2008, 02:13 PM -
Making arrays by reading user input
By apfroggy0408 in forum New To JavaReplies: 23Last Post: 04-30-2008, 01:23 AM -
How to read block of rows from database tables
By lmenaria in forum JDBCReplies: 1Last Post: 08-08-2007, 01:22 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks