/**Método principal para llevar a cabo el alta de algun bloque*/ public int Alta_HashEstatica(CNodoEntidad e, CBloque b) { int fH, fC; int res; CHash tHash; fH = fC = 0; if (e.getApCabDatos() == -1) { tHash = new CHash(getArchivo().ENDF(), TAM_HASH); getArchivo().EscribeTablaHash(tHash); e.setApCabDatos(tHash.getDir()); getArchivo().escribeEntidad(e, e.getDir()); }else tHash = getArchivo().LeerTablaHash(e.getApCabDatos());//Se lee la tabla Hash FuncionHash(b, ref fH, ref fC); cubetaSel = fH; res = InsDirBloque(tHash, fH, b, fC); return (res); }
/**Escribe una tabla hash*/ public void EscribeTablaHash(CHash tabla) { bw.BaseStream.Seek(tabla.getDir(), SeekOrigin.Begin); bw.Write(tabla.getDir()); bw.Write(tabla.getTamaño()); bw.Write(tabla.getNumCubetas()); for (int i = 0; i < tabla.getTamaño(); bw.Write(tabla.getAtDirCubeta(i)), i++) ; }
/**Función de Mantenimiento para la Hash Estatica*/ private void MantenimientoHashEstatica(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque) { CHash tablaHash, nuevaTablaHash; long cabTabla; cabTabla = ent.getApCabDatos(); if (cabTabla != -1) { tablaHash = fileOri.LeerTablaHash(cabTabla); nuevaTablaHash = new CHash(fileNew.ENDF(), tablaHash.getTamaño()); nuevaTablaHash.setNumCubetas(tablaHash.getNumCubetas()); fileNew.EscribeTablaHash(nuevaTablaHash); for (int i = 0; i < tablaHash.getTamaño(); i++) nuevaTablaHash.setAtDirCubeta(i, CopiarListaCubetasRec(tablaHash.getAtDirCubeta(i), fileOri, fileNew, tamBloque)); fileNew.EscribeTablaHash(nuevaTablaHash); entC.setApCabDatos(nuevaTablaHash.getDir()); fileNew.escribeEntidad(entC, entC.getDir()); } }