Esempio n. 1
0
        /**Se realiza una busqueda de un indice primario, que sera utilizado como entrada
         * en al inserción del nuevo bloque*/
        private void buscaIndicePri(ref CIndice ind, string nameInd)
        {
            long ptrAux = ent.getApCabDatos();
            string cad;

            getArchivo().AbrirArchivo();

            while (ptrAux != -1)
            {
                ind = getArchivo().LeerIndicePrimario(ptrAux);
                cad = dameIndPri(ind);

                if (cad.CompareTo(nameInd) == 0)
                    break;
                else
                    ptrAux = ind.getSigInd();
            }

            getArchivo().CerrarArchivo();
        }
Esempio n. 2
0
        /**Escribede un objeto de la clase CIndice*/
        public void EscribeIndicePrimario(CIndice indPri)
        {
            BinaryWriter bw;

            bw = getBw();
            bw.BaseStream.Seek(indPri.getDirInd(), SeekOrigin.Begin);

            bw.Write(indPri.getTipoInd());
            bw.Write(indPri.getTamIndPri());
            bw.Write(indPri.getIndPrim());
            bw.Write(indPri.getSigInd());
            bw.Write(indPri.getCabBloques());
            bw.Write(indPri.getDirInd());
        }
Esempio n. 3
0
        /**\brief Inserta un bloque de datos a la organización*/
        public int AltaOSI(CNodoEntidad e, CBloque nuevo, long posB)
        {
            CIndice indPri, indAux = null;
            int res;
            long ptrAux, posInd;

            
            indPri = generaIndPri(nuevo);
            getArchivo().AbrirArchivo();
            
            ptrAux = e.getApCabDatos();
            
            while (ptrAux != -1)
            {
                indPrim = getArchivo().LeerIndicePrimario(ptrAux);
                if (indPrim.comparateTo(indPri) != 0)
                    ptrAux = indPrim.getSigInd();
                else
                    break;
            }

            if (ptrAux == -1)
            {
                posInd = getArchivo().getFS().Length;
                insIndicePri(e, ref indPri,posInd);
                posB = getArchivo().getFS().Length;
                indPrim = indPri;
                res = insBloque(indPri, nuevo, posB);
            }
            else
                res = insBloque(indPrim, nuevo, posB);
           
            getArchivo().CerrarArchivo();
            return (res);
        }