Пример #1
0
    } END_PIE

    BEGIN_PIE(TPCC_PAYMENT,      // txn
            TPCC_PAYMENT_5,    // piece 4, W histroy
            DF_REAL) {
        // ############################################################
        verify(input_size == 9);
        Log::debug("TPCC_PAYMENT, piece: %d", TPCC_PAYMENT_5);
        // ############################################################

        TPL_KISS_NONE;

        i32 output_index = 0;
        mdb::Txn *txn = DTxnMgr::get_sole_mgr()->get_mdb_txn(header);
        mdb::Table *tbl = txn->get_table(TPCC_TB_HISTORY);

        // insert history
        mdb::Row *r = NULL;
        if (!(IS_MODE_RCC || IS_MODE_RO6) || 
                ((IS_MODE_RCC || IS_MODE_RO6) && IN_PHASE_1)) { 
            // non-rcc || rcc start request
        }

        RCC_PHASE1_RET;

        std::vector<Value> row_data(9);
        row_data[0] = input[0];             // h_key
        row_data[1] = input[5];             // h_c_id   =>  c_id
        row_data[2] = input[7];             // h_c_d_id =>  c_d_id
        row_data[3] = input[6];             // h_c_w_id =>  c_w_id
        row_data[4] = input[4];             // h_d_id   =>  d_id
        row_data[5] = input[3];             // h_d_w_id =>  d_w_id
        row_data[6] = Value(std::to_string(time(NULL)));    // h_date
        row_data[7] = input[8];             // h_amount =>  h_amount
        row_data[8] = Value(input[1].get_str() + "    " + input[2].get_str()); // d_data => w_name + 4spaces + d_name

        CREATE_ROW(tbl->schema(), row_data);

        txn->insert_row(tbl, r);

        // ############################################################
        verify(*output_size >= output_index);
        *res = SUCCESS;
        Log::debug("TPCC_PAYMENT, piece: %d end", TPCC_PAYMENT_5);
        // ############################################################
        *output_size = output_index;
    } END_PIE
  Projection const Image_processor::
  read_tiff(const std::string & name,unsigned long threshold) throw(Exception)
  {
    uint16 width,height;
    std::vector<float> data;

    TIFF* tiff = TIFFOpen((path_+name).c_str(),"r");

    if(tiff)
    {
      const unsigned short information_number = 4;
      unsigned short field = TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width);
      field += TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height);
      field += TIFFGetField(tiff,TIFFTAG_SAMPLESPERPIXEL,&channel_number_);
      field += TIFFGetField(tiff,TIFFTAG_BITSPERSAMPLE,&channel_size_);

      if(field != information_number)
      
        throw(Exception
        ("image processing error : missing image information ->" + name));

      auto line_size = TIFFScanlineSize(tiff);
      buffer_ = _TIFFmalloc(line_size);
      buffer_count_ = width;

      for(uint16 row = 0 ; row < height ; ++row)
      {
        if(TIFFReadScanline(tiff,buffer_,row) == -1) 
        
          throw(Exception
          ("\nimage processing error : unknown compression scheme ->" + name));

        std::vector<float> row_data(process_buffer(threshold));
        data.insert(data.end(),row_data.begin(),row_data.end());
      }

      delete_buffer();
      TIFFClose(tiff);
    }

    else throw(Exception
    ("\nimage processing error : unknown file -> " + path_+name));

    return ct::Projection(data,width,height);
  }
void history_scan_database::add(const address_bitset& key,
    const uint8_t marker, const point_type& point,
    uint32_t block_height, uint64_t value)
{
    BITCOIN_ASSERT(key.size() >= settings_.sharded_bitsize);
    // Both add() and sync() must have identical lookup of shards.
    hsdb_shard& shard = lookup(key);
    address_bitset sub_key = drop_prefix(key);
    BITCOIN_ASSERT(sub_key.size() == settings_.scan_bitsize());
#ifdef HSDB_DEBUG
    log_debug(LOG_HSDB) << "Sub key = " << sub_key;
#endif
    data_chunk row_data(settings_.row_value_size);
    auto serial = make_serializer(row_data.begin());
    serial.write_byte(marker);
    serial.write_hash(point.hash);
    serial.write_4_bytes(point.index);
    serial.write_4_bytes(block_height);
    serial.write_8_bytes(value);
    BITCOIN_ASSERT(serial.iterator() ==
        row_data.begin() + settings_.row_value_size);
    shard.add(sub_key, row_data);
}
 row_data row (int y) const { return row_data(0, safe_cast<int>(data_.width() - 1), row_ptr(y)); }
Пример #5
0
	bool PNG::Encode (ImageBuffer *imageBuffer, ByteArray *bytes) {
		
		png_structp png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, user_error_fn, user_warning_fn);
		
		if (!png_ptr) {
			
			return false;
			
		}
		
		png_infop info_ptr = png_create_info_struct (png_ptr);
		
		if (!info_ptr) {
			
			return false;
			
		}
		
		if (setjmp (png_jmpbuf (png_ptr))) {
			
			png_destroy_write_struct (&png_ptr, &info_ptr);
			return false;
			
		}
		
		QuickVec<uint8> out_buffer;
		
		png_set_write_fn (png_ptr, &out_buffer, user_write_data, user_flush_data);
		
		int w = imageBuffer->width;
		int h = imageBuffer->height;
		
		int bit_depth = 8;
		//int color_type = (inSurface->Format () & pfHasAlpha) ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB;
		int color_type = PNG_COLOR_TYPE_RGB_ALPHA;
		png_set_IHDR (png_ptr, info_ptr, w, h, bit_depth, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
		
		png_write_info (png_ptr, info_ptr);
		
		bool do_alpha = (color_type == PNG_COLOR_TYPE_RGBA);
		unsigned char* imageData = imageBuffer->data->Bytes();
		int stride = w * imageBuffer->bpp;
		
		{
			QuickVec<uint8> row_data (w * 4);
			png_bytep row = &row_data[0];
			
			for (int y = 0; y < h; y++) {
				
				uint8 *buf = &row_data[0];
				const uint8 *src = (const uint8 *)(imageData + (stride * y));
				
				for (int x = 0; x < w; x++) {
					
					buf[0] = src[0];
					buf[1] = src[1];
					buf[2] = src[2];
					src += 3;
					buf += 3;
					
					if (do_alpha) {
						
						*buf++ = *src;
						
					}
					
					src++;
					
				}
				
				png_write_rows (png_ptr, &row, 1);
				
			}
			
		}
		
		png_write_end (png_ptr, NULL);
		
		*bytes = ByteArray (out_buffer);
		
		return true;
		
	}