private SynFootprint ReadFootprint(BinaryReader br) { byte eof = br.ReadByte(); if (eof == 1) { return(null); } return(SynFootprint.FromStream(br, m_srcInfo.KeyCols.Length)); }
public static SynFootprint FromStream(BinaryReader br, int keylen) { var res = new SynFootprint(); res.KeyData = new string[keylen]; for (int i = 0; i < keylen; i++) { res.KeyData[i] = br.ReadString(); } res.Hash = br.ReadString(); return(res); }
public static SynFootprint FromReader(IBedRecord record, int keylen, BedValueHolder holder, BedValueConvertor conv, IDataSynAdapter adapter) { var res = new SynFootprint(); res.KeyData = new string[keylen]; for (int i = 0; i < keylen; i++) { record.ReadValue(i); conv.ConvertValue(record, TypeStorage.String, holder); res.KeyData[i] = holder.GetString(); } record.ReadValue(keylen); res.Hash = adapter.ReadHash(record, conv, holder); return(res); }
private void DoLoadFootprint(IDatabaseSource conn, SynSourceInfo info, string cacheFile) { // HACK: external sorting must be implemented using (var fw = new FileStream(cacheFile, FileMode.Create)) { var fts = new List <SynFootprint>(); using (var bw = new BinaryWriter(fw)) { var sada = conn.Dialect.CreateDataSynAdapter(); if (sada == null) { throw new ExpectedError("DAE-00365 " + Texts.Get("s_dialect_doesnt_support_sync$dialect", "dialect", conn.Dialect.DisplayName)); } var qbuf = new StringWriter(); var dmp = conn.Dialect.CreateDumper(qbuf); var qtype = m_options.Update == true ? SynQueryType.SelectKeyMd5 : SynQueryType.SelectKeyNull; info.Query.GenerateSql(dmp, sada, info, qtype, d2 => { if (!info.SqlCondition.IsEmpty()) { d2.Put(" ^where "); d2.WriteRaw(info.SqlCondition); } }); using (var cmd = conn.Connection.SystemConnection.CreateCommand()) { cmd.CommandText = qbuf.ToString(); using (IBedReader reader = conn.GetAnyDDA().AdaptReader(cmd.ExecuteReader())) { while (reader.Read()) { var ft = SynFootprint.FromReader(reader, info.KeyCols.Length, m_holder, m_conv, sada); fts.Add(ft); } } } fts.Sort(); foreach (var ft in fts) { bw.Write((byte)0); ft.SaveToStream(bw); } bw.Write((byte)1); } } }
public bool EqualKey(SynFootprint other) { return(KeyData.EqualSequence(other.KeyData)); }