私は読んでCassandra- The definitive guide by E.Hewitt
います。私は、サンプル ホテル アプリケーションのコードについて著者が説明している第 4 章にいます。本の画像を参考までに載せておきます。
HotelByCityに挿入する方法はrowkeys
次のとおりです。column Family
private void insertByCityIndex(String rowKey, String hotelName) throws Exception {
Clock clock = new Clock(System.nanoTime());
Column nameCol = new Column(hotelName.getBytes(UTF8), new byte[0], clock);
ColumnOrSuperColumn nameCosc = new ColumnOrSuperColumn();
nameCosc.column = nameCol;
Mutation nameMut = new Mutation();
nameMut.column_or_supercolumn = nameCosc;
//set up the batch
Map<String, Map<String, List<Mutation>>> mutationMap =
new HashMap<String, Map<String, List<Mutation>>>();
Map<String, List<Mutation>> muts =
new HashMap<String, List<Mutation>>();
List<Mutation> cols = new ArrayList<Mutation>();
cols.add(nameMut);
String columnFamily = "HotelByCity";
muts.put(columnFamily, cols);
//outer map key is a row key
//inner map key is the column family name
mutationMap.put(rowKey, muts);
//create representation of the column
ColumnPath cp = new ColumnPath(columnFamily);
cp.setColumn(hotelName.getBytes(UTF8));
ColumnParent parent = new ColumnParent(columnFamily);
//here, the column name IS the value (there's no value)
Column col = new Column(hotelName.getBytes(UTF8), new byte[0], clock);
client.insert(rowKey.getBytes(), parent, col, CL);
LOG.debug("Inserted HotelByCity index for " + hotelName); } //end inserting ByCity index
コードをたどるのに苦労しています。特に、非常に多くのコンテナー (マップ) が作成される理由です。Mutation
オブジェクトなどの目的は何ですか?行キーはどのくらい正確に挿入されますか?
コードの各ステップで何が起こっているのかを説明できれば、それは素晴らしいことです。この本には説明がなく、私はこれがどのように行われるかを理解することができません.
PS: 私は Java 開発者です。だから私はマップなどに精通していますが、マップが別のマップの中に詰め込まれている理由やその他の詳細については知りません
ありがとう