コード例 #1
0
orc::Buffer *HdfsInputStream::read(uint64_t offset, uint64_t length, orc::Buffer *buffer)
{
    if(!configured_) {
        throw std::runtime_error("Need to configure first");
    }
    if (buffer == NULL) {
        buffer = new HeapBuffer(length);
    } else if (buffer->getLength() < length) {
        delete buffer;
        buffer = new HeapBuffer(length);
    }

    //blockreader::BlockPtr block = hdfsBlockReader_.getBlock(offset, length);

    hdfsutils::HdfsBlockLocator locator;
    base::ConfigurationMap conf;
    conf["filename"] = url_;
    conf["hdfsConfigurationFile"] = hdfsConfigurationFile_;
    conf["fileStatCache"] = fileStatCache_;
    locator.configure(conf);
    BufferPtr block = locator.getBlock(offset, length);
    if(block->size() != length) {
        throw std::runtime_error("size mismatch");
    }
    // TODO get rid of this copy
    memcpy(buffer->getStart(), block->data(), block->size());
    return buffer;
}
コード例 #2
0
ファイル: TcpConnection.cpp プロジェクト: cchd0001/gld_work
void TcpConnection::RealSend(const BufferPtr& buffer)
{
    send_buf_.push_back(buffer);

    socket_.Send(std::bind(&TcpConnection::OnWrite, shared_from_this(),
        std::placeholders::_1, std::placeholders::_2), &(*buffer->begin()), buffer->size());
}
コード例 #3
0
ファイル: mesh.cpp プロジェクト: artcom/cclib
void 
Mesh::vertices(BufferPtr theVertices, int theVertexSize) {
    _myNumberOfVertices = theVertices->size() / theVertexSize;
    _myVertexSize = theVertexSize;
    _myVertices = theVertices;
    theVertices->rewind();
}
コード例 #4
0
ファイル: file.hpp プロジェクト: akoshelnik/openvpn3
 // Read a text file as a std::string, throw error if file is binary
 inline std::string read_text(const std::string& filename, const boost::uint64_t max_size = 0)
 {
   BufferPtr bp = read_binary(filename, max_size);
   if (bp->contains_null())
     OPENVPN_THROW(file_is_binary, "file is binary: " << filename);
   return std::string((const char *)bp->c_data(), bp->size());
 }
コード例 #5
0
ファイル: mesh.cpp プロジェクト: artcom/cclib
void 
Mesh::textureCoords(int theLevel, BufferPtr theTextureCoords, int theTextureCoordSize) {
    _myNumberOfVertices = theTextureCoords->size() / theTextureCoordSize;
    _myTextureCoordSize[theLevel] = theTextureCoordSize;
    _myTextureCoords[theLevel] = theTextureCoords;
    theTextureCoords->rewind();
}
コード例 #6
0
ファイル: mesh.cpp プロジェクト: artcom/cclib
void 
Mesh::colors(BufferPtr theColors) {
    prepareColorData(theColors->size() / 4);
    _myColors->rewind();
    _myColors->put(theColors);
    _myColors->rewind();
}
コード例 #7
0
DLLEXPORT double udp_send(double handle, const char *host, double port) {
    uint16_t intPort;
    try {
        intPort = numeric_cast<uint16_t> (port);
    } catch (bad_numeric_cast &e) {
        intPort = 0;
    }

    if (intPort == 0) {
        return false;
    }

    BufferPtr buffer = handles.find<Buffer> (handle);
    if(buffer) {
        if(!defaultUdpSocket) {
            defaultUdpSocket = UdpSocket::bind(0);
        }
        defaultUdpSocket->write(buffer->getData(), buffer->size());
        defaultUdpSocket->send(host, intPort);
        return true;
    }

    boost::shared_ptr<UdpSocket> sock = handles.find<UdpSocket>(handle);
    if(sock) {
        return sock->send(host, intPort);
    }
    return false;
}
コード例 #8
0
DLLEXPORT double buffer_size(double handle) {
    BufferPtr buffer = handles.find<Buffer> (handle);
    if (buffer) {
        return buffer->size();
    } else {
        return 0;
    }
}
コード例 #9
0
ファイル: file.hpp プロジェクト: akoshelnik/openvpn3
  // Read a UTF-8 file as a std::string, throw errors if file is binary or malformed UTF-8
  inline std::string read_text_utf8(const std::string& filename, const boost::uint64_t max_size = 0)
  {
    BufferPtr bp = read_binary(filename, max_size);

    // check if binary
    if (bp->contains_null())
      OPENVPN_THROW(file_is_binary, "file is binary: " << filename);

    // remove Windows UTF-8 BOM if present
    if (bp->size() >= 3)
      {
	const unsigned char *data = bp->c_data();
	if (data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF)
	  bp->advance(3);
      }

    // verify that file is valid UTF-8
    if (!Unicode::is_valid_utf8(bp->c_data(), bp->size()))
      OPENVPN_THROW(file_not_utf8, "file is not UTF8: " << filename);

    return std::string((const char *)bp->c_data(), bp->size());
  }
コード例 #10
0
ファイル: Stream.cpp プロジェクト: jvaemape/aeon_streams
size_t Stream::write(BufferPtr buffer)
{
	if(!buffer)
	{
#ifdef AEON_USE_AEON_CONSOLE_LIBRARY
		Console::error("Stream: Tried writing an empty buffer to a stream.");
#endif

		return 0;
	}

	return write(buffer->get(), buffer->size());
}