Revert "[NO ISSUE][RT] Profiling fixes"

This reverts commit c775dd9d2c01a66b9f2da8447c75400bac6ddf90.

Reason for revert: makes CB test hang now?

Change-Id: I64a67157d2485741edb7cc2890ae80ab84c70ee5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/4803
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
index a5c8162..c0cf8eb 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/IStatementExecutor.java
@@ -54,15 +54,11 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
 
 /**
  * An interface that takes care of executing a list of statements that are submitted through an Asterix API
  */
 public interface IStatementExecutor {
-    public static final char UNIT_SEPARATOR = 31;
-    public static final char END_OF_BLOCK = 23;
 
     /**
      * Specifies result delivery of executed statements
@@ -204,35 +200,12 @@
 
         private void writeObject(ObjectOutputStream out) throws IOException {
             ObjectMapper om = new ObjectMapper();
-            java.lang.String prof = om.writeValueAsString(profile);
-            //split the string if it is >=64K to avoid writeUTF limit
-            List<String> pieces;
-            if (prof.length() > 65534L) {
-                pieces = Lists.newArrayList(Splitter.fixedLength(32768).split(prof));
-            } else {
-                pieces = Lists.newArrayList(prof);
-            }
-
-            for (int i = 0; i < pieces.size(); i++) {
-                if (i == pieces.size() - 1) {
-                    out.writeChar(UNIT_SEPARATOR);
-                } else {
-                    out.writeChar(END_OF_BLOCK);
-                }
-                out.writeUTF(pieces.get(i));
-            }
-
+            out.writeUTF(om.writeValueAsString(profile));
         }
 
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             ObjectMapper om = new ObjectMapper();
-            StringBuilder objSplits = new StringBuilder();
-            for (char cmd = in.readChar(); cmd != END_OF_BLOCK && cmd == UNIT_SEPARATOR; cmd = in.readChar()) {
-                objSplits.append(in.readUTF());
-            }
-            objSplits.append(in.readUTF());
-
-            JsonNode inNode = om.readTree(objSplits.toString());
+            JsonNode inNode = om.readTree(in.readUTF());
             if (!inNode.isObject()) {
                 throw new IOException("Deserialization error");
             }
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/TimedOperatorNodePushable.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/TimedOperatorNodePushable.java
index 1d47c98..2d46bea 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/TimedOperatorNodePushable.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/TimedOperatorNodePushable.java
@@ -33,7 +33,7 @@
     HashMap<Integer, IFrameWriter> inputs;
     long frameStart;
 
-    private TimedOperatorNodePushable(IOperatorNodePushable op, IStatsCollector collector) {
+    TimedOperatorNodePushable(IOperatorNodePushable op, IStatsCollector collector) throws HyracksDataException {
         super(null, collector, op.getDisplayName());
         this.op = op;
         inputs = new HashMap<>();
@@ -41,16 +41,20 @@
 
     @Override
     public void initialize() throws HyracksDataException {
-        startClock();
-        op.initialize();
-        stopClock();
+        synchronized (collector) {
+            startClock();
+            op.initialize();
+            stopClock();
+        }
     }
 
     @Override
     public void deinitialize() throws HyracksDataException {
-        startClock();
-        op.deinitialize();
-        stopClock();
+        synchronized (collector) {
+            startClock();
+            op.deinitialize();
+            stopClock();
+        }
     }
 
     @Override
@@ -79,19 +83,15 @@
     }
 
     private void stopClock() {
-        synchronized (collector) {
-            pause();
-            collector.giveClock(this);
-        }
+        pause();
+        collector.giveClock(this);
     }
 
     private void startClock() {
-        synchronized (collector) {
-            if (frameStart > 0) {
-                return;
-            }
-            frameStart = collector.takeClock(this);
+        if (frameStart > 0) {
+            return;
         }
+        frameStart = collector.takeClock(this);
     }
 
     @Override
@@ -113,11 +113,11 @@
         }
     }
 
-    public static IOperatorNodePushable time(IOperatorNodePushable op, IHyracksTaskContext ctx) {
+    public static IOperatorNodePushable time(IOperatorNodePushable op, IHyracksTaskContext ctx)
+            throws HyracksDataException {
         if (!(op instanceof TimedOperatorNodePushable) && !(op instanceof SuperActivityOperatorNodePushable)) {
             return new TimedOperatorNodePushable(op, ctx.getStatsCollector());
         }
         return op;
     }
-
 }