Exemplo n.º 1
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.º 2
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);
        }