Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tGoMongoCollection.FindOne() has new overloads to find minimum or maximum value of a field. #20

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
165a076
Added new overloads to TgoMongoCollection.FindOne;
Jun 24, 2022
6820ba4
Merge branch 'master' of https://github.com/tuurke63/DelphiMongoDB in…
Jul 11, 2022
2f571d6
Merge pull request #1 from tuurke63/development
tuurke63 Jul 12, 2022
d6cbc47
Merge pull request #2 from grijjy/master
tuurke63 Jul 12, 2022
cc8332d
Merge branch 'development' of https://github.com/tuurke63/DelphiMongo…
Jul 12, 2022
1a65f69
Implemented MongoDB commands BuildInfo, Features, HostInfo, LogRotate
Jul 14, 2022
ba10c55
Merge pull request #3 from tuurke63/development
tuurke63 Jul 21, 2022
7504843
Added method IgoMongoDatabase.DBCommandDoc (needed for IgoMongoCursor…
Aug 8, 2022
2626aaf
Merge pull request #4 from tuurke63/development
tuurke63 Aug 8, 2022
cf3669c
Breaking change: No longer using "utf8string" for any members or para…
Aug 16, 2022
8462aff
TgoMongoProtocol now determines the minimum and maximum supported Mon…
Aug 16, 2022
eee2fbc
Preparations for new wire protocol. The new wire protocol needs colle…
Aug 17, 2022
ece6b58
work on OP_MSG Protocol
Aug 19, 2022
c6f75d5
trying to fix compatibility problem
Aug 22, 2022
e558bcc
New wire protocol version 6 should work now.
Aug 22, 2022
b136997
Merge pull request #5 from tuurke63/development
tuurke63 Aug 22, 2022
5aa0e0d
Bugfix: Unit test didn't pass
Aug 22, 2022
25ff89c
Merge pull request #6 from tuurke63/development
tuurke63 Aug 22, 2022
c97699d
Modified igoMongoreply so it can handle op_msg features
Aug 23, 2022
b5742d4
MongoDB Wire Protocol 6 implemented (but no checksum or compression yet)
Aug 23, 2022
5790718
Merge pull request #7 from tuurke63/development
tuurke63 Aug 23, 2022
9d4d5ac
Better validation of msg format in comms buffer (TgoMongoMsgReply.Val…
Aug 25, 2022
80cec71
Merge pull request #8 from tuurke63/development
tuurke63 Aug 25, 2022
006bf0d
"command" and "admincommand" now return a cursor instead of a single …
Aug 25, 2022
8bfb449
Merge pull request #9 from tuurke63/development
tuurke63 Aug 25, 2022
a54c2ec
introduced ReadPreference in tgoMongoClient, tgoMongoDatabase, tgoMon…
Aug 26, 2022
314f071
Database and collection will use parent object's readpreferences unle…
Aug 26, 2022
4ea55b0
Merge pull request #10 from tuurke63/development
tuurke63 Aug 30, 2022
d054bc2
igoMongoCollection.Find() now optionally uses a fluent interface (igo…
Sep 7, 2022
da8b025
Merge pull request #11 from tuurke63/development
tuurke63 Sep 7, 2022
b156bd9
Changed timeout routines to use tStopwatch instead of tDatetime, so t…
Sep 8, 2022
e2b21d4
Merge pull request #12 from tuurke63/development
tuurke63 Sep 8, 2022
54c1784
Bugfix in fluent interface of Find()
Sep 8, 2022
6d29aa1
Merge pull request #13 from tuurke63/bugfix
tuurke63 Sep 8, 2022
92c6ecf
Added support for ZLIB and Snappy compression.
Jan 3, 2023
0cd39b2
initial handshake more tolerant
Jan 5, 2023
058d8f6
Fixed a bug in incoming data buffer
Jan 5, 2023
e399e75
Small modifications.
Jan 10, 2023
b7177cd
Introduced constant "NoCursorID"
Jan 12, 2023
1038a48
New constant MongoDefBatchSize
Jan 12, 2023
fdedce5
Suppress compiler warnings
Jan 19, 2023
01cfb36
igoMongoFindOptions can now be saved and restored to json and bson.
Apr 28, 2023
4b87d1d
Snappy object files replaced by DLL's.
May 3, 2023
f51a4dc
- Formatting
Aug 29, 2024
6e75b29
Optimized connection pool and made it into an interface
Aug 30, 2024
27478db
Added missing method ReleaseToPool to interface igoConnectionPool.
Sep 2, 2024
a9e02f4
Made tgoCursorHelper public
Sep 2, 2024
4bd7a7e
Work on autoreconnect, auth, ssl
Oct 1, 2024
2ce6845
tgoMongoProtocol
Oct 2, 2024
fe77dd1
Disconnect shouldn't free fCompletedreplies and fPartialReplies, this…
Oct 3, 2024
60a6ffa
Reduced latency by using tEvent for reception signaling.
Oct 3, 2024
4a2e3bb
Removed compression parameter in OPMSG.
Oct 7, 2024
be46f5d
Grijjy.MongoDB.protocol.pas:
Oct 30, 2024
b486004
Implemented new method igomongocollection.estimatedDocumentCount.
Nov 1, 2024
47a1cbd
Implemented collection.aggregation and igoAggregationPipeline.
Nov 5, 2024
86d8fc4
test for merge
Nov 7, 2024
b3e8394
Merge pull request #17 from tuurke63/test
tuurke63 Nov 7, 2024
705b896
More overloads in igoAggregationPipeline.
Nov 7, 2024
77cbf4e
Merge pull request #18 from tuurke63/aggregates
tuurke63 Nov 7, 2024
6263c3e
tgoMongoExpression: Many new functions.
Nov 8, 2024
a932a87
Merge pull request #19 from tuurke63/aggregates
tuurke63 Nov 8, 2024
5630c4a
Added new aggregation operator "count"
Nov 8, 2024
12c11e3
Merge pull request #20 from tuurke63/aggregations
tuurke63 Nov 8, 2024
29cfab2
Added several new tgoMongoExpression methods.
Nov 11, 2024
cf67255
Merge pull request #21 from tuurke63/aggregates
tuurke63 Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Bin32/snappy32.dll
Binary file not shown.
Binary file added Bin64/libsnappy64.dylib
Binary file not shown.
Binary file added Bin64/libsnappy64.so
Binary file not shown.
Binary file added Bin64/snappy64.dll
Binary file not shown.
163 changes: 163 additions & 0 deletions Grijjy.MongoDB.Compressors.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
unit Grijjy.MongoDB.Compressors;

interface

uses system.SysUtils, system.ZLib, Snappy;

function Snappy_Implemented: Boolean;

const
ZLIB_Implemented = True;

type
tNoopCompressor = class
class function Compress(adata: Pointer; aUncompressedSize: Integer; out aCompressedSize: Integer; out Output: tBytes): Boolean;
class function Expand(adata: Pointer; aCompressedSize, aUncompressedSize:
Integer; out Output: tBytes): Boolean;
end;

tZlibCompressor = class
class function Compress(adata: Pointer; aUncompressedSize: Integer; out aCompressedSize: Integer; out Output: tBytes): Boolean;
class function Expand(adata: Pointer; aCompressedSize, aUncompressedSize: Integer; out OutputBuffer: tBytes): Boolean;
end;

// currently support Snappy only under Windows
tSnappyCompressor = class
class function Compress(adata: Pointer; aUncompressedSize: Integer; out aCompressedSize: Integer; out Output: tBytes): Boolean;
class function Expand(adata: Pointer; aCompressedSize, aUncompressedSize: Integer; out Output: tBytes): Boolean;
end;

implementation

{$HINTS OFF}

function Snappy_Implemented: Boolean;
begin
result := Snappy.Snappy_Implemented;
end;

class function tSnappyCompressor.Compress(adata: Pointer; aUncompressedSize: Integer; out aCompressedSize: Integer; out Output: tBytes):
Boolean;
var
OutSize: Integer;
OutBuffer: Pointer;
var
OutLen: NativeUInt;
Status: Snappy_Status;
begin
result := false;
setlength(Output, 0);
aCompressedSize := 0;
if Snappy_Implemented then
begin
if aUncompressedSize <= 0 then
Exit
else
begin
OutLen := snappy_max_compressed_length(aUncompressedSize); //worst-case
setlength(Output, OutLen);
Status := snappy_compress(adata, aUncompressedSize, @Output[0], OutLen);
if Status = Snappy_OK then
begin
result := True;
aCompressedSize := OutLen;
setlength(Output, aCompressedSize); // truncate
end;
end;
end;
end;

class function tSnappyCompressor.Expand(adata: Pointer; aCompressedSize, aUncompressedSize: Integer; out Output: tBytes): Boolean;
var
ExpandedSize: NativeUInt;
Status: Snappy_Status;
begin
result := false;
setlength(Output, 0);
if Snappy_Implemented then
begin
if aCompressedSize <= 0 then
Exit
else
begin
Status := snappy_uncompressed_length(adata, aCompressedSize, ExpandedSize);
result := (Status = Snappy_OK);
if result then
begin
result := (ExpandedSize = aUncompressedSize);
if result then
begin
setlength(Output, ExpandedSize);
Status := snappy_uncompress(adata, aCompressedSize, @Output[0], ExpandedSize);
result := (Status = Snappy_OK);
end ;
end;
end;
end;
end;

class function tNoopCompressor.Compress(adata: Pointer; aUncompressedSize: Integer; out aCompressedSize: Integer; out Output: tBytes):
Boolean;
begin
aCompressedSize := aUncompressedSize;
setlength(Output, aUncompressedSize);
Move(adata^, Output[0], aUncompressedSize);
result := True;
end;

class function tNoopCompressor.Expand(adata: Pointer; aCompressedSize, aUncompressedSize: Integer; out Output: tBytes): Boolean;
begin
setlength(Output, aCompressedSize);
if aCompressedSize > 0 then
Move(adata^, Output[0], aCompressedSize);
result := True;
end;

class function tZlibCompressor.Compress(adata: Pointer; aUncompressedSize: Integer; out aCompressedSize: Integer; out Output: tBytes):
Boolean;
var
OutSize: Integer;
tempBuffer: Pointer;
begin
result := false;
setlength(Output, 0);
aCompressedSize := 0;
if aUncompressedSize <= 0 then
Exit
else
begin
zcompress(adata, aUncompressedSize, tempBuffer, aCompressedSize, clDefault);
if aCompressedSize > 0 then
begin
result := True;
setlength(Output, aCompressedSize);
Move(tempBuffer^, Output[0], aCompressedSize);
FreeMem(tempBuffer);
end;
end;
end;

class function tZlibCompressor.Expand(adata: Pointer; aCompressedSize, aUncompressedSize: Integer; out OutputBuffer: tBytes): Boolean;
var
ExpandedSize: Integer;
tempBuffer: Pointer;
begin
result := false;
setlength(OutputBuffer, 0);
if aCompressedSize <= 0 then
Exit(false)
else
begin
ZDecompress(adata, aCompressedSize, tempBuffer, ExpandedSize, 0);
if ExpandedSize = aUncompressedSize then
begin
result := True;
setlength(OutputBuffer, aUncompressedSize);
Move(tempBuffer^, OutputBuffer[0], aUncompressedSize);
FreeMem(tempBuffer);
end;
end;
end;

end.

Loading