Solved

Removing older records from a file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
create a gui in perl 3 72
@SBGen Method 3 38
Groovy:unable to resolve class error 2 70
Java - Why doesn't this JFrame work 3 43
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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.

920 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

19 Experts available now in Live!

Get 1:1 Help Now