14

CQLSHでテスト目的でテキストまたは文字列をblobとして挿入しようとしていました

insert into test_by_score (commit, delta, test, score)
       values (textAsBlob('bdb14fbe076f6b94444c660e36a400151f26fc6f'), 0,
       textAsBlob('{"prefix": "enwiki", "title": "\"Aghnadarragh\""}'), 100);

私がやった後、それは本当にうまくいきませんでした:

select * from test_by_score where commit = 0x0b5db8b91bfdeb0a304b372dd8dda123b3fd1ab6;

列が0個あると言われました...これは少し予想外でした(エラーが発生しなかったため)が、textAsBlobはcqlshのものではないと思います。それでは、誰かがこれを行う方法を知っていますか?


スキーマ:

CREATE TABLE IF NOT EXISTS test_by_score (
    commit blob, 
    delta int, 
    score int, 
    test blob, 
    PRIMARY KEY(commit, delta, test)
);

私の質問はこの特定のスキーマに関するものではないと思うので、少ししぶしぶスキーマを投稿しました。私が知りたいのは、ブロブを保持する列が1つある場合、最初にブロブに変更してからcqlshに挿入することで、その位置に文字列を挿入することは可能ですか?

4

1 に答える 1

17

以下は動作しているようです。WHEREステートメントの条件がSELECT、間違った hex にアクセスしようとしている可能性があります0x0b5db8b91bfdeb0a304b372dd8dda123b3fd1ab6

DROP KEYSPACE example;
CREATE KEYSPACE example WITH replication = {'class':'SimpleStrategy', 'replication_factor':1};
USE example;

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 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": "enwiki", "title": "\"Aghnadarragh\""}'), 100
);

INSERT INTO test_by_score (commit, delta, test, score) VALUES (
  textAsBlob('adb14fbe076f6b94444c660e36a400151f26fc6f'), 0, textAsBlob('{"prefix": "enwiki", "title": "\"Aghnadarragh\""}'), 100
);

すべての行を取得するには

SELECT * FROM example.test_by_score 

特定の行を選択します。

SELECT * FROM example.test_by_score 
  WHERE commit = 0x62646231346662653037366636623934343434633636306533366134303031353166323666633666;
于 2014-04-23T05:34:47.113 に答える