Cassandra blob type
- Blob 데이터 형식은 0 [xX] (hex) +로 정의 된 16 진수 상수
- 여기서 16 진수는 [0-9a-fA-F]와 같은 16 진수 문자. 예를 들어 0xcafe
- Blob의 최대 이론적 크기는 2GB
- 실제 제한은 1MB 미만
- Blob 유형은 작은 이미지 또는 짧은 문자열을 저장하는 데 적합
blob 변환 함수
- typeAsBlob (값) : CQL에서 지원하는 모든 기본 비 블롭 데이터 유형에 대해 해당 데이터 유형의 인수를 가져와이를 블롭으로 리턴
- blobAsType (값) : 64 비트 blob 인수를 사용하여 가능한 경우 지정된 데이터 유형의 값으로 변환
사용예 : textAsBlob
테이블 생성
CREATE TABLE IF NOT EXISTS test_by_score (
commit blob, -- blob representing the commit hash
delta int, -- how much the scores have changed
score int, -- the test score, which is determined by the client
test blob, -- blob for the test
PRIMARY KEY(commit, delta, test)
);
데이터 Insert
INSERT INTO test_by_score (commit, delta, test, score) VALUES(textAsBlob('bdb14fbe076f6b94444c660e36a400151f26fc6f'), 0, textAsBlob('{"prefix": "enwiki", "title": "\"Aghnadarragh\""}'), 100);
INSERT INTO test_by_score (commit, delta, test, score) VALUES (textAsBlob('cdb14fbe076f6b94444c660e36a400151f26fc6f'), 0, textAsBlob('{"prefix": "enwiki1", "title": "\"Aghnadarragh2\""}'), 100);
INSERT INTO test_by_score (commit, delta, test, score) VALUES (textAsBlob('adb14fbe076f6b94444c660e36a400151f26fc6f'), 0, textAsBlob('{"prefix": "enwiki2", "title": "\"Aghnadarragh3\""}'), 100);
PS. COPY FROM 명령어를 사용하여 CSV 파일로 데이터를 넣으보려고 했지만 지원을 안하는 것 같다.
https://issues.apache.org/jira/browse/CASSANDRA-11375
참고 사이트
https://www.geeksforgeeks.org/blob-conversion-function-in-cassandra/
https://docs.datastax.com/en/dse/5.1/cql/cql/cql_using/refBlob.html
'Database > Cassandra' 카테고리의 다른 글
[Cassandra] Compression Configuration (0) | 2020.06.03 |
---|---|
[Cassandra][datastax]Logical_Mapping Patterns (0) | 2020.05.27 |
[Cassandra][datastax]Logical Mapping Rules (0) | 2020.05.27 |