Updated all the javadoc comments for java 1.8's new doclint. The new JavaDocs now have a format checker in Java 1.8. The site would not build without these changes. If JavaDoc exists for a method certain attributes must exists (@param, @return, @throws, etc.). Also, any HTML must be formatted correctly. I also added a few ignore options to help clean up eclipse warnings.
Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/51a98938 Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/51a98938 Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/51a98938 Branch: refs/heads/master Commit: 51a989382be8b5340ae84214dff9dc16807234c6 Parents: 4684567 Author: Preston Carman <[email protected]> Authored: Thu Oct 29 10:56:50 2015 -0700 Committer: Preston Carman <[email protected]> Committed: Thu Oct 29 10:56:50 2015 -0700 ---------------------------------------------------------------------- .../VXQueryComparatorFactoryProvider.java | 1 + .../compiler/rewriter/RewriteRuleset.java | 5 + .../rewriter/rules/AbstractCollectionRule.java | 11 +- ...tAssignSortDistinctNodesToOperatorsRule.java | 7 +- .../rewriter/rules/IntroduceCollectionRule.java | 20 +- .../rules/PushChildIntoDataScanRule.java | 20 +- .../RemoveUnusedSortDistinctNodesRule.java | 48 ++--- .../rules/RemoveUnusedUnnestIterateRule.java | 20 +- .../rules/SetCollectionDataSourceRule.java | 9 +- .../ExtractFunctionsFromJoinConditionRule.java | 15 +- .../rules/util/CardinalityRuleToolbox.java | 14 +- .../rewriter/rules/util/ExpressionToolbox.java | 12 ++ .../apache/vxquery/datamodel/util/DateTime.java | 44 +++- .../org/apache/vxquery/functions/Signature.java | 2 + .../functions/cast/AbstractCastToOperation.java | 22 +- .../cast/CastToBase64BinaryOperation.java | 1 + .../castable/AbstractCastableAsOperation.java | 6 +- .../error/FnErrorScalarEvaluatorFactory.java | 16 +- .../FnSubsequenceScalarEvaluatorFactory.java | 4 +- ...stractDescendantPathStepScalarEvaluator.java | 4 +- .../step/ChildPathStepOperatorDescriptor.java | 16 ++ .../functions/step/ChildPathStepUnnesting.java | 12 +- .../step/DescendantOrSelfPathStepUnnesting.java | 13 +- .../runtime/functions/util/FunctionHelper.java | 33 ++- .../apache/vxquery/types/AbstractNodeType.java | 2 + .../org/apache/vxquery/types/AnyItemType.java | 1 + .../org/apache/vxquery/types/AnyNodeType.java | 1 + .../org/apache/vxquery/types/AnySimpleType.java | 1 + .../java/org/apache/vxquery/types/AnyType.java | 1 + .../org/apache/vxquery/types/AttributeType.java | 2 + .../org/apache/vxquery/types/CommentType.java | 1 + .../org/apache/vxquery/types/DocumentType.java | 2 + .../org/apache/vxquery/types/ElementType.java | 2 + .../apache/vxquery/types/EmptySequenceType.java | 1 + .../java/org/apache/vxquery/types/NoneType.java | 1 + .../types/ProcessingInstructionType.java | 2 + .../java/org/apache/vxquery/types/TextType.java | 1 + .../xmlquery/query/XMLQueryCompiler.java | 2 +- .../org/apache/vxquery/xtest/TestRunner.java | 25 +-- .../vxquery/xtest/util/DiskPerformance.java | 215 ------------------- .../xtest/util/tests/AbstractDiskTest.java | 90 -------- .../tests/BufferedParsedCharacterStream.java | 45 ---- .../tests/BufferedReaderBufferedStream.java | 48 ----- .../xtest/util/tests/BufferedReaderStream.java | 46 ---- .../xtest/util/tests/BufferedStream.java | 45 ---- .../vxquery/xtest/util/tests/IDiskTest.java | 31 --- .../util/tests/ParsedBufferedByteStream.java | 48 ----- .../tests/ParsedBufferedCharacterStream.java | 48 ----- .../xtest/util/tests/ParsedByteStream.java | 46 ---- .../xtest/util/tests/ParsedCharacterStream.java | 47 ---- .../xtest/util/tests/ReaderBufferedStream.java | 46 ---- .../vxquery/xtest/util/tests/ReaderStream.java | 45 ---- .../apache/vxquery/xtest/util/tests/Stream.java | 44 ---- 53 files changed, 262 insertions(+), 982 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryComparatorFactoryProvider.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryComparatorFactoryProvider.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryComparatorFactoryProvider.java index 2643dc5..b7196cf 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryComparatorFactoryProvider.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/VXQueryComparatorFactoryProvider.java @@ -33,6 +33,7 @@ public class VXQueryComparatorFactoryProvider implements IBinaryComparatorFactor private static class BinaryComparatorFactory implements IBinaryComparatorFactory { private static final long serialVersionUID = 1L; + @SuppressWarnings("unused") private final boolean ascending; public BinaryComparatorFactory(Object type, boolean ascending) { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/RewriteRuleset.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/RewriteRuleset.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/RewriteRuleset.java index 075fb3e..6f09543 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/RewriteRuleset.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/RewriteRuleset.java @@ -90,6 +90,7 @@ import org.apache.hyracks.algebricks.rewriter.rules.SubplanOutOfGroupRule; public class RewriteRuleset { /** * Optimizations specific to XQuery. + * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildPathStepNormalizationRuleCollection() { List<IAlgebraicRewriteRule> normalization = new LinkedList<IAlgebraicRewriteRule>(); @@ -146,6 +147,7 @@ public class RewriteRuleset { /** * Optimizations specific to XQuery. + * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildXQueryNormalizationRuleCollection() { List<IAlgebraicRewriteRule> normalization = new LinkedList<IAlgebraicRewriteRule>(); @@ -170,6 +172,7 @@ public class RewriteRuleset { /** * Remove expressions known to be redundant. + * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildInlineRedundantExpressionNormalizationRuleCollection() { List<IAlgebraicRewriteRule> normalization = new LinkedList<IAlgebraicRewriteRule>(); @@ -188,6 +191,7 @@ public class RewriteRuleset { /** * When a nested data sources exist, convert the plan to use the join operator. + * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildNestedDataSourceRuleCollection() { List<IAlgebraicRewriteRule> xquery = new LinkedList<IAlgebraicRewriteRule>(); @@ -211,6 +215,7 @@ public class RewriteRuleset { /** * Unnest more complex structures. + * @return List of algebraic rewrite rules. */ public final static List<IAlgebraicRewriteRule> buildUnnestingRuleCollection() { List<IAlgebraicRewriteRule> xquery = new LinkedList<IAlgebraicRewriteRule>(); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractCollectionRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractCollectionRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractCollectionRule.java index f343b41..53011d2 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractCollectionRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractCollectionRule.java @@ -55,8 +55,12 @@ public abstract class AbstractCollectionRule implements IAlgebraicRewriteRule { /** * Get the constant value for the collection. Return null for not a collection. + * + * @param opRef + * Logical operator + * @return collection name */ - protected String getCollectionName(Mutable<ILogicalOperator> opRef) throws AlgebricksException { + protected String getCollectionName(Mutable<ILogicalOperator> opRef) { VXQueryConstantValue constantValue; AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); @@ -114,9 +118,8 @@ public abstract class AbstractCollectionRule implements IAlgebraicRewriteRule { if (tvp.getTag() == ValueTag.XS_STRING_TAG) { tvp.getValue(stringp); try { - bbis.setByteBuffer( - ByteBuffer.wrap(Arrays.copyOfRange(stringp.getByteArray(), stringp.getStartOffset(), - stringp.getLength() + stringp.getStartOffset())), 0); + bbis.setByteBuffer(ByteBuffer.wrap(Arrays.copyOfRange(stringp.getByteArray(), stringp.getStartOffset(), + stringp.getLength() + stringp.getStartOffset())), 0); collectionName = di.readUTF(); } catch (IOException e) { e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignSortDistinctNodesToOperatorsRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignSortDistinctNodesToOperatorsRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignSortDistinctNodesToOperatorsRule.java index f70e656..f928209 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignSortDistinctNodesToOperatorsRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignSortDistinctNodesToOperatorsRule.java @@ -21,8 +21,6 @@ import java.util.List; import org.apache.commons.lang3.mutable.Mutable; import org.apache.commons.lang3.mutable.MutableObject; -import org.apache.vxquery.functions.BuiltinOperators; - import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.common.utils.Pair; import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; @@ -47,6 +45,7 @@ import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperato import org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator; import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule; +import org.apache.vxquery.functions.BuiltinOperators; public class ConvertAssignSortDistinctNodesToOperatorsRule implements IAlgebraicRewriteRule { @@ -59,6 +58,7 @@ public class ConvertAssignSortDistinctNodesToOperatorsRule implements IAlgebraic * Find where a sort distinct nodes is being used and not required based on input parameters. * Search pattern: assign [function-call: sort-distinct-nodes-asc-or-atomics] */ + @SuppressWarnings("unused") @Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) { Mutable<ILogicalOperator> nextOperatorRef; @@ -160,7 +160,7 @@ public class ConvertAssignSortDistinctNodesToOperatorsRule implements IAlgebraic Mutable<ILogicalExpression> unnestVariableRef = new MutableObject<ILogicalExpression>( new VariableReferenceExpression(unnestVariable)); aggregateSequenceArgs.add(unnestVariableRef); - + List<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>(); ILogicalExpression aggregateExp = new AggregateFunctionCallExpression(BuiltinOperators.SEQUENCE, false, aggregateSequenceArgs); @@ -199,6 +199,7 @@ public class ConvertAssignSortDistinctNodesToOperatorsRule implements IAlgebraic } } + @SuppressWarnings("unused") private OrderOperator getOrderOperator(Mutable<ILogicalExpression> variableRef) { List<Pair<IOrder, Mutable<ILogicalExpression>>> orderArgs = new ArrayList<Pair<IOrder, Mutable<ILogicalExpression>>>(); orderArgs.add(new Pair<IOrder, Mutable<ILogicalExpression>>(OrderOperator.ASC_ORDER, variableRef)); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/IntroduceCollectionRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/IntroduceCollectionRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/IntroduceCollectionRule.java index c7dd2ee..cc857a1 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/IntroduceCollectionRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/IntroduceCollectionRule.java @@ -36,33 +36,33 @@ import org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestOperat * parallelization. The rule searches for unnest followed by an assign for the * collection function expression. When this plan block exists the data source * scan operator added in the blocks place. - * + * * <pre> * Before - * + * * plan__parent * UNNEST( $v2 : exp($v1) ) * ASSIGN( $v1 : collection( $v0 ) ) * ASSIGN( $v0 : constant ) * plan__child - * - * After - * + * + * After + * * plan__parent * UNNEST( $v2 : exp($v1) ) * DATASCAN( collection( $v0 ) , $v1 ) * plan__child - * - * Where DATASCAN operator is configured to use the collection( $v0) for - * data represented by the "constant" and $v1 represents the xml document + * + * Where DATASCAN operator is configured to use the collection( $v0) for + * data represented by the "constant" and $v1 represents the xml document * nodes from the collection. * </pre> - * + * * @author prestonc */ public class IntroduceCollectionRule extends AbstractCollectionRule { @Override - public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { + public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) { VXQueryOptimizationContext vxqueryContext = (VXQueryOptimizationContext) context; String collectionName = getCollectionName(opRef); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/PushChildIntoDataScanRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/PushChildIntoDataScanRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/PushChildIntoDataScanRule.java index 3ad068d..7ffcd90 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/PushChildIntoDataScanRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/PushChildIntoDataScanRule.java @@ -20,24 +20,22 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.mutable.Mutable; -import org.apache.vxquery.compiler.rewriter.VXQueryOptimizationContext; -import org.apache.vxquery.compiler.rewriter.rules.util.ExpressionToolbox; -import org.apache.vxquery.context.StaticContext; -import org.apache.vxquery.functions.BuiltinOperators; -import org.apache.vxquery.metadata.VXQueryCollectionDataSource; -import org.apache.vxquery.metadata.VXQueryMetadataProvider; -import org.apache.vxquery.types.ElementType; - import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator; import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext; import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag; -import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator; +import org.apache.vxquery.compiler.rewriter.VXQueryOptimizationContext; +import org.apache.vxquery.compiler.rewriter.rules.util.ExpressionToolbox; +import org.apache.vxquery.context.StaticContext; +import org.apache.vxquery.functions.BuiltinOperators; +import org.apache.vxquery.metadata.VXQueryCollectionDataSource; +import org.apache.vxquery.metadata.VXQueryMetadataProvider; +import org.apache.vxquery.types.ElementType; /** * The rule searches for an unnest operator immediately following a data scan @@ -72,8 +70,8 @@ public class PushChildIntoDataScanRule extends AbstractUsedVariablesProcessingRu protected boolean processOperator(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (dCtx == null) { - IMetadataProvider metadataProvider = ((VXQueryOptimizationContext) context).getMetadataProvider(); - dCtx = ((VXQueryMetadataProvider) metadataProvider).getStaticContext(); + VXQueryOptimizationContext vxqueryCtx = (VXQueryOptimizationContext) context; + dCtx = ((VXQueryMetadataProvider) vxqueryCtx.getMetadataProvider()).getStaticContext(); } AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue(); if (op1.getOperatorTag() != LogicalOperatorTag.UNNEST) { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedSortDistinctNodesRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedSortDistinctNodesRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedSortDistinctNodesRule.java index 55c8de0..69940ad 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedSortDistinctNodesRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedSortDistinctNodesRule.java @@ -51,43 +51,43 @@ import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule; * The rule searches for where the xquery sort distinct function is used and * determines if the sort and distinct is necessary. The plan is modified if * any of these items is not required. - * + * * <pre> * Before - * + * * plan__parent * ASSIGN( $v1 : sort_distinct_nodes_asc_or_atomics( $v0 ) ) * plan__child - * + * * Where $v0 is a variable defined in plan__child. - * - * After - * - * if ( $v0 is unique nodes && $v0 is in document order ) - * + * + * After + * + * if ( $v0 is unique nodes && $v0 is in document order ) + * * plan__parent * ASSIGN( $v1 : $v0 ) * plan__child - * - * if ( $v0 is NOT unique nodes && $v0 is in document order ) - * + * + * if ( $v0 is NOT unique nodes && $v0 is in document order ) + * * plan__parent * ASSIGN( $v1 : distinct_nodes_or_atomics( $v0 ) ) * plan__child - * - * if ( $v0 is unique nodes && $v0 is NOT in document order ) - * + * + * if ( $v0 is unique nodes && $v0 is NOT in document order ) + * * plan__parent * ASSIGN( $v1 : sort_nodes_asc( $v0 ) ) * plan__child - * - * if ( $v0 is NOT unique nodes && $v0 is NOT in document order ) - * + * + * if ( $v0 is NOT unique nodes && $v0 is NOT in document order ) + * * plan__parent * ASSIGN( $v1 : sort_distinct_nodes_asc_or_atomics( $v0 ) ) * plan__child * </pre> - * + * * @author prestonc */ @@ -123,7 +123,7 @@ public class RemoveUnusedSortDistinctNodesRule implements IAlgebraicRewriteRule int variableId = getOperatorSortDistinctNodesAscOrAtomicsArgumentVariableId(opRef); if (variableId > 0) { // Find the function expression. - // All the checks for these variable assigns and casting were done in the + // All the checks for these variable assigns and casting were done in the // getOperatorSortDistinctNodesAscOrAtomicsArgumentVariableId function. AssignOperator assign = (AssignOperator) op; ILogicalExpression logicalExpression = (ILogicalExpression) assign.getExpressions().get(0).getValue(); @@ -194,7 +194,7 @@ public class RemoveUnusedSortDistinctNodesRule implements IAlgebraicRewriteRule /** * Get the DocumentOrder variable map of the parent operator. - * + * * @param op * @param vxqueryContext * @return @@ -217,10 +217,10 @@ public class RemoveUnusedSortDistinctNodesRule implements IAlgebraicRewriteRule /** * Get the UniqueNodes variable map of the parent operator. - * + * * @param op * @param vxqueryContext - * @return + * @return Hash map of variables to unique nodes. */ private HashMap<Integer, UniqueNodes> getProducerUniqueNodesVariableMap(ILogicalOperator op, VXQueryOptimizationContext vxqueryContext) { @@ -297,7 +297,7 @@ public class RemoveUnusedSortDistinctNodesRule implements IAlgebraicRewriteRule /** * Sets all the variables to DocumentOrder. - * + * * @param documentOrderVariables * @param documentOrder */ @@ -310,7 +310,7 @@ public class RemoveUnusedSortDistinctNodesRule implements IAlgebraicRewriteRule /** * Sets all the variables to UniqueNodes. - * + * * @param uniqueNodesVariables * @param uniqueNodes */ http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedUnnestIterateRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedUnnestIterateRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedUnnestIterateRule.java index 946f854..1da93b9 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedUnnestIterateRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/RemoveUnusedUnnestIterateRule.java @@ -17,10 +17,6 @@ package org.apache.vxquery.compiler.rewriter.rules; import org.apache.commons.lang3.mutable.Mutable; -import org.apache.vxquery.compiler.rewriter.rules.propagationpolicies.documentorder.DocumentOrder; -import org.apache.vxquery.compiler.rewriter.rules.propagationpolicies.uniquenodes.UniqueNodes; -import org.apache.vxquery.functions.BuiltinOperators; - import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator; @@ -33,32 +29,32 @@ import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceE import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractScanOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator; -import org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator; +import org.apache.vxquery.functions.BuiltinOperators; /** * The rule searches for an unnest operator (1) immediately following an unnest * or data scan operator (2). If the variable is only used in unnest (1) then * unnest (1) can be removed. - * + * * <pre> - * Before - * + * Before + * * plan__parent * UNNEST( $v2 : iterate( $v1 ) ) * UNNEST( $v1 : $v ) * plan__child - * + * * Where $v1 is not used in plan__parent. - * + * * After - * + * * plan__parent * ASSIGN( $v2 : $v1 ) * UNNEST( $v1 : $v ) * plan__child * </pre> - * + * * @author prestonc */ public class RemoveUnusedUnnestIterateRule extends AbstractUsedVariablesProcessingRule { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/SetCollectionDataSourceRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/SetCollectionDataSourceRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/SetCollectionDataSourceRule.java index 936a12a..f4ebde7 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/SetCollectionDataSourceRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/SetCollectionDataSourceRule.java @@ -25,11 +25,16 @@ import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext; /** * Find the collection functions and generate the data source objects. - * Search pattern: unnest <- assign [function-call: collection] <- assign [constant: string] + * + * <pre> + * Search pattern: + * unnest <- assign [function-call: collection] <- assign [constant: string] + * </pre> */ public class SetCollectionDataSourceRule extends AbstractCollectionRule { @Override - public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { + public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) + throws AlgebricksException { if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/algebricksalternatives/ExtractFunctionsFromJoinConditionRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/algebricksalternatives/ExtractFunctionsFromJoinConditionRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/algebricksalternatives/ExtractFunctionsFromJoinConditionRule.java index 9ae19f5..80ff036 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/algebricksalternatives/ExtractFunctionsFromJoinConditionRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/algebricksalternatives/ExtractFunctionsFromJoinConditionRule.java @@ -43,13 +43,18 @@ import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule; * Factors out function expressions from each comparison function or similarity function in join condition by assigning them to a variables, and replacing the function expressions with references to those variables. * Examples: * Plan with function expressions in comparison or similarity condition of join expression. Generates one assign operator per extracted function expression. - * Example + * + * <pre> * Before plan: - * join ( eq( funcX($$1), funcX($$2) ) ) + * + * join ( eq( funcX($$1), funcX($$2) ) ) + * * After plan: - * join (eq($$3,$$4)) - * assign [$$4] <- [funcY($$2)] - * assign [$$3] <- [funcX($$1)] + * + * join (eq($$3,$$4)) + * assign [$$4] <- [funcY($$2)] + * assign [$$3] <- [funcX($$1)] + * </pre> */ public class ExtractFunctionsFromJoinConditionRule implements IAlgebraicRewriteRule { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/CardinalityRuleToolbox.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/CardinalityRuleToolbox.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/CardinalityRuleToolbox.java index 7744eb2..fe18204 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/CardinalityRuleToolbox.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/CardinalityRuleToolbox.java @@ -27,10 +27,12 @@ import org.apache.hyracks.algebricks.core.algebra.operators.logical.NestedTupleS public class CardinalityRuleToolbox { /** * Get the Cardinality variable of the parent operator. - * + * * @param op + * Logical operator * @param vxqueryContext - * @return + * VXQuery context + * @return Cardinality of the producer. */ public static Cardinality getProducerCardinality(ILogicalOperator op, VXQueryOptimizationContext vxqueryContext) { AbstractLogicalOperator producerOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); @@ -55,8 +57,8 @@ public class CardinalityRuleToolbox { case SUBPLAN: // Find the last operator to set a variable and call this function again. AbstractOperatorWithNestedPlans operatorWithNestedPlan = (AbstractOperatorWithNestedPlans) op; - AbstractLogicalOperator lastOperator = (AbstractLogicalOperator) operatorWithNestedPlan - .getNestedPlans().get(0).getRoots().get(0).getValue(); + AbstractLogicalOperator lastOperator = (AbstractLogicalOperator) operatorWithNestedPlan.getNestedPlans() + .get(0).getRoots().get(0).getValue(); cardinalityVariable = vxqueryContext.getCardinalityOperatorMap(lastOperator); break; case DATASOURCESCAN: @@ -82,8 +84,8 @@ public class CardinalityRuleToolbox { // The following operators' analysis has not yet been implemented. default: - throw new RuntimeException("Operator (" + op.getOperatorTag() - + ") has not been implemented in rewrite rule."); + throw new RuntimeException( + "Operator (" + op.getOperatorTag() + ") has not been implemented in rewrite rule."); } return cardinalityVariable; } http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java index 10a8dca..0dd3b31 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java @@ -131,6 +131,11 @@ public class ExpressionToolbox { /** * Finds all functions for a given expression. + * + * @param mutableLe + * Search logical expression + * @param finds + * Logical expressions found */ public static void findAllFunctionExpressions(Mutable<ILogicalExpression> mutableLe, List<Mutable<ILogicalExpression>> finds) { @@ -146,6 +151,13 @@ public class ExpressionToolbox { /** * Finds all functions for a given expression and function identifier. + * + * @param mutableLe + * Search logical expression + * @param fi + * Function indentifier + * @param finds + * Logical expressions found */ public static void findAllFunctionExpressions(Mutable<ILogicalExpression> mutableLe, FunctionIdentifier fi, List<Mutable<ILogicalExpression>> finds) { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/datamodel/util/DateTime.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/util/DateTime.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/util/DateTime.java index 1850dd1..16c350f 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/util/DateTime.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/util/DateTime.java @@ -63,9 +63,10 @@ public class DateTime { /** * Check whether a given year is a leap year. - * + * * @param year - * @return + * A long for year. + * @return Boolean for leap year. */ public static boolean isLeapYear(long year) { return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0); @@ -73,9 +74,24 @@ public class DateTime { /** * Check whether a given year is a leap year. - * + * * @param year - * @return + * year + * @param month + * month + * @param day + * day + * @param hour + * hour + * @param minute + * minute + * @param millisecond + * millisecond + * @param timezoneHour + * timezoneHour + * @param timezoneMinute + * timezoneMinute + * @return Boolean for valid date. */ public static boolean valid(long year, long month, long day, long hour, long minute, long millisecond, long timezoneHour, long timezoneMinute) { @@ -115,6 +131,19 @@ public class DateTime { /** * Return a normalized time. + * + * @param yearMonth + * Months + * @param dayTime + * Time + * @param timezoneHour + * timezoneHour + * @param timezoneMinute + * timezoneMinute + * @param dOut + * Data out + * @throws IOException + * Could not write result. */ public static void normalizeDateTime(long yearMonth, long dayTime, long timezoneHour, long timezoneMinute, DataOutput dOut) throws IOException { @@ -221,7 +250,8 @@ public class DateTime { DateTime.normalizeDateTime(timezonep.getYearMonth(), dayTime, 0, 0, dOut); } - public static void adjustDateTimeToTimezone(ITimezone timezonep, long timezone, DataOutput dOut) throws IOException { + public static void adjustDateTimeToTimezone(ITimezone timezonep, long timezone, DataOutput dOut) + throws IOException { long timezoneHour = timezone / 60; long timezoneMinute = timezone % 60; long dayTime = timezonep.getDayTime(); @@ -229,8 +259,8 @@ public class DateTime { || timezonep.getTimezoneMinute() == DateTime.TIMEZONE_MINUTE_NULL) { // No change. } else { - dayTime -= (timezonep.getTimezoneHour() * DateTime.CHRONON_OF_HOUR + timezonep.getTimezoneMinute() - * DateTime.CHRONON_OF_MINUTE); + dayTime -= (timezonep.getTimezoneHour() * DateTime.CHRONON_OF_HOUR + + timezonep.getTimezoneMinute() * DateTime.CHRONON_OF_MINUTE); dayTime += (timezoneHour * DateTime.CHRONON_OF_HOUR + timezoneMinute * DateTime.CHRONON_OF_MINUTE); } DateTime.normalizeDateTime(timezonep.getYearMonth(), dayTime, timezoneHour, timezoneMinute, dOut); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/functions/Signature.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/functions/Signature.java b/vxquery-core/src/main/java/org/apache/vxquery/functions/Signature.java index 8604212..d8d0a85 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/functions/Signature.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/functions/Signature.java @@ -27,10 +27,12 @@ public final class Signature { private SequenceType[] parameterTypes; private SequenceType rType; + @SuppressWarnings("unchecked") public Signature(SequenceType rType, Pair<QName, SequenceType>... parameters) { this(rType, false, parameters); } + @SuppressWarnings("unchecked") public Signature(SequenceType rType, boolean varArgs, Pair<QName, SequenceType>... parameters) { int len = parameters.length; this.varArgs = varArgs; http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java index f58a39a..f686361 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java @@ -40,9 +40,9 @@ import org.apache.hyracks.data.std.primitive.UTF8StringPointable; public abstract class AbstractCastToOperation { - /** - * Primitive Datatypes - */ + // + // Primitive Datatypes + // public void convertAnyURI(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, IOException { throw new SystemException(ErrorCode.XPTY0004); } @@ -135,9 +135,9 @@ public abstract class AbstractCastToOperation { throw new SystemException(ErrorCode.XPTY0004); } - /** - * Derived Numeric Datatypes - */ + // + // Derived Numeric Datatypes + // public void convertByte(BytePointable bytep, DataOutput dOut) throws SystemException, IOException { throw new SystemException(ErrorCode.XPTY0004); } @@ -186,9 +186,9 @@ public abstract class AbstractCastToOperation { throw new SystemException(ErrorCode.XPTY0004); } - /** - * Derived String Datatypes - */ + // + // Derived String Datatypes + // public void convertEntity(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, IOException { throw new SystemException(ErrorCode.XPTY0004); @@ -218,8 +218,8 @@ public abstract class AbstractCastToOperation { throw new SystemException(ErrorCode.XPTY0004); } - public void convertNormalizedString(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, - IOException { + public void convertNormalizedString(UTF8StringPointable stringp, DataOutput dOut) + throws SystemException, IOException { throw new SystemException(ErrorCode.XPTY0004); } http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToBase64BinaryOperation.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToBase64BinaryOperation.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToBase64BinaryOperation.java index e2d33a5..680ce08 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToBase64BinaryOperation.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToBase64BinaryOperation.java @@ -47,6 +47,7 @@ public class CastToBase64BinaryOperation extends AbstractCastToOperation { baaos.reset(); Base64OutputStream b64os = new Base64OutputStream(baaos, false); b64os.write(stringp.getByteArray(), stringp.getStartOffset() + 2, stringp.getLength() - 2); + b64os.close(); dOut.write(ValueTag.XS_BASE64_BINARY_TAG); dOut.write((byte) ((baaos.size() >>> 8) & 0xFF)); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java index 2c042e7..8076191 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java @@ -154,9 +154,9 @@ public abstract class AbstractCastableAsOperation { dOut.write((byte) 0); } - /** - * Derived Datatypes - */ + // + // Derived Datatypes + // public void convertByte(BytePointable bytep, DataOutput dOut) throws SystemException, IOException { dOut.write(ValueTag.XS_BOOLEAN_TAG); dOut.write((byte) 0); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/error/FnErrorScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/error/FnErrorScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/error/FnErrorScalarEvaluatorFactory.java index e879378..0588820 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/error/FnErrorScalarEvaluatorFactory.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/error/FnErrorScalarEvaluatorFactory.java @@ -18,6 +18,13 @@ package org.apache.vxquery.runtime.functions.error; import java.io.DataInputStream; +import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; +import org.apache.hyracks.api.context.IHyracksTaskContext; +import org.apache.hyracks.data.std.api.IPointable; +import org.apache.hyracks.data.std.primitive.UTF8StringPointable; +import org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream; import org.apache.vxquery.datamodel.accessors.SequencePointable; import org.apache.vxquery.datamodel.accessors.TaggedValuePointable; import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable; @@ -28,14 +35,6 @@ import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScal import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory; import org.apache.vxquery.runtime.functions.util.FunctionHelper; -import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; -import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; -import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; -import org.apache.hyracks.api.context.IHyracksTaskContext; -import org.apache.hyracks.data.std.api.IPointable; -import org.apache.hyracks.data.std.primitive.UTF8StringPointable; -import org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream; - public class FnErrorScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory { private static final long serialVersionUID = 1L; @@ -43,6 +42,7 @@ public class FnErrorScalarEvaluatorFactory extends AbstractTaggedValueArgumentSc super(args); } + @SuppressWarnings("unused") @Override protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) throws AlgebricksException { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnSubsequenceScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnSubsequenceScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnSubsequenceScalarEvaluatorFactory.java index 690c4a4..6c21169 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnSubsequenceScalarEvaluatorFactory.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/sequence/FnSubsequenceScalarEvaluatorFactory.java @@ -110,9 +110,9 @@ public class FnSubsequenceScalarEvaluatorFactory extends AbstractTaggedValueArgu /** * XQuery Specification calls for double value. Integer and Decimal are allowed to cut down on casting. - * + * * @param tvp - * @return + * @return long * @throws SystemException * @throws IOException */ http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java index f3442a5..adee6f2 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java @@ -46,9 +46,11 @@ public abstract class AbstractDescendantPathStepScalarEvaluator extends Abstract /** * Search through all tree children and children's children. - * + * * @param nodePointable + * Node pointable * @throws SystemException + * Could not save result. */ protected void searchSubtree(TaggedValuePointable nodePointable) throws SystemException { try { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java index eed6bc5..a90963b 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java @@ -66,6 +66,12 @@ public class ChildPathStepOperatorDescriptor extends AbstractForwardAxisPathStep /** * Single node tree input. * Requirement: "ntp" must be the node tree. + * + * @param result + * Node tree pointable + * @return found result + * @throws AlgebricksException + * Could not save result. */ public boolean step(IPointable result) throws AlgebricksException { ntp.getRootNode(tvpStep); @@ -77,6 +83,16 @@ public class ChildPathStepOperatorDescriptor extends AbstractForwardAxisPathStep /** * Find the next node to return. + * + * @param tvpInput + * pointable + * @param level + * level + * @param result + * result + * @return found result + * @throws AlgebricksException + * Could not save result. */ protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result) throws AlgebricksException { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java index 682fd7e..74ec91b 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java @@ -62,7 +62,7 @@ public class ChildPathStepUnnesting extends AbstractForwardAxisPathStep { SequenceType sType = dCtx.getStaticContext().lookupSequenceType(ip.getInteger()); filter = NodeTestFilter.getNodeTestFilter(sType); } - + if (args[0].getTag() == ValueTag.SEQUENCE_TAG) { args[0].getValue(seqNtp); seqArgsLength = seqNtp.getEntryCount(); @@ -101,6 +101,16 @@ public class ChildPathStepUnnesting extends AbstractForwardAxisPathStep { /** * Find the next node to return. + * + * @param tvpInput + * pointable + * @param level + * level + * @param result + * result + * @return found result + * @throws AlgebricksException + * Could not save result. */ protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result) throws AlgebricksException { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java index 2cc6818..37cd400 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java @@ -133,9 +133,16 @@ public class DescendantOrSelfPathStepUnnesting extends AbstractForwardAxisPathSt /** * Search through all tree children and children's children. - * - * @param nodePointable - * @throws SystemException + * + * @param tvpInput + * pointable + * @param level + * level + * @param result + * result + * @return found result + * @throws AlgebricksException + * Could not save result. */ protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result) throws AlgebricksException { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java index 920c815..a57bf72 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java @@ -458,7 +458,7 @@ public class FunctionHelper { public static boolean compareTaggedValues(AbstractValueComparisonOperation aOp, TaggedValuePointable tvp1, TaggedValuePointable tvp2, DynamicContext dCtx, TypedPointables tp1, TypedPointables tp2) - throws SystemException { + throws SystemException { int tid1 = getBaseTypeForComparisons(tvp1.getTag()); int tid2 = getBaseTypeForComparisons(tvp2.getTag()); @@ -1028,6 +1028,12 @@ public class FunctionHelper { /** * Get the local node id from a tagged value pointable when available. + * + * @param tvp1 + * pointable + * @param tp + * Typed pointable + * @return local node id */ public static int getLocalNodeId(TaggedValuePointable tvp1, TypedPointables tp) { final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable(); @@ -1067,6 +1073,10 @@ public class FunctionHelper { /** * Returns the number of digits in a long. A few special cases that needed attention. + * + * @param value + * value + * @return Number of digits */ public static int getNumberOfDigits(long value) { if (value == 0) { @@ -1095,9 +1105,8 @@ public class FunctionHelper { public static String getStringFromPointable(UTF8StringPointable stringp, ByteBufferInputStream bbis, DataInputStream di) throws SystemException { try { - bbis.setByteBuffer( - ByteBuffer.wrap(Arrays.copyOfRange(stringp.getByteArray(), stringp.getStartOffset(), - stringp.getLength() + stringp.getStartOffset())), 0); + bbis.setByteBuffer(ByteBuffer.wrap(Arrays.copyOfRange(stringp.getByteArray(), stringp.getStartOffset(), + stringp.getLength() + stringp.getStartOffset())), 0); return di.readUTF(); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); @@ -1105,8 +1114,8 @@ public class FunctionHelper { } public static long getTimezone(ITimezone timezonep) { - return timezonep.getTimezoneHour() * DateTime.CHRONON_OF_HOUR + timezonep.getTimezoneMinute() - * DateTime.CHRONON_OF_MINUTE; + return timezonep.getTimezoneHour() * DateTime.CHRONON_OF_HOUR + + timezonep.getTimezoneMinute() * DateTime.CHRONON_OF_MINUTE; } public static boolean isDerivedFromDouble(int tid) { @@ -1159,9 +1168,10 @@ public class FunctionHelper { /** * Returns 0 if positive, nonzero if negative. - * + * * @param value - * @return + * value + * @return boolean */ public static boolean isNumberPostive(long value) { return ((value & 0x8000000000000000L) == 0 ? true : false); @@ -1281,12 +1291,15 @@ public class FunctionHelper { /** * Writes a number to the DataOutput with zeros as place holders if the number is too small to fill the padding. - * + * * @param value + * value * @param padding + * padding * @param dOut - * @throws IOException + * data output */ + public static void writeNumberWithPadding(long value, int padding, DataOutput dOut) { if (value < 0) { writeChar('-', dOut); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/AbstractNodeType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/AbstractNodeType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/AbstractNodeType.java index 8177a06..c7180ae 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/AbstractNodeType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/AbstractNodeType.java @@ -17,6 +17,8 @@ package org.apache.vxquery.types; abstract class AbstractNodeType implements NodeType { + private static final long serialVersionUID = 1L; + @Override public final boolean isAtomicType() { return false; http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/AnyItemType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/AnyItemType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/AnyItemType.java index c6db3ad..a2cb3ab 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/AnyItemType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/AnyItemType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class AnyItemType implements ItemType { + private static final long serialVersionUID = 1L; public static final AnyItemType INSTANCE = new AnyItemType(); private AnyItemType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/AnyNodeType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/AnyNodeType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/AnyNodeType.java index 74e6630..1e85eb6 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/AnyNodeType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/AnyNodeType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class AnyNodeType extends AbstractNodeType { + private static final long serialVersionUID = 1L; public static final AnyNodeType INSTANCE = new AnyNodeType(); private AnyNodeType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/AnySimpleType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/AnySimpleType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/AnySimpleType.java index ae4ce25..ee6193f 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/AnySimpleType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/AnySimpleType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class AnySimpleType implements SimpleType { + private static final long serialVersionUID = 1L; public static final SimpleType INSTANCE = new AnySimpleType(); private AnySimpleType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/AnyType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/AnyType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/AnyType.java index 92f21ed..2cb9672 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/AnyType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/AnyType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class AnyType implements ComplexType { + private static final long serialVersionUID = 1L; public static final SchemaType INSTANCE = new AnyType(); private AnyType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/AttributeType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/AttributeType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/AttributeType.java index b99b349..72b9497 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/AttributeType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/AttributeType.java @@ -17,6 +17,8 @@ package org.apache.vxquery.types; public final class AttributeType extends AbstractNodeType { + private static final long serialVersionUID = 1L; + public static final AttributeType ANYATTRIBUTE = new AttributeType(NameTest.STAR_NAMETEST, BuiltinTypeRegistry.XS_ANY_ATOMIC); http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java index 5766a75..d84d848 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/CommentType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class CommentType extends AbstractNodeType { + private static final long serialVersionUID = 1L; public static final CommentType INSTANCE = new CommentType(); private CommentType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java index 66124f8..aa62ebd 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/DocumentType.java @@ -17,6 +17,8 @@ package org.apache.vxquery.types; public final class DocumentType extends AbstractNodeType { + private static final long serialVersionUID = 1L; + public static final DocumentType ANYDOCUMENT = new DocumentType(ElementType.ANYELEMENT); private ElementType elementType; http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java index 6f7d431..0fd1594 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/ElementType.java @@ -17,6 +17,8 @@ package org.apache.vxquery.types; public final class ElementType extends AbstractNodeType { + private static final long serialVersionUID = 1L; + public static final ElementType ANYELEMENT = new ElementType(NameTest.STAR_NAMETEST, AnyType.INSTANCE, true); private NameTest nameTest; http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java index 61d1c4b..4afeb40 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/EmptySequenceType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class EmptySequenceType implements ItemType { + private static final long serialVersionUID = 1L; public static final EmptySequenceType INSTANCE = new EmptySequenceType(); private EmptySequenceType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java index 7c58f52..70c0a0a 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/NoneType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class NoneType implements ItemType { + private static final long serialVersionUID = 1L; public static final NoneType INSTANCE = new NoneType(); private NoneType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java index 46f847e..c445ba7 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/ProcessingInstructionType.java @@ -21,6 +21,8 @@ import java.util.Arrays; import org.apache.hyracks.data.std.primitive.UTF8StringPointable; public final class ProcessingInstructionType extends AbstractNodeType { + private static final long serialVersionUID = 1L; + public static final ProcessingInstructionType ANYPI = new ProcessingInstructionType(null); private byte[] target; http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java b/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java index 2656775..7c7fec7 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/types/TextType.java @@ -17,6 +17,7 @@ package org.apache.vxquery.types; public final class TextType extends AbstractNodeType { + private static final long serialVersionUID = 1L; public static final TextType INSTANCE = new TextType(); private TextType() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java index e9efa11..e42caba 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java @@ -126,7 +126,7 @@ public class XMLQueryCompiler { builder.setLogicalRewrites(buildDefaultLogicalRewrites()); builder.setPhysicalRewrites(buildDefaultPhysicalRewrites()); builder.setSerializerDeserializerProvider(new ISerializerDeserializerProvider() { - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") @Override public ISerializerDeserializer getSerializerDeserializer(Object type) throws AlgebricksException { return null; http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java index d8543f5..18db5c1 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java @@ -18,27 +18,13 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.Reader; -import java.nio.ByteBuffer; import java.util.EnumSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.io.IOUtils; -import org.apache.vxquery.compiler.CompilerControlBlock; -import org.apache.vxquery.compiler.algebricks.VXQueryGlobalDataFactory; -import org.apache.vxquery.context.DynamicContext; -import org.apache.vxquery.context.DynamicContextImpl; -import org.apache.vxquery.context.RootStaticContextImpl; -import org.apache.vxquery.context.StaticContextImpl; -import org.apache.vxquery.exceptions.ErrorCode; -import org.apache.vxquery.exceptions.SystemException; -import org.apache.vxquery.result.ResultUtils; -import org.apache.vxquery.xmlquery.query.VXQueryCompilationListener; -import org.apache.vxquery.xmlquery.query.XMLQueryCompiler; - import org.apache.hyracks.api.client.HyracksConnection; import org.apache.hyracks.api.client.IHyracksClientConnection; -import org.apache.hyracks.api.comm.FixedSizeFrame; import org.apache.hyracks.api.comm.IFrame; import org.apache.hyracks.api.comm.IFrameTupleAccessor; import org.apache.hyracks.api.comm.VSizeFrame; @@ -56,6 +42,17 @@ import org.apache.hyracks.control.common.controllers.NCConfig; import org.apache.hyracks.control.nc.NodeControllerService; import org.apache.hyracks.control.nc.resources.memory.FrameManager; import org.apache.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor; +import org.apache.vxquery.compiler.CompilerControlBlock; +import org.apache.vxquery.compiler.algebricks.VXQueryGlobalDataFactory; +import org.apache.vxquery.context.DynamicContext; +import org.apache.vxquery.context.DynamicContextImpl; +import org.apache.vxquery.context.RootStaticContextImpl; +import org.apache.vxquery.context.StaticContextImpl; +import org.apache.vxquery.exceptions.ErrorCode; +import org.apache.vxquery.exceptions.SystemException; +import org.apache.vxquery.result.ResultUtils; +import org.apache.vxquery.xmlquery.query.VXQueryCompilationListener; +import org.apache.vxquery.xmlquery.query.XMLQueryCompiler; public class TestRunner { private static final Pattern EMBEDDED_SYSERROR_PATTERN = Pattern http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/DiskPerformance.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/DiskPerformance.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/DiskPerformance.java deleted file mode 100644 index 63fce8b..0000000 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/DiskPerformance.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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.vxquery.xtest.util; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.TrueFileFilter; -import org.apache.vxquery.datamodel.builders.atomic.StringValueBuilder; -import org.apache.vxquery.metadata.VXQueryIOFileFilter; -import org.apache.vxquery.types.AnyType; -import org.apache.vxquery.types.ElementType; -import org.apache.vxquery.types.NameTest; -import org.apache.vxquery.types.Quantifier; -import org.apache.vxquery.types.SequenceType; -import org.apache.vxquery.xmlparser.SAXContentHandler; -import org.apache.vxquery.xmlparser.TreeNodeIdProvider; -import org.apache.vxquery.xtest.util.tests.BufferedParsedCharacterStream; -import org.apache.vxquery.xtest.util.tests.BufferedReaderBufferedStream; -import org.apache.vxquery.xtest.util.tests.BufferedReaderStream; -import org.apache.vxquery.xtest.util.tests.BufferedStream; -import org.apache.vxquery.xtest.util.tests.IDiskTest; -import org.apache.vxquery.xtest.util.tests.ParsedBufferedByteStream; -import org.apache.vxquery.xtest.util.tests.ParsedBufferedCharacterStream; -import org.apache.vxquery.xtest.util.tests.ParsedByteStream; -import org.apache.vxquery.xtest.util.tests.ParsedCharacterStream; -import org.apache.vxquery.xtest.util.tests.ReaderBufferedStream; -import org.apache.vxquery.xtest.util.tests.ReaderStream; -import org.apache.vxquery.xtest.util.tests.Stream; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -import org.apache.hyracks.algebricks.common.utils.Pair; -import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; - -public class DiskPerformance { - XMLReader parser; - SAXContentHandler handler; - Collection<File> cTestFiles; - Iterator<File> testFilesIt; - - public DiskPerformance() { - Pair<XMLReader, SAXContentHandler> p = getNewParser(); - parser = p.first; - handler = p.second; - cTestFiles = null; - } - - public Pair<XMLReader, SAXContentHandler> getNewParser() { - XMLReader parser; - SAXContentHandler handler; - - try { - parser = XMLReaderFactory.createXMLReader(); - List<SequenceType> childSeq = new ArrayList<SequenceType>(); - NameTest nt = new NameTest(createUTF8String(""), createUTF8String("data")); - childSeq.add(SequenceType.create(new ElementType(nt, AnyType.INSTANCE, false), Quantifier.QUANT_ONE)); - handler = new SAXContentHandler(false, new TreeNodeIdProvider((short) 0), null, childSeq); - parser.setContentHandler(handler); - parser.setProperty("http://xml.org/sax/properties/lexical-handler", handler); - return new Pair<XMLReader, SAXContentHandler>(parser, handler); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public void setDirectory(String filename) { - File directory = new File(filename); - if (directory.isDirectory()) { - cTestFiles = FileUtils.listFiles(directory, new VXQueryIOFileFilter(), TrueFileFilter.INSTANCE); - if (cTestFiles.size() < 1) { - System.err.println("No XML files found in given directory."); - return; - } - } - testFilesIt = cTestFiles.iterator(); - } - - public File getNextFile() { - if (!testFilesIt.hasNext()) { - testFilesIt = cTestFiles.iterator(); - } - return testFilesIt.next(); - } - - private byte[] createUTF8String(String str) { - ArrayBackedValueStorage abvs = new ArrayBackedValueStorage(); - StringValueBuilder svb = new StringValueBuilder(); - try { - svb.write(str, abvs.getDataOutput()); - } catch (IOException e) { - throw new IllegalStateException(e); - } - return Arrays.copyOf(abvs.getByteArray(), abvs.getLength()); - } - - public static void main(String... args) throws IOException { - // First Argument (XML folder) - if (args.length < 1) { - System.err.println("Please provide a directory for the test XML documents."); - return; - } - // Second argument (threads) - int threads = 1; - if (args.length > 1) { - threads = Integer.parseInt(args[1]); - } - - // Third argument (repeat) - int repeat = 1; - if (args.length > 2) { - repeat = Integer.parseInt(args[2]); - } - - // Fourth argument (buffer size) - int bufferSize = -1; - if (args.length > 3) { - bufferSize = Integer.parseInt(args[3]); - } - - DiskPerformance dp = new DiskPerformance(); - dp.setDirectory(args[0]); - - ArrayList<Class> tests = new ArrayList<Class>(); - // Parsed Character Streams - tests.add(ParsedBufferedCharacterStream.class); - // tests.add(BufferedParsedCharacterStream.class); - // tests.add(ParsedCharacterStream.class); - // Parsed Byte Streams - // tests.add(ParsedBufferedByteStream.class); - // tests.add(ParsedByteStream.class); - // Character Streams - // tests.add(BufferedReaderBufferedStream.class); - // tests.add(BufferedReaderStream.class); - // tests.add(ReaderBufferedStream.class); - // tests.add(ReaderStream.class); - // Byte Streams - // tests.add(BufferedStream.class); - // tests.add(Stream.class); - - System.out.println("------"); - System.out.println("Started Test Group: " + new Date()); - System.out.println("Thread: " + threads); - System.out.println("Repeat: " + repeat); - System.out.println("Buffer: " + bufferSize); - System.out.println("------"); - - for (Class<IDiskTest> testClass : tests) { - for (int r = 0; r < repeat; ++r) { - try { - if (threads > 1) { - runThreadTest(testClass, dp, threads, bufferSize); - } else { - IDiskTest test = testClass.newInstance(); - test.setFile(dp.getNextFile()); - test.setBufferSize(bufferSize); - test.setParser(dp.parser); - test.run(); - } - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - } - } - - } - - static <T> void runThreadTest(Class<T> testType, DiskPerformance dp, int threads, int bufferSize) - throws InstantiationException, IllegalAccessException { - ExecutorService es = Executors.newCachedThreadPool(); - ArrayList<IDiskTest> threadTests = new ArrayList<IDiskTest>(); - for (int i = 0; i < threads; ++i) { - threadTests.add((IDiskTest) testType.newInstance()); - } - for (IDiskTest test : threadTests) { - test.setFile(dp.getNextFile()); - test.setBufferSize(bufferSize); - test.setParser(dp.getNewParser().first); - es.execute((Runnable) test); - } - es.shutdown(); - try { - es.awaitTermination(60, TimeUnit.MINUTES); - } catch (InterruptedException e) { - e.printStackTrace(); - } - // System.out.println("Completed thread batch: " + new Date()); - } -} http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/AbstractDiskTest.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/AbstractDiskTest.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/AbstractDiskTest.java deleted file mode 100644 index f41a02b..0000000 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/AbstractDiskTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.vxquery.xtest.util.tests; - -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import org.xml.sax.XMLReader; - -abstract class AbstractDiskTest implements IDiskTest, Runnable { - private String filename; - private int bufferSize; - protected XMLReader parser; - - public void setFile(File file) { - this.filename = file.getAbsolutePath(); - } - - public String getPrintFilename() { - return filename.substring(filename.length() - 20); - } - - public void setBufferSize(int bufferSize) { - this.bufferSize = bufferSize; - } - - public void setParser(XMLReader parser) { - this.parser = parser; - } - - public void start() { - run(); - } - - public void run() { - long size = -1; - // System.out.printf(getPrintFilename() + "\t" + getMessage() + " - Starting%n"); - long start = System.nanoTime(); - try { - size = test(filename, bufferSize); - } catch (IOException e) { - e.printStackTrace(); - } - long end = System.nanoTime(); - long timeDelta = end - start; - double speed = 0; - if (size > 0) { - speed = (size * 1e3) / timeDelta; - } - // System.out.printf("checkSum: %d%n", checkSum); - // System.out.printf(getPrintFilename() + "\t" + getMessage() + "%.1f ms\t%.2f MB/s\t%.2f MB/s", - // (timeDelta) / 1e6, 1024 * 1024 * 1e6 / (timeDelta), speed); - // CSV output of the results. - try { - System.out.printf("%s,", InetAddress.getLocalHost().getHostName()); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - System.out.printf("%s,%s,%.1f,%.2f", filename, getMessage(), (timeDelta) / 1e6, - 1024 * 1024 * 1e6 / (timeDelta), speed); - if (isBuffered() && bufferSize > 0) { - System.out.printf(",%.1f", bufferSize / 1024.0); - } else { - System.out.printf(",0"); - } - System.out.println(); - } - - public boolean isBuffered() { - return true; - } - - abstract public String getMessage(); - - abstract public long test(String filename, int bufferSize) throws IOException; -} http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedParsedCharacterStream.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedParsedCharacterStream.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedParsedCharacterStream.java deleted file mode 100644 index 8a9ee18..0000000 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedParsedCharacterStream.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.vxquery.xtest.util.tests; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class BufferedParsedCharacterStream extends AbstractDiskTest { - @Override - public String getMessage() { - return "Buffered Parsed - Character Stream"; - } - - @Override - public long test(String filename, int bufferSize) throws IOException { - try { - if (bufferSize > 0) { - parser.setProperty("http://apache.org/xml/properties/input-buffer-size", new Integer(bufferSize)); - } - InputStreamReader f = new InputStreamReader(new FileInputStream(filename)); - InputSource in = new InputSource(); - in.setCharacterStream(f); - parser.parse(in); - } catch (SAXException e) { - e.printStackTrace(); - } - return -1; - } -} http://git-wip-us.apache.org/repos/asf/vxquery/blob/51a98938/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedReaderBufferedStream.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedReaderBufferedStream.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedReaderBufferedStream.java deleted file mode 100644 index d964241..0000000 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/util/tests/BufferedReaderBufferedStream.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.vxquery.xtest.util.tests; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; - -public class BufferedReaderBufferedStream extends AbstractDiskTest { - @Override - public String getMessage() { - return "Buffered Reader - Buffered Stream"; - } - - @Override - public long test(String filename, int bufferSize) throws IOException { - BufferedReader f; - if (bufferSize > 0) { - f = new BufferedReader(new InputStreamReader(new BufferedInputStream(new FileInputStream(filename), - bufferSize)), bufferSize); - } else { - f = new BufferedReader(new InputStreamReader(new BufferedInputStream(new FileInputStream(filename)))); - } - int b; - long byteCount = 0L; - long checkSum = 0L; - while ((b = f.read()) != -1) { - checkSum += b; - byteCount++; - } - f.close(); - return byteCount; - } -}
