MCPcopy Create free account
hub / github.com/ByConity/ByConity / sendData

Method sendData

programs/client/Client.cpp:1921–1976  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1919
1920
1921 void sendData(Block & sample, const ColumnsDescription & columns_description)
1922 {
1923 /// If INSERT data must be sent.
1924 auto * parsed_insert_query = parsed_query->as<ASTInsertQuery>();
1925 if (!parsed_insert_query)
1926 return;
1927
1928 if (parsed_insert_query->data)
1929 {
1930 /// Send data contained in the query.
1931 ReadBufferFromMemory data_in(parsed_insert_query->data, parsed_insert_query->end - parsed_insert_query->data);
1932 try
1933 {
1934 sendDataFrom(data_in, sample, columns_description);
1935 }
1936 catch (Exception & e)
1937 {
1938 /// The following query will use data from input
1939 // "INSERT INTO data FORMAT TSV\n " < data.csv
1940 // And may be pretty hard to debug, so add information about data source to make it easier.
1941 e.addMessage("data for INSERT was parsed from query");
1942 throw;
1943 }
1944 // Remember where the data ended. We use this info later to determine
1945 // where the next query begins.
1946 parsed_insert_query->end = parsed_insert_query->data + data_in.count();
1947 }
1948 else if (!is_interactive)
1949 {
1950 /// Send data read from stdin.
1951 try
1952 {
1953 if (need_render_progress)
1954 {
1955 /// Set total_bytes_to_read for current fd.
1956 FileProgress file_progress(0, std_in.getFileSize());
1957 progress_indication.updateProgress(Progress(file_progress));
1958
1959 /// Set callback to be called on file progress.
1960 progress_indication.setFileProgressCallback(context, true);
1961
1962 /// Add callback to track reading from fd.
1963 std_in.setProgressCallback(context);
1964 }
1965
1966 sendDataFrom(std_in, sample, columns_description);
1967 }
1968 catch (Exception & e)
1969 {
1970 e.addMessage("data for INSERT was parsed from stdin");
1971 throw;
1972 }
1973 }
1974 else
1975 throw Exception("No data to insert", ErrorCodes::NO_DATA_TO_INSERT);
1976 }
1977
1978

Callers 1

sendDataFromMethod · 0.45

Calls 8

addMessageMethod · 0.80
ProgressClass · 0.50
ExceptionClass · 0.50
countMethod · 0.45
getFileSizeMethod · 0.45
updateProgressMethod · 0.45
setProgressCallbackMethod · 0.45

Tested by

no test coverage detected