public RRDatabase(File file) throws IOException {
  name=file.getName();
  rrdFile=new RRDFile(file);
  header=new Header(rrdFile);
  nameindex=new HashMap<String,Integer>(header.dsCount);
  dataSources=new ArrayList<DataSource>(header.dsCount);
  for (int i=0; i < header.dsCount; i++) {
    DataSource ds=new DataSource(rrdFile);
    nameindex.put(ds.getName(),i);
    dataSources.add(ds);
  }
  archives=new ArrayList<Archive>(header.rraCount);
  for (int i=0; i < header.rraCount; i++) {
    Archive archive=new Archive(this);
    archives.add(archive);
  }
  long last_up=(long)rrdFile.readLong() * 1000;
  if (header.getVersionAsInt() >= Constants.VERSION_WITH_LAST_UPDATE_SEC) {
    long last_up_usec=rrdFile.readLong();
    last_up+=last_up_usec / 1000;
  }
  lastUpdate=new Date(last_up);
  for (int i=0; i < header.dsCount; i++) {
    DataSource ds=dataSources.get(i);
    ds.loadPDPStatusBlock(rrdFile);
  }
  for (int i=0; i < header.rraCount; i++) {
    Archive archive=archives.get(i);
    archive.loadCDPStatusBlocks(rrdFile,header.dsCount);
  }
  for (int i=0; i < header.rraCount; i++) {
    Archive archive=archives.get(i);
    archive.loadCurrentRow(rrdFile);
  }
  for (int i=0; i < header.rraCount; i++) {
    Archive archive=archives.get(i);
    archive.loadData(rrdFile,header.dsCount);
  }
}

public RRDatabase ( File file ) throws IOException { name = file . getName ( ) ; rrdFile = new RRDFile ( file ) ; header = new Header ( rrdFile ) ; nameindex = new HashMap < String , Integer > ( header . dsCount ) ; dataSources = new ArrayList < DataSource > ( header . dsCount ) ; for ( int i = 0 ; i < header . dsCount ; i ++ ) { DataSource ds = new DataSource ( rrdFile ) ; nameindex . put ( ds . getName ( ) , i ) ; dataSources . add ( ds ) ; } archives = new ArrayList < Archive > ( header . rraCount ) ; for ( int i = 0 ; i < header . rraCount ; i ++ ) { Archive archive = new Archive ( this ) ; archives . add ( archive ) ; } long last_up = ( long ) rrdFile . readLong ( ) * 1000 ; if ( header . getVersionAsInt ( ) >= Constants . VERSION_WITH_LAST_UPDATE_SEC ) { long last_up_usec = rrdFile . readLong ( ) ; last_up += last_up_usec / 1000 ; } lastUpdate = new Date ( last_up ) ; for ( int i = 0 ; i < header . dsCount ; i ++ ) { DataSource ds = dataSources . get ( i ) ; ds . loadPDPStatusBlock ( rrdFile ) ; } for ( int i = 0 ; i < header . rraCount ; i ++ ) { Archive archive = archives . get ( i ) ; archive . loadCDPStatusBlocks ( rrdFile , header . dsCount ) ; } for ( int i = 0 ; i < header . rraCount ; i ++ ) { Archive archive = archives . get ( i ) ; archive . loadCurrentRow ( rrdFile ) ; } for ( int i = 0 ; i < header . rraCount ; i ++ ) { Archive archive = archives . get ( i ) ; archive . loadData ( rrdFile , header . dsCount ) ; } }
creates a database to read from .
