Funeral for US police officer attended by thousands