asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianf...@apache.org
Subject [01/15] incubator-asterixdb git commit: ASTERIXDB-1102: VarSize Encoding to store length of String and ByteArray
Date Thu, 29 Oct 2015 04:44:52 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 1eeb3d29c -> 742aba85e


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
index b964179..424d46b 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
@@ -39,8 +39,10 @@ import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+import org.apache.hyracks.util.string.UTF8StringWriter;
 
 public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynamicDescriptor
{
 
@@ -86,6 +88,9 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
 
                     private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
 
+                    private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
+                    private final UTF8StringWriter utf8Writer = new UTF8StringWriter();
+
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
                         argOut0.reset();
@@ -112,7 +117,9 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
 
-                            int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(),
3);
+                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() -
1);
+                            int timezone = ATimeParserFactory
+                                    .parseTimezonePart(utf8Ptr.getByteArray(), utf8Ptr.getCharStartOffset());
 
                             if (!calInstance.validateTimeZone(timezone)) {
                                 throw new AlgebricksException(FID.getName() + ": wrong format
for a time zone string!");
@@ -128,8 +135,7 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
                                     Fields.MILLISECOND, true);
 
                             out.writeByte(SER_STRING_TYPE_TAG);
-                            out.writeUTF(sbder.toString());
-
+                            utf8Writer.writeUTF8(sbder.toString(), out);
                         } catch (Exception e1) {
                             throw new AlgebricksException(e1);
                         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
index 13e1c5b..32e16e4 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
@@ -39,8 +39,10 @@ import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+import org.apache.hyracks.util.string.UTF8StringWriter;
 
 public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynamicDescriptor
{
 
@@ -85,6 +87,8 @@ public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynam
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
+                    private final UTF8StringWriter writer = new UTF8StringWriter();
+                    private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
@@ -112,7 +116,9 @@ public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynam
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
 
-                            int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(),
3);
+                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() -
1);
+                            int timezone = ATimeParserFactory
+                                    .parseTimezonePart(argOut1.getByteArray(), utf8Ptr.getCharStartOffset());
 
                             if (!calInstance.validateTimeZone(timezone)) {
                                 throw new AlgebricksException(FID.getName() + ": wrong format
for a time zone string!");
@@ -128,7 +134,7 @@ public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynam
                                     Fields.MILLISECOND, true);
 
                             out.writeByte(SER_STRING_TYPE_TAG);
-                            out.writeUTF(sbder.toString());
+                            writer.writeUTF8(sbder.toString(), out);
 
                         } catch (Exception e1) {
                             throw new AlgebricksException(e1);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
index 8ca047e..b1fbf7c 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
@@ -26,8 +26,8 @@ import org.apache.asterix.om.base.AMutableDate;
 import org.apache.asterix.om.base.ANull;
 import org.apache.asterix.om.base.temporal.AsterixTemporalTypeParseException;
 import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
-import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
 import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
+import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -42,13 +42,13 @@ import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 /**
  * <b>|(bar)</b> is a special separator used to separate different formatting
options.
  * Multiple format strings can be used by separating them using <b>|(bar)</b>,
and the parsing will be successful only when the format string has the <b>exact</b>
match with the given data string. This means that a time string like <it>08:23:12 AM</it>
will not be valid for the format string <it>h:m:s</it> as there is no AM/PM format
character in the format string.
- * <p/>
  */
 public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
@@ -91,6 +91,7 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                             .getSerializerDeserializer(BuiltinType.ADATE);
 
                     private AMutableDate aDate = new AMutableDate(0);
+                    private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
@@ -115,25 +116,28 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0])
                                         + ")");
                             }
-                            int length0 = (argOut0.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut0.getByteArray()[2] & 0xff << 0);
-                            int length1 = (argOut1.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut1.getByteArray()[2] & 0xff << 0);
+                            utf8Ptr.set(argOut0.getByteArray(), 1, argOut0.getLength() -
1);
+                            int start0 = utf8Ptr.getCharStartOffset();
+                            int length0 = utf8Ptr.getUTF8Length();
+
+                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() -
1);
+                            int start1 = utf8Ptr.getCharStartOffset();
+                            int length1 = utf8Ptr.getUTF8Length();
                             long chronon = 0;
 
-                            int formatStart = 3;
+                            int formatStart = start1;
                             int formatLength = 0;
                             boolean processSuccessfully = false;
-                            while (!processSuccessfully && formatStart < 3 + length1)
{
+                            while (!processSuccessfully && formatStart < start1
+ length1) {
                                 // search for "|"
                                 formatLength = 0;
-                                for (; formatStart + formatLength < 3 + length1; formatLength++)
{
+                                for (; formatStart + formatLength < start1 + length1;
formatLength++) {
                                     if (argOut1.getByteArray()[formatStart + formatLength]
== '|') {
                                         break;
                                     }
                                 }
                                 try {
-                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(),
3, length0,
+                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(),
start0, length0,
                                             argOut1.getByteArray(), formatStart, formatLength,
                                             DateTimeParseMode.DATE_ONLY);
                                 } catch (AsterixTemporalTypeParseException ex) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
index 44b4281..2a7be96 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
@@ -41,6 +41,7 @@ import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
@@ -85,6 +86,7 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                             .getSerializerDeserializer(BuiltinType.ADATETIME);
 
                     private AMutableDateTime aDateTime = new AMutableDateTime(0);
+                    private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
@@ -109,25 +111,28 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0])
                                         + ")");
                             }
-                            int length0 = (argOut0.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut0.getByteArray()[2] & 0xff << 0);
-                            int length1 = (argOut1.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut1.getByteArray()[2] & 0xff << 0);
+                            utf8Ptr.set(argOut0.getByteArray(), 1, argOut0.getLength()-1);
+                            int start0 = utf8Ptr.getCharStartOffset();
+                            int length0 = utf8Ptr.getUTF8Length();
+
+                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength()-1);
+                            int start1 = utf8Ptr.getCharStartOffset();
+                            int length1 = utf8Ptr.getUTF8Length();
                             long chronon = 0;
 
-                            int formatStart = 3;
+                            int formatStart = start1;
                             int formatLength = 0;
                             boolean processSuccessfully = false;
-                            while (!processSuccessfully && formatStart < 3 + length1)
{
+                            while (!processSuccessfully && formatStart < start1
+ length1) {
                                 // search for "|"
                                 formatLength = 0;
-                                for (; formatStart + formatLength < 3 + length1; formatLength++)
{
+                                for (; formatStart + formatLength < start1 + length1;
formatLength++) {
                                     if (argOut1.getByteArray()[formatStart + formatLength]
== '|') {
                                         break;
                                     }
                                 }
                                 try {
-                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(),
3, length0,
+                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(),
start0, length0,
                                             argOut1.getByteArray(), formatStart, formatLength,
                                             DateTimeParseMode.DATETIME);
                                 } catch (AsterixTemporalTypeParseException ex) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
index a5cec47..007ddca 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
@@ -41,6 +41,7 @@ import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
@@ -85,6 +86,7 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                             .getSerializerDeserializer(BuiltinType.ATIME);
 
                     private AMutableTime aTime = new AMutableTime(0);
+                    private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
@@ -109,25 +111,28 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0])
                                         + ")");
                             }
-                            int length0 = (argOut0.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut0.getByteArray()[2] & 0xff << 0);
-                            int length1 = (argOut1.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut1.getByteArray()[2] & 0xff << 0);
+                            utf8Ptr.set(argOut0.getByteArray(), 1, argOut0.getLength()-1);
+                            int start0 = utf8Ptr.getCharStartOffset();
+                            int length0 = utf8Ptr.getUTF8Length();
+
+                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() -1);
+                            int start1 = utf8Ptr.getCharStartOffset();
+                            int length1 = utf8Ptr.getUTF8Length();
                             long chronon = 0;
 
-                            int formatStart = 3;
+                            int formatStart = start1;
                             int formatLength = 0;
                             boolean processSuccessfully = false;
-                            while (!processSuccessfully && formatStart < 3 + length1)
{
+                            while (!processSuccessfully && formatStart < start1
+ length1) {
                                 // search for "|"
                                 formatLength = 0;
-                                for (; formatStart + formatLength < 3 + length1; formatLength++)
{
+                                for (; formatStart + formatLength < start1 + length1;
formatLength++) {
                                     if (argOut1.getByteArray()[formatStart + formatLength]
== '|') {
                                         break;
                                     }
                                 }
                                 try {
-                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(),
3, length0,
+                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(),
start0, length0,
                                             argOut1.getByteArray(), formatStart, formatLength,
                                             DateTimeParseMode.TIME_ONLY);
                                 } catch (AsterixTemporalTypeParseException ex) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
index c56aa8e..d731fff 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
@@ -25,8 +25,8 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADateSerializerDeseriali
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ANull;
 import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
-import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
 import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
+import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -42,6 +42,8 @@ import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+import org.apache.hyracks.util.string.UTF8StringUtil;
+import org.apache.hyracks.util.string.UTF8StringWriter;
 
 public class PrintDateDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
@@ -82,6 +84,7 @@ public class PrintDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     private StringBuilder sbder = new StringBuilder();
+                    private final UTF8StringWriter utf8Writer = new UTF8StringWriter();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
@@ -109,14 +112,14 @@ public class PrintDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
 
                             long chronon = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(),
1)
                                     * GregorianCalendarSystem.CHRONON_OF_DAY;
-                            int formatLength = (argOut1.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut1.getByteArray()[2] & 0xff << 0);
+                            int formatLength = UTF8StringUtil.getUTFLength(argOut1.getByteArray(),
1);
+                            int offset = UTF8StringUtil.getNumBytesToStoreLength(formatLength);
                             sbder.delete(0, sbder.length());
-                            DT_UTILS.printDateTime(chronon, 0, argOut1.getByteArray(), 3,
formatLength, sbder,
+                            DT_UTILS.printDateTime(chronon, 0, argOut1.getByteArray(), 1
+ offset, formatLength, sbder,
                                     DateTimeParseMode.DATE_ONLY);
 
                             out.writeByte(ATypeTag.STRING.serialize());
-                            out.writeUTF(sbder.toString());
+                            utf8Writer.writeUTF8(sbder.toString(), out);
 
                         } catch (IOException ex) {
                             throw new AlgebricksException(ex);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
index fc53203..a31e1e5 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
@@ -39,8 +39,10 @@ import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+import org.apache.hyracks.util.string.UTF8StringWriter;
 
 public class PrintDateTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
@@ -81,6 +83,8 @@ public class PrintDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     private StringBuilder sbder = new StringBuilder();
+                    private UTF8StringWriter utf8Writer = new UTF8StringWriter();
+                    private UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
@@ -106,14 +110,14 @@ public class PrintDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                                         + ")");
                             }
                             long chronon = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(),
1);
-                            int formatLength = (argOut1.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut1.getByteArray()[2] & 0xff << 0);
+                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() -
1);
+                            int formatLength = utf8Ptr.getUTF8Length();
                             sbder.delete(0, sbder.length());
-                            DT_UTILS.printDateTime(chronon, 0, argOut1.getByteArray(), 3,
formatLength, sbder,
-                                    DateTimeParseMode.DATETIME);
+                            DT_UTILS.printDateTime(chronon, 0, utf8Ptr.getByteArray(), utf8Ptr.getCharStartOffset(),
+                                    formatLength, sbder, DateTimeParseMode.DATETIME);
 
                             out.writeByte(ATypeTag.STRING.serialize());
-                            out.writeUTF(sbder.toString());
+                            utf8Writer.writeUTF8(sbder.toString(), out);
 
                         } catch (IOException ex) {
                             throw new AlgebricksException(ex);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
index 01ff402..961c44d 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
@@ -39,8 +39,10 @@ import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+import org.apache.hyracks.util.string.UTF8StringWriter;
 
 public class PrintTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
@@ -81,6 +83,8 @@ public class PrintTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     private StringBuilder sbder = new StringBuilder();
+                    private final UTF8StringWriter writer = new UTF8StringWriter();
+                    private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException
{
@@ -107,14 +111,14 @@ public class PrintTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                             }
 
                             long chronon = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(),
1);
-                            int formatLength = (argOut1.getByteArray()[1] & 0xff <<
8)
-                                    + (argOut1.getByteArray()[2] & 0xff << 0);
+                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() -
1);
+                            int formatLength = utf8Ptr.getUTF8Length();
                             sbder.delete(0, sbder.length());
-                            DT_UTILS.printDateTime(chronon, 0, argOut1.getByteArray(), 3,
formatLength, sbder,
-                                    DateTimeParseMode.TIME_ONLY);
+                            DT_UTILS.printDateTime(chronon, 0, utf8Ptr.getByteArray(), utf8Ptr.getCharStartOffset(),
+                                    formatLength, sbder, DateTimeParseMode.TIME_ONLY);
 
                             out.writeByte(ATypeTag.STRING.serialize());
-                            out.writeUTF(sbder.toString());
+                            writer.writeUTF8(sbder.toString(), out);
 
                         } catch (IOException ex) {
                             throw new AlgebricksException(ex);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
index d00ad3c..ef7a6c8 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -166,7 +166,7 @@ import org.apache.asterix.runtime.evaluators.functions.AnyCollectionMemberDescri
 import org.apache.asterix.runtime.evaluators.functions.CastListDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.CastRecordDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.CodePointToStringDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.ContainsDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.StringContainsDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.CountHashedGramTokensDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.CountHashedWordTokensDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.CreateCircleDescriptor;
@@ -182,7 +182,7 @@ import org.apache.asterix.runtime.evaluators.functions.EditDistanceDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.EditDistanceListIsFilterable;
 import org.apache.asterix.runtime.evaluators.functions.EditDistanceStringIsFilterable;
 import org.apache.asterix.runtime.evaluators.functions.EmbedTypeDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.EndsWithDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.StringEndsWithDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.FlowRecordDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.FuzzyEqDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.GetItemDescriptor;
@@ -193,7 +193,7 @@ import org.apache.asterix.runtime.evaluators.functions.InjectFailureDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.IsNullDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.IsSystemNullDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.LenDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.LikeDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.StringLikeDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NotDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NotNullDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.NumericAbsDescriptor;
@@ -223,9 +223,8 @@ import org.apache.asterix.runtime.evaluators.functions.SpatialAreaDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.SpatialCellDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.SpatialDistanceDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.SpatialIntersectDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.StartsWithDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.StringStartsWithDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.StringConcatDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.StringEndWithDescrtiptor;
 import org.apache.asterix.runtime.evaluators.functions.StringEqualDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.StringJoinDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.StringLengthDescriptor;
@@ -234,7 +233,6 @@ import org.apache.asterix.runtime.evaluators.functions.StringMatchesDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.StringMatchesWithFlagDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.StringReplaceDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.StringReplaceWithFlagsDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.StringStartWithDescrtiptor;
 import org.apache.asterix.runtime.evaluators.functions.StringToCodePointDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.StringUpperCaseDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.Substring2Descriptor;
@@ -402,16 +400,12 @@ public class NonTaggedDataFormat implements IDataFormat {
         List<IFunctionDescriptorFactory> temp = new ArrayList<IFunctionDescriptorFactory>();
 
         // format-independent
-        temp.add(ContainsDescriptor.FACTORY);
-        temp.add(EndsWithDescriptor.FACTORY);
-        temp.add(StartsWithDescriptor.FACTORY);
-        temp.add(SubstringDescriptor.FACTORY);
         temp.add(TidRunningAggregateDescriptor.FACTORY);
 
         // format-dependent
         temp.add(AndDescriptor.FACTORY);
         temp.add(OrDescriptor.FACTORY);
-        temp.add(LikeDescriptor.FACTORY);
+        temp.add(StringLikeDescriptor.FACTORY);
         temp.add(ScanCollectionDescriptor.FACTORY);
         temp.add(AnyCollectionMemberDescriptor.FACTORY);
         temp.add(ClosedRecordConstructorDescriptor.FACTORY);
@@ -460,9 +454,11 @@ public class NonTaggedDataFormat implements IDataFormat {
         temp.add(FindBinaryFromDescriptor.FACTORY);
 
         // String functions
+        temp.add(StringContainsDescriptor.FACTORY);
+        temp.add(StringEndsWithDescriptor.FACTORY);
+        temp.add(StringStartsWithDescriptor.FACTORY);
+        temp.add(SubstringDescriptor.FACTORY);
         temp.add(StringEqualDescriptor.FACTORY);
-        temp.add(StringStartWithDescrtiptor.FACTORY);
-        temp.add(StringEndWithDescrtiptor.FACTORY);
         temp.add(StringMatchesDescriptor.FACTORY);
         temp.add(StringLowerCaseDescriptor.FACTORY);
         temp.add(StringUpperCaseDescriptor.FACTORY);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/file/AbstractDataParser.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/file/AbstractDataParser.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/file/AbstractDataParser.java
index 062d83c..4b10560 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/file/AbstractDataParser.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/file/AbstractDataParser.java
@@ -72,8 +72,8 @@ import org.apache.asterix.om.types.BuiltinType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.dataflow.common.data.parsers.ByteArrayBase64ParserFactory;
-import org.apache.hyracks.dataflow.common.data.parsers.ByteArrayHexParserFactory;
+import org.apache.hyracks.util.bytes.Base64Parser;
+import org.apache.hyracks.util.bytes.HexParser;
 
 /**
  * Base class for data parsers. Includes the common set of definitions for
@@ -88,7 +88,7 @@ public abstract class AbstractDataParser implements IDataParser {
     protected AMutableDouble aDouble = new AMutableDouble(0);
     protected AMutableFloat aFloat = new AMutableFloat(0);
     protected AMutableString aString = new AMutableString("");
-    protected AMutableBinary aBinary = new AMutableBinary(new byte[] {}, 0, 0);
+    protected AMutableBinary aBinary = new AMutableBinary(null, 0, 0);
     protected AMutableString aStringFieldName = new AMutableString("");
     protected AMutableUUID aUUID = new AMutableUUID(0, 0);
     // For temporal and spatial data types
@@ -105,8 +105,6 @@ public abstract class AbstractDataParser implements IDataParser {
     protected AMutableLine aLine = new AMutableLine(null, null);
     protected AMutableDate aDate = new AMutableDate(0);
 
-    private final byte[] base64ParserQuadruplet = new byte[4];
-
     // Serializers
     @SuppressWarnings("unchecked")
     protected ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -114,6 +112,8 @@ public abstract class AbstractDataParser implements IDataParser {
     @SuppressWarnings("unchecked")
     protected ISerializerDeserializer<AString> stringSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.ASTRING);
+    protected ISerializerDeserializer<ABinary> binarySerde = AqlSerializerDeserializerProvider.INSTANCE
+            .getSerializerDeserializer(BuiltinType.ABINARY);
     @SuppressWarnings("unchecked")
     protected ISerializerDeserializer<AFloat> floatSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.AFLOAT);
@@ -136,6 +136,9 @@ public abstract class AbstractDataParser implements IDataParser {
     protected ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.ANULL);
 
+    protected final HexParser hexParser = new HexParser();
+    protected final Base64Parser base64Parser = new Base64Parser();
+
     // For UUID, we assume that the format is the string representation of UUID
     // (xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx) when parsing the data.
     // Thus, we need to call UUID.fromStringToAMuatbleUUID() to convert it to the internal
representation (two long values).
@@ -144,6 +147,7 @@ public abstract class AbstractDataParser implements IDataParser {
             .getSerializerDeserializer(BuiltinType.AUUID);
 
     // To avoid race conditions, the serdes for temporal and spatial data types needs to
be one per parser
+    // ^^^^^^^^^^^^^^^^^^^^^^^^ ??? then why all these serdes are static?
     @SuppressWarnings("unchecked")
     protected static final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.ATIME);
@@ -177,9 +181,6 @@ public abstract class AbstractDataParser implements IDataParser {
     @SuppressWarnings("unchecked")
     protected final static ISerializerDeserializer<ALine> lineSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.ALINE);
-    @SuppressWarnings("unchecked")
-    protected final static ISerializerDeserializer<ABinary> binarySerde = AqlSerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ABINARY);
 
     protected String filename;
 
@@ -339,17 +340,15 @@ public abstract class AbstractDataParser implements IDataParser {
 
     protected void parseHexBinaryString(char[] input, int start, int length, DataOutput out)
             throws HyracksDataException {
-        byte[] newBytes = ByteArrayHexParserFactory.extractPointableArrayFromHexString(input,
start, length,
-                aBinary.getBytes());
-        aBinary.setValue(newBytes, 0, newBytes.length);
+        hexParser.generateByteArrayFromHexString(input, start, length);
+        aBinary.setValue(hexParser.getByteArray(), 0, hexParser.getLength());
         binarySerde.serialize(aBinary, out);
     }
 
     protected void parseBase64BinaryString(char[] input, int start, int length, DataOutput
out)
             throws HyracksDataException {
-        byte[] newBytes = ByteArrayBase64ParserFactory.extractPointableArrayFromBase64String(input,
start, length,
-                aBinary.getBytes(), base64ParserQuadruplet);
-        aBinary.setValue(newBytes, 0, newBytes.length);
+        base64Parser.generatePureByteArrayFromBase64String(input, start, length);
+        aBinary.setValue(base64Parser.getByteArray(), 0, base64Parser.getLength());
         binarySerde.serialize(aBinary, out);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/asterix-tools/src/main/java/org/apache/asterix/tools/external/data/ExternalFilesIndexOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-tools/src/main/java/org/apache/asterix/tools/external/data/ExternalFilesIndexOperatorDescriptor.java
b/asterix-tools/src/main/java/org/apache/asterix/tools/external/data/ExternalFilesIndexOperatorDescriptor.java
index ffa99fd..f4b3392 100644
--- a/asterix-tools/src/main/java/org/apache/asterix/tools/external/data/ExternalFilesIndexOperatorDescriptor.java
+++ b/asterix-tools/src/main/java/org/apache/asterix/tools/external/data/ExternalFilesIndexOperatorDescriptor.java
@@ -66,8 +66,8 @@ public class ExternalFilesIndexOperatorDescriptor extends AbstractTreeIndexOpera
             IFileSplitProvider fileSplitProvider, IIndexDataflowHelperFactory dataflowHelperFactory,
             ILocalResourceFactoryProvider localResourceFactoryProvider, List<ExternalFile>
files, boolean createNewIndex) {
         super(spec, 0, 0, null, storageManager, lifecycleManagerProvider, fileSplitProvider,
-                FilesIndexDescription.EXTERNAL_FILE_INDEX_TYPE_TRAITS,
-                FilesIndexDescription.FILES_INDEX_COMP_FACTORIES, FilesIndexDescription.BLOOM_FILTER_FIELDS,
+                new FilesIndexDescription().EXTERNAL_FILE_INDEX_TYPE_TRAITS,
+                new FilesIndexDescription().FILES_INDEX_COMP_FACTORIES, FilesIndexDescription.BLOOM_FILTER_FIELDS,
                 dataflowHelperFactory, null, false, false, null, localResourceFactoryProvider,
                 NoOpOperationCallbackFactory.INSTANCE, NoOpOperationCallbackFactory.INSTANCE);
         this.createNewIndex = createNewIndex;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/742aba85/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 71c2b2c..9f02d63 100644
--- a/pom.xml
+++ b/pom.xml
@@ -481,11 +481,21 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.hyracks</groupId>
+                <artifactId>hyracks-util</artifactId>
+                <version>${hyracks.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.hyracks</groupId>
                 <artifactId>hyracks-dataflow-std</artifactId>
                 <version>${hyracks.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.apache.hyracks</groupId>
+                <artifactId>hyracks-data</artifactId>
+                <version>${hyracks.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.hyracks</groupId>
                 <artifactId>hyracks-control-cc</artifactId>
                 <version>${hyracks.version}</version>
             </dependency>



Mime
View raw message