@@ -11,12 +11,12 @@ import (
11
11
"github.com/ozontech/seq-db/cache"
12
12
"github.com/ozontech/seq-db/consts"
13
13
"github.com/ozontech/seq-db/frac/common"
14
+ "github.com/ozontech/seq-db/frac/processor"
14
15
"github.com/ozontech/seq-db/frac/sealed"
15
16
"github.com/ozontech/seq-db/frac/sealed/lids"
16
17
"github.com/ozontech/seq-db/frac/sealed/seqids"
17
18
"github.com/ozontech/seq-db/frac/sealed/token"
18
19
"github.com/ozontech/seq-db/logger"
19
- "github.com/ozontech/seq-db/metric"
20
20
"github.com/ozontech/seq-db/seq"
21
21
"github.com/ozontech/seq-db/storage"
22
22
"github.com/ozontech/seq-db/storage/s3"
@@ -41,9 +41,6 @@ type Remote struct {
41
41
42
42
info * common.Info
43
43
44
- useMu sync.RWMutex
45
- suicided bool
46
-
47
44
docsFile storage.ImmutableFile
48
45
docsCache * cache.Cache [[]byte ]
49
46
docsReader storage.DocsReader
@@ -114,37 +111,20 @@ func (f *Remote) Contains(mid seq.MID) bool {
114
111
return f .info .IsIntersecting (mid , mid )
115
112
}
116
113
117
- func (f * Remote ) DataProvider (ctx context.Context ) (DataProvider , func ()) {
118
- f .useMu .RLock ()
119
-
120
- if f .suicided {
121
- metric .CountersTotal .WithLabelValues ("fraction_suicided" ).Inc ()
122
- f .useMu .RUnlock ()
123
- return EmptyDataProvider {}, func () {}
124
- }
125
-
126
- defer func () {
127
- if panicData := recover (); panicData != nil {
128
- f .useMu .RUnlock ()
129
- panic (panicData )
130
- }
131
- }()
132
-
133
- if err := f .load (); err != nil {
134
- logger .Error (
135
- "will create empty data provider: cannot load remote fraction" ,
136
- zap .String ("fraction" , f .Info ().Name ()),
137
- zap .Error (err ),
138
- )
139
- f .useMu .RUnlock ()
140
- return EmptyDataProvider {}, func () {}
114
+ func (f * Remote ) Fetch (ctx context.Context , ids []seq.ID ) ([][]byte , error ) {
115
+ dp , err := f .createDataProvider (ctx )
116
+ if err != nil {
117
+ return nil , err
141
118
}
119
+ return dp .Fetch (ids )
120
+ }
142
121
143
- dp := f . createDataProvider (ctx )
144
- return dp , func () {
145
- dp . release ()
146
- f . useMu . RUnlock ()
122
+ func ( f * Remote ) Search (ctx context. Context , params processor. SearchParams ) ( * seq. QPR , error ) {
123
+ dp , err := f . createDataProvider ( ctx )
124
+ if err != nil {
125
+ return & seq. QPR { Aggs : make ([]seq. AggregatableSamples , len ( params . AggQ ))}, err
147
126
}
127
+ return dp .Search (params )
148
128
}
149
129
150
130
func (f * Remote ) Info () * common.Info {
@@ -155,15 +135,7 @@ func (f *Remote) IsIntersecting(from, to seq.MID) bool {
155
135
return f .info .IsIntersecting (from , to )
156
136
}
157
137
158
- func (f * Remote ) Offload (context.Context , storage.Uploader ) (bool , error ) {
159
- panic ("BUG: remote fraction cannot be offloaded" )
160
- }
161
-
162
138
func (f * Remote ) Suicide () {
163
- f .useMu .Lock ()
164
- f .suicided = true
165
- f .useMu .Unlock ()
166
-
167
139
util .MustRemoveFileByPath (f .BaseFileName + consts .RemoteFractionSuffix )
168
140
169
141
f .docsCache .Release ()
@@ -189,7 +161,15 @@ func (f *Remote) String() string {
189
161
return fracToString (f , "remote" )
190
162
}
191
163
192
- func (f * Remote ) createDataProvider (ctx context.Context ) * sealedDataProvider {
164
+ func (f * Remote ) createDataProvider (ctx context.Context ) (* sealedDataProvider , error ) {
165
+ if err := f .load (); err != nil {
166
+ logger .Error (
167
+ "will create empty data provider: cannot load remote fraction" ,
168
+ zap .String ("fraction" , f .Info ().Name ()),
169
+ zap .Error (err ),
170
+ )
171
+ return nil , err
172
+ }
193
173
return & sealedDataProvider {
194
174
ctx : ctx ,
195
175
info : f .info ,
@@ -210,7 +190,7 @@ func (f *Remote) createDataProvider(ctx context.Context) *sealedDataProvider {
210
190
& f .blocksData .IDsTable ,
211
191
f .info .BinaryDataVer ,
212
192
),
213
- }
193
+ }, nil
214
194
}
215
195
216
196
func (f * Remote ) load () error {
0 commit comments