scala.collection.mutable.ArrayBuffer Java Examples

The following examples show how to use scala.collection.mutable.ArrayBuffer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 6 votes vote down vote up
private ScalarFunctionSplitter createScalarFunctionSplitter(
	int primitiveLeftFieldCount,
	ArrayBuffer<RexNode> extractedRexNodes,
	RexNode tableFunctionNode) {
	return new ScalarFunctionSplitter(
		primitiveLeftFieldCount,
		extractedRexNodes,
		node -> {
			if (PythonUtil.isNonPythonCall(tableFunctionNode)) {
				// splits the RexCalls which contain Python functions into separate node
				return PythonUtil.isPythonCall(node, null);
			} else if (PythonUtil.containsNonPythonCall(node)) {
				// splits the RexCalls which contain non-Python functions into separate node
				return PythonUtil.isNonPythonCall(node);
			} else {
				// splits the RexFieldAccesses which contain non-Python functions into separate node
				return node instanceof RexFieldAccess;
			}
		}
	);
}
 
Example #2
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 6 votes vote down vote up
private ScalarFunctionSplitter createScalarFunctionSplitter(
	int primitiveLeftFieldCount,
	ArrayBuffer<RexNode> extractedRexNodes,
	RexNode tableFunctionNode) {
	return new ScalarFunctionSplitter(
		primitiveLeftFieldCount,
		extractedRexNodes,
		node -> {
			if (PythonUtil.isNonPythonCall(tableFunctionNode)) {
				// splits the RexCalls which contain Python functions into separate node
				return PythonUtil.isPythonCall(node, null);
			} else if (PythonUtil.containsNonPythonCall(node)) {
				// splits the RexCalls which contain non-Python functions into separate node
				return PythonUtil.isNonPythonCall(node);
			} else {
				// splits the RexFieldAccesses which contain non-Python functions into separate node
				return node instanceof RexFieldAccess;
			}
		}
	);
}
 
Example #3
Source File: CollectionUtils.java    From Tok-Android with GNU General Public License v3.0 5 votes vote down vote up
public static List convertArrayBufferToList(ArrayBuffer arrayBuffer) {
    List list = new ArrayList<>();
    Iterator it = arrayBuffer.iterator();
    while (it.hasNext()) {
        list.add(it.next());
    }
    return list;
}
 
Example #4
Source File: MizoRDD.java    From mizo with Apache License 2.0 5 votes vote down vote up
public MizoRDD(SparkContext context, IMizoRDDConfig config, ClassTag<TReturn> classTag) {
    super(context, new ArrayBuffer<>(), classTag);

    if (!Strings.isNullOrEmpty(config.logConfigPath())) {
        PropertyConfigurator.configure(config.logConfigPath());
    }

    this.config = config;
    this.regionsPaths = getRegionsPaths(config.regionDirectoriesPath());
    this.relationTypes = loadRelationTypes(config.titanConfigPath());
}
 
Example #5
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 5 votes vote down vote up
private List<String> createNewFieldNames(
	RelDataType rowType,
	RexBuilder rexBuilder,
	int primitiveFieldCount,
	ArrayBuffer<RexNode> extractedRexNodes,
	List<RexNode> calcProjects) {
	for (int i = 0; i < primitiveFieldCount; i++) {
		calcProjects.add(RexInputRef.of(i, rowType));
	}
	// add the fields of the extracted rex calls.
	Iterator<RexNode> iterator = extractedRexNodes.iterator();
	while (iterator.hasNext()) {
		calcProjects.add(iterator.next());
	}

	List<String> nameList = new LinkedList<>();
	for (int i = 0; i < primitiveFieldCount; i++) {
		nameList.add(rowType.getFieldNames().get(i));
	}
	Iterator<Object> indicesIterator = extractedRexNodes.indices().iterator();
	while (indicesIterator.hasNext()) {
		nameList.add("f" + indicesIterator.next());
	}
	return SqlValidatorUtil.uniquify(
		nameList,
		rexBuilder.getTypeFactory().getTypeSystem().isSchemaCaseSensitive());
}
 
Example #6
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 5 votes vote down vote up
private FlinkLogicalCalc createNewLeftCalc(
	RelNode left,
	RexBuilder rexBuilder,
	ArrayBuffer<RexNode> extractedRexNodes,
	FlinkLogicalCorrelate correlate) {
	// add the fields of the primitive left input.
	List<RexNode> leftCalcProjects = new LinkedList<>();
	RelDataType leftRowType = left.getRowType();
	List<String> leftCalcCalcFieldNames = createNewFieldNames(
		leftRowType,
		rexBuilder,
		leftRowType.getFieldCount(),
		extractedRexNodes,
		leftCalcProjects);

	// create a new calc
	return new FlinkLogicalCalc(
		correlate.getCluster(),
		correlate.getTraitSet(),
		left,
		RexProgram.create(
			leftRowType,
			leftCalcProjects,
			null,
			leftCalcCalcFieldNames,
			rexBuilder));
}
 
Example #7
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 5 votes vote down vote up
private FlinkLogicalCalc createTopCalc(
	int primitiveLeftFieldCount,
	RexBuilder rexBuilder,
	ArrayBuffer<RexNode> extractedRexNodes,
	RelDataType calcRowType,
	FlinkLogicalCorrelate newCorrelate) {
	RexProgram rexProgram = new RexProgramBuilder(newCorrelate.getRowType(), rexBuilder).getProgram();
	int offset = extractedRexNodes.size() + primitiveLeftFieldCount;

	// extract correlate output RexNode.
	List<RexNode> newTopCalcProjects = rexProgram
		.getExprList()
		.stream()
		.filter(x -> x instanceof RexInputRef)
		.filter(x -> {
			int index = ((RexInputRef) x).getIndex();
			return index < primitiveLeftFieldCount || index >= offset;
		})
		.collect(Collectors.toList());

	return new FlinkLogicalCalc(
		newCorrelate.getCluster(),
		newCorrelate.getTraitSet(),
		newCorrelate,
		RexProgram.create(
			newCorrelate.getRowType(),
			newTopCalcProjects,
			null,
			calcRowType,
			rexBuilder));
}
 
Example #8
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 5 votes vote down vote up
private List<String> createNewFieldNames(
	RelDataType rowType,
	RexBuilder rexBuilder,
	int primitiveFieldCount,
	ArrayBuffer<RexNode> extractedRexNodes,
	List<RexNode> calcProjects) {
	for (int i = 0; i < primitiveFieldCount; i++) {
		calcProjects.add(RexInputRef.of(i, rowType));
	}
	// add the fields of the extracted rex calls.
	Iterator<RexNode> iterator = extractedRexNodes.iterator();
	while (iterator.hasNext()) {
		calcProjects.add(iterator.next());
	}

	List<String> nameList = new LinkedList<>();
	for (int i = 0; i < primitiveFieldCount; i++) {
		nameList.add(rowType.getFieldNames().get(i));
	}
	Iterator<Object> indicesIterator = extractedRexNodes.indices().iterator();
	while (indicesIterator.hasNext()) {
		nameList.add("f" + indicesIterator.next());
	}
	return SqlValidatorUtil.uniquify(
		nameList,
		rexBuilder.getTypeFactory().getTypeSystem().isSchemaCaseSensitive());
}
 
Example #9
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 5 votes vote down vote up
private FlinkLogicalCalc createNewLeftCalc(
	RelNode left,
	RexBuilder rexBuilder,
	ArrayBuffer<RexNode> extractedRexNodes,
	FlinkLogicalCorrelate correlate) {
	// add the fields of the primitive left input.
	List<RexNode> leftCalcProjects = new LinkedList<>();
	RelDataType leftRowType = left.getRowType();
	List<String> leftCalcCalcFieldNames = createNewFieldNames(
		leftRowType,
		rexBuilder,
		leftRowType.getFieldCount(),
		extractedRexNodes,
		leftCalcProjects);

	// create a new calc
	return new FlinkLogicalCalc(
		correlate.getCluster(),
		correlate.getTraitSet(),
		left,
		RexProgram.create(
			leftRowType,
			leftCalcProjects,
			null,
			leftCalcCalcFieldNames,
			rexBuilder));
}
 
Example #10
Source File: PythonCorrelateSplitRule.java    From flink with Apache License 2.0 5 votes vote down vote up
private FlinkLogicalCalc createTopCalc(
	int primitiveLeftFieldCount,
	RexBuilder rexBuilder,
	ArrayBuffer<RexNode> extractedRexNodes,
	RelDataType calcRowType,
	FlinkLogicalCorrelate newCorrelate) {
	RexProgram rexProgram = new RexProgramBuilder(newCorrelate.getRowType(), rexBuilder).getProgram();
	int offset = extractedRexNodes.size() + primitiveLeftFieldCount;

	// extract correlate output RexNode.
	List<RexNode> newTopCalcProjects = rexProgram
		.getExprList()
		.stream()
		.filter(x -> x instanceof RexInputRef)
		.filter(x -> {
			int index = ((RexInputRef) x).getIndex();
			return index < primitiveLeftFieldCount || index >= offset;
		})
		.collect(Collectors.toList());

	return new FlinkLogicalCalc(
		newCorrelate.getCluster(),
		newCorrelate.getTraitSet(),
		newCorrelate,
		RexProgram.create(
			newCorrelate.getRowType(),
			newTopCalcProjects,
			null,
			calcRowType,
			rexBuilder));
}