Exemplo n.º 1
0
        /* Inserta un indice primario en la lista de indices*/
        private void insIndicePri(CNodoEntidad e, ref CIndice nuevo, long posInd)
        {
            CIndice indAux, indAnt = null;
            long ptrAux, ptrAnt = -1;

            ptrAux = e.getApCabDatos();
            
            while (ptrAux != -1)
            {
                indAux = getArchivo().LeerIndicePrimario(ptrAux);

                if (indAux.comparateTo(nuevo) < 0)
                {
                    ptrAnt = ptrAux;
                    indAnt = indAux;
                    ptrAux = indAux.getSigInd();
                }
                else
                    break;
            }

            if (ptrAux == e.getApCabDatos())
            {
                e.setApCabDatos(posInd);
                getArchivo().escribeEntidad(e, e.getDir());
            }
            else
            {
                indAnt.setSigInd(posInd);
                getArchivo().EscribeIndicePrimario(indAnt);
            }

            nuevo.setDirInd(posInd);
            nuevo.setSigInd(ptrAux);
            getArchivo().EscribeIndicePrimario(nuevo);
        }
Exemplo n.º 2
0
        /**Se lee del archivo de trabajo un objeto de la clase CIndice, que sera utilzado
         * en la organización secuencial indexada*/
        public CIndice LeerIndicePrimario(long pos)
        {
            BinaryReader br;
            CIndice indPri = new CIndice();

            br = getBr();

            br.BaseStream.Seek(pos, SeekOrigin.Begin);

            indPri.setTipoInd(br.ReadInt32());
            indPri.setTamIndPri(br.ReadInt32());
            indPri.setIndPrim(br.ReadBytes(indPri.getTamIndPri()));
            indPri.setSigInd(br.ReadInt64());
            indPri.setCabBloques(br.ReadInt64());
            indPri.setDirInd(br.ReadInt64());

            return (indPri);
        }
Exemplo n.º 3
0
        /**Función de Mantenimiento para la Organizacion Secuencial indexada*/
        public void MantenimientoSecInd(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
        {
            List<CBloque> listBloque;
            List<CIndice> listaInd;
            CIndice indPri,nuevoInd;
            long aux;
            
            listaInd = new List<CIndice>();
            
            aux = ent.getApCabDatos();
            
            while (aux != -1)
            {
                indPri = fileOri.LeerIndicePrimario(aux);
                nuevoInd = new CIndice();

                nuevoInd.setIndPrim(indPri.getIndPrim());
                nuevoInd.setTamIndPri(indPri.getTamIndPri());
                nuevoInd.setTipoInd(indPri.getTipoInd());

                listBloque = new List<CBloque>();
                
                CopiarSec(fileOri, fileNew, indPri.getCabBloques(), tamBloque, ref listBloque);
                
                nuevoInd.setDirInd(fileNew.ENDF());
                nuevoInd.setCabBloques(listBloque[0].getDir());
                fileNew.EscribeIndicePrimario(nuevoInd);
                
                listaInd.Add(nuevoInd);
                
                aux = indPri.getSigInd();
            }

            for (int i = 0; i < listaInd.Count - 1; i++)
            {
                listaInd[i].setSigInd(listaInd[i + 1].getDirInd());
                fileNew.EscribeIndicePrimario((listaInd[i]));
            }
            
            entC.setApCabDatos(listaInd[0].getDirInd());
            fileNew.escribeEntidad(entC, ent.getDir());
        }