Repository: cassandra
Updated Branches:
  refs/heads/trunk 41c11262a -> c2acf4716 (forced update)


Make ResultSetBuilder.rowToJson public

patch by Berenguer Blasi; reviewed by Aleksey Yeschenko for
CASSANDRA-11526


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c2acf471
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c2acf471
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c2acf471

Branch: refs/heads/trunk
Commit: c2acf47168d3f03af0cd68cbd5570c84a321d713
Parents: 1aeeff4
Author: Bereng <berenguerbl...@gmail.com>
Authored: Thu Apr 7 17:52:16 2016 +0100
Committer: Aleksey Yeschenko <alek...@apache.org>
Committed: Mon Apr 11 18:32:37 2016 +0100

----------------------------------------------------------------------
 .../cassandra/cql3/selection/Selection.java     | 54 ++++++++++----------
 1 file changed, 27 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c2acf471/src/java/org/apache/cassandra/cql3/selection/Selection.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/selection/Selection.java 
b/src/java/org/apache/cassandra/cql3/selection/Selection.java
index e0e1bd8..3bee743 100644
--- a/src/java/org/apache/cassandra/cql3/selection/Selection.java
+++ b/src/java/org/apache/cassandra/cql3/selection/Selection.java
@@ -258,6 +258,32 @@ public abstract class Selection
                 .toString();
     }
 
+    public static List<ByteBuffer> rowToJson(List<ByteBuffer> row, int 
protocolVersion, ResultSet.ResultMetadata metadata)
+    {
+        StringBuilder sb = new StringBuilder("{");
+        for (int i = 0; i < metadata.names.size(); i++)
+        {
+            if (i > 0)
+                sb.append(", ");
+
+            ColumnSpecification spec = metadata.names.get(i);
+            String columnName = spec.name.toString();
+            if (!columnName.equals(columnName.toLowerCase(Locale.US)))
+                columnName = "\"" + columnName + "\"";
+
+            ByteBuffer buffer = row.get(i);
+            sb.append('"');
+            sb.append(Json.quoteAsJsonString(columnName));
+            sb.append("\": ");
+            if (buffer == null)
+                sb.append("null");
+            else
+                sb.append(spec.type.toJSONString(buffer, protocolVersion));
+        }
+        sb.append("}");
+        return 
Collections.singletonList(UTF8Type.instance.getSerializer().serialize(sb.toString()));
+    }
+
     public class ResultSetBuilder
     {
         private final ResultSet resultSet;
@@ -367,35 +393,9 @@ public abstract class Selection
         private List<ByteBuffer> getOutputRow(int protocolVersion)
         {
             List<ByteBuffer> outputRow = 
selectors.getOutputRow(protocolVersion);
-            return isJson ? rowToJson(outputRow, protocolVersion)
+            return isJson ? rowToJson(outputRow, protocolVersion, metadata)
                           : outputRow;
         }
-
-        private List<ByteBuffer> rowToJson(List<ByteBuffer> row, int 
protocolVersion)
-        {
-            StringBuilder sb = new StringBuilder("{");
-            for (int i = 0; i < metadata.names.size(); i++)
-            {
-                if (i > 0)
-                    sb.append(", ");
-
-                ColumnSpecification spec = metadata.names.get(i);
-                String columnName = spec.name.toString();
-                if (!columnName.equals(columnName.toLowerCase(Locale.US)))
-                    columnName = "\"" + columnName + "\"";
-
-                ByteBuffer buffer = row.get(i);
-                sb.append('"');
-                sb.append(Json.quoteAsJsonString(columnName));
-                sb.append("\": ");
-                if (buffer == null)
-                    sb.append("null");
-                else
-                    sb.append(spec.type.toJSONString(buffer, protocolVersion));
-            }
-            sb.append("}");
-            return 
Collections.singletonList(UTF8Type.instance.getSerializer().serialize(sb.toString()));
-        }
     }
 
     private static interface Selectors

Reply via email to