Пример #1
0
 // Lấy thông tin mô tả của file
 private void LayThongTinMoTa(FileStream fs, int iSizeCount, int iSizeKeyword, int iSizePosition,
                              out int iCount, out int iKeyword, out int iPosition)
 {
     byte[] temp = new byte[iSizeCount + iSizeKeyword + iSizePosition];
     fs.Read(temp, 0, temp.Length);
     iCount    = CFunctions.GetInt(temp, 0, iSizeCount);
     iKeyword  = CFunctions.GetInt(temp, iSizeCount, iSizeKeyword);
     iPosition = CFunctions.GetInt(temp, iSizeCount + iSizeKeyword, iSizePosition);
 }
Пример #2
0
    // Đưa vị trí các word của file Index vào List<int>
    // iSizeCount: số byte qui định về Số lượng kí tự
    // iSizeKeyword: số byte qui định về Keyword
    // iSizePosition: số byte qui định về Position
    // iSizeCount + iSizeKeyword + iSizePosition: tổng số byte dùng để mô tả thông tin của file
    private void FileToIndex(FileStream fs, List <int> lst, int iSizeCount, int iSizeKeyword, int iSizePosition)
    {
        int iCount, iKeyword, iPosition;

        LayThongTinMoTa(fs, iSizeCount, iSizeKeyword, iSizePosition, out iCount, out iKeyword, out iPosition);

        byte[] arrtemp = new byte[(iCount + 1) * iKeyword];
        fs.Read(arrtemp, 0, arrtemp.Length);
        for (int i = 0; i < arrtemp.Length; i += iKeyword)
        {
            lst.Add(CFunctions.GetInt(arrtemp, i, iKeyword));
        }
        _iPositionIndex = iPosition;
    }
Пример #3
0
    // Lấy thông tin của Record (word, pos) thứ index trong file Index
    private Infor GetInfoFromIndex(int index)
    {
        Infor kq = new Infor();

        int posWord       = _Index[index];
        int lenRecordWord = _Index[index + 1] - _Index[index];

        _fsIndex.Position = posWord;
        byte[] temp = new byte[lenRecordWord];
        _fsIndex.Read(temp, 0, temp.Length);

        kq.szWord    = Encoding.UTF8.GetString(temp, 0, lenRecordWord - _iPositionIndex);
        kq.iPosition = CFunctions.GetInt(temp, lenRecordWord - _iPositionIndex, _iPositionIndex);

        return(kq);
    }
Пример #4
0
    // Đưa nội dung của file Hash vào List<Infor>
    // iSizeCount: số byte qui định về Số lượng kí tự
    // iSizeKeyword: số byte qui định về Keyword
    // iSizePosition: số byte qui định về Position
    // iSizeCount + iSizeKeyword + iSizePosition: tổng số byte dùng để mô tả thông tin của file
    private void FileToHash(FileStream fs, List <Infor> lst, int iSizeCount, int iSizeKeyword, int iSizePosition)
    {
        int iCount;
        int iKeyword;
        int iPosition;

        LayThongTinMoTa(fs, iSizeCount, iSizeKeyword, iSizePosition, out iCount, out iKeyword, out iPosition);

        byte[] temp = new byte[iKeyword + iPosition];
        while (fs.Read(temp, 0, temp.Length) != 0)
        {
            string key = Encoding.UTF8.GetString(temp, 0, iKeyword);
            int    pos = CFunctions.GetInt(temp, iKeyword, iPosition);

            Infor ele = new Infor();
            ele.szWord    = key.TrimEnd(new char[] { ' ' });
            ele.iPosition = pos;
            lst.Add(ele);
        }
    }