void DistributedBlockOutputStream::write(const Block & block) { if (storage.getShardingKeyExpr() && (cluster->getShardsInfo().size() > 1)) return writeSplit(block); writeImpl(block); }
void DistributedBlockOutputStream::writeSplit(const Block & block) { const auto num_cols = block.columns(); /// cache column pointers for later reuse std::vector<const IColumn *> columns(num_cols); for (size_t i = 0; i < columns.size(); ++i) columns[i] = block.safeGetByPosition(i).column.get(); auto selector = createSelector(block); /// Split block to num_shard smaller block, using 'selector'. const size_t num_shards = cluster->getShardsInfo().size(); Blocks splitted_blocks(num_shards); for (size_t shard_idx = 0; shard_idx < num_shards; ++shard_idx) splitted_blocks[shard_idx] = block.cloneEmpty(); size_t columns_in_block = block.columns(); for (size_t col_idx_in_block = 0; col_idx_in_block < columns_in_block; ++col_idx_in_block) { Columns splitted_columns = block.getByPosition(col_idx_in_block).column->scatter(num_shards, selector); for (size_t shard_idx = 0; shard_idx < num_shards; ++shard_idx) splitted_blocks[shard_idx].getByPosition(col_idx_in_block).column = std::move(splitted_columns[shard_idx]); } for (size_t shard_idx = 0; shard_idx < num_shards; ++shard_idx) if (splitted_blocks[shard_idx].rows()) writeImpl(splitted_blocks[shard_idx], shard_idx); }
int File::putc(char c) { char buf[1]; buf[0] = c; int ret = writeImpl(buf, 1); m_position += ret; return ret; }
kj::Promise<void> TlsPskAdaptor::write(const void* data, size_t dataSize) { if (!channel) return KJ_EXCEPTION(DISCONNECTED, "Adaptor cannot be used without a channel. Call setChannel first"); if (handshakeCompletedFulfiller->isWaiting()) { // Defer passing this data to the TLS layer until after the handshake completes auto buffer = kj::heapArray<const kj::byte>(static_cast<const kj::byte*>(data), dataSize); return handshakeCompleted.addBranch().then([this, buffer = kj::mv(buffer)]() mutable -> kj::Promise<void> { return writeImpl(buffer); }); } else { // Go ahead and send it now, skip making a copy :D return writeImpl(kj::ArrayPtr<const kj::byte>(static_cast<const kj::byte*>(data), dataSize)); } }
int SerialChannelImpl::writeImpl(const char* pBuffer, std::size_t length) { if (0 == length) return 0; std::string str; str.assign(pBuffer, length); return writeImpl(str); }
void TcpSession::writeNolock(const char* data_ptr,int len) { if (!isOk()) return; if(!_socket.is_open()) return; writeImpl(data_ptr,len); }
void TcpSession::writeLock(const char* data_ptr,int len) { if (!isOk()) return; if(!_socket.is_open()) return; boost::mutex::scoped_lock lock(_writeMutex); writeImpl(data_ptr,len); }
int64 File::write(CStrRef data, int64 length /* = 0 */) { if (seekable()) { m_readpos = m_writepos = 0; // invalidating read buffer seek(m_position, SEEK_SET); } if (length <= 0 || length > data.size()) { length = data.size(); } if (length) { int64 written = writeImpl(data.data(), length); m_position += written; return written; } return 0; }
std::size_t SerialPort::write(const char* data, std::size_t size) { if (!isOpenImpl()) throw Poco::IllegalStateException("Port is not open"); if (_logger.debug()) { _logger.dump(format("Sending %z byte(s)", size), data, size, Poco::Message::PRIO_DEBUG); } int n = writeImpl(data, size); if (n < 0) throw Poco::IOException("serial port write error"); else if (n < size) throw Poco::IOException(format("short write on serial port: %d of %z bytes", n, size)); else return static_cast<std::size_t>(n); }
/** If the data is not sorted, but we pre-calculated the permutation, after which they will be sorted. * This method is used to save RAM, since you do not need to keep two blocks at once - the source and the sorted. */ void MergedBlockOutputStream::writeWithPermutation(const Block & block, const IColumn::Permutation * permutation) { writeImpl(block, permutation); }
/// If data is pre-sorted. void MergedBlockOutputStream::write(const Block & block) { writeImpl(block, nullptr); }
int SerialChannelImpl::writeImpl(char c) { return writeImpl(&c, 1); }
void DynamicConfig::write(const Key &key, const Value &value) { writeImpl(t_, key, value); }