Mercurial > hg > Database > Cassandra
comparison src/java/org/apache/cassandra/db/Row.java @ 0:d485154379c8 default tip
apache-cassandra-0.6.0-rc1-src
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 02 Apr 2010 13:36:02 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d485154379c8 |
---|---|
1 /** | |
2 * Licensed to the Apache Software Foundation (ASF) under one | |
3 * or more contributor license agreements. See the NOTICE file | |
4 * distributed with this work for additional information | |
5 * regarding copyright ownership. The ASF licenses this file | |
6 * to you under the Apache License, Version 2.0 (the | |
7 * "License"); you may not use this file except in compliance | |
8 * with the License. You may obtain a copy of the License at | |
9 * | |
10 * http://www.apache.org/licenses/LICENSE-2.0 | |
11 * | |
12 * Unless required by applicable law or agreed to in writing, software | |
13 * distributed under the License is distributed on an "AS IS" BASIS, | |
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 * See the License for the specific language governing permissions and | |
16 * limitations under the License. | |
17 */ | |
18 | |
19 package org.apache.cassandra.db; | |
20 | |
21 import java.io.DataInputStream; | |
22 import java.io.DataOutputStream; | |
23 import java.io.IOException; | |
24 import java.util.Collection; | |
25 import java.security.MessageDigest; | |
26 import java.security.NoSuchAlgorithmException; | |
27 | |
28 import org.apache.log4j.Logger; | |
29 | |
30 import org.apache.cassandra.io.ICompactSerializer; | |
31 | |
32 public class Row | |
33 { | |
34 private static Logger logger_ = Logger.getLogger(Row.class); | |
35 private static RowSerializer serializer = new RowSerializer(); | |
36 | |
37 static RowSerializer serializer() | |
38 { | |
39 return serializer; | |
40 } | |
41 | |
42 public final String key; | |
43 public final ColumnFamily cf; | |
44 | |
45 public Row(String key, ColumnFamily cf) | |
46 { | |
47 assert key != null; | |
48 // cf may be null, indicating no data | |
49 this.key = key; | |
50 this.cf = cf; | |
51 } | |
52 | |
53 @Override | |
54 public String toString() | |
55 { | |
56 return "Row(" + | |
57 "key='" + key + '\'' + | |
58 ", cf=" + cf + | |
59 ')'; | |
60 } | |
61 } | |
62 | |
63 class RowSerializer implements ICompactSerializer<Row> | |
64 { | |
65 public void serialize(Row row, DataOutputStream dos) throws IOException | |
66 { | |
67 dos.writeUTF(row.key); | |
68 ColumnFamily.serializer().serialize(row.cf, dos); | |
69 } | |
70 | |
71 public Row deserialize(DataInputStream dis) throws IOException | |
72 { | |
73 return new Row(dis.readUTF(), ColumnFamily.serializer().deserialize(dis)); | |
74 } | |
75 } |