You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2015/03/12 23:05:05 UTC
phoenix git commit: Transaction util class
Repository: phoenix
Updated Branches:
refs/heads/txn be8836662 -> 8d5e3691b
Transaction util class
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8d5e3691
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8d5e3691
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8d5e3691
Branch: refs/heads/txn
Commit: 8d5e3691bf63e03aec4c86a9d009f5592c1aede4
Parents: be88366
Author: James Taylor <jt...@salesforce.com>
Authored: Thu Mar 12 15:05:10 2015 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Thu Mar 12 15:05:10 2015 -0700
----------------------------------------------------------------------
.../apache/phoenix/util/TransactionUtil.java | 47 ++++++++++++++++++++
1 file changed, 47 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/8d5e3691/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
new file mode 100644
index 0000000..08dc473
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.util;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import co.cask.tephra.Transaction;
+import co.cask.tephra.TransactionCodec;
+
+public class TransactionUtil {
+ private TransactionUtil() {
+ }
+
+ private static final TransactionCodec codec = new TransactionCodec();
+
+ public static byte[] encodeTxnState(Transaction txn) throws SQLException {
+ try {
+ return codec.encode(txn);
+ } catch (IOException e) {
+ throw new SQLException(e);
+ }
+ }
+
+ public static Transaction decodeTxnState(byte[] txnBytes) throws SQLException {
+ try {
+ return codec.decode(txnBytes);
+ } catch (IOException e) {
+ throw new SQLException(e);
+ }
+ }
+}