WeightedDirectedGraphAsAdjMatrix(int numVertex, T initWeight = T()) : mNumVertex(numVertex) { int size = mNumVertex * mNumVertex; Alloc alloc; mData = alloc.allocate(size); for (int i = 0; i < size; ++i) { mData[i] = initWeight; } }
Array1D(int size, bool init = false, T initValue = T()) : mSize(size) { Alloc alloc; mData = alloc.allocate(mSize); if (init) { for (int i = 0; i < mSize; ++i) { alloc.construct(&mData[i], initValue); } } }
ResizeContext Resize::get_context(Alloc &alloc, PixelType type) const { ResizeContext ctx{}; if (!m_skip_h && !m_skip_v) { double xscale = (double)m_dst_width / (double)m_src_width; double yscale = (double)m_dst_height / (double)m_src_height; bool h_first = resize_h_first(xscale, yscale); ctx.impl1 = h_first ? m_impl_h.get() : m_impl_v.get(); ctx.impl2 = h_first ? m_impl_v.get() : m_impl_h.get(); ctx.tmp_width = h_first ? m_dst_width : m_src_width; ctx.tmp_height = h_first ? m_src_height : m_dst_height; ctx.in_buffering1 = std::min(ctx.impl1->input_buffering(type), m_src_height); ctx.in_buffering2 = std::min(ctx.impl2->input_buffering(type), ctx.tmp_height); ctx.out_buffering1 = ctx.impl1->output_buffering(type); ctx.out_buffering2 = ctx.impl2->output_buffering(type); ctx.src_border_buf = alloc_line_buffer(alloc, ctx.in_buffering1, m_src_width, type); ctx.dst_border_buf = alloc_line_buffer(alloc, ctx.out_buffering2, m_dst_width, type); ctx.tmp_buf = alloc_line_buffer(alloc, ctx.out_buffering1 + ctx.in_buffering2 - 1, ctx.tmp_width, type); ctx.tmp_data = alloc.allocate(std::max(ctx.impl1->tmp_size(type, ctx.tmp_width), ctx.impl2->tmp_size(type, m_dst_width))); } else if (!(m_skip_h && m_skip_v)) { ctx.impl1 = m_impl_h ? m_impl_h.get() : m_impl_v.get(); ctx.in_buffering1 = std::min(ctx.impl1->input_buffering(type), m_src_height); ctx.out_buffering1 = ctx.impl1->output_buffering(type); ctx.src_border_buf = alloc_line_buffer(alloc, ctx.in_buffering1, m_src_width, type); ctx.dst_border_buf = alloc_line_buffer(alloc, ctx.out_buffering1, m_dst_width, type); ctx.tmp_data = alloc.allocate(ctx.impl1->tmp_size(type, m_dst_width)); } return ctx; }
// variableLengthOffsetStart // ^ _____________ // | | | // |______________________||____________||______V___________________| // int,date(long),float offsets strings/variable length // |____________________________________| // Fixed Length | // V // fixedSizedOffset // // offsets() creates a pair of arrays with offset at each index to its // associated Attribute's offset in the returned serialized buffer // It uses maxOffsetBuffer and lastOffsetOfWrittenBuffer as temporary // holders to fill in the const members: fixedSizedOffset, // variableLengthOffsetStart // RecordSerializer::RecordSerializer(srch2::instantsearch::Schema& schema, Alloc& allocator) : allocator(allocator), schema(schema), maxOffsetOfBuffer(0), lastOffsetOfWrittenBuffer(0), offsets(initAttributeOffsetArray(schema, maxOffsetOfBuffer, lastOffsetOfWrittenBuffer)), fixedSizedOffset(maxOffsetOfBuffer), variableLengthOffsetStart(lastOffsetOfWrittenBuffer) { lastOffsetOfWrittenBuffer = fixedSizedOffset; //rounds default size of the nearest allocation page size maxOffsetOfBuffer = allocator.round(fixedSizedOffset + DEFAULT_VARIBLE_ATTRIBUTE_LENGTH * (offsets.first.size())); buffer = allocator.allocate(maxOffsetOfBuffer); std::memset(buffer, 0x0, fixedSizedOffset); }
static pointer allocate(Alloc& a, size_type n) { return a.allocate(n); }
initer() : a() , success(false) , m_t(nullptr) { m_t = a.allocate(1); }
pointer allocator_traits<Alloc>::allocate(Alloc& a, size_type n) { return a.allocate(n); }
pointer allocator_traits<Alloc>::allocate(Alloc& a, size_type n, const_void_pointer hint) { return a.allocate(n,hint); //TODO: it may not be implemented! }