VariableSizeFrame(VSizeFrame) support for Asterix (Runtime Only)
Apply the https://asterix-gerrit.ics.uci.edu/#/c/234/ API changes to
Asterix level.
Change-Id: I5459e877707a1494fc1bebf03d4457a7427e9e0f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/259
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultReader.java b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultReader.java
index ad21dd1..a64f350 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultReader.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultReader.java
@@ -14,12 +14,9 @@
*/
package edu.uci.ics.asterix.result;
-import java.nio.ByteBuffer;
-
-import edu.uci.ics.asterix.common.config.AsterixCompilerProperties;
-import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.om.util.AsterixAppContextInfo;
import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
+import edu.uci.ics.hyracks.api.comm.IFrame;
import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
import edu.uci.ics.hyracks.api.dataset.DatasetJobRecord.Status;
import edu.uci.ics.hyracks.api.dataset.IHyracksDataset;
@@ -47,15 +44,15 @@
public void open(JobId jobId, ResultSetId resultSetId) throws HyracksDataException {
reader = hyracksDataset.createReader(jobId, resultSetId);
- frameTupleAccessor = new ResultFrameTupleAccessor(FRAME_SIZE);
+ frameTupleAccessor = new ResultFrameTupleAccessor();
}
public Status getStatus() {
return reader.getResultStatus();
}
- public int read(ByteBuffer buffer) throws HyracksDataException {
- return reader.read(buffer);
+ public int read(IFrame frame) throws HyracksDataException {
+ return reader.read(frame);
}
public IFrameTupleAccessor getFrameTupleAccessor() {
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
index 326697f..3a4fd5f 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
@@ -20,7 +20,6 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
@@ -37,8 +36,11 @@
import edu.uci.ics.asterix.api.http.servlet.APIServlet;
import edu.uci.ics.asterix.om.types.ARecordType;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.api.comm.IFrame;
import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
+import edu.uci.ics.hyracks.api.comm.VSizeFrame;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.control.nc.resources.memory.FrameManager;
import edu.uci.ics.hyracks.dataflow.common.comm.util.ByteBufferInputStream;
public class ResultUtils {
@@ -84,13 +86,14 @@
conf.out().print("\r\n");
}
+ public static FrameManager resultDisplayFrameMgr = new FrameManager(ResultReader.FRAME_SIZE);
+
public static void displayResults(ResultReader resultReader, SessionConfig conf)
throws HyracksDataException {
IFrameTupleAccessor fta = resultReader.getFrameTupleAccessor();
- ByteBuffer buffer = ByteBuffer.allocate(ResultReader.FRAME_SIZE);
- buffer.clear();
- int bytesRead = resultReader.read(buffer);
+ IFrame frame = new VSizeFrame(resultDisplayFrameMgr);
+ int bytesRead = resultReader.read(frame);
ByteBufferInputStream bbis = new ByteBufferInputStream();
// Whether we need to separate top-level ADM instances with commas
@@ -122,13 +125,13 @@
if (bytesRead > 0) {
do {
try {
- fta.reset(buffer);
+ fta.reset(frame.getBuffer());
int last = fta.getTupleCount();
String result;
for (int tIndex = 0; tIndex < last; tIndex++) {
int start = fta.getTupleStartOffset(tIndex);
int length = fta.getTupleEndOffset(tIndex) - start;
- bbis.setByteBuffer(buffer, start);
+ bbis.setByteBuffer(frame.getBuffer(), start);
byte[] recordBytes = new byte[length];
int numread = bbis.read(recordBytes, 0, length);
if (conf.fmt() == OutputFormat.CSV) {
@@ -146,7 +149,7 @@
conf.out().print("\r\n");
}
}
- buffer.clear();
+ frame.getBuffer().clear();
} finally {
try {
bbis.close();
@@ -154,7 +157,7 @@
throw new HyracksDataException(e);
}
}
- } while (resultReader.read(buffer) > 0);
+ } while (resultReader.read(frame) > 0);
}
conf.out().flush();
diff --git a/asterix-app/src/main/java/edu/uci/ics/hyracks/dataflow/std/misc/ConstantTupleSourceOperatorNodePushable.java b/asterix-app/src/main/java/edu/uci/ics/hyracks/dataflow/std/misc/ConstantTupleSourceOperatorNodePushable.java
index 4cfb8c6..4ee37ba 100644
--- a/asterix-app/src/main/java/edu/uci/ics/hyracks/dataflow/std/misc/ConstantTupleSourceOperatorNodePushable.java
+++ b/asterix-app/src/main/java/edu/uci/ics/hyracks/dataflow/std/misc/ConstantTupleSourceOperatorNodePushable.java
@@ -15,8 +15,7 @@
package edu.uci.ics.hyracks.dataflow.std.misc;
-import java.nio.ByteBuffer;
-
+import edu.uci.ics.hyracks.api.comm.VSizeFrame;
import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.comm.io.FrameTupleAppender;
@@ -41,14 +40,12 @@
@Override
public void initialize() throws HyracksDataException {
- ByteBuffer writeBuffer = ctx.allocateFrame();
- FrameTupleAppender appender = new FrameTupleAppender(ctx.getFrameSize());
- appender.reset(writeBuffer, true);
+ FrameTupleAppender appender = new FrameTupleAppender(new VSizeFrame(ctx));
if (fieldSlots != null && tupleData != null && tupleSize > 0)
appender.append(fieldSlots, tupleData, 0, tupleSize);
writer.open();
try {
- FrameUtils.flushFrame(writeBuffer, writer);
+ appender.flush(writer, true);
}
finally {
writer.close();
diff --git a/asterix-app/src/main/resources/asterix-build-configuration.xml b/asterix-app/src/main/resources/asterix-build-configuration.xml
index 03f2f0e..9ac89e7 100644
--- a/asterix-app/src/main/resources/asterix-build-configuration.xml
+++ b/asterix-app/src/main/resources/asterix-build-configuration.xml
@@ -47,15 +47,15 @@
</property>
<property>
<name>compiler.sortmemory</name>
- <value>98304</value>
+ <value>163840</value>
</property>
<property>
<name>compiler.groupmemory</name>
- <value>98304</value>
+ <value>163840</value>
</property>
<property>
<name>compiler.joinmemory</name>
- <value>131072</value>
+ <value>163840</value>
</property>
<property>
<name>storage.buffercache.pagesize</name>