请问一下,我这个语句的压缩解压有什么问题?100分(100分)

  • 主题发起人 主题发起人 psynet123
  • 开始时间 开始时间
P

psynet123

Unregistered / Unconfirmed
GUEST, unregistred user!
var
recsout,i: integer;
arraybin:TAriantArray;
oledata:OleVariant;
zStream:TZCompressionStream;
sMemstream,dectStream,ss:TMemoryStream;
b:TMemoryStream;
icount:Int64;
sbuff:PChar;
unstream:TZDecompressionStream;
begin
try
try
sMemstream:=TMemoryStream.Create; dectStream:=TMemoryStream.Create;

arraybin:=TAriantArray.Create;
// ListObj.Add(arraybin) ;
ServerForm.Memo3.Lines.Clear;
for i:=0 to sSQL.Count-1 do
begin
// sqlQuery1

with SimpleDataSet1 do
begin

ServerForm.Memo3.Lines.Add(IntToStr(GetTickCount));
Close;
// SQL.Clear;
// sql.Add(sSQL.Items);
DataSet.CommandText:=sSQL.Items;

Open;

ServerForm.Memo3.Lines.Add(IntToStr(GetTickCount));

// sMemstream.Position:=0;
zStream:=TZCompressionStream.Create(dectStream,zcFastest);

SaveToStream(sMemstream);
icount:=sMemstream.Size;
ServerForm.Memo3.Lines.Add(IntToStr(sMemstream.Size)+'k1');
sMemstream.SaveToStream(zStream);
sMemstream.Clear;
dectStream.Position:=0;
sMemstream.Position:=0;
// sMemstream.WriteBuffer(icount,SizeOf(icount)) ;
sMemstream.CopyFrom(dectStream,0) ;
//------------------------------------------------------------
// sMemstream.Position:=0;
icount:=0;
// sMemstream.ReadBuffer(iCount, SizeOf(iCount));
//GetMem(sbuff,icount);

ServerForm.Memo3.Lines.Add(IntToStr(sMemstream.Size)+'k2');
ss:=TMemoryStream.Create;
ServerForm.Memo3.Lines.Add(IntToStr(1));
// dectStream.Position:=0;
ServerForm.Memo3.Lines.Add(IntToStr(2));
sMemstream.Position:=0;
unstream:=TZDecompressionStream.Create(sMemstream);
ServerForm.Memo3.Lines.Add(vartostr(unstream.Size)+'k3');
ServerForm.Memo3.Lines.Add(IntToStr(3));

//unstream.ReadBuffer(sbuff^,SizeOf(icount));
ServerForm.Memo3.Lines.Add(IntToStr(4));
//ss.WriteBuffer(sbuff^,icount);
ServerForm.Memo3.Lines.Add(IntToStr(5));
// ss.Position:=0;
unstream.Position:=0;
ss.CopyFrom(unstream,0) ;
ServerForm.Memo3.Lines.Add(IntToStr(6));


//ss.WriteBuffer(sbuff^,icount);
ss.Position:=0;
ss.SaveToFile('dddddddddd');
// SimpleDataSet2.Close;
SimpleDataSet2.LoadFromFile('dddddddddd');
// SimpleDataSet2.LoadFromStream(ss);
ServerForm.Memo3.Lines.Add(IntToStr(7));
//---------------------------------------------------------
//zStream.Write(sMemstream,SizeOf(sMemstream));
// .save
// oledata:=DataSetProvider.Data;
oledata:=SimpleDataSet2.Data;


ServerForm.Memo3.Lines.Add(IntToStr(GetTickCount));

arraybin.add(BinaryFromVariant(oledata));
// TROBinaryMemoryStream
// arraybin.add(sMemstream);
ServerForm.Memo3.Lines.Add(IntToStr(GetTickCount));
Close;
end ;
//dbexpmss.dll
end;
 
var
recsout,i: integer;
oledata:OleVariant;
comStream:TZCompressionStream;
source,dest:TMemoryStream;
icount:Int64;
sbuff:PChar;
decstream:TZDecompressionStream;
begin
try
try

source:=TMemoryStream.Create; dest:=TMemoryStream.Create;
comStream:=TZCompressionStream.Create(dest,zcFastest);
ClientDataSet2.Close;
ClientDataSet2.CommandText:='select top 1000 * from item' ;
ClientDataSet2.Open;
ClientDataSet2.SaveToStream(comStream);
ShowMessage(IntToStr(dest.size)+inttostr(ClientDataSet2.recordcount));
source.Clear;
decstream:=TZDecompressionStream.Create(dest);
source.CopyFrom(decstream,0);
ShowMessage(IntToStr(source.size));
ClientDataSet1.LoadFromStream(source);

except
raise Exception.CreateFmt('There were %d errors', [icount]);
end;
finally

source.Free;
dest.Free;
decstream.Free;
comStream.Free;
ADOQuery1.Close;
end;
end;
看这个清楚一点吧
 
后退
顶部