コード例 #1
0
        internal VersionEntry GetVersionEntryByKey(string tableId, object recordKey, long versionKey, VersionEntry ve)
        {
            var rs = this.CQLExecute(string.Format(PartitionedCassandraVersionTable.CQL_GET_VERSION_ENTRY,
                                                   tableId, recordKey.ToString(), versionKey));
            var rse = rs.GetEnumerator();

            rse.MoveNext();
            Row row = rse.Current;

            if (row == null)
            {
                return(null);
            }

            if (ve == null)
            {
                return(new VersionEntry(versionKey, row.GetValue <long>("begintimestamp"),
                                        row.GetValue <long>("endtimestamp"),
                                        BytesSerializer.Deserialize(row.GetValue <byte[]>("record")),
                                        row.GetValue <long>("txid"),
                                        row.GetValue <long>("maxcommitts")));
            }
            else
            {
                ve.Set(
                    versionKey, row.GetValue <long>("begintimestamp"),
                    row.GetValue <long>("endtimestamp"),
                    BytesSerializer.Deserialize(row.GetValue <byte[]>("record")),
                    row.GetValue <long>("txid"),
                    row.GetValue <long>("maxcommitts"));

                return(ve);
            }
        }
コード例 #2
0
        internal override void Visit(GetVersionListRequest req)
        {
            List <VersionEntry> entries = new List <VersionEntry>();
            var rs = this.CQLExecute(string.Format(CassandraVersionTable.CQL_GET_VERSION_TOP_2,
                                                   req.TableId, req.RecordKey.ToString()));

            foreach (var row in rs)
            {
                entries.Add(new VersionEntry(
                                row.GetValue <long>("versionkey"),
                                row.GetValue <long>("begintimestamp"),
                                row.GetValue <long>("endtimestamp"),
                                BytesSerializer.Deserialize(row.GetValue <byte[]>("record")),
                                row.GetValue <long>("txid"),
                                row.GetValue <long>("maxcommitts")
                                ));
            }

            req.Result   = entries;
            req.Finished = true;
        }
コード例 #3
0
        internal override void Visit(GetVersionListRequest req)
        {
            var rs = this.CQLExecute(string.Format(PartitionedCassandraVersionTable.CQL_GET_VERSION_TOP_2,
                                                   req.TableId, req.RecordKey.ToString()));
            int cnt = 0;

            foreach (var row in rs)
            {
                req.LocalContainer[cnt].Set(
                    row.GetValue <long>("versionkey"),
                    row.GetValue <long>("begintimestamp"),
                    row.GetValue <long>("endtimestamp"),
                    BytesSerializer.Deserialize(row.GetValue <byte[]>("record")),
                    row.GetValue <long>("txid"),
                    row.GetValue <long>("maxcommitts")
                    );
                cnt += 1;
            }

            req.Result   = cnt;
            req.Finished = true;
        }
コード例 #4
0
ファイル: VersionEntry.cs プロジェクト: GerHobbelt/GraphView
        /// <summary>
        /// Deserialize a version entry by the given recordKey, versionKey and content bytes
        /// </summary>
        /// <param name="recordKey"></param>
        /// <param name="versionKey"></param>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static VersionEntry Deserialize(long versionKey, byte[] bytes, VersionEntry versionEntry = null)
        {
            long beginTimestamp = BitConverter.ToInt64(bytes, VersionEntry.BEGIN_TIMESTAMP_OFFSET);
            long endTimestamp   = BitConverter.ToInt64(bytes, VersionEntry.END_TIMESTAMP_OFFSET);
            long txId           = BitConverter.ToInt64(bytes, VersionEntry.TXID_OFFSET);
            long maxCommitTs    = BitConverter.ToInt64(bytes, VersionEntry.MAX_COMMIT_TS_OFFSET);

            byte[] recordBytes = new byte[bytes.Length - VersionEntry.RECORD_OFFSET];
            Buffer.BlockCopy(bytes, VersionEntry.RECORD_OFFSET, recordBytes, 0, recordBytes.Length);
            object record = BytesSerializer.Deserialize(recordBytes);

            if (versionEntry == null)
            {
                return(new VersionEntry(versionKey, beginTimestamp, endTimestamp,
                                        record, txId, maxCommitTs));
            }
            else
            {
                versionEntry.Set(versionKey, beginTimestamp, endTimestamp,
                                 record, txId, maxCommitTs);
                return(versionEntry);
            }
        }