void whitelist_static_app::main(string url) { DEBUG("static requested: ["+url+"]"); string hash = hash_function_(url); DEBUG("static hash: ["+hash+"]"); value file_info = whitelist_.find(hash); if (file_info.is_undefined()) { DEBUG("Requested url not in white list"); response().status(404); return; } auto file_path = folder_ / file_info.get<string>("path"); DEBUG("Static path: ["+file_path.string()+"]"); ifstream f(file_path.string()); if (!f) { DEBUG("File not found in the folder"); response().status(404); return; } // TODO: support file download using headers based on file size DEBUG("dumping file"); response().content_type(file_info.get<string>("mime")); response().out() << f.rdbuf(); }
void FlushPartition(size_t partition_id, bool consume, bool grow) { Super::table_.FlushPartitionEmit( partition_id, consume, grow, [this](const size_t& partition_id, const TableItem& ti) { Key key = Super::MakeTableItem::GetKey( ti, Super::table_.key_extractor()); if (!non_duplicates_[hash_function_(key) % max_hash_]) { duplicated_elements_++; Super::emit_.Emit(partition_id, ti); } else { non_duplicate_elements_++; Super::emit_.Emit(Super::table_.ctx().my_rank(), ti); } }); if (Super::table_.has_spilled_data_on_partition(partition_id)) { data::File::Reader reader = Super::table_.partition_files()[partition_id].GetReader(true); while (reader.HasNext()) { TableItem ti = reader.Next<TableItem>(); Key key = Super::MakeTableItem::GetKey( ti, Super::table_.key_extractor()); if (!non_duplicates_[hash_function_(key) % max_hash_]) { duplicated_elements_++; Super::emit_.Emit(partition_id, ti); } else { non_duplicate_elements_++; Super::emit_.Emit(Super::table_.ctx().my_rank(), ti); } } } // flush elements pushed into emitter Super::emit_.Flush(partition_id); Super::emit_.Flush(Super::table_.ctx().my_rank()); }
void Insert(const Value& v) { if (Super::table_.Insert( Super::MakeTableItem::Make(v, Super::table_.key_extractor()))) { hashes_.push_back(hash_function_(Super::key_extractor_(v))); } }