레이블이 decimal to hexadecimal인 게시물을 표시합니다. 모든 게시물 표시
레이블이 decimal to hexadecimal인 게시물을 표시합니다. 모든 게시물 표시

2015년 10월 4일 일요일

[MSSQL] Convert decimal to hexadecimal, hexadecimal to decimal ( Big Int )

1. Convert decimal to hexadecimal ( decimal data type: bigint )
SELECT CONVERT(VARCHAR(16),CONVERT(VARBINARY(8), CONVERT(BIGINT, 9223372036854775807 )),2) AS DEC2HEX







2. Convert hexadecimal to decimal ( decimal data type: bigint )
SELECT CONVERT(BIGINT,CONVERT(VARBINARY(8),'7FFFFFFFFFFFFFFF',2))  AS HEX2DEC

2015년 8월 26일 수요일

[PIG] Calling Static Java Functions

1. Syntax
DEFINE alias GenericInvoker(String fullName)
DEFINE alias GenericInvoker(String fullName, String paramSpecsStr)
DEFINE alias GenericInvoker(String fullName, String paramSpecsStr, String isStatic)
2. Terms
alias: UDF 함수 이름 지정
GenericInvoker: return type에 따라 InvokeForInt, InvokeForLong, InvokeForFloat, InvokeForDouble, InvokeForString 중 택 1
fullName: Java Method 지정
paramSpecsStr: 매개변수 type 지정
isStatic: Static 여부 지정, Default = 'true'

3. Example 1
decimal to hexadecimal
DEFINE IntToHex InvokeForString('java.lang.Integer.toHexString', 'int');
pvd = load 'PageViewData' as (exchange, symbol, date, open, high, low, close, volume, str_hex);
inhex = foreach pvd {
generate symbol, IntToHex((int)volume);
}

4. Example 2
hexadecimal to decimal ( Long )
DEFINE Hex2Long InvokeForLong('java.lang.Long.parseLong', 'String int');
pvd = load 'PageViewData' as (exchange, symbol, date, open, high, low, close, volume, str_hex);
hexLong = foreach pvd {
generate symbol, Hex2Long(str_hex, 16);
}

5. 참고 link
https://www.safaribooksonline.com/library/view/programming-pig/9781449317881/ch05s04.html
http://pig.apache.org/docs/r0.10.0/api/org/apache/pig/builtin/GenericInvoker.html
http://www.tutorialspoint.com/java/lang/long_parselong_radix.htm

추천 게시물

python: SVD(Singular Value Decomposition)로 간단한 추천시스템 만들기( feat. surprise )

svd_example In [15]: # !pip install surprise In [21]: from...