0

cassandra-thrift-1.1.2.jar

問題コード:

            ColumnOrSuperColumn cosc = null;
        org.apache.cassandra.thrift.Column c = 新しい org.apache.cassandra.thrift.Column ();
        c.setName ("full_name".getBytes ("UTF-8"));
        c.setValue ("テスト名".getBytes ("UTF-8"));
        c.setTimestamp (System.currentTimeMillis());

        // データを挿入
// 長いタイムスタンプ = System.currentTimeMillis();

        試す {
            client.set_keyspace("CClient");

            bb=ByteBuffer.allocate (10);
            client.insert (bb.putInt(1),
                            新しい ColumnParent (「ユーザー」)、
                            c、
                            ConsistencyLevel.QUORUM);
            bb.putInt (2);
            cosc = client.get (bb, cp, ConsistencyLevel.QUORUM);
        }
        catch (TimedOutException toe) {
            System.out.println (toe.getMessage());
        }
        catch (org.apache.cassandra.thrift.UnavailableException e) {
            // TODO 自動生成された catch ブロック
            e.printStackTrace();
        }
        キャッチ (例外 e) {
            e.printStackTrace();
        }
        最後に {
            System.out.println (新しい文字列 (cosc.getColumn().getName()) + "-" + 新しい文字列 (cosc.getColumn().getValue()));
        }

上記のコードは、ジャンクまたは null をデータベースに挿入しますが、その理由がわかりません。

CLI でどのように表示されるかを確認します。

 
行キー:
=> (列 = フルネーム、値 = テスト名、タイムスタンプ = 1345743985973)

これについての助けは大歓迎です。

ありがとう。

4

1 に答える 1

0

行キーをバイトとして行を作成しています。Cassandra cli では、行をバイトとしてリストすると、おそらく行キーが表示されます。たとえば、cassandra cli タイプで
は、ユーザーのキーをバイトとして想定します。
ユーザーを一覧表示します。

于 2012-08-27T19:53:21.397 に答える