Solved

Removing older records from a file

Posted on 2004-04-15
5
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

623 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