Solved

Removing older records from a file

Posted on 2004-04-15
5
216 Views
Last Modified: 2010-03-31
Hi,

i have an application that provides me with fixed-length records. These files are organized by date. What i would like to do is to get statistical data from them in the following way:

Last hour - 5 minutes
Last day - 15 minutes
Last week - 30 minutes
Last month - 1 hour

This should be updated every 5 minutes. Also, I want to delete automatically records older than one year, for example. What's your advice on an algorithm to store the stats and to remove the older records (i don't want to copy all the remaing records every time i delete the older ones).

Thanks in advance,
  Bruno
0
Comment
Question by:brunomsilva
  • 2
5 Comments
 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 250 total points
ID: 10837220
>> i don't want to copy all the remaing records every time i delete the older ones
Unfortunately that's the way you have to do it unless you use an indexing scheme for accessing the data in the file.

How often do you wish to 'expire' records? Once a week or continously (i.e. every 5 minutes)?
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 10837761
you could mark them as deleted in the file, and then periodically purge deleted records from the file by copying all undeleted records to a new file.
A RandomAccessFile could be used to mark records as deleted.
0
 
LVL 4

Author Comment

by:brunomsilva
ID: 10840632
orangehead911,

about once a week. and how should i remove the records when they should be stored with a higher interval (for example, after a day keep only 15 minutes stats?
0
 
LVL 92

Expert Comment

by:objects
ID: 10846677
to remove the records physically from the file you need to recreate the file ie. copy existing records to new file
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now