// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.math.BigDecimal;
import java.util.Random;

import dk.vajhoej.isam.IsamException;
import dk.vajhoej.isam.IsamResult;
import dk.vajhoej.isam.IsamSource;
import dk.vajhoej.isam.Key0;
import dk.vajhoej.isam.local.LocalIsamSource;
import dk.vajhoej.record.RecordException;

public class ListPerf {
    public static void main(String[] args) throws IsamException, RecordException {
        int lim = Integer.parseInt(args[0]);
        IsamSource pisam = new LocalIsamSource("perf.isq", "dk.vajhoej.vms.rms.IndexSequential", false);
        Random rng = new Random();
        int n = 0;
        for(int i = 0; i < lim; i++) {
            int ix = 1 + rng.nextInt(99990);
            IsamResult<Perf> prs = pisam.readGE(Perf.class, new Key0<Integer>(ix));
            while(prs.read()) {
                Perf p = prs.current();
                if(p.getId() >= ix + 10) break;
                n++;
            }
            prs.close();
        }
        System.out.println(n);
        pisam.close();
    }
}
