- Apache Pig 教程
- Apache Pig - 首頁
- Apache Pig 簡介
- Apache Pig - 概述
- Apache Pig - 架構
- Apache Pig 環境
- Apache Pig - 安裝
- Apache Pig - 執行
- Apache Pig - Grunt Shell
- Pig Latin
- Pig Latin - 基礎
- 載入和儲存運算子
- Apache Pig - 讀取資料
- Apache Pig - 儲存資料
- 診斷運算子
- Apache Pig - 診斷運算子
- Apache Pig - Describe 運算子
- Apache Pig - Explain 運算子
- Apache Pig - Illustrate 運算子
- Pig Latin 內建函式
- Apache Pig - Eval 函式
- 載入和儲存函式
- Apache Pig - Bag 和 Tuple 函式
- Apache Pig - 字串函式
- Apache Pig - 日期時間函式
- Apache Pig - 數學函式
- Apache Pig 有用資源
- Apache Pig - 快速指南
- Apache Pig - 有用資源
- Apache Pig - 討論
Apache Pig - FLOOR() 函式
**FLOOR()** 函式用於計算表示式的值,向下舍入到最接近的整數。以下是 **FLOOR()** 函式的語法。
grunt> FLOOR(expression)
示例
假設在 **HDFS** 目錄 ** /pig_data/ ** 中有一個名為 **math.txt** 的檔案。此檔案包含如下所示的整數和浮點數。
math.tx
5 16 9 2.5 5.9 3.1
並且,我們已使用名為 **math_data** 的關係將此檔案載入到 Pig 中,如下所示。
grunt> math_data = LOAD 'hdfs://:9000/pig_data/math.txt' USING PigStorage(',')
as (data:float);
現在,讓我們使用 **FLOOR()** 計算 math.txt 檔案內容的向下取整值,如下所示。
grunt> floor_data = foreach math_data generate (data), FLOOR(data);
上述語句將結果儲存在名為 **floor_data** 的關係中。使用 Dump 運算子驗證關係的內容,如下所示。
grunt> Dump floor_data; (5.0,5.0) (16.0,16.0) (9.0,9.0) (2.5,2.0) (5.9,5.0) (3.1,3.0)
apache_pig_math_functions.htm
廣告