public synchronized DatasetObject getObject(int id) throws Exception{
        
//        System.out.println("ObjectDatbase: Executed getObject!!!!!");
       if(offsetFile==null || databaseFile==null)
            openFiles(indexDirectory);
        
      //With persistent offsets
       long position=id*8;
       long l=offsetFile.length();
       if(position>=offsetFile.length())
           throw new Exception("Object with internal identifier "+id+" does not exist!");
        
        offsetFile.seek(position);
        
        long startOffset=offsetFile.readLong();
        long endOffset;
        if(position+8!=offsetFile.length())
            endOffset=offsetFile.readLong();
        else
            endOffset=databaseFile.length();/**/
     
       //With in memory offsets;
/*       if(offsets==null){
           offsets=new long[(int)(offsetFile.length()/8)];
           for(int i=0;i<offsetFile.length();i+=8)
               offsets[i/8]=offsetFile.readLong();
       }
       if(id>=offsets.length)
           throw new Exception("Object with internal identifier "+id+" does not exist!");
   
        long startOffset=offsets[id];
        long endOffset;
        if(id+1!=offsets.length)
            endOffset=offsets[id+1];
        else
            endOffset=databaseFile.length(); /**/
       
        //With persistent database
        byte[] buff=new byte[(int)(endOffset-startOffset)];
        databaseFile.seek(startOffset);
        databaseFile.read(buff);/**/
       
       //START NEW with MemoryMappedBuffers
/*       int position=id*8;
       if(position>=offsets.capacity())
           throw new Exception("Object with internal identifier "+id+" does not exist!");
        
        offsets.position(position);
        
        long startOffset=offsets.getLong();
        long endOffset;
        if(position+8!=offsets.capacity())
            endOffset=offsets.getLong();
        else
            endOffset=database.capacity();
        
        byte[] buff=new byte[(int)(endOffset-startOffset)];
        database.position((int)startOffset);
        database.get(buff);
       //END NEW*/
                
        ByteArrayInputStream bais=new ByteArrayInputStream(buff);
        ObjectInputStream baiso=new ObjectInputStream(bais);
        DatasetObject obj=(DatasetObject)baiso.readObject();
        
        return obj;
        
    }