MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / WindowedStream

Method WindowedStream

src/jrd/recsrc/WindowedStream.cpp:208–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206// ------------------------------
207
208WindowedStream::WindowedStream(thread_db* tdbb, Optimizer* opt,
209 ObjectsArray<WindowSourceNode::Window>& windows, RecordSource* next)
210 : RecordSource(opt->getCompilerScratch()),
211 m_joinedStream(nullptr)
212{
213 const auto csb = opt->getCompilerScratch();
214
215 m_next = FB_NEW_POOL(csb->csb_pool) BufferedStream(csb, next);
216 m_impure = csb->allocImpure<Impure>();
217 m_cardinality = next->getCardinality();
218
219 // Process the unpartioned and unordered map, if existent.
220
221 for (auto& window : windows)
222 {
223 // While here, verify not supported functions/clauses.
224
225 if (window.order || window.frameExtent->unit == FrameExtent::Unit::ROWS)
226 {
227 for (const auto& source : window.map->sourceList)
228 {
229 if (const auto aggNode = nodeAs<AggNode>(source))
230 {
231 const char* arg = nullptr;
232
233 if (aggNode->distinct)
234 arg = "DISTINCT";
235 else if (!(aggNode->getCapabilities() & AggNode::CAP_SUPPORTS_WINDOW_FRAME))
236 arg = aggNode->aggInfo.name;
237
238 if (arg)
239 {
240 string msg;
241 msg.printf("%s is not supported in windows with ORDER BY or frame by ROWS clauses", arg);
242
243 status_exception::raise(
244 Arg::Gds(isc_wish_list) <<
245 Arg::Gds(isc_random) << msg);
246 }
247 }
248 }
249 }
250
251 if (!window.group && !window.order)
252 {
253 if (!m_joinedStream)
254 {
255 m_joinedStream = FB_NEW_POOL(csb->csb_pool) WindowStream(tdbb, csb, window.stream,
256 nullptr, FB_NEW_POOL(csb->csb_pool) BufferedStreamWindow(csb, m_next),
257 nullptr, window.map, window.frameExtent, window.exclusion);
258 }
259 else
260 {
261 m_joinedStream = FB_NEW_POOL(csb->csb_pool) WindowStream(tdbb, csb, window.stream,
262 nullptr, FB_NEW_POOL(csb->csb_pool) BufferedStream(csb, m_joinedStream),
263 nullptr, window.map, window.frameExtent, window.exclusion);
264 }
265

Callers

nothing calls this directly

Calls 15

BufferedStreamClass · 0.85
raiseFunction · 0.85
GdsClass · 0.85
WindowStreamClass · 0.85
getCompilerScratchMethod · 0.80
getCardinalityMethod · 0.80
generateSortMethod · 0.80
SortNodeClass · 0.50
getCapabilitiesMethod · 0.45
printfMethod · 0.45

Tested by

no test coverage detected