Frage

Grundsätzlich frage ich das Gleiche wie in dies Frage , aber für die Python Cassandra-Bibliothek, Pycassa.

lassen Sie sagen, dass Sie ein Composite-Typ-Speichern von Daten wie diesem haben: generasacodicetagpre.

Ich weiß, dass ich leicht vom ersten Teil des zusammengesetzten Typs scheiben kann, indem ich: generasacodicetagpre.

Wenn ich aber nur das Finalcore will, würde ich davon ausgehen, dass ich tun könnte: generasacodicetagpre.

zu bekommen: generasacodicetagpre.

aber stattdessen bekomme ich: generasacodicetagpre.

gleich wie der erste Anruf.

Mache ich etwas falsch? Sollte das funktionieren? Oder gibt es eine Syntax mit der cf.get (... Spalten= [('20120216', 'Finalcore')])? Ich habe das auch ausprobiert und eine Ausnahme bekommen.

nach http://www.datastax .com / dev / blog / Einführung-zu-Composite-Säulen-Teil-1 , ich sollte in der Lage sein, so etwas zu tun ...

danke

War es hilfreich?

Lösung

If know all the components of the composite column then you should the 'columns' option:

cf.get('1234', columns=[('20120216', 'finalscore')])

You said you got an error trying to do this, but I would suggest trying again. It works fine for me.

When you are slicing composite columns you need to think about how they are sorted. Composite columns sort starting first with the left most component, and then sorting each component toward the right. So In your example the columns would look like this:

+------------+---------------+------------+---------------+------------+----------------+
| 20120216   | 20120216      | 20120221   | 20120221      | 20120228   | 20120228       |
| finalscore | halftimescore | finalscore | halftimescore | finalscore | halftimescore  |
+------------+---------------+------------+---------------+------------+----------------+

Thus when you slice from ('20120216', 'finalscore') to ('20120221', 'finalscore') you get both values for '20120216'. To make your query work as you want it to you could change the column_finish to ('20120216', 'halftimescore').

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top