Solved

Removing older records from a file

Posted on 2004-04-15
5
223 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse apache tomcat admin console 52 147
null output 3 42
Delete Android all or certain applications data programmatically 9 106
passing enum to a method 4 34
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

679 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