|
1 | 1 | import type {PlanToSvgQueryParams} from '../../store/reducers/planToSvg'; |
2 | | -import { |
3 | | - isQueryResponseChunk, |
4 | | - isSessionChunk, |
5 | | - isStreamDataChunk, |
6 | | -} from '../../store/reducers/query/utils'; |
7 | 2 | import type {TMetaInfo} from '../../types/api/acl'; |
8 | 3 | import type {TQueryAutocomplete} from '../../types/api/autocomplete'; |
9 | 4 | import type {CapabilitiesResponse} from '../../types/api/capabilities'; |
@@ -38,10 +33,8 @@ import type {DescribeTopicResult} from '../../types/api/topic'; |
38 | 33 | import type {TEvVDiskStateResponse} from '../../types/api/vdisk'; |
39 | 34 | import type {TUserToken} from '../../types/api/whoami'; |
40 | 35 | import type {QuerySyntax, TransactionMode} from '../../types/store/query'; |
41 | | -import type {StreamDataChunk, StreamingChunk} from '../../types/store/streaming'; |
42 | 36 | import {BINARY_DATA_IN_PLAIN_TEXT_DISPLAY} from '../../utils/constants'; |
43 | 37 | import type {Nullable} from '../../utils/typecheckers'; |
44 | | -import {parseMultipart} from '../parsers/parseMultipart'; |
45 | 38 | import {settingsManager} from '../settings'; |
46 | 39 |
|
47 | 40 | import {BaseYdbAPI} from './base'; |
@@ -375,97 +368,6 @@ export class ViewerAPI extends BaseYdbAPI { |
375 | 368 | ); |
376 | 369 | } |
377 | 370 |
|
378 | | - streamQuery<Action extends Actions>( |
379 | | - params: { |
380 | | - query?: string; |
381 | | - database?: string; |
382 | | - action?: Action; |
383 | | - syntax?: QuerySyntax; |
384 | | - stats?: Stats; |
385 | | - tracingLevel?: TracingLevel; |
386 | | - transaction_mode?: TransactionMode; |
387 | | - timeout?: Timeout; |
388 | | - limit_rows?: number; |
389 | | - output_chunk_max_size: number; |
390 | | - concurrent_results?: boolean; |
391 | | - }, |
392 | | - { |
393 | | - concurrentId, |
394 | | - signal, |
395 | | - onChunk, |
396 | | - }: AxiosOptions & { |
397 | | - onChunk: (chunk: StreamingChunk) => void; |
398 | | - }, |
399 | | - ) { |
400 | | - const base64 = !settingsManager.readUserSettingsValue( |
401 | | - BINARY_DATA_IN_PLAIN_TEXT_DISPLAY, |
402 | | - true, |
403 | | - ); |
404 | | - |
405 | | - let lastProcessedLength = 0; |
406 | | - |
407 | | - return this.get<string>( |
408 | | - this.getPath('/viewer/query'), |
409 | | - { |
410 | | - ...params, |
411 | | - base64, |
412 | | - schema: 'multipart', |
413 | | - }, |
414 | | - { |
415 | | - concurrentId, |
416 | | - timeout: params.timeout, |
417 | | - requestConfig: { |
418 | | - signal, |
419 | | - 'axios-retry': {retries: 0}, // No retries for streaming |
420 | | - responseType: 'arraybuffer', |
421 | | - }, |
422 | | - headers: { |
423 | | - ...(params.tracingLevel ? {'X-Trace-Verbosity': params.tracingLevel} : {}), |
424 | | - Accept: 'multipart/x-mixed-replace', |
425 | | - }, |
426 | | - onDownloadProgress: (progressEvent) => { |
427 | | - const xhr = progressEvent.event.target as XMLHttpRequest; |
428 | | - const {chunks, lastProcessedLength: currentLength} = parseMultipart({ |
429 | | - response: xhr.response, |
430 | | - lastProcessedLength, |
431 | | - }); |
432 | | - lastProcessedLength = currentLength; |
433 | | - const mergedChunks = new Map<number, StreamDataChunk>(); |
434 | | - |
435 | | - for (const chunk of chunks) { |
436 | | - if (isSessionChunk(chunk)) { |
437 | | - const traceId = xhr.getResponseHeader('traceresponse')?.split('-')[1]; |
438 | | - |
439 | | - chunk.meta.trace_id = traceId; |
440 | | - onChunk(chunk); |
441 | | - } else if (isQueryResponseChunk(chunk)) { |
442 | | - for (const [index, mergedChunk] of mergedChunks) { |
443 | | - onChunk(mergedChunk); |
444 | | - mergedChunks.delete(index); |
445 | | - } |
446 | | - |
447 | | - onChunk(chunk); |
448 | | - } else if (isStreamDataChunk(chunk)) { |
449 | | - const resultIndex = chunk.meta.result_index; |
450 | | - const mergedChunk = mergedChunks.get(resultIndex); |
451 | | - |
452 | | - if (mergedChunk && mergedChunk.result.rows && chunk.result.rows) { |
453 | | - mergedChunk.result.rows.push(...chunk.result.rows); |
454 | | - } else { |
455 | | - mergedChunks.set(resultIndex, chunk); |
456 | | - } |
457 | | - } |
458 | | - } |
459 | | - |
460 | | - for (const [index, mergedChunk] of mergedChunks) { |
461 | | - onChunk(mergedChunk); |
462 | | - mergedChunks.delete(index); |
463 | | - } |
464 | | - }, |
465 | | - }, |
466 | | - ); |
467 | | - } |
468 | | - |
469 | 371 | getHotKeys( |
470 | 372 | {path, database, enableSampling}: {path: string; database: string; enableSampling: boolean}, |
471 | 373 | {concurrentId, signal}: AxiosOptions = {}, |
|
0 commit comments