We planned so many new things for this new year and one of them is this exact post. So far we published our most popular Instagram photo at the end of each month and now we want to replace that with a new tradition: a monthly recap at the end of each month. We plan to share more private moments from our lives in these pieces as well as to give you a summary about the best new content on the blog.
So January. An unusually cold and icy January that we spent mostly at home in Budapest. But this is something new: our home! Our blog focuses on our travels so we haven't mentioned yet that we've just moved into our own place. We wouldn't have thought of it even a year ago and we couldn't be happier now. January was mostly about this happiness that we think we definitely deserve after months of tiring administrative and whatever tasks.
We had planned only one weekend getaway for January but we cancelled it eventually. Road conditions were very bad due to the constant mix of rain and snow and the official advice was not to drive only if you really can't avoid it. We thought we could so we stayed at home and baked cookies instead. And started planning our summer travels.
Walking along icy River Danube in Budapest. Winters in Hungary were mild, grey, muddy and rainy in the past couple of years. I was probably a child when I saw sparkling snowy landscapes all around the country last time. But this January was different: it brought cold temperatures (like even below -20°C) and snow. Lakes and even rivers got frozen. Even the Danube got almost frozen (but of course, it won't ever get entirely frozen because of the icebreakers). We walked around Budapest and it was a very different city than what we've got used to.
Our favorite new recipe this month is called "bajadér slices". I don't have any idea how to translate it into English properly and Google could help me neither. That and because we got the recipe from my mum I just assume this is a Hungarian specialty. Here's a link to give you an idea what it actually is and how it is made (in Hungarian but the video and the pictures are quite descriptive).
Welcoming friends and family in our new home. We are always happy to meet with the ones we love. But inviting them to our new home and sharing our happiness is truly special.
Our Slovenian Beach Getaway: Strunjan – Slovenia is not particularly famous for its beaches but we found our perfect one. Along with the loveliest coastal small town in Slovenia: Piran.
[Video post] Let Slovenia Steal Your Heart In 2 Minutes! – our travel videos are also something new in 2017 and the latest one is about Slovenia, one of our favorite countries in the world!
We don't have any fixed travel plans for February. It ultimately depends on the weather. Maybe we'll go skiing or snowshoe hiking. Or nowhere. But even if we spend the whole February in Budapest we have some ideas what to do. Uhm… actually, we can maybe do something about our resolution that we share a lot more local tips about what to see and do in Budapest and in Hungary.
As for our blog… We've started our YouTube channel lately where we plan to publish a couple of travel videos every month. We are total newbies in this video topic but we are enthusiastic for sure. You decide all the rest. Have you already subscribed?
How was your January? What are your plans for the next month?
The Most Charming European Capital: Ljubljana + Giveaway!


text:
Allan Hansen (født 27. februar 1949 i Bogense) er en dansk idrætsleder, der var formand for Dansk Boldspil-Union (DBU) fra 2002 til 2014.

Karriere
Allan Hansen blev efter endt skolegang udlært som murer. Derefter begyndte han på Politiskolen, og han har været ansat ved Politiet siden 1971. Siden 1981 har han været ansat som kriminalassistent ved politiet i Fredericia.

Fodbold
Hansen har spillet fodbold på amatørbasis i Bogense, Gentofte og Middelfart. I 1974 påtog han sig det første organisatoriske arbejde i en forening, da han kom i bestyrelsen for Ndr. Birks og Fredericia Politis Idrætsforening. I perioden 1984-1994 var han bestyrelsesmedlem og ungdomsformand Middelfart Gymnastik & Boldklub. Allan Hansen var aktiv fodbolddommer fra 1978-1984.

Han blev i 1997 formand for Fyns Boldspil-Union og samtidig medlem af Dansk Boldspil-Unions bestyrelse. I februar 2002 var Allan Hansen én af to kandidater til formandsposten i DBU, efter at Poul Hyldgaard trak sig tilbage efter 11 år som formand. Allan Hansen vandt med 92 stemmer, mod hans modstanders, daværende næstformand Henning R. Jensen, 46 stemmer.

I juni 2013 meddelte Allan Hansen at han ikke ville genopstille når hans formandsperiode udløb den 1. marts 2014. Han blev afløst af Jesper Møller, da denne var eneste kandidat ved formandsvalget. Hansen fortsatte som medlem af UEFAs Excecutive Committee og FIFAs Audit & Compliance Committee.

Referencer

Eksterne henvisninger
 Allan Hansens profil  på DBUs officielle hjemmeside

Personer fra Bogense
Politifolk fra Danmark
Fodbolddommere fra Danmark
Formænd for Dansk Boldspil-Union
Danskere i 2000'erne
Personer i Kraks Blå Bog

redpajama_set_name: RedPajamaWikipedia


text:
Home » Computers » Desktop » All-in-One PC » Dell XPS One 27 a powerful all-in-One PC: Review, Specs and Features
Dell XPS One 27 a powerful all-in-One PC: Review, Specs and Features
The new computer from Dell that is Dell XPS One 27 combines beautiful design and a high level of performance. Its 27-inch offers a high definition but it shines a little too.
Dell returns to the all-in-one premium PC. Echoing some features of the Inspiron 2320 One and a bit of the old design XPS One 24, the XPS One 27 dazzles with its glossy 27-inch, showing a definition of 2560 points per 1440. This large piece is available in two versions on the manufacturer's website. In a test the Premium, priced at 1799 euros version was tested and we have brought the review for you, just to rub directly on the Asus ET2701 and to a lesser extent, the HP Omni 27.
Reality of Dell XPS One 27
Dell XPS One 27 comes with articulated foot and solid aluminium, 27-inch display with no apparent edge, the XPS One 27 is very similar to the Apple iMac. A quick tour of the machine shows that Dell has paid special attention to finishing and connectivity. Rich in connectivity, it consists of six 3.0 USB ports, an optical audio output (compatible with 7.1), the analog microphone input, a Gigabit Ethernet network jack, and an output and HDMI input. This HDMI input, usable only when the PC is on, can host game console, TV box, camcorder, etc. The display switches between the Bureau of Windows 7 and that of the connected HDMI device through the touch buttons, located on the bottom right of the screen next to the ejection of Blu-ray. The same touch buttons also control the brightness of the panel and the speaker volume.
Beautiful images and sound in Dell XPS One 27
Dell relies heavily on the screen. And right! It displays a definition of 2560 points in 1440 and is full retinas. Despite a correct brightness (262 cd/m2) and a contrast ratio greater than 1000:1, the glossy panel will interfere with the professional image and video. The pros prefer to work with matte screens to avoid glare. Nevertheless, videographers, photographers or budding mad Excel spreadsheets will appreciate the work surface. Finally, thanks to good viewing angles of the screen, watching a Blu-ray is very nice. With such an image, it's a shame that Dell is deprived of HD TV tuner and remote control. Its side, the XPS One 27 integrates high-quality stereo speakers and powerful enough to drown out the noise of the fan: 48 dB at full power the PC is too! Placed under the screen facing down, they allow sound to a desktop correctly or a living room. careful though not to over turn up the volume when listening to music because of the small speakers tend to saturate! The steering gear is only with the keyboard / wireless mouse (the receiver is integrated), whose finish is rather plain for a machine of this price.
Much work and multimedia, but some slack in Dell XPS One 27
Behind the big screen hides a powerful configuration in Dell XPS One 27 All-in-One, consisting of an Intel Core i7-3770S (four cores clocked at 3.1 GHz) and 8 GB of memory. For archiving your data, a 2 TB hard drive, supported by a module 32GB SSD in mSata. Its role is to boost Windows 7 boot and run your favorite applications a little faster. The test results are conclusive, the machine appears to be much reactive. For the graphical part, Dell has retained the chip from Nvidia GeForce GT 640M, a version for laptops equipped with 2 GB of GDDR5 memory. It uses the latest NVIDIA architecture Kepler, the same as the great Aspire Acer TimeLine U M3. The chip turns quite properly when tested with games ( Dirt 2 in DirectX 11 and Resident Evil 5 in DX 10) by displaying 42 to 50 frames per second, every detail thoroughly in Full HD (1920 or 1080 points per ). The chip is also suitable for Diablo III or Secret World. It did not make the Dell a real machine for gamers. Do not try to play in native resolution of the display! The scores recorded are all below 30 frames / s, which is in practice unplayable.
Significant power consumption
Dell has had the foresight to put the power supply inside the Dell XPS One 27 All-in-One PC. This avoids having a big ugly adapter on the desktop. With technology Nvidia Optimus integration, the XPS One 27 uses only 70 watts at rest, in comparison, a 27-inch iMac consumes almost double the rest. However, this voracious all-in-one absorbs almost 195 watts at full speed. Certainly, it is 20 watts less than an iMac but it is too.
The XPS One 27 is an all-in-one high-end rather successful. Powerful and well supplied with connectivity, it has a beautiful screen, with an unusual definition for a PC. It has only one flaw: a slab too bright. And we regret for the lack of a HD TV tuner and remote control. But Dell XPS One 27 is really impressive.
Image Source: http://www.dell.com/nz/p/desktops
July 26, 2012parimalm All-in-One PC, Reviews Tags: 27inches All-in-One PC, All-in-One, Dell XPS One, Dell XPS One 27, Dell XPS One 27 All-in-One, XPS One 27, XPS One 27 design, XPS One 27 features, XPS One 27 performance, XPS One 27 premium, XPS One 27 premium review, XPS One 27 price, XPS One 27 review, XPS One 27 specs -
«Toshiba AT300 the new tablet from Toshiba: Review, Specs & Features
New NVIDIA Quadro 'Kepler' for professional notebooks: Specs and Features»

redpajama_set_name: RedPajamaCommonCrawl


text:
DECLARE_bool(disable_mem_pools);

using namespace boost;
using namespace impala;
using namespace std;
using namespace strings;

// Control the number of disks on the machine.  If 0, this comes from the system
// settings.
DEFINE_int32(num_disks, 0, "Number of disks on data node.");
// Default IoMgr configs:
// The maximum number of the threads per disk is also the max queue depth per disk.
DEFINE_int32(num_threads_per_disk, 0, "number of threads per disk");
// The maximum number of S3 I/O threads. The default value of 16 was chosen emperically
// to maximize S3 throughput. Maximum throughput is achieved with multiple connections
// open to S3 and use of multiple CPU cores since S3 reads are relatively compute
// expensive (SSL and JNI buffer overheads).
DEFINE_int32(num_s3_io_threads, 16, "number of S3 I/O threads");
// The read size is the size of the reads sent to hdfs/os.
// There is a trade off of latency and throughout, trying to keep disks busy but
// not introduce seeks.  The literature seems to agree that with 8 MB reads, random
// io and sequential io perform similarly.
DEFINE_int32(read_size, 8 * 1024 * 1024, "Read Size (in bytes)");
DEFINE_int32(min_buffer_size, 1024, "The minimum read buffer size (in bytes)");

// With 1024B through 8MB buffers, this is up to ~2GB of buffers.
DEFINE_int32(max_free_io_buffers, 128,
    "For each io buffer size, the maximum number of buffers the IoMgr will hold onto");

// Rotational disks should have 1 thread per disk to minimize seeks.  Non-rotational
// don't have this penalty and benefit from multiple concurrent IO requests.
static const int THREADS_PER_ROTATIONAL_DISK = 1;
static const int THREADS_PER_FLASH_DISK = 8;

// The IoMgr is able to run with a wide range of memory usage. If a query has memory
// remaining less than this value, the IoMgr will stop all buffering regardless of the
// current queue size.
static const int LOW_MEMORY = 64 * 1024 * 1024;

const int DiskIoMgr::DEFAULT_QUEUE_CAPACITY = 2;

// This class provides a cache of RequestContext objects.  RequestContexts are recycled.
// This is good for locality as well as lock contention.  The cache has the property that
// regardless of how many clients get added/removed, the memory locations for
// existing clients do not change (not the case with std::vector) minimizing the locks we
// have to take across all readers.
// All functions on this object are thread safe
class DiskIoMgr::RequestContextCache {
 public:
  RequestContextCache(DiskIoMgr* io_mgr) : io_mgr_(io_mgr) {}

  // Returns a context to the cache.  This object can now be reused.
  void ReturnContext(RequestContext* reader) {
    DCHECK(reader->state_ != RequestContext::Inactive);
    reader->state_ = RequestContext::Inactive;
    lock_guard<mutex> l(lock_);
    inactive_contexts_.push_back(reader);
  }

  // Returns a new RequestContext object.  Allocates a new object if necessary.
  RequestContext* GetNewContext() {
    lock_guard<mutex> l(lock_);
    if (!inactive_contexts_.empty()) {
      RequestContext* reader = inactive_contexts_.front();
      inactive_contexts_.pop_front();
      return reader;
    } else {
      RequestContext* reader = new RequestContext(io_mgr_, io_mgr_->num_total_disks());
      all_contexts_.push_back(reader);
      return reader;
    }
  }

  // This object has the same lifetime as the disk IoMgr.
  ~RequestContextCache() {
    for (list<RequestContext*>::iterator it = all_contexts_.begin();
        it != all_contexts_.end(); ++it) {
      delete *it;
    }
  }

  // Validates that all readers are cleaned up and in the inactive state.  No locks
  // are taken since this is only called from the disk IoMgr destructor.
  bool ValidateAllInactive() {
    for (list<RequestContext*>::iterator it = all_contexts_.begin();
        it != all_contexts_.end(); ++it) {
      if ((*it)->state_ != RequestContext::Inactive) {
        return false;
      }
    }
    DCHECK_EQ(all_contexts_.size(), inactive_contexts_.size());
    return all_contexts_.size() == inactive_contexts_.size();
  }

  string DebugString();

 private:
  DiskIoMgr* io_mgr_;

  // lock to protect all members below
  mutex lock_;

  // List of all request contexts created.  Used for debugging
  list<RequestContext*> all_contexts_;

  // List of inactive readers.  These objects can be used for a new reader.
  list<RequestContext*> inactive_contexts_;
};

string DiskIoMgr::RequestContextCache::DebugString() {
  lock_guard<mutex> l(lock_);
  stringstream ss;
  for (list<RequestContext*>::iterator it = all_contexts_.begin();
      it != all_contexts_.end(); ++it) {
    unique_lock<mutex> lock((*it)->lock_);
    ss << (*it)->DebugString() << endl;
  }
  return ss.str();
}

string DiskIoMgr::DebugString() {
  stringstream ss;
  ss << "RequestContexts: " << endl << request_context_cache_->DebugString() << endl;

  ss << "Disks: " << endl;
  for (int i = 0; i < disk_queues_.size(); ++i) {
    unique_lock<mutex> lock(disk_queues_[i]->lock);
    ss << "  " << (void*) disk_queues_[i] << ":" ;
    if (!disk_queues_[i]->request_contexts.empty()) {
      ss << " Readers: ";
      BOOST_FOREACH(RequestContext* req_context, disk_queues_[i]->request_contexts) {
        ss << (void*)req_context;
      }
    }
    ss << endl;
  }
  return ss.str();
}

DiskIoMgr::BufferDescriptor::BufferDescriptor(DiskIoMgr* io_mgr) :
  io_mgr_(io_mgr), reader_(NULL), buffer_(NULL) {
}

void DiskIoMgr::BufferDescriptor::Reset(RequestContext* reader,
      ScanRange* range, char* buffer, int64_t buffer_len) {
  DCHECK(io_mgr_ != NULL);
  DCHECK(buffer_ == NULL);
  DCHECK(range != NULL);
  DCHECK(buffer != NULL);
  DCHECK_GE(buffer_len, 0);
  reader_ = reader;
  scan_range_ = range;
  buffer_ = buffer;
  buffer_len_ = buffer_len;
  len_ = 0;
  eosr_ = false;
  status_ = Status::OK;
  mem_tracker_ = NULL;
}

void DiskIoMgr::BufferDescriptor::Return() {
  DCHECK(io_mgr_ != NULL);
  io_mgr_->ReturnBuffer(this);
}

void DiskIoMgr::BufferDescriptor::SetMemTracker(MemTracker* tracker) {
  // Cached buffers don't count towards mem usage.
  if (scan_range_->cached_buffer_ != NULL) return;
  if (mem_tracker_ == tracker) return;
  if (mem_tracker_ != NULL) mem_tracker_->Release(buffer_len_);
  mem_tracker_ = tracker;
  if (mem_tracker_ != NULL) mem_tracker_->Consume(buffer_len_);
}

DiskIoMgr::WriteRange::WriteRange(const string& file, int64_t file_offset, int disk_id,
    WriteDoneCallback callback) {
  file_ = file;
  offset_ = file_offset;
  disk_id_ = disk_id;
  callback_ = callback;
  request_type_ = RequestType::WRITE;
}

void DiskIoMgr::WriteRange::SetData(const uint8_t* buffer, int64_t len) {
  data_ = buffer;
  len_ = len;
}

static void CheckSseSupport() {
  if (!CpuInfo::IsSupported(CpuInfo::SSE4_2)) {
    LOG(WARNING) << "This machine does not support sse4_2.  The default IO system "
                    "configurations are suboptimal for this hardware.  Consider "
                    "increasing the number of threads per disk by restarting impalad "
                    "using the --num_threads_per_disk flag with a higher value";
  }
}

DiskIoMgr::DiskIoMgr() :
    num_threads_per_disk_(FLAGS_num_threads_per_disk),
    max_buffer_size_(FLAGS_read_size),
    min_buffer_size_(FLAGS_min_buffer_size),
    cached_read_options_(NULL),
    shut_down_(false),
    total_bytes_read_counter_(TUnit::BYTES),
    read_timer_(TUnit::TIME_NS) {
  int64_t max_buffer_size_scaled = BitUtil::Ceil(max_buffer_size_, min_buffer_size_);
  free_buffers_.resize(BitUtil::Log2(max_buffer_size_scaled) + 1);
  int num_local_disks = FLAGS_num_disks == 0 ? DiskInfo::num_disks() : FLAGS_num_disks;
  disk_queues_.resize(num_local_disks + REMOTE_NUM_DISKS);
  CheckSseSupport();
}

DiskIoMgr::DiskIoMgr(int num_local_disks, int threads_per_disk, int min_buffer_size,
                     int max_buffer_size) :
    num_threads_per_disk_(threads_per_disk),
    max_buffer_size_(max_buffer_size),
    min_buffer_size_(min_buffer_size),
    cached_read_options_(NULL),
    shut_down_(false),
    total_bytes_read_counter_(TUnit::BYTES),
    read_timer_(TUnit::TIME_NS) {
  int64_t max_buffer_size_scaled = BitUtil::Ceil(max_buffer_size_, min_buffer_size_);
  free_buffers_.resize(BitUtil::Log2(max_buffer_size_scaled) + 1);
  if (num_local_disks == 0) num_local_disks = DiskInfo::num_disks();
  disk_queues_.resize(num_local_disks + REMOTE_NUM_DISKS);
  CheckSseSupport();
}

DiskIoMgr::~DiskIoMgr() {
  shut_down_ = true;
  // Notify all worker threads and shut them down.
  for (int i = 0; i < disk_queues_.size(); ++i) {
    if (disk_queues_[i] == NULL) continue;
    {
      // This lock is necessary to properly use the condition var to notify
      // the disk worker threads.  The readers also grab this lock so updates
      // to shut_down_ are protected.
      unique_lock<mutex> disk_lock(disk_queues_[i]->lock);
    }
    disk_queues_[i]->work_available.notify_all();
  }
  disk_thread_group_.JoinAll();

  for (int i = 0; i < disk_queues_.size(); ++i) {
    if (disk_queues_[i] == NULL) continue;
    int disk_id = disk_queues_[i]->disk_id;
    for (list<RequestContext*>::iterator it = disk_queues_[i]->request_contexts.begin();
        it != disk_queues_[i]->request_contexts.end(); ++it) {
      DCHECK_EQ((*it)->disk_states_[disk_id].num_threads_in_op(), 0);
      DCHECK((*it)->disk_states_[disk_id].done());
      (*it)->DecrementDiskRefCount();
    }
  }

  DCHECK(request_context_cache_.get() == NULL ||
      request_context_cache_->ValidateAllInactive())
      << endl << DebugString();
  DCHECK_EQ(num_buffers_in_readers_, 0);

  // Delete all allocated buffers
  int num_free_buffers = 0;
  for (int idx = 0; idx < free_buffers_.size(); ++idx) {
    num_free_buffers += free_buffers_[idx].size();
  }
  DCHECK_EQ(num_allocated_buffers_, num_free_buffers);
  GcIoBuffers();

  for (int i = 0; i < disk_queues_.size(); ++i) {
    delete disk_queues_[i];
  }

  if (cached_read_options_ != NULL) hadoopRzOptionsFree(cached_read_options_);
}

Status DiskIoMgr::Init(MemTracker* process_mem_tracker) {
  DCHECK(process_mem_tracker != NULL);
  process_mem_tracker_ = process_mem_tracker;
  // If we hit the process limit, see if we can reclaim some memory by removing
  // previously allocated (but unused) io buffers.
  process_mem_tracker->AddGcFunction(bind(&DiskIoMgr::GcIoBuffers, this));

  for (int i = 0; i < disk_queues_.size(); ++i) {
    disk_queues_[i] = new DiskQueue(i);
    int num_threads_per_disk;
    if (i == RemoteS3DiskId()) {
      num_threads_per_disk = FLAGS_num_s3_io_threads;
    } else if (num_threads_per_disk_ != 0) {
      num_threads_per_disk = num_threads_per_disk_;
    } else if (DiskInfo::is_rotational(i)) {
      num_threads_per_disk = THREADS_PER_ROTATIONAL_DISK;
    } else {
      num_threads_per_disk = THREADS_PER_FLASH_DISK;
    }
    for (int j = 0; j < num_threads_per_disk; ++j) {
      stringstream ss;
      ss << "work-loop(Disk: " << i << ", Thread: " << j << ")";
      disk_thread_group_.AddThread(new Thread("disk-io-mgr", ss.str(),
          &DiskIoMgr::WorkLoop, this, disk_queues_[i]));
    }
  }
  request_context_cache_.reset(new RequestContextCache(this));

  cached_read_options_ = hadoopRzOptionsAlloc();
  DCHECK(cached_read_options_ != NULL);
  // Disable checksumming for cached reads.
  int ret = hadoopRzOptionsSetSkipChecksum(cached_read_options_, true);
  DCHECK_EQ(ret, 0);
  // Disable automatic fallback for cached reads.
  ret = hadoopRzOptionsSetByteBufferPool(cached_read_options_, NULL);
  DCHECK_EQ(ret, 0);

  return Status::OK;
}

Status DiskIoMgr::RegisterContext(RequestContext** request_context,
    MemTracker* mem_tracker) {
  DCHECK(request_context_cache_.get() != NULL) << "Must call Init() first.";
  *request_context = request_context_cache_->GetNewContext();
  (*request_context)->Reset(mem_tracker);
  return Status::OK;
}

void DiskIoMgr::UnregisterContext(RequestContext* reader) {
  // Blocking cancel (waiting for disks completion).
  CancelContext(reader, true);

  // All the disks are done with clean, validate nothing is leaking.
  unique_lock<mutex> reader_lock(reader->lock_);
  DCHECK_EQ(reader->num_buffers_in_reader_, 0) << endl << reader->DebugString();
  DCHECK_EQ(reader->num_used_buffers_, 0) << endl << reader->DebugString();

  DCHECK(reader->Validate()) << endl << reader->DebugString();
  request_context_cache_->ReturnContext(reader);
}

// Cancellation requires coordination from multiple threads.  Each thread that currently
// has a reference to the request context must notice the cancel and remove it from its
// tracking structures.  The last thread to touch the context should deallocate (aka
// recycle) the request context object.  Potential threads are:
//  1. Disk threads that are currently reading for this reader.
//  2. Caller threads that are waiting in GetNext.
//
// The steps are:
// 1. Cancel will immediately set the context in the Cancelled state.  This prevents any
// other thread from adding more ready buffers to the context (they all take a lock and
// check the state before doing so), or any write ranges to the context.
// 2. Cancel will call cancel on each ScanRange that is not yet complete, unblocking
// any threads in GetNext(). The reader will see the cancelled Status returned. Cancel
// also invokes the callback for the WriteRanges with the cancelled state.
// 3. Disk threads notice the context is cancelled either when picking the next context
// to process or when they try to enqueue a ready buffer.  Upon noticing the cancelled
// state, removes the context from the disk queue.  The last thread per disk with an
// outstanding reference to the context decrements the number of disk queues the context
// is on.
// If wait_for_disks_completion is true, wait for the number of active disks to become 0.
void DiskIoMgr::CancelContext(RequestContext* context, bool wait_for_disks_completion) {
  context->Cancel(Status::CANCELLED);

  if (wait_for_disks_completion) {
    unique_lock<mutex> lock(context->lock_);
    DCHECK(context->Validate()) << endl << context->DebugString();
    while (context->num_disks_with_ranges_ > 0) {
      context->disks_complete_cond_var_.wait(lock);
    }
  }
}

void DiskIoMgr::set_read_timer(RequestContext* r, RuntimeProfile::Counter* c) {
  r->read_timer_ = c;
}

void DiskIoMgr::set_bytes_read_counter(RequestContext* r, RuntimeProfile::Counter* c) {
  r->bytes_read_counter_ = c;
}

void DiskIoMgr::set_active_read_thread_counter(RequestContext* r,
    RuntimeProfile::Counter* c) {
  r->active_read_thread_counter_ = c;
}

void DiskIoMgr::set_disks_access_bitmap(RequestContext* r,
    RuntimeProfile::Counter* c) {
  r->disks_accessed_bitmap_ = c;
}

int64_t DiskIoMgr::queue_size(RequestContext* reader) const {
  return reader->num_ready_buffers_;
}

Status DiskIoMgr::context_status(RequestContext* context) const {
  unique_lock<mutex> lock(context->lock_);
  return context->status_;
}

int DiskIoMgr::num_unstarted_ranges(RequestContext* reader) const {
  return reader->num_unstarted_scan_ranges_;
}

int64_t DiskIoMgr::bytes_read_local(RequestContext* reader) const {
  return reader->bytes_read_local_;
}

int64_t DiskIoMgr::bytes_read_short_circuit(RequestContext* reader) const {
  return reader->bytes_read_short_circuit_;
}

int64_t DiskIoMgr::bytes_read_dn_cache(RequestContext* reader) const {
  return reader->bytes_read_dn_cache_;
}

int DiskIoMgr::num_remote_ranges(RequestContext* reader) const {
  return reader->num_remote_ranges_;
}

int64_t DiskIoMgr::unexpected_remote_bytes(RequestContext* reader) const {
  return reader->unexpected_remote_bytes_;
}

int64_t DiskIoMgr::GetReadThroughput() {
  return RuntimeProfile::UnitsPerSecond(&total_bytes_read_counter_, &read_timer_);
}

Status DiskIoMgr::ValidateScanRange(ScanRange* range) {
  int disk_id = range->disk_id_;
  if (disk_id < 0 || disk_id >= disk_queues_.size()) {
    stringstream ss;
    ss << "Invalid scan range.  Bad disk id: " << disk_id;
    DCHECK(false) << ss.str();
    return Status(ss.str());
  }
  return Status::OK;
}

Status DiskIoMgr::AddScanRanges(RequestContext* reader,
    const vector<ScanRange*>& ranges, bool schedule_immediately) {
  if (ranges.empty()) return Status::OK;

  // Validate and initialize all ranges
  for (int i = 0; i < ranges.size(); ++i) {
    RETURN_IF_ERROR(ValidateScanRange(ranges[i]));
    ranges[i]->InitInternal(this, reader);
  }

  // disks that this reader needs to be scheduled on.
  unique_lock<mutex> reader_lock(reader->lock_);
  DCHECK(reader->Validate()) << endl << reader->DebugString();

  if (reader->state_ == RequestContext::Cancelled) {
    DCHECK(!reader->status_.ok());
    return reader->status_;
  }

  // Add each range to the queue of the disk the range is on
  for (int i = 0; i < ranges.size(); ++i) {
    // Don't add empty ranges.
    DCHECK_NE(ranges[i]->len(), 0);
    ScanRange* range = ranges[i];

    if (range->try_cache_) {
      if (schedule_immediately) {
        bool cached_read_succeeded;
        RETURN_IF_ERROR(range->ReadFromCache(&cached_read_succeeded));
        if (cached_read_succeeded) continue;
        // Cached read failed, fall back to AddRequestRange() below.
      } else {
        reader->cached_ranges_.Enqueue(range);
        continue;
      }
    }
    reader->AddRequestRange(range, schedule_immediately);
  }
  DCHECK(reader->Validate()) << endl << reader->DebugString();

  return Status::OK;
}

// This function returns the next scan range the reader should work on, checking
// for eos and error cases. If there isn't already a cached scan range or a scan
// range prepared by the disk threads, the caller waits on the disk threads.
Status DiskIoMgr::GetNextRange(RequestContext* reader, ScanRange** range) {
  DCHECK_NOTNULL(reader);
  DCHECK_NOTNULL(range);
  *range = NULL;
  Status status = Status::OK;

  unique_lock<mutex> reader_lock(reader->lock_);
  DCHECK(reader->Validate()) << endl << reader->DebugString();

  while (true) {
    if (reader->state_ == RequestContext::Cancelled) {
      DCHECK(!reader->status_.ok());
      status = reader->status_;
      break;
    }

    if (reader->num_unstarted_scan_ranges_ == 0 &&
        reader->ready_to_start_ranges_.empty() && reader->cached_ranges_.empty()) {
      // All ranges are done, just return.
      break;
    }

    if (!reader->cached_ranges_.empty()) {
      // We have a cached range.
      *range = reader->cached_ranges_.Dequeue();
      DCHECK((*range)->try_cache_);
      bool cached_read_succeeded;
      RETURN_IF_ERROR((*range)->ReadFromCache(&cached_read_succeeded));
      if (cached_read_succeeded) return Status::OK;

      // This range ended up not being cached. Loop again and pick up a new range.
      reader->AddRequestRange(*range, false);
      DCHECK(reader->Validate()) << endl << reader->DebugString();
      *range = NULL;
      continue;
    }

    if (reader->ready_to_start_ranges_.empty()) {
      reader->ready_to_start_ranges_cv_.wait(reader_lock);
    } else {
      *range = reader->ready_to_start_ranges_.Dequeue();
      DCHECK_NOTNULL(*range);
      int disk_id = (*range)->disk_id();
      DCHECK_EQ(*range, reader->disk_states_[disk_id].next_scan_range_to_start());
      // Set this to NULL, the next time this disk runs for this reader, it will
      // get another range ready.
      reader->disk_states_[disk_id].set_next_scan_range_to_start(NULL);
      reader->ScheduleScanRange(*range);
      break;
    }
  }
  return status;
}

Status DiskIoMgr::Read(RequestContext* reader,
    ScanRange* range, BufferDescriptor** buffer) {
  DCHECK_NOTNULL(range);
  DCHECK_NOTNULL(buffer);
  *buffer = NULL;

  if (range->len() > max_buffer_size_) {
    return Status(Substitute("Cannot perform sync read larger than $0. Request was $1",
                             max_buffer_size_, range->len()));
  }

  vector<DiskIoMgr::ScanRange*> ranges;
  ranges.push_back(range);
  RETURN_IF_ERROR(AddScanRanges(reader, ranges, true));
  RETURN_IF_ERROR(range->GetNext(buffer));
  DCHECK((*buffer) != NULL);
  DCHECK((*buffer)->eosr());
  return Status::OK;
}

void DiskIoMgr::ReturnBuffer(BufferDescriptor* buffer_desc) {
  DCHECK_NOTNULL(buffer_desc);
  if (!buffer_desc->status_.ok()) DCHECK(buffer_desc->buffer_ == NULL);

  RequestContext* reader = buffer_desc->reader_;
  if (buffer_desc->buffer_ != NULL) {
    if (buffer_desc->scan_range_->cached_buffer_ == NULL) {
      // Not a cached buffer. Return the io buffer and update mem tracking.
      ReturnFreeBuffer(buffer_desc);
    }
    buffer_desc->buffer_ = NULL;
    --num_buffers_in_readers_;
    --reader->num_buffers_in_reader_;
  } else {
    // A NULL buffer means there was an error in which case there is no buffer
    // to return.
  }

  if (buffer_desc->eosr_ || buffer_desc->scan_range_->is_cancelled_) {
    // Need to close the scan range if returning the last buffer or the scan range
    // has been cancelled (and the caller might never get the last buffer).
    // Close() is idempotent so multiple cancelled buffers is okay.
    buffer_desc->scan_range_->Close();
  }
  ReturnBufferDesc(buffer_desc);
}

void DiskIoMgr::ReturnBufferDesc(BufferDescriptor* desc) {
  DCHECK(desc != NULL);
  unique_lock<mutex> lock(free_buffers_lock_);
  DCHECK(find(free_buffer_descs_.begin(), free_buffer_descs_.end(), desc)
         == free_buffer_descs_.end());
  free_buffer_descs_.push_back(desc);
}

DiskIoMgr::BufferDescriptor* DiskIoMgr::GetBufferDesc(
    RequestContext* reader, ScanRange* range, char* buffer, int64_t buffer_size) {
  BufferDescriptor* buffer_desc;
  {
    unique_lock<mutex> lock(free_buffers_lock_);
    if (free_buffer_descs_.empty()) {
      buffer_desc = pool_.Add(new BufferDescriptor(this));
    } else {
      buffer_desc = free_buffer_descs_.front();
      free_buffer_descs_.pop_front();
    }
  }
  buffer_desc->Reset(reader, range, buffer, buffer_size);
  buffer_desc->SetMemTracker(reader->mem_tracker_);
  return buffer_desc;
}

char* DiskIoMgr::GetFreeBuffer(int64_t* buffer_size) {
  DCHECK_LE(*buffer_size, max_buffer_size_);
  DCHECK_GT(*buffer_size, 0);
  *buffer_size = min(static_cast<int64_t>(max_buffer_size_), *buffer_size);
  int idx = free_buffers_idx(*buffer_size);
  // Quantize buffer size to nearest power of 2 greater than the specified buffer size and
  // convert to bytes
  *buffer_size = (1 << idx) * min_buffer_size_;

  unique_lock<mutex> lock(free_buffers_lock_);
  char* buffer = NULL;
  if (free_buffers_[idx].empty()) {
    ++num_allocated_buffers_;
    if (ImpaladMetrics::IO_MGR_NUM_BUFFERS != NULL) {
      ImpaladMetrics::IO_MGR_NUM_BUFFERS->Increment(1L);
    }
    if (ImpaladMetrics::IO_MGR_TOTAL_BYTES != NULL) {
      ImpaladMetrics::IO_MGR_TOTAL_BYTES->Increment(*buffer_size);
    }
    // Update the process mem usage.  This is checked the next time we start
    // a read for the next reader (DiskIoMgr::GetNextScanRange)
    process_mem_tracker_->Consume(*buffer_size);
    buffer = new char[*buffer_size];
  } else {
    if (ImpaladMetrics::IO_MGR_NUM_UNUSED_BUFFERS != NULL) {
      ImpaladMetrics::IO_MGR_NUM_UNUSED_BUFFERS->Increment(-1L);
    }
    buffer = free_buffers_[idx].front();
    free_buffers_[idx].pop_front();
  }
  DCHECK(buffer != NULL);
  return buffer;
}

void DiskIoMgr::GcIoBuffers() {
  unique_lock<mutex> lock(free_buffers_lock_);
  int buffers_freed = 0;
  int bytes_freed = 0;
  for (int idx = 0; idx < free_buffers_.size(); ++idx) {
    for (list<char*>::iterator iter = free_buffers_[idx].begin();
         iter != free_buffers_[idx].end(); ++iter) {
      int64_t buffer_size = (1 << idx) * min_buffer_size_;
      process_mem_tracker_->Release(buffer_size);
      --num_allocated_buffers_;
      delete[] *iter;

      ++buffers_freed;
      bytes_freed += buffer_size;
    }
    free_buffers_[idx].clear();
  }

  if (ImpaladMetrics::IO_MGR_NUM_BUFFERS != NULL) {
    ImpaladMetrics::IO_MGR_NUM_BUFFERS->Increment(-buffers_freed);
  }
  if (ImpaladMetrics::IO_MGR_TOTAL_BYTES != NULL) {
    ImpaladMetrics::IO_MGR_TOTAL_BYTES->Increment(-bytes_freed);
  }
  if (ImpaladMetrics::IO_MGR_NUM_UNUSED_BUFFERS != NULL) {
    ImpaladMetrics::IO_MGR_NUM_UNUSED_BUFFERS->set_value(0);
  }
}

void DiskIoMgr::ReturnFreeBuffer(BufferDescriptor* desc) {
  ReturnFreeBuffer(desc->buffer_, desc->buffer_len_);
  desc->SetMemTracker(NULL);
  desc->buffer_ = NULL;
}

void DiskIoMgr::ReturnFreeBuffer(char* buffer, int64_t buffer_size) {
  DCHECK(buffer != NULL);
  int idx = free_buffers_idx(buffer_size);
  DCHECK_EQ(BitUtil::Ceil(buffer_size, min_buffer_size_) & ~(1 << idx), 0)
      << "buffer_size_ / min_buffer_size_ should be power of 2, got buffer_size = "
      << buffer_size << ", min_buffer_size_ = " << min_buffer_size_;
  unique_lock<mutex> lock(free_buffers_lock_);
  if (!FLAGS_disable_mem_pools && free_buffers_[idx].size() < FLAGS_max_free_io_buffers) {
    free_buffers_[idx].push_back(buffer);
    if (ImpaladMetrics::IO_MGR_NUM_UNUSED_BUFFERS != NULL) {
      ImpaladMetrics::IO_MGR_NUM_UNUSED_BUFFERS->Increment(1L);
    }
  } else {
    process_mem_tracker_->Release(buffer_size);
    --num_allocated_buffers_;
    delete[] buffer;
    if (ImpaladMetrics::IO_MGR_NUM_BUFFERS != NULL) {
      ImpaladMetrics::IO_MGR_NUM_BUFFERS->Increment(-1L);
    }
    if (ImpaladMetrics::IO_MGR_TOTAL_BYTES != NULL) {
      ImpaladMetrics::IO_MGR_TOTAL_BYTES->Increment(-buffer_size);
    }
  }
}

// This function gets the next RequestRange to work on for this disk. It checks for
// cancellation and
// a) Updates ready_to_start_ranges if there are no scan ranges queued for this disk.
// b) Adds an unstarted write range to in_flight_ranges_. The write range is processed
//    immediately if there are no preceding scan ranges in in_flight_ranges_
// It blocks until work is available or the thread is shut down.
// Work is available if there is a RequestContext with
//  - A ScanRange with a buffer available, or
//  - A WriteRange in unstarted_write_ranges_.
bool DiskIoMgr::GetNextRequestRange(DiskQueue* disk_queue, RequestRange** range,
    RequestContext** request_context) {
  int disk_id = disk_queue->disk_id;
  *range = NULL;

  // This loops returns either with work to do or when the disk IoMgr shuts down.
  while (true) {
    *request_context = NULL;
    RequestContext::PerDiskState* request_disk_state = NULL;
    {
      unique_lock<mutex> disk_lock(disk_queue->lock);

      while (!shut_down_ && disk_queue->request_contexts.empty()) {
        // wait if there are no readers on the queue
        disk_queue->work_available.wait(disk_lock);
      }
      if (shut_down_) break;
      DCHECK(!disk_queue->request_contexts.empty());

      // Get the next reader and remove the reader so that another disk thread
      // can't pick it up.  It will be enqueued before issuing the read to HDFS
      // so this is not a big deal (i.e. multiple disk threads can read for the
      // same reader).
      // TODO: revisit.
      *request_context = disk_queue->request_contexts.front();
      disk_queue->request_contexts.pop_front();
      DCHECK(*request_context != NULL);
      request_disk_state = &((*request_context)->disk_states_[disk_id]);
      request_disk_state->IncrementRequestThreadAndDequeue();
    }

    // NOTE: no locks were taken in between.  We need to be careful about what state
    // could have changed to the reader and disk in between.
    // There are some invariants here.  Only one disk thread can have the
    // same reader here (the reader is removed from the queue).  There can be
    // other disk threads operating on this reader in other functions though.

    // We just picked a reader, check the mem limits.
    // TODO: we can do a lot better here.  The reader can likely make progress
    // with fewer io buffers.
    bool process_limit_exceeded = process_mem_tracker_->LimitExceeded();
    bool reader_limit_exceeded = (*request_context)->mem_tracker_ != NULL
        ? (*request_context)->mem_tracker_->AnyLimitExceeded() : false;

    if (process_limit_exceeded || reader_limit_exceeded) {
      (*request_context)->Cancel(Status::MEM_LIMIT_EXCEEDED);
    }

    unique_lock<mutex> request_lock((*request_context)->lock_);
    VLOG_FILE << "Disk (id=" << disk_id << ") reading for "
        << (*request_context)->DebugString();

    // Check if reader has been cancelled
    if ((*request_context)->state_ == RequestContext::Cancelled) {
      request_disk_state->DecrementRequestThreadAndCheckDone(*request_context);
      continue;
    }

    DCHECK_EQ((*request_context)->state_, RequestContext::Active)
        << (*request_context)->DebugString();

    if (request_disk_state->next_scan_range_to_start() == NULL &&
        !request_disk_state->unstarted_scan_ranges()->empty()) {
      // We don't have a range queued for this disk for what the caller should
      // read next. Populate that.  We want to have one range waiting to minimize
      // wait time in GetNextRange.
      ScanRange* new_range = request_disk_state->unstarted_scan_ranges()->Dequeue();
      --(*request_context)->num_unstarted_scan_ranges_;
      (*request_context)->ready_to_start_ranges_.Enqueue(new_range);
      request_disk_state->set_next_scan_range_to_start(new_range);

      if ((*request_context)->num_unstarted_scan_ranges_ == 0) {
        // All the ranges have been started, notify everyone blocked on GetNextRange.
        // Only one of them will get work so make sure to return NULL to the other
        // caller threads.
        (*request_context)->ready_to_start_ranges_cv_.notify_all();
      } else {
        (*request_context)->ready_to_start_ranges_cv_.notify_one();
      }
    }

    // Always enqueue a WriteRange to be processed into in_flight_ranges_.
    // This is done so in_flight_ranges_ does not exclusively contain ScanRanges.
    // For now, enqueuing a WriteRange on each invocation of GetNextRequestRange()
    // does not flood in_flight_ranges() with WriteRanges because the entire
    // WriteRange is processed and removed from the queue after GetNextRequestRange()
    // returns. (A DCHECK is used to ensure that writes do not exceed 8MB).
    if (!request_disk_state->unstarted_write_ranges()->empty()) {
      WriteRange* write_range = request_disk_state->unstarted_write_ranges()->Dequeue();
      request_disk_state->in_flight_ranges()->Enqueue(write_range);
    }

    // Get the next scan range to work on from the reader. Only in_flight_ranges
    // are eligible since the disk threads do not start new ranges on their own.

    // There are no inflight ranges, nothing to do.
    if (request_disk_state->in_flight_ranges()->empty()) {
      request_disk_state->DecrementRequestThread();
      continue;
    }
    DCHECK_GT(request_disk_state->num_remaining_ranges(), 0);
    *range = request_disk_state->in_flight_ranges()->Dequeue();
    DCHECK(*range != NULL);

    // Now that we've picked a request range, put the context back on the queue so
    // another thread can pick up another request range for this context.
    request_disk_state->ScheduleContext(*request_context, disk_id);
    DCHECK((*request_context)->Validate()) << endl << (*request_context)->DebugString();
    return true;
  }

  DCHECK(shut_down_);
  return false;
}

void DiskIoMgr::HandleWriteFinished(RequestContext* writer, WriteRange* write_range,
    const Status& write_status) {
  // Execute the callback before decrementing the thread count. Otherwise CancelContext()
  // that waits for the disk ref count to be 0 will return, creating a race, e.g.
  // between BufferedBlockMgr::WriteComplete() and BufferedBlockMgr::~BufferedBlockMgr().
  // See IMPALA-1890.
  // The status of the write does not affect the status of the writer context.
  write_range->callback_(write_status);
  {
    unique_lock<mutex> writer_lock(writer->lock_);
    DCHECK(writer->Validate()) << endl << writer->DebugString();
    RequestContext::PerDiskState& state = writer->disk_states_[write_range->disk_id_];
    if (writer->state_ == RequestContext::Cancelled) {
      state.DecrementRequestThreadAndCheckDone(writer);
    } else {
      state.DecrementRequestThread();
    }
    --state.num_remaining_ranges();
  }
}

void DiskIoMgr::HandleReadFinished(DiskQueue* disk_queue, RequestContext* reader,
    BufferDescriptor* buffer) {
  unique_lock<mutex> reader_lock(reader->lock_);

  RequestContext::PerDiskState& state = reader->disk_states_[disk_queue->disk_id];
  DCHECK(reader->Validate()) << endl << reader->DebugString();
  DCHECK_GT(state.num_threads_in_op(), 0);
  DCHECK(buffer->buffer_ != NULL);

  if (reader->state_ == RequestContext::Cancelled) {
    state.DecrementRequestThreadAndCheckDone(reader);
    DCHECK(reader->Validate()) << endl << reader->DebugString();
    ReturnFreeBuffer(buffer);
    buffer->buffer_ = NULL;
    buffer->scan_range_->Cancel(reader->status_);
    // Enqueue the buffer to use the scan range's buffer cleanup path.
    buffer->scan_range_->EnqueueBuffer(buffer);
    return;
  }

  DCHECK_EQ(reader->state_, RequestContext::Active);
  DCHECK(buffer->buffer_ != NULL);

  // Update the reader's scan ranges.  There are a three cases here:
  //  1. Read error
  //  2. End of scan range
  //  3. Middle of scan range
  if (!buffer->status_.ok()) {
    // Error case
    ReturnFreeBuffer(buffer);
    buffer->eosr_ = true;
    --state.num_remaining_ranges();
    buffer->scan_range_->Cancel(buffer->status_);
  } else if (buffer->eosr_) {
    --state.num_remaining_ranges();
  }

  bool queue_full = buffer->scan_range_->EnqueueBuffer(buffer);
  if (buffer->eosr_) {
    // For cached buffers, we can't close the range until the cached buffer is returned.
    // Close() is called from DiskIoMgr::ReturnBuffer().
    if (buffer->scan_range_->cached_buffer_ == NULL) {
      buffer->scan_range_->Close();
    }
  } else {
    if (queue_full) {
      reader->blocked_ranges_.Enqueue(buffer->scan_range_);
    } else {
      reader->ScheduleScanRange(buffer->scan_range_);
    }
  }
  state.DecrementRequestThread();
}

void DiskIoMgr::WorkLoop(DiskQueue* disk_queue) {
  // The thread waits until there is work or the entire system is being shut down.
  // If there is work, performs the read or write requested and re-enqueues the
  // requesting context.
  // Locks are not taken when reading from or writing to disk.
  // The main loop has three parts:
  //   1. GetNextRequestContext(): get the next request context (read or write) to
  //      process and dequeue it.
  //   2. For the dequeued request, gets the next scan- or write-range to process and
  //      re-enqueues the request.
  //   3. Perform the read or write as specified.
  // Cancellation checking needs to happen in both steps 1 and 3.
  while (true) {
    RequestContext* worker_context = NULL;;
    RequestRange* range = NULL;

    if (!GetNextRequestRange(disk_queue, &range, &worker_context)) {
      DCHECK(shut_down_);
      break;
    }

    if (range->request_type() == RequestType::READ) {
      ReadRange(disk_queue, worker_context, static_cast<ScanRange*>(range));
    } else {
      DCHECK(range->request_type() == RequestType::WRITE);
      Write(worker_context, static_cast<WriteRange*>(range));
    }
  }

  DCHECK(shut_down_);
}

// This function reads the specified scan range associated with the
// specified reader context and disk queue.
void DiskIoMgr::ReadRange(DiskQueue* disk_queue, RequestContext* reader,
    ScanRange* range) {
  char* buffer = NULL;
  int64_t bytes_remaining = range->len_ - range->bytes_read_;
  DCHECK_GT(bytes_remaining, 0);
  int64_t buffer_size = ::min(bytes_remaining, static_cast<int64_t>(max_buffer_size_));
  bool enough_memory = true;
  if (reader->mem_tracker_ != NULL) {
    enough_memory = reader->mem_tracker_->SpareCapacity() > LOW_MEMORY;
    if (!enough_memory) {
      // Low memory, GC and try again.
      GcIoBuffers();
      enough_memory = reader->mem_tracker_->SpareCapacity() > LOW_MEMORY;
    }
  }

  if (!enough_memory) {
    RequestContext::PerDiskState& state = reader->disk_states_[disk_queue->disk_id];
    unique_lock<mutex> reader_lock(reader->lock_);

    // Just grabbed the reader lock, check for cancellation.
    if (reader->state_ == RequestContext::Cancelled) {
      DCHECK(reader->Validate()) << endl << reader->DebugString();
      state.DecrementRequestThreadAndCheckDone(reader);
      range->Cancel(reader->status_);
      DCHECK(reader->Validate()) << endl << reader->DebugString();
      return;
    }

    if (!range->ready_buffers_.empty()) {
      // We have memory pressure and this range doesn't need another buffer
      // (it already has one queued). Skip this range and pick it up later.
      range->blocked_on_queue_ = true;
      reader->blocked_ranges_.Enqueue(range);
      state.DecrementRequestThread();
      return;
    } else {
      // We need to get a buffer anyway since there are none queued. The query
      // is likely to fail due to mem limits but there's nothing we can do about that
      // now.
    }
  }

  buffer = GetFreeBuffer(&buffer_size);
  ++reader->num_used_buffers_;

  // Validate more invariants.
  DCHECK_GT(reader->num_used_buffers_, 0);
  DCHECK(range != NULL);
  DCHECK(reader != NULL);
  DCHECK(buffer != NULL);

  BufferDescriptor* buffer_desc = GetBufferDesc(reader, range, buffer, buffer_size);
  DCHECK(buffer_desc != NULL);

  // No locks in this section.  Only working on local vars.  We don't want to hold a
  // lock across the read call.
  buffer_desc->status_ = range->Open();
  if (buffer_desc->status_.ok()) {
    // Update counters.
    if (reader->active_read_thread_counter_) {
      reader->active_read_thread_counter_->Add(1L);
    }
    if (reader->disks_accessed_bitmap_) {
      int64_t disk_bit = 1 << disk_queue->disk_id;
      reader->disks_accessed_bitmap_->BitOr(disk_bit);
    }
    SCOPED_TIMER(&read_timer_);
    SCOPED_TIMER(reader->read_timer_);

    buffer_desc->status_ = range->Read(buffer, &buffer_desc->len_, &buffer_desc->eosr_);
    buffer_desc->scan_range_offset_ = range->bytes_read_ - buffer_desc->len_;

    if (reader->bytes_read_counter_ != NULL) {
      COUNTER_ADD(reader->bytes_read_counter_, buffer_desc->len_);
    }

    COUNTER_ADD(&total_bytes_read_counter_, buffer_desc->len_);
    if (reader->active_read_thread_counter_) {
      reader->active_read_thread_counter_->Add(-1L);
    }
  }

  // Finished read, update reader/disk based on the results
  HandleReadFinished(disk_queue, reader, buffer_desc);
}

void DiskIoMgr::Write(RequestContext* writer_context, WriteRange* write_range) {
  FILE* file_handle = fopen(write_range->file(), "rb+");
  Status ret_status;
  if (file_handle == NULL) {
    ret_status = Status(ErrorMsg(TErrorCode::RUNTIME_ERROR,
        Substitute("fopen($0, \"rb+\") failed with errno=$1 description=$2",
            write_range->file_, errno, GetStrErrMsg())));
  } else {
    ret_status = WriteRangeHelper(file_handle, write_range);

    int success = fclose(file_handle);
    if (ret_status.ok() && success != 0) {
      ret_status = Status(ErrorMsg(TErrorCode::RUNTIME_ERROR, Substitute("fclose($0) failed",
          write_range->file_)));
    }
  }

  HandleWriteFinished(writer_context, write_range, ret_status);
}

Status DiskIoMgr::WriteRangeHelper(FILE* file_handle, WriteRange* write_range) {
  // First ensure that disk space is allocated via fallocate().
  int file_desc = fileno(file_handle);
  int success = 0;
  if (write_range->len_ > 0) {
    success = posix_fallocate(file_desc, write_range->offset(), write_range->len_);
  }
  if (success != 0) {
    return Status(ErrorMsg(TErrorCode::RUNTIME_ERROR,
        Substitute("posix_fallocate($0, $1, $2) failed for file $3"
            " with returnval=$4 description=$5", file_desc, write_range->offset(),
            write_range->len_, write_range->file_, success, GetStrErrMsg())));
  }
  // Seek to the correct offset and perform the write.
  success = fseek(file_handle, write_range->offset(), SEEK_SET);
  if (success != 0) {
    return Status(ErrorMsg(TErrorCode::RUNTIME_ERROR,
        Substitute("fseek($0, $1, SEEK_SET) failed with errno=$2 description=$3",
        write_range->file_, write_range->offset(), errno, GetStrErrMsg())));
  }

  int64_t bytes_written = fwrite(write_range->data_, 1, write_range->len_, file_handle);
  if (bytes_written < write_range->len_) {
    return Status(ErrorMsg(TErrorCode::RUNTIME_ERROR,
        Substitute("fwrite(buffer, 1, $0, $1) failed with errno=$2 description=$3",
        write_range->len_, write_range->file_, errno, GetStrErrMsg())));
  }
  if (ImpaladMetrics::IO_MGR_BYTES_WRITTEN != NULL) {
    ImpaladMetrics::IO_MGR_BYTES_WRITTEN->Increment(write_range->len_);
  }

  return Status::OK;
}

int DiskIoMgr::free_buffers_idx(int64_t buffer_size) {
  int64_t buffer_size_scaled = BitUtil::Ceil(buffer_size, min_buffer_size_);
  int idx = BitUtil::Log2(buffer_size_scaled);
  DCHECK_GE(idx, 0);
  DCHECK_LT(idx, free_buffers_.size());
  return idx;
}

Status DiskIoMgr::AddWriteRange(RequestContext* writer, WriteRange* write_range) {
  DCHECK_LE(write_range->len(), max_buffer_size_);
  unique_lock<mutex> writer_lock(writer->lock_);

  if (writer->state_ == RequestContext::Cancelled) {
    DCHECK(!writer->status_.ok());
    return writer->status_;
  }

  writer->AddRequestRange(write_range, false);
  return Status::OK;
}

int DiskIoMgr::AssignQueue(const char* file, int disk_id, bool expected_local) {
  // TODO: add a queue for remote HDFS accesses.
  if (IsS3APath(file)) {
    DCHECK(!expected_local);
    return RemoteS3DiskId();
  }
  if (disk_id == -1) {
    // disk id is unknown, assign it a random one.
    static int next_disk_id = 0;
    disk_id = next_disk_id++;
  }
  // TODO: we need to parse the config for the number of dirs configured for this
  // data node.
  return disk_id % num_local_disks();
}

redpajama_set_name: RedPajamaGithub


tckhhhhhhh-... Testing... Achtung, Damen und Herren!
Found your perfect boyfriend/girlfriend but unsatisfied with their size/softness?
Or, just want to play a loony prank to your friend?
The perfect magic tool to assault people's necks and puff them from behind!
It's basically a magic attachable/detachable pooltoy valve, with the mythical vampire clichè qualities, except it doesn't DRAIN! It PUFFS!
Congratulations, you now turned the victim into a squishy stretchy inflatable pooltoy!
Inflated? Overinflated? Doesn't matter! VampAir's magic doesn't allow any kind of pop! COOL, HUH??
SO WHAT ARE YOU WAITING FOR?!?!?!?
Available in stores right NAO!


text:
Q: nested Ajax response data acess not working I am beginner at javascript , I am trying to calculate distance between two postcodes.
I am using a REST api with ajax get method to get latitude and longitude of a post code then send another ajax call to a servlet which returns the distance in json format.
Now I am having a hard time accessing the returned json string. When i check what's inside the data variable i only find the json elements returned on the first call. But when I check on my browser i find both of the ajax called successfully returned and i can see the json string of second ajax which returned the distance in browser console.
nested ajax returns following
{"distance":"0.005011484329483577"} (found it from browser inspect element console)

I need to be able to store the value of distance into a variable.I tried using data.distance. but it returns undefined.
maybe scope problem?
please help

    /*
     * Nurul Alam
     * and open the template in the editor.
     */
    $(document).ready(function(){
        $('#PostCodeLookUp').submit(function(){
            var p = document.getElementById("postCode").value;
            $.ajax({
                url:'http://api.postcodes.io/postcodes/'+p,
                type:'GET',
                dataType:'json',
                //data:$('#updateUserName').serialize(),
                success:function(data){
                    if(data){
                        var lat = data.result.latitude;
                        var lng = data.result.longitude;
                        //send the data in a ajax call to a servlet which process the data and returns the distance
                        $.ajax({
                            url:'postCodeConverterServlet',
                            type:'POST',
                            dataType:'xml',
                            data:$.param({lat: lat, lng:lng}),
                            success:function(){
                              alert(data.distance);
                            }
                        });
                        //
                        //$('#displayName').html(d);
                        //$('#displayName').slideDown(500);
                    }else{
                       $('#displayName').html("Problem");
                    }
                }
            });
            return false;
        });
    });

A: In the success function of your second ajax call, you are accessing the return from the first again by using data. Change your second ajax success function to the below giving it its own parameter name for its own response, then use that. You can give the argument a more meaningful name if you'd like but this would work:
success:function(nestedData){
    alert(nestedData.distance);
}

redpajama_set_name: RedPajamaStackExchange


text:
Abolish the priesthood to save the Catholic Church urges leading critic
When Pope Francis said after leaving Ireland he had never heard of the Magdalene Laundry scandal he was lying, writes James Carroll, a leading ex-priest in the lead story in Atlantic Monthly.
@niallodowd
Should we put an end to the priesthood? Getty
That alleged lie has led Carroll to argue for ending the priesthood in order to save the church.
James Carroll, a leading former cleric and best-selling author has called on the Catholic Church to end the priesthood and give the church back to lay people. The reality of the priesthood is that it has become toxic, he states, in the lead article in Atlantic Monthly.
He cites the incredible number of abusive priests and the massive cover-ups by cardinals and indeed, popes, as the reason. He states he is glad his Irish immigrant mother did not live to see the scandals almost destroy her beloved church.
Carroll adds that it was Pope Francis telling a lie while in Ireland that he had never heard of the abuse of helpless young women in the Magdalene Laundries that finally convinced him to end mass going, taking sacraments and believing in the priesthood.
Read more: Why Pope Francis should speak to Irish Catholic Church abuse survivors
He writes: "The Ryan Commission (in Ireland) published its 2,600-page report in 2009. Despite government inspections and supervision, Catholic clergy had, across decades, violently tormented thousands of children."
Carroll said there was a massive cover-up concerning "the notorious Magdalene Laundries," where girls and women were condemned to lives of coercive servitude. Not only priests had behaved despicably. So had nuns.
"In August 2018, Pope Francis made a much-publicized visit to Ireland. His timing could not have been worse."
Before, during, and after his trip to Ireland, Francis had expressed, as he put it, "shame and sorrow." But he showed no sign of understanding the need for the Church to significantly reform itself or to undertake acts of true penance.
Carroll writes that "one of the astonishments of Pope Francis's Irish pilgrimage was his claim, made to reporters during his return trip to Rome, that until then he had known nothing of the Magdalene Laundries or their scandals: 'I had never heard of these mothers—they call it the laundromat of women, where an unwed woman is pregnant and goes into these hospitals.'"
Read more: Sinead O'Connor asks Pope Francis to excommunicate her from the Catholic Church
Pope Francis in Ireland. Image: RollingNews.ie.
Carroll was appalled. He writes: "Never heard of these mothers? When I read that, I said to myself: A lie. Pope Francis is lying. He may not have been lying—he may merely have been ignorant. But to be uninformed about the long-simmering Magdalene scandal was just as bad. As I read the pope's words, a taut wire in me snapped … So it took some doing to bring me to a breaking point, and Pope Francis—whom in many ways I admire, and in whom I had placed an almost desperate hope—is the unlikely person who brought me to breaking point."
Carroll identifies clericalism, the overwhelming power of the supposedly celibate men in charge of the Church as the problem. The world needs the Church to be "rational, historically minded, pluralistic, committed to peace, a champion of the equality of women, and a tribune of justice." It is not, he says.
"The Church's maleness and misogyny became inseparable from its structure. The conceptual underpinnings of clericalism can be laid out simply: Women were subservient to men.
Laypeople were subservient to priests, who were defined as having been made "ontologically" superior by the sacrament of holy orders. He writes: "Now, with children as victims and witnesses both, the corruption of priestly dominance has been shown for the evil that it is."
Clericalism he says "explains both how the sexual-abuse crisis could happen and how it could be covered up for so long. If the structure of clericalism is not dismantled, the Roman Catholic Church will not survive, and will not deserve to."
Carroll writes that a "subculture" at the very highest levels of the church has "licensed, protected, and enabled those malevolent men of the cloth who are prepared to exploit the young.
"The very priesthood is toxic … Many parishes lack any priests at all. In the United States, Catholicism is losing members faster than any other religious denomination. For every non-Catholic adult who joins the Church through conversion, there are six Catholics who lapse."
He adds that "the renewal offered by Vatican II may have been thwarted, but a reformed, enlightened, and hopeful Catholic Church is essential in our world."
Carroll asks: "What if multitudes of the faithful, appalled by what the sex-abuse crisis has shown the Church leadership to have become, were to detach themselves from—and renounce—the cassock-ridden power structure of the Church and reclaim Vatican II's insistence that that power structure is not the Church? The Church is the people of God. The Church is a community that transcends space and time. Catholics should not yield to clerical despots the final authority over our personal relationship to the Church. I refuse to let a predator priest or a complicit bishop rip my faith from me.
"Replacing the diseased model of the Church with something healthy The Church, whatever else it may be, is not the organizational apparatus. It is a community of memory, keeping alive the story of Jesus Christ. The Church is an in-the-flesh connection to him—or it is nothing."
He concludes: "The Church is the fellowship of those who follow Jesus, of those who seek to imitate him—a fellowship, to repeat the earliest words ever used about us, of "those that loved him at the first and did not let go of their affection for him."
What are your thoughts? Let us know in the comments section, below.
Read more: Bishop Eamon Casey raped his niece (5) and assaulted other children
Related: Catholic


text:
Q: Inappropriate view of x-axis labels in jfreecharts. I have an issue with my jfreechart graph. Actually at x-axis the value are in big numbers (i-e 1500-2000) and the amounts of these values are also too large (i.e in significant notation).So the chart is just showing a dashed line instead of values at x-axis.
public static byte[] createImageByXyChart(String str_chartLabel,
        String str_xAxisLabel, String str_yAxisLabel,
        String str_fileFormat, Integer i_height, Integer i_width,
        List<double[]> co_ordinates) throws IOException {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < co_ordinates.size(); i++) {
        double[] xy_coOrdinates = co_ordinates.get(i);
        double xCoordiate = xy_coOrdinates[0];
        double yCoordiate = xy_coOrdinates[1];
        dataset.setValue(yCoordiate, str_chartLabel, "" + xCoordiate);

}
      JFreeChart chart =
     ChartFactory.createLineChart(str_chartLabel,str_xAxisLabel,
     str_yAxisLabel, dataset);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangePannable(true);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlineStroke(new BasicStroke(1.0f));
    plot.setRangeGridlineStroke(new BasicStroke(1.0f));
    plot.setDomainGridlinePaint(Color.GRAY.brighter());
    plot.setRangeGridlinePaint(Color.GRAY.brighter());

    ChartPanel panel = new ChartPanel(chart);

    JFrame frame = new JFrame("Show chart");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel);

    frame.setSize(600, 600);
    frame.setVisible(true);

    return null;
}
public static void main(String[] arg) throws Exception {

    System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@  ");
    File fileData = new File("curve.txt");

    BufferedReader br = new BufferedReader(new FileReader(fileData));
    List<double[]> co_ordinates = new ArrayList<double[]>();
    String line = null;

    while ((line = br.readLine()) != null) {

        String[] abcd = line.split(",");
        double[] xy_cor = new double[2];
        NumberFormat df = new DecimalFormat("######.####");
        xy_cor[0] = Double.parseDouble(df.format(Double
                .parseDouble(abcd[0])));
        System.out.println(xy_cor[0]);
        xy_cor[1] = Double.parseDouble(abcd[1]);

        System.out.println(Arrays.toString(xy_cor));
        co_ordinates.add(xy_cor);

    }

    br.close();

    String str_chartLaber = "Curve";
    String str_xAxisLabel = "Time(s)";
    String str_yAxisLaber = "Accelaration (mm_per__s_2)";
    String str_fileFormate = ImageFormats.JPEG;
    Integer heigth = 1800;
    Integer width = 1080;

    byte[] image_bytes = ImageUtils.createImageByXyChart(str_chartLaber,
            str_xAxisLabel, str_yAxisLaber, str_fileFormate, heigth, width,
            co_ordinates);

    }

the input data is that
Heading

A: i use
XYDataset dataset ;

instead of
DefaultCategoryDataset dataset = new DefaultCategoryDataset();

The XYDataset enable auto interval where DefaultCategoryDataset do not.I don't know the reason but it is.


text:
A zsidók passiója (The Passion of the Jew) a South Park című animációs sorozat 114. része (a 8. évad 3. epizódja). Elsőként 2004. március 31-én sugározták az Egyesült Államokban.

Az epizód főként A passió című filmet kritizálja, amely szintén 2004-ben jelent meg. A cselekmény szerint a zsidó származású Kyle Broflovskinak szörnyű bűntudata támad, miután megnézi a filmet. Eközben barátai, Stan Marsh és Kenny McCormick is megnézik A passiót, de nem tetszik nekik, ezért vissza akarják kérni a jegy árát a rendezőtől, Mel Gibsontól...

Cselekmény

A gyerekek űrhajósat játszanak, de Kyle Broflovski és Eric Cartman között szokás szerint feszültség támad; Cartman ismét zsidó származása miatt támadja Kyle-t, majd szóba kerül, hogy szerinte a zsidók felelősek Jézus haláláért. Hogy állításait igazolja, Cartman arra ösztönzi Kyle-t, nézze meg A passió című filmet (amelyet ő már 34 alkalommal látott) mert ez alátámasztja kijelentéseit. Kyle nagy nehezen rászánja magát a film megtekintésére, és elborzadva látja, hogy milyen kínokat kellett Jézusnak elszenvednie.

Kyle nagyon elbizonytalanodik és mérhetetlen bűntudata támad, ezért meglátogatja Cartmant és elismeri, hogy a fiúnak végig igaza volt a zsidókkal kapcsolatban. Cartman ezt hallva egy Mel Gibson poszter előtt imádkozva megfogadja A passió rendezőjének, hogy egységbe kovácsolja a film híveit és terjeszteni fogja annak üzenetét. Eközben Stan Marsh és Kenny McCormick is megnézi A passiót, de nem tetszik nekik és vissza akarják kérni a jegy árát, viszont a jegypénztáros ezt nem hajlandó megtenni. Kiderítik, hogy Mel Gibson Malibuban lakik, így útnak indulnak, hogy visszaszerezzék pénzüket és egyben tiltakozzanak a rossz filmek ellen.

Cartman barna uniformist ölt (melyben Hitlerre hasonlít) és találkozót szervez a film híveinek. Ők azt hiszik, ez csupán egy keresztény összejövetel, de mint kiderül, Cartman valódi célja a zsidók deportálása. Stanék megtalálják Mel Gibson házát, de hamar nyilvánvalóvá válik, hogy a férfi őrült és mazochista, emiatt menekülniük kell, de előtte még gyorsan visszalopják a mozijegyek árát. Kyle – akit a film megnézése óta rémálmok gyötörnek (melyekben Alan Alda színész is felbukkan) – megkeresi South Park lelkészét, Maxi atyát, aki a bűntudata ellen vezeklést javasol neki. Cartman náci vezényszavakat tanít híveinek (akik ezekről tévesen azt hiszik, arámi nyelven íródtak), majd menetelni kezdenek az utcán, miközben ezeket az antiszemita mondatokat harsogják.

Kyle a zsinagógában azt tanácsolja az egybegyűlteknek, hogy talán bocsánatot kellene kérniük Jézus haláláért. Kyle szülei és a többi ember ezen felháborodik, mert szerintük ez is azt igazolja, hogy A passió antiszemita. A rabbi próbálja megnyugtatni híveit, de ebben a pillanatban az épület előtt feltűnik Cartman és mögötte a skandáló tömeg. Heves szócsata alakul ki a két tábor között, de hirtelen megérkezik Stan és Kenny, valamint az őket üldöző, A rettenthetetlen című filmből ismert arcfestést viselő Mel Gibson. A rendező elméje teljesen elborul és mindenki szeme láttára abszurd dolgokat művel; ekkor Kyle rádöbben, hogy teljesen feleslegesen érezte rosszul magát a film miatt, hiszen a férfi nyilvánvalóan nem beszámítható. Stan beszédet tart arról, hogy a keresztényeknek Jézus tanításait kellene hirdetniük és nem a halálát, hiszen a keresztrefeszítés az ókorban mindennapos volt; a hit erejével kell elutasítaniuk az erőszakot. A tömeg szétszéled, így Cartman nem valósíthatja meg tervét, ráadásul a megvadult Mel Gibson még az arcába is székel.

Fogadtatás
Virginia Heffernan a The New York Times-tól dicsérte az epizódot; az antiszemitizmus ellen küzdő Anti-Defamation League és Max Gross, a Forward nevű zsidó napilap egyik újságírója szintén pozitívan nyilatkozott az epizódról, mint "a napjainkig megjelent legcsípősebb hangvételű Passió-kritikáról".

Jegyzetek

További információk

A zsidók passiója  a South Park Studios hivatalos honlapon

South Park-epizódok – 8. évad

it:Episodi di South Park (ottava stagione)#La passione dell'ebreo


text:
Fewer children walk or bike to school, U of T research finds – and that hurts everyone
Ron Buliung: cars play an "increasingly dominant role" in the lives of kids and teens
Professor Ron Buliung would like to see more students follow the lead of the girls seen above and walk or bike to school (photo by Jaap Joris via flickr)
More than twice as many kids are driven to school these days compared to 25 years ago, the University of Toronto's Ron Buliung says – and that's having an impact on everyone.
"We have a multi-billion dollar congestion problem in the region," says Buliung, a professor of geography at the University of Toronto Mississauga.
"We're dealing with the hangover from the auto century."
In a study released April 5 by Metrolinx, the Greater Toronto and Hamilton Area's transportation planning agency, Buliung found a decline among youth in the use of physically active modes of transportation to commute to school over a 25-year period.
Buliung,who has worked with Metrolinx on transportation research for a decade, looked at regional school transportation data from 1986 to 2011 and found that fewer students were walking or cycling to school. The agency's goal is to have 60 per cent of students engage in some form of active commuting to and from school by 2031.
"We're interested in creating a more active commuter workforce," Buliung says, "and if we're looking at a long-term cultural change, it's important to look at children and young adults, because they are the adult commuters of the future."
In 1986, 56 per cent of kids between the ages of 11 and 13 walked to school and only 12 per cent were driven. Twenty-five years later, only 39 per cent were walkers, compared to 31 per cent who were driven.
But the researchers found students in the 11 to 13 age group are still more likely to walk or cycle than their 14- to 17-year-old counterparts. (Transportation data are not recorded for children under the age of 11).
Buliung's research also found that students ages 11 to 17 are more likely to be driven to school in the morning than the afternoon and that boys are more likely to use active modes of transportation than girls. These findings are consistent with societal trends toward two parents working – making them unavailable for afternoon car transport – and with personal safety concerns among girls.
In an interview with Radio Canada International, Buliung said "the walk to school provides an opportunity to acquire and practice geographic skills like spatial awareness, orientation, way-finding" as well as an opportunity to play with friends.
Parents tend to cite convenience and safety among the factors encouraging them to drive their kids, Buliung said. He added that while children may cite concerns about bullying by other kids, parents talk more about "stranger danger" and worries about traffic safety.
"Paradoxically, if you're driving your child to school you're making someone else's child a little less safe," Buliung told Radio Canada.
Listen to the interview with Radio Canada
Given the prevalence of childhood obesity in North America, and the impact of traffic congestion and air pollution on everyone's health, Buliung says he was "disappointed" by the data but points out much effort has been made since the turn of this century to increase active transportation.
"In the last five years, we've really been gaining ground," he says. "School boards in Hamilton-Wentworth and Toronto, for example, have created active and safe school travel charters, and Peel Public Health is very interested in active transportation for school and otherwise."
Read a Toronto Star article about the study
In an interview with the Globe and Mail, Buliung said walking or cycling may also result in a student having "an improved ability to concentrate" and there are benefits for parents who walk with their kids as well.
"One of the things that households can actually miss out on is that contact time, just hanging out on that walk to school and having a conversation about what's happening in your child's life," Buliung told the Globe. "You learn things."
Read the Globe and Mail article
"We want to get this research out into the public arena so we can reach the widest possible audience, have a discussion about the increasingly dominant role of the auto in the lives of our children and see what we can do to get them moving again," Buliung says.
Read about university students' commute to school
(Visit Flickr to see the original of the photo by Jaap Joris used at top of article)
Elaine Smith
City & CultureBreaking Research
EnvironmentHealthKidsPollutionResearchSustainabilityTop StoriesTrafficTransitUTM
U of T launches Iranian Student Memorial Scholarship Fund to honour plane crash victims


text:
US charges Sam Bankman-Fried with defrauding investors
Image source, Tom Williams/Getty Images
By Chris Vallance
Technology reporter
US authorities have charged Sam Bankman-Fried with "one of the biggest financial frauds in US history" in the failed cryptocurrency exchange FTX.
The former FTX boss was arrested on Monday.
Mr Bankman-Fried built a "house of cards on a foundation of deception", Security and Exchange Commission (SEC) Chair Gary Gensler said.
Officials have also accused him of violating campaign finance laws.
Mr Gensler added that the charges for alleged fraud were a warning for other platforms to comply with US laws.
The US Attorney's Office for the Southern District of New York and the Commodity Futures Trading Commission (CFTC) also announced charges against Mr Bankman-Fried in parallel actions.
At a news conference on Tuesday, Damian Williams, the US Attorney for the Southern District of New York, said that the fraud Mr Bankman-Fried is accused of is among the largest in US history.
In addition to accusing Mr Bankman-Fried of defrauding lenders, investors and customers, Mr Williams accused him of using "tens of millions" in ill-gotten gains for illegal campaign contributions to Democrats and Republicans alike.
"All this dirty money was used in service of Bankman-Fried's desire to buy bipartisan influence and impact the direction of public policy in Washington," Mr Williams said.
Speaking to BBC News earlier this month, Mr Bankman-Fried sought to distance himself from accusations of illegal activity.
"I didn't knowingly commit fraud. I don't think I committed fraud. I didn't want any of this to happen. I was certainly not nearly as competent as I thought I was," he told BBC News cyber reporter Joe Tidy.
Mr Bankman-Fried also denied allegations he must have been aware that FTX's affiliated trading company, Alameda Research, was using FTX customer funds.
He was once viewed as a young version of legendary US investor Warren Buffett. As recently as late October, he had a net worth estimated at more than $15bn (£12.1bn).
A well-known political donor, he was arrested in the Bahamas and is being held there in custody pending extradition to the US. He said on Tuesday he would fight the extradition.
Meanwhile, the firm's new chief executive, John Ray, told a US congressional committee that FTX's collapse appeared to be the result of it being controlled by a small group of "grossly inexperienced, non-sophisticated individuals".
He said he had seen "an utter lack of record-keeping – no internal controls whatsoever".
Last month, FTX filed for bankruptcy in the US, leaving many users unable to withdraw their funds.
According to a court filing last month, FTX owed its 50 largest creditors almost $3.1bn.
The FTX exchange allowed customers to trade normal money for cryptocurrencies such as Bitcoin.
Cryptocurrencies are not currencies in the traditional sense, but are stored online and act more like investment vehicles or securities – often with a high degree of volatility.
Their anonymity means they have been favoured for criminal activities such as drug dealing and ransomware attacks, but their supporters say there is huge potential for innovation – and independence from governments.
Billions invested
Since 2019, Bahamas-based FTX had raised more than $1.8bn from equity investors, the SEC said, including approximately $1.1bn from about 90 US-based investors.
It is alleged that while Mr Bankman-Fried promoted FTX as a "safe, responsible crypto asset trading platform", in reality he "orchestrated a years-long fraud" to conceal from FTX's investors the diversion of FTX customers' funds to Alameda Research LLC, his privately held crypto hedge fund.
The SEC also alleges that he concealed FTX's exposure to Alameda's significant holdings of overvalued FTX-affiliated tokens.
Mr Bankman-Fried is also accused of "co-mingling" FTX customers' funds at Alameda to make "undisclosed venture investments, lavish real estate purchases, and large political donations".
In what has turned out to be one of his last interviews before arrest, Mr Bankman-Fried seemed extremely confident – telling me he would not be arrested and was innocent of any criminal wrongdoing.
The 30-year-old turned up in his trademark shorts and scruffy T-shirt, seeming surprisingly calm.
But he did admit he was not getting much sleep since his empire collapsed and he became crypto public enemy number one.
Mr Bankman-Fried spoke to us not in his home, but in an apartment still owned by FTX, in the luxury Albany complex about 30 minutes from the Bahamian capital, Nassau.
Before we started recording, we were told not to take any shots of the multimillion pound yachts or manicured gardens in the marina.
We were also warned not to film his apartment building, which he has had to vacate for "safety reasons".
Once we began the interview, Mr Bankman-Fried spoke for 35 minutes with no topic or question ruled out.
As in other recent interviews, he admitted to mismanaging his FTX empire but tried to distance himself from any criminal wrongdoing.
He also said he did not think he would be arrested and, off-camera, heavily hinted details would soon emerge to make the public more believing of his version of events.
"FTX operated behind a veneer of legitimacy Mr Bankman-Fried created," said Gurbir S Grewal, director of the SEC's Division of Enforcement.
"But as we allege in our complaint, that veneer wasn't just thin, it was fraudulent."
He added that FTX's collapse highlighted the risk unregistered crypto asset trading platforms can pose to consumers and investors.
The SEC charged Mr Bankman-Fried with violating the anti-fraud provisions of the Securities Act of 1933 and the Securities Exchange Act of 1934.
In New York, Mr Williams vowed that authorities "are not done" with the investigation and called on "anyone who participated in wrongdoing" to come forward.
"Come see us before we come and see you," he said.
Robert Greenall and Bernd Debusmann Jr also contributed to this article
FTX founder Sam Bankman-Fried arrested in Bahamas
The fall of 'King of Crypto' Sam Bankman-Fried
Bankman-Fried: I hope to make money to pay people back
Poverty eradication with Chinese characteristics


text:
All Apple All Day
Building an iOS home, bit by bit.
AirPlay and Sonos
Plex and macOS Server
Summer Updates - Staying Connected
On Monday, July 18, 2016 By Matt Gasaway
We're still here - sorry for the lack of updates, but there hasn't been a whole lot going on in the world of AAPL or AAAD.
We're almost-but-not-quite finished with our basement renovation, so I haven't been able to pull the trigger on the final "Going Underground" update, either.
When it comes to the basement, we're finished - except for the cabinets and countertops for the bar and drink ledge.
And, of course, furniture.
At the moment, our new bedroom has one piece of furniture, and that's our foosball table.
The sectional sofa will be arriving in short order - that's the primary "missing piece" that will turn the basement from "kids videogame explosion" into "usable space for grown-ups".
We're also re-thinking all of our bundled home services.
Our internet is currently with WOW - but the price just moved from $50 to $75/month, for what is supposed to be 60 Mbps, but which almost never reaches that level.
That's troubling, to me.... because WOW's advertised rate for their 60 Mbps level of service is $54.99 - $40 on contract.
I gave them a call, and asked why I was still paying $75, especially given that I'm not under any contract..
They said the new rates were for new customers, but they were able to match that price for me - it will be $54,99 for another 12 months. That's acceptable - but still on the high end, and not ALL that much bandwidth.
At the same time, we're approaching the end of our DirecTV contract, too - and it's gotten shockingly expensive.
It may be time to see if we can get some synergy and savings, by bundling TV and internet again.
Unfortunately, the competition for both is Comcast/Xfinity, and they've been ludicrously bad at getting service to my house.
Our DirecTV contract ends in August, and I'll be running all of the numbers.
I'm also - for the first time in years - giving some thought to ditching Verizon for our mobile plan.
Lots of things to consider. But first, let's get this basement finished.
Like This Post? Please share!
Subscribe to AAAD
Subscribe and get the latest updates sent directly to your inbox.
Not All AirPort Extremes are Created Equal (UPDATED)
I'm looking for a used AirPort Extreme. In all the usual places - eBay, Craigslist. I'll probably get one this week. Why? It&#...
Review: NuCore Flooring from Floor & Decor
This NuCore flooring review will also function as a Basement Update: We're finally, officially moving forward on the Phase 2 finis...
Harry's Razors Review - Are the Savings Worth The Hassle?
In a recent AAAD post, we discussed the virtues of Harry's vs. Dollar Shave Club . Ultimately, I went with Harry's. And now.... ...
Mac Mini Generations - Not All Mac Minis Are Created Equal
As I mentioned in our last post, we're going to be adding a Mac Mini Server to our iOS home . Our Mac Mini is going to have to do ...
Replacing an iMac Hard Drive with an SSD
Back in the early days of AAAD, our late-2009 iMac was the center of our connected home. It held all of our photos, our iTunes library, and ...
Is HP Instant Ink a Good Deal?
We recently purchased a new all-in-one printer, and signed up for HP's new Instant Ink program. They claim that it can save users as muc...
Review - WOW Ultra TV vs. DirecTV HR34 Genie
Here in the Chicago suburbs, we had two options for whole-home DVR services. We initially went with WOW Ultra TV, and after about 4 mon...
Further Adventures With ADT Pulse - Updates
Hope you had a great weekend. It was quiet at the AAAD house - not only was Saturday our first day in nearly 2 weeks with no houseguests, an...
ADT Pulse Review - Great, with a "but".
ADT stopped by our house on Friday to upgrade our Brinks security system to an ADT Pulse system. There was nothing wrong with our ol...
How to Replace (or Upgrade) a Time Capsule Hard Drive
I used to have a first-generation 500 GB Time Capsule. I still have it. Except now, it's a 1 TB Time Capsule. Maybe your or...
Matt Gasaway
Subscribe through email and get Free updates
Copyright © 2015 All Apple All Day • All Rights Reserved • Designed By Blogtipsntricks


Sometimes when I wake up in the morning and the sun is shining brightly through my white curtains, I just know that it's going to be a great day.
Then I start to get up out of bed. Whoops!
That first step is wobbly and stiff. I reach for the footboard on the bed. Take a few more steps.
Ok. Getting the flow now.
Here is where YOU click over and check out my new diggs at Health Central.
Yep, you heard me right. I'll be blogging next to our friend Mandy of MS Maze who has been a prominent feature at Health Central since last fall.
So please do come over and let me know you've arrived. I am not giving up my blog here but will be adding twice a week posts at MultipleSclerosisCentral.com in addition to all the cool stuff that Brass and Ivory and the Carnival of MS Bloggers have to offer.
Thanks for the info. I'll check it out.
This may be tacky but, I consider you writing over "there" a big success and recognition (popping cork on the bottle now)...I guess the "tacky" feeling coming from me is the idea I may be celebrating your MS, too? Whatever...CHEERS!
You go girl! I am bookmarking the site when I sign off here.
I am rather pleased that Health Central would consider it a good idea to have me do some blogging for them. And if it weren't for the MS, I never would have even known about all this cool online community we got going on here.
Regarding energy. Well it comes and goes. Too bad it evaporates into the ether much too quickly to get it in a bottle.
Soon I will have a widget for the site (I hope). But there is already a RSS feed available. I do think this is pretty cool.
Thank You for Your Continued Patronage!!
"National MS Disease Registry Act"
Why do I talk about MS?
What would you like me to talk about?


Yes, that's quite often said and I wouldn't argue against it without the benefit of in-depth study and analysis of the situation. If it is true, however, then one might point to this as an example of the democratic nature of the Israeli state (as enunciated in one of Israel's Basic Laws – the one from 1992 in point of fact).
Having said that, I don't think it would be sufficient to make me want to go and live in Israel, in the same way that the frequent praise of President rasPutin's Russia br certain people is insifficient to make those people want to go and live in Russia.
A perspective for the situation or a hubbub?
I am concerned about the power of the government to strip people of their citizenship without due process. Does anyone know whether the extension of the power to people who would be made stateless as a result has already become law?
Nevermind Saw this and thought of you! I expect that there are many such examples in every location.
The Guardian are reporting that there are over 700,000 empty homes in the UK and 11m in Europe. A scandal indeed.
Dropped like a hot potato from the Basic Law of 1992 (which is when it first became legally binding) was, of course, the equality clause in the Declaration of Independence….
So I wouldn't fall over myself to praise Israel just because Israeli Jews allow each other to debate there.
Any more than I endorse Putin, who does not have a large, well-organised and politically embedded lobby group working to elide his many crimes and retain the uncritical support of the UK and US.
A couple of comments on your post at 11h34.
" However, the Knesset maintains that the declaration is neither a law nor an ordinary legal document. The Supreme Court has ruled that the guarantees were merely guiding principles, and that the declaration is not a constitutional law.."; it is therefore somewhat illogical to complain that something which has been declared a guiding principle has not become part of a subsequent Law, thereby acquiring the status of a law.
No, that is not exact. Israeli Arabs have the vote and, for that matter, their own political parties. Furthermore, I think that Israeli Arabs do enjoy "..freedom of religion, conscience, language, education and culture." (to take up your quote from the Declaration of Independence).
More emotive language which I don't think is borne out by anything posted here on this blog.
That is factually correct but, if I may say so, irrelevant to the question of whether or not Israel is a democracy (or indeed to the question of the extent to which rasPutin's Russia is a democracy as most people would understand that term).
Not a very reassuring bit of writing and not very likely to instill confidence in the writer's objectivity, is it.
Geopolitics rules OK? While many in Britain rely on food-banks to survive and many more in Britain are homeless, chancellor Osborne promises an open checkbook to any pro-European and pro-NATO 'associate' in need of financial assistance.
Speaking in Sydney after the G20 finance ministers conference, George Osborne, the chancellor, said British cash is available to help Ukraine return to stability.
"We are here ready to help just as soon as there is someone at the end of the telephone. We should be there with a chequebook to help the people of Ukraine rebuild their country," he said.
Russian Foreign Minister Sergei Lavrov criticized on Thursday the West's threat to impose sanctions on Ukraine as a blackmail and double standards.
In a cold-war context–in which East and West battle for influence, Britain has used the 'sanctions' threat against the elected government of Ukraine and America has 'warned' Russia against putting 'boots on the ground' in an attempt to protect it's interests.
As a component of the Western backed coup, CIA man and and Yulia Tymoshenko's buddy Oleksandr Turchynov, has issued an arrest for impeached President Yanukovych for crimes against humanity.
I myself believe this game of chess is to 'check' Russia and force her into creating independence to Russian aligned East Ukraine thus keeping her eye is 'off the ball' to the situation in Kiev. Putin would be wise to concentrate on his economic leverage forcing the West into granting Ukraine debt forgiveness and restructuring along with a hefty aid package.
It's a pity you can't bring yourself pick the nits out of the Israeli Basic Law as diligently as you search for them in anything remotely supporting the Palestinian case for self-determination in their own native land.
And I see you are a big fan of obfuscation and weasel words. But thank you for confirming that the concept of equality before the law (you can ask the thousands of Palestinians held without charge or access for years in Israeli jails about that) was too inconvenient to be formally embodied in the code, and get-out clauses had to be liberally sprinkled over the mess in case anyone thought the original terms of the D of I were anything but a cosmetic measure designed to appease the UN.
Meanwhile in Gaza, the involuntarily stateless persist in their ghetto.
What else can you possibly call it?
Habbabkuk (La vita è bella!
Quite true Habbabkuk not unique at all.
Power corrupts; absolute power corrupts absolutely. History is full of examples.
A prime example being Hitler's Nazis and the extermination camps.
Good advice Habbabkuk please take it yourself.
Hello Habbabkuk… did you notice I'd replied to your questions to me on CCTV and state surveillance?
National Service bill – (18yrs-26yrs) – to include apart from killing, instruction in personal financial budgeting, household bills, nutrition, cooking, time keeping, life skills, tolerance towards others, treating elderly and disabled people with dignity and respect.
Thanks for signing up to the Privacy International mailing list! Last week, you participated in a global day of action: The Day We Fight Back. It was an amazing effort from thousands of organisations, and thanks to people like you, we are at the beginning of a movement to put an end to mass surveillance around the world.
You may be new to Privacy International, so let us introduce ourselves. PI is a London-based charity that is committed to fighting for the right to privacy across the world. We're a team of activists, investigators, researchers, and lawyers who envision a world in which the right to privacy is protected, respected, and fulfilled. We've been around since 1990, and were the first international organisation working on privacy rights, back when that meant dealing with this emerging thing called the "internet".
We filed a criminal complaint with the UK National Crime Agency on behalf of an Ethiopian political refugee here in the UK, who was spied on using British-made surveillance technology sold to governments.
We recently launched a campaign to pry open the alliance of the US National Security Agency and its fellow intelligence agencies in Australia, Canada, New Zealand, and the UK, and bring it under the rule of law. Recently, we wrote to all of them to get copies of their spy agreement, and their responses were…interesting.
Repressive regimes have ambitions to keep pace with the NSA through the help of the commercial surveillance market. Through materials collected at surveillance trade shows around the world and information provided by Wikileaks and other organisations, PI hosts the Surveillance Industry Index, the largest catalogue of the private surveillance sector ever assembled.
We'll help you stay on top of urgent and emerging issues related to privacy, surveillance, and so much more through our monthly newsletter, Private Thoughts.
Stayed tuned for updates on our new project working with partners in 13 countries around the world to understand modern surveillance techniques, an upcoming meeting in Geneva at the Human Rights Council led by PI, and the latest in our legal challenge against the UK Government for its involvement in PRISM and its vast global communications surveillance apparatus, Tempora.
We're excited you're a part of our growing community. The Day We Fight Back may be over, but we still need you to be our activists on the ground.
If you think PI is doing great work, why not help us spread the word? Follow us on Twitter, like us on Facebook, and encourage your friends, family and colleagues to sign-up to our mailing list. As a charity, we also rely heavily on donations. Please consider lending your support by making a donation to PI.
Ukrainians – beware of Greeks bearing gifts. If you get an IMF bailout, you won't know what's hit you in terms of cuts and austerity.
'Interim Finance Minister Yuriy Kolobov has said Ukraine needs around $35bn (£21bn) in urgent foreign aid and asked for an international donors' conference to be held.
Moscow recently agreed to provide $15bn for Ukraine's struggling economy – a move seen as a reward for Mr Yanukovych's controversial decision not to sign the long-planned trade deal with the EU.
'The anti-government forces have invested in her rehabilitation. She is being purified as figurehead, ill but unrepentant. Her record is being white washed, and she is being granted holy orders in the revolutionary movement. Yanukovych might be deemed a beast, but Tymoshenko is no saintly maiden of clean persuasions.


We all have moments where a home comfort meal makes us feel the world of good. Generally speaking, comforting food comes in the form of something which doesn't always make you feel that great after consumption though, however with a few changes we can still enjoy these same comforts but with a healthy twist, and subsequently enjoy them guilt free.
There are different kinds of chip eaters – whether you're a sharer, an occasional enjoyer, a wrap them up and take them home to enjoy on your own kind of person, or someone who simply can't get enough of them, a portion of the nation's favourite shaped potato doesn't ever go amiss.
However, they aren't always the healthiest option; the humble sweet potato though makes for an entirely different story. One of our absolute favourite home comfort alternatives comes in the form of sweet potato fries, and is a great way also of getting a wonderful amount of beta-carotene, fibre and hair, nail and skin nourishing goodness into your system without any compromise on comfort! Simply slice them, add a small drizzle of olive oil, herbs, and whichever flavourings take your fancy, and pop them in the oven – it really couldn't be easier!
The perfect carby comfort food, try spirallazing your favourite vegetable, we like butternut squash, courgette or carrot and gently cook these in a drizzle of oil until softened. Serve with your favourite veggie packed Bolognese and a generous helping of reduced fat cheese, or a lighter cheese such as feta.
Another great option is buckwheat or brown rice pasta, as they are completely gluten free as well as healthful and honestly taste just as good. Try mashing together an avocado, basil, lemon and pine nuts for a healthy creamy alternative too!
Making for the perfect Sunday brunch option (or just whichever meal takes your fancy), it's undeniable that these are some of our favourite go-to's for an indulgent, home comfort-style meal. However, with the general ingredients for our favourite round indulgence being not extremely healthy, and therefore not something we generally indulge in on a daily basis, its important to recognise the ingredients which will make up for this so that we can do just that! Ingredients which are great for this include oats, banana, almond milk, medjool dates and more – all completely natural and make for a delicious, energy abundant treat whenever takes your fancy.
Try a cashew coconut cookies for a wonderfully crunchy snack with a slight Christmassy feel to them with the ginger and cinnamon element to them. As well as this, chocolate-banana oat cookies are a great alternative to our choccy childhood faves, with cacao powder and date syrup creating the flavours we all love and once again, oats and bananas the consistency. They really are great, and you can be rest assured once you smell them exiting the oven, it will be as though you have been transformed back to your childhood home treats once again.
So enjoy your tasty summer comfort foods, on us!


1.The items are Asian sizes, about 1-2cm smaller than US size. Please check size guide.
2.Please allow 1-2cm differs due to manual measurement.
Click the button below to add the Rihanna Unapologetic Floral Rose 3D Print Sweatshirt - Unisex to your wish list.


text:
Ляуфен () — місто в Німеччині, знаходиться в землі Баварія. Підпорядковується адміністративному округу Верхня Баварія. Входить до складу району Берхтесгаден.

Площа — 35,31 км2. Населення становить  ос. (станом на ).

Відомі люди
 Йоганн Міхаель Роттмайр — (, , Ляуфен — , Мужен, Франція) — один з провідних австрійських художників епохи бароко.

Галерея

Примітки

Посилання

 Офіційний сайт

Міста Баварії