Skip to content

Commit 8f6d662

Browse files
committed
Merge pull request #17754 from ydb-platform/merge-libs-250425-1915
2 parents 290386c + ad35ebc commit 8f6d662

File tree

140 files changed

+1996
-810
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+1996
-810
lines changed

build/conf/compilers/gnu_compiler.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ when ($ARCH_XTENSA == "yes") {
9797

9898
when ($OS_EMSCRIPTEN == "yes") {
9999
FSTACK=-fno-stack-protector
100-
CFLAGS+=-D__EMSCRIPTEN__
100+
CFLAGS+=-D__EMSCRIPTEN__=1
101101
CFLAGS+=-DSTANDALONE_WASM=1
102102
}
103103

build/ymake.core.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5922,8 +5922,8 @@ macro LINK_EXCLUDE_LIBRARIES(Libs...) {
59225922
###
59235923
### GENERATE_IMPLIB(cuda $CUDA_TARGET_ROOT/lib64/stubs/libcuda.so SONAME libcuda.so.1)
59245924
###
5925-
macro GENERATE_IMPLIB(Lib, Path, SONAME="") {
5926-
.CMD=${tool:"contrib/tools/implib"} --target $HARDWARE_TYPE --outdir $BINDIR ${pre=--library-load-name :SONAME} $Path ${hide;output;suf=.init.c;nopath:Path} ${hide;output;suf=.tramp.S;nopath:Path}
5925+
macro GENERATE_IMPLIB(Lib, Path, SONAME="", DLOPEN_CALLBACK="_") {
5926+
.CMD=${tool:"contrib/tools/implib"} --target $HARDWARE_TYPE --dlopen-callback $DLOPEN_CALLBACK --outdir $BINDIR ${pre=--library-load-name :SONAME} $Path ${hide;output;suf=.init.c;nopath:Path} ${hide;output;suf=.tramp.S;nopath:Path}
59275927

59285928
LINK_EXCLUDE_LIBRARIES($Lib)
59295929
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--- contrib/libs/yajl/yajl_tree.c (3b4a018b6b389390da3ee13f6b4ce0880cb71807)
2+
+++ contrib/libs/yajl/yajl_tree.c (5fe0776c5f96630ddffb63e4ff0292037e12039e)
3+
@@ -143,7 +143,7 @@ static yajl_val context_pop(context_t *ctx)
4+
ctx->stack = stack->next;
5+
6+
v = stack->value;
7+
-
8+
+ free (stack->key);
9+
free (stack);
10+
11+
return (v);
12+
@@ -453,7 +453,14 @@ yajl_val yajl_tree_parse (const char *input,
13+
(const unsigned char *) input,
14+
strlen(input)));
15+
}
16+
+ while(ctx.stack != NULL) {
17+
+ yajl_val v = context_pop(&ctx);
18+
+ yajl_tree_free(v);
19+
+ }
20+
yajl_free (handle);
21+
+ //If the requested memory is not released in time, it will cause memory leakage
22+
+ if(ctx.root)
23+
+ yajl_tree_free(ctx.root);
24+
return NULL;
25+
}
26+

contrib/libs/yajl/yajl_tree.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static yajl_val context_pop(context_t *ctx)
143143
ctx->stack = stack->next;
144144

145145
v = stack->value;
146-
146+
free (stack->key);
147147
free (stack);
148148

149149
return (v);
@@ -453,7 +453,14 @@ yajl_val yajl_tree_parse (const char *input,
453453
(const unsigned char *) input,
454454
strlen(input)));
455455
}
456+
while(ctx.stack != NULL) {
457+
yajl_val v = context_pop(&ctx);
458+
yajl_tree_free(v);
459+
}
456460
yajl_free (handle);
461+
//If the requested memory is not released in time, it will cause memory leakage
462+
if(ctx.root)
463+
yajl_tree_free(ctx.root);
457464
return NULL;
458465
}
459466

contrib/python/ydb/py3/.dist-info/METADATA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: ydb
3-
Version: 3.20.1
3+
Version: 3.21.0
44
Summary: YDB Python SDK
55
Home-page: http://github.com/ydb-platform/ydb-python-sdk
66
Author: Yandex LLC

contrib/python/ydb/py3/ya.make

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
PY3_LIBRARY()
44

5-
VERSION(3.20.1)
5+
VERSION(3.21.0)
66

77
LICENSE(Apache-2.0)
88

@@ -40,6 +40,7 @@ PY_SRCS(
4040
ydb/_topic_common/common.py
4141
ydb/_topic_reader/__init__.py
4242
ydb/_topic_reader/datatypes.py
43+
ydb/_topic_reader/events.py
4344
ydb/_topic_reader/topic_reader.py
4445
ydb/_topic_reader/topic_reader_asyncio.py
4546
ydb/_topic_reader/topic_reader_sync.py

contrib/python/ydb/py3/ydb/_apis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class TopicService(object):
116116
StreamRead = "StreamRead"
117117
StreamWrite = "StreamWrite"
118118
UpdateOffsetsInTransaction = "UpdateOffsetsInTransaction"
119+
CommitOffset = "CommitOffset"
119120

120121

121122
class QueryService(object):

contrib/python/ydb/py3/ydb/_grpc/grpcwrapper/ydb_topic.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ def from_proto(msg: ydb_topic_pb2.UpdateTokenResponse) -> typing.Any:
136136
return UpdateTokenResponse()
137137

138138

139+
@dataclass
140+
class CommitOffsetRequest(IToProto):
141+
path: str
142+
consumer: str
143+
partition_id: int
144+
offset: int
145+
146+
def to_proto(self) -> ydb_topic_pb2.CommitOffsetRequest:
147+
return ydb_topic_pb2.CommitOffsetRequest(
148+
path=self.path,
149+
consumer=self.consumer,
150+
partition_id=self.partition_id,
151+
offset=self.offset,
152+
)
153+
154+
139155
########################################################################################################################
140156
# StreamWrite
141157
########################################################################################################################
@@ -438,12 +454,13 @@ def from_proto(
438454
@dataclass
439455
class InitRequest(IToProto):
440456
topics_read_settings: List["StreamReadMessage.InitRequest.TopicReadSettings"]
441-
consumer: str
457+
consumer: Optional[str]
442458
auto_partitioning_support: bool
443459

444460
def to_proto(self) -> ydb_topic_pb2.StreamReadMessage.InitRequest:
445461
res = ydb_topic_pb2.StreamReadMessage.InitRequest()
446-
res.consumer = self.consumer
462+
if self.consumer is not None:
463+
res.consumer = self.consumer
447464
for settings in self.topics_read_settings:
448465
res.topics_read_settings.append(settings.to_proto())
449466
res.auto_partitioning_support = self.auto_partitioning_support

contrib/python/ydb/py3/ydb/_topic_reader/datatypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def _commit_get_offsets_range(self) -> OffsetsRange:
5656
def alive(self) -> bool:
5757
return not self._partition_session.closed
5858

59+
@property
60+
def partition_id(self) -> int:
61+
return self._partition_session.partition_id
62+
5963

6064
@dataclass
6165
class PartitionSession:
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import asyncio
2+
from dataclasses import dataclass
3+
from typing import Awaitable, Union
4+
5+
from ..issues import ClientInternalError
6+
7+
__all__ = [
8+
"OnCommit",
9+
"OnPartitionGetStartOffsetRequest",
10+
"OnPartitionGetStartOffsetResponse",
11+
"OnInitPartition",
12+
"OnShutdownPartition",
13+
"EventHandler",
14+
]
15+
16+
17+
class BaseReaderEvent:
18+
pass
19+
20+
21+
@dataclass
22+
class OnCommit(BaseReaderEvent):
23+
topic: str
24+
offset: int
25+
26+
27+
@dataclass
28+
class OnPartitionGetStartOffsetRequest(BaseReaderEvent):
29+
topic: str
30+
partition_id: int
31+
32+
33+
@dataclass
34+
class OnPartitionGetStartOffsetResponse:
35+
start_offset: int
36+
37+
38+
class OnInitPartition(BaseReaderEvent):
39+
pass
40+
41+
42+
class OnShutdownPartition:
43+
pass
44+
45+
46+
TopicEventDispatchType = Union[OnPartitionGetStartOffsetResponse, None]
47+
48+
49+
class EventHandler:
50+
def on_commit(self, event: OnCommit) -> Union[None, Awaitable[None]]:
51+
pass
52+
53+
def on_partition_get_start_offset(
54+
self,
55+
event: OnPartitionGetStartOffsetRequest,
56+
) -> Union[OnPartitionGetStartOffsetResponse, Awaitable[OnPartitionGetStartOffsetResponse]]:
57+
pass
58+
59+
def on_init_partition(self, event: OnInitPartition) -> Union[None, Awaitable[None]]:
60+
pass
61+
62+
def on_shutdown_partition(self, event: OnShutdownPartition) -> Union[None, Awaitable[None]]:
63+
pass
64+
65+
async def _dispatch(self, event: BaseReaderEvent) -> Awaitable[TopicEventDispatchType]:
66+
f = None
67+
if isinstance(event, OnCommit):
68+
f = self.on_commit
69+
elif isinstance(event, OnPartitionGetStartOffsetRequest):
70+
f = self.on_partition_get_start_offset
71+
elif isinstance(event, OnInitPartition):
72+
f = self.on_init_partition
73+
elif isinstance(event, OnShutdownPartition):
74+
f = self.on_shutdown_partition
75+
else:
76+
raise ClientInternalError("Unsupported topic reader event")
77+
78+
if asyncio.iscoroutinefunction(f):
79+
return await f(event)
80+
81+
return f(event)

contrib/python/ydb/py3/ydb/_topic_reader/topic_reader.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Callable,
1111
)
1212

13+
from .events import EventHandler
1314
from ..retries import RetrySettings
1415
from .._grpc.grpcwrapper.ydb_topic import StreamReadMessage, OffsetsRange
1516

@@ -20,6 +21,7 @@ class PublicTopicSelector:
2021
partitions: Optional[Union[int, List[int]]] = None
2122
read_from: Optional[datetime.datetime] = None
2223
max_lag: Optional[datetime.timedelta] = None
24+
read_offset: Optional[int] = None
2325

2426
def _to_topic_read_settings(self) -> StreamReadMessage.InitRequest.TopicReadSettings:
2527
partitions = self.partitions
@@ -42,7 +44,7 @@ def _to_topic_read_settings(self) -> StreamReadMessage.InitRequest.TopicReadSett
4244

4345
@dataclass
4446
class PublicReaderSettings:
45-
consumer: str
47+
consumer: Optional[str]
4648
topic: TopicSelectorTypes
4749
buffer_size_bytes: int = 50 * 1024 * 1024
4850
auto_partitioning_support: bool = True
@@ -53,13 +55,14 @@ class PublicReaderSettings:
5355
# decoder_executor, must be set for handle non raw messages
5456
decoder_executor: Optional[concurrent.futures.Executor] = None
5557
update_token_interval: Union[int, float] = 3600
58+
event_handler: Optional[EventHandler] = None
5659

5760
def __post_init__(self):
5861
# check possible create init message
5962
_ = self._init_message()
6063

6164
def _init_message(self) -> StreamReadMessage.InitRequest:
62-
if not isinstance(self.consumer, str):
65+
if self.consumer is not None and not isinstance(self.consumer, str):
6366
raise TypeError("Unsupported type for customer field: '%s'" % type(self.consumer))
6467

6568
if isinstance(self.topic, list):
@@ -85,25 +88,6 @@ def _retry_settings(self) -> RetrySettings:
8588
return RetrySettings(idempotent=True)
8689

8790

88-
class Events:
89-
class OnCommit:
90-
topic: str
91-
offset: int
92-
93-
class OnPartitionGetStartOffsetRequest:
94-
topic: str
95-
partition_id: int
96-
97-
class OnPartitionGetStartOffsetResponse:
98-
start_offset: int
99-
100-
class OnInitPartition:
101-
pass
102-
103-
class OnShutdownPatition:
104-
pass
105-
106-
10791
class RetryPolicy:
10892
connection_timeout_sec: float
10993
overload_timeout_sec: float

0 commit comments

Comments
 (0)