4
4
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
5
5
"""Contains implementations of database retrieveing objects"""
6
6
from gitdb .util import (
7
- pool ,
8
7
join ,
9
8
LazyMixin ,
10
9
hex_to_bin
15
14
AmbiguousObjectName
16
15
)
17
16
18
- from async import (
19
- ChannelThreadTask
20
- )
21
-
22
17
from itertools import chain
23
18
from functools import reduce
24
19
@@ -41,47 +36,18 @@ def has_object(self, sha):
41
36
binary sha is contained in the database"""
42
37
raise NotImplementedError ("To be implemented in subclass" )
43
38
44
- def has_object_async (self , reader ):
45
- """Return a reader yielding information about the membership of objects
46
- as identified by shas
47
- :param reader: Reader yielding 20 byte shas.
48
- :return: async.Reader yielding tuples of (sha, bool) pairs which indicate
49
- whether the given sha exists in the database or not"""
50
- task = ChannelThreadTask (reader , str (self .has_object_async ), lambda sha : (sha , self .has_object (sha )))
51
- return pool .add_task (task )
52
-
53
39
def info (self , sha ):
54
40
""" :return: OInfo instance
55
41
:param sha: bytes binary sha
56
42
:raise BadObject:"""
57
43
raise NotImplementedError ("To be implemented in subclass" )
58
44
59
- def info_async (self , reader ):
60
- """Retrieve information of a multitude of objects asynchronously
61
- :param reader: Channel yielding the sha's of the objects of interest
62
- :return: async.Reader yielding OInfo|InvalidOInfo, in any order"""
63
- task = ChannelThreadTask (reader , str (self .info_async ), self .info )
64
- return pool .add_task (task )
65
-
66
45
def stream (self , sha ):
67
46
""":return: OStream instance
68
47
:param sha: 20 bytes binary sha
69
48
:raise BadObject:"""
70
49
raise NotImplementedError ("To be implemented in subclass" )
71
50
72
- def stream_async (self , reader ):
73
- """Retrieve the OStream of multiple objects
74
- :param reader: see ``info``
75
- :param max_threads: see ``ObjectDBW.store``
76
- :return: async.Reader yielding OStream|InvalidOStream instances in any order
77
-
78
- **Note:** depending on the system configuration, it might not be possible to
79
- read all OStreams at once. Instead, read them individually using reader.read(x)
80
- where x is small enough."""
81
- # base implementation just uses the stream method repeatedly
82
- task = ChannelThreadTask (reader , str (self .stream_async ), self .stream )
83
- return pool .add_task (task )
84
-
85
51
def size (self ):
86
52
""":return: amount of objects in this database"""
87
53
raise NotImplementedError ()
@@ -129,27 +95,6 @@ def store(self, istream):
129
95
:raise IOError: if data could not be written"""
130
96
raise NotImplementedError ("To be implemented in subclass" )
131
97
132
- def store_async (self , reader ):
133
- """
134
- Create multiple new objects in the database asynchronously. The method will
135
- return right away, returning an output channel which receives the results as
136
- they are computed.
137
-
138
- :return: Channel yielding your IStream which served as input, in any order.
139
- The IStreams sha will be set to the sha it received during the process,
140
- or its error attribute will be set to the exception informing about the error.
141
-
142
- :param reader: async.Reader yielding IStream instances.
143
- The same instances will be used in the output channel as were received
144
- in by the Reader.
145
-
146
- **Note:** As some ODB implementations implement this operation atomic, they might
147
- abort the whole operation if one item could not be processed. Hence check how
148
- many items have actually been produced."""
149
- # base implementation uses store to perform the work
150
- task = ChannelThreadTask (reader , str (self .store_async ), self .store )
151
- return pool .add_task (task )
152
-
153
98
#} END edit interface
154
99
155
100
0 commit comments