public int bulkInsert(DatasetObject obj) throws Exception{
        File bulk_load_in_progress_f=new File(indexDirectory+"/bulk_load_in_progress.dat");
        if(bulk_load_in_progress_f.exists()){
            int id=objDb.insert(obj);
            TreeMap<Double,Integer> knp;
            if(isUseIntrinsicDimensionality()){
                knp=ros.kNearestReferenceObjectsIntrinsic(obj,ks);
            }else
                knp=ros.kNearestReferenceObjects(obj,ki);
            Iterator iter=knp.entrySet().iterator();
            int pos=0;
            while(iter.hasNext())
            {
                Map.Entry e=(Map.Entry)iter.next();
                int piv=(Integer)e.getValue();
                invFile.insert(id,piv,pos);
        //                        System.out.print(" "+piv+" "+pos);
                pos++;
            }
            return id;
        }else
            throw new Exception("Cannot execute bulk insert...beginBulkLoad not executed or failed"); 
    }