سؤال

أساسا أنا أسأل نفس الشيء كما هو الحال في هذا سؤال ولكن بالنسبة لمكتبة بيثون كاساندرا، Pycassa.

دعونا نقول أن لديك بيانات تخزين من النوع المركزة مثل هذا: giveacodicetagpre.

لذلك، أعلم أنني أستطيع بسهولة شريحة خارج الجزء الأول من النوع المركب من خلال القيام: giveacodicetagpre.

ولكن إذا كنت أريد فقط Finalscore، فسوف أفترض أنني أستطيع القيام به: giveacodicetagpre.

للحصول على: giveacodicetagpre.

ولكن بدلا من ذلك، أحصل على: giveacodicetagpre.

نفس المكالمة الأولى.

هل أفعل شيئا خطأ؟ يجب أن هذا العمل؟ أو هل يوجد بعض بناء الجملة باستخدام CF.GET (... الأعمدة= [('20120216'، 'Finalscore')])؟ حاولت ذلك أيضا وحصلت على استثناء.

وفقا ل http://www.datastax .com / dev / blog / مقدمة-مركب أعمدة-1 ، يجب أن أكون قادرا على القيام بشيء مثل هذا ...

شكرا

هل كانت مفيدة؟

المحلول

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').

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top