public static MatrixSchema buildResultSchema(MatrixSchema leftSchema, MatrixSchema rightSchema) { assert(leftSchema.type == rightSchema.type); return buildSchema(leftSchema.getRows(), rightSchema.getColumns(), leftSchema.type); }
protected MatrixSchema(int rows, int columns, MatrixTypes type, FieldReferenceOffsetManager from) { super(from); this.rows = rows; this.columns = columns; this.type = type; this.typeSize = type.size(); }
public static HistogramSumStage newInstance(GraphManager gm, Pipe<HistogramSchema> output, Pipe<HistogramSchema> ... inputs) { return new HistogramSumStage(gm, output, inputs); }
public static <M extends MatrixSchema<M>> Pipe<RowSchema<M>> buildProductGraphRR(GraphManager gm, int targetThreadCount, Pipe<RowSchema<M>> left, Pipe<RowSchema<M>> right) { Pipe<ColumnSchema<M>>[] colResults = buildProductGraphRC(gm, left, right, targetThreadCount); ////////////////// ////////////////// MatrixSchema resultSchema2 = colResults[0].config().schema().rootSchema(); PipeConfig<RowSchema<M>> config = new PipeConfig<RowSchema<M>>(new RowSchema<M>(resultSchema2), resultSchema2.getRows()); config.hideLabels(); Pipe<RowSchema<M>> rowResults = new Pipe<RowSchema<M>>(config); ColumnsToRowsStage<M> ctr = new ColumnsToRowsStage( gm, colResults, rowResults); return rowResults; }
int len) { MatrixSchema<M> leftSchema = leftInput.config().schema().rootSchema(); new Pipe<RowSchema<M>>(leftInput.config().grow2x()); new ColumnComputeStage( gm, inputs, splitterPipes[--splitterPipesCount] = pipe, outputs, resultSchema, leftSchema, rightSchema.getRows(), rightSchema.getColumns(), rightSchema.type); return splitterPipesCount;
/** * * @param graphManager * @param columnPipeInput _in_ Pipes containing ColumnSchema that will be converted to RowSchema * @param matrixPipeOutput _out_ Pipes onto which ColumnSchema will be output to RowSchema */ public ColumnsToRowsStage(GraphManager graphManager, Pipe<ColumnSchema<M>>[] columnPipeInput, Pipe<RowSchema<M>> matrixPipeOutput) { super(graphManager, columnPipeInput, matrixPipeOutput); M matrixSchema = (M) matrixPipeOutput.config().schema().rootSchema(); this.columnPipeInput = columnPipeInput; this.matrixPipeOutput = matrixPipeOutput; this.matrixSchema = matrixSchema; this.shutdownCount = columnPipeInput.length; this.typeSize = matrixSchema.typeSize; this.rowLimit = matrixSchema.getRows(); this.columnLimit = matrixSchema.getColumns(); this.remainingRows = rowLimit; assert(columnLimit==columnPipeInput.length); this.colSizeOf = Pipe.sizeOf(columnPipeInput[0], matrixSchema.columnId); this.matrixSize = Pipe.sizeOf(matrixPipeOutput, matrixSchema.rowId); }
super(graphManager, join(colInput, rowInput), colOutput); this.colInput = colInput; this.rowInput = rowInput; this.rowLimit = resultSchema.getRows(); this.remainingRows = rowLimit; if (cSchema.getColumns() != rRows) { throw new UnsupportedOperationException("column count of left input must match row count of right input "+cSchema.getColumns()+" vs "+rRows); if (resultSchema.getColumns() != rCols) { throw new UnsupportedOperationException("column count of right input must match result output "+ rCols+" vs "+resultSchema.getColumns()); if (resultSchema.getRows() != cSchema.getRows()) { throw new UnsupportedOperationException("rows count of left input must match result output "+cSchema.getColumns()+" vs "+resultSchema.getRows());
private static <M extends MatrixSchema<M>> MatrixSchema resultSchema(Pipe<RowSchema<M>> left, Pipe<RowSchema<M>> right) { MatrixSchema<M> leftSchema1 = left.config().schema().rootSchema(); MatrixSchema<M> rightSchema1 = right.config().schema().rootSchema(); MatrixSchema resultSchema = BuildMatrixCompute.buildResultSchema(leftSchema1, rightSchema1); return resultSchema; }
/** * * @param graphManager * @param input _in_ Input pipe as matrix with RowSchema * @param output _out_ Output pipe in which RowSchema is converted to DecimalSchema */ public ConvertToDecimalStage(GraphManager graphManager, Pipe<RowSchema<M>> input, Pipe<DecimalSchema<M>> output) { super(graphManager, input, output); this.input = input; this.output = output; M schema = (M) input.config().schema(); this.blockSize = schema.getRows()*schema.getColumns(); this.inputType = schema.type; }
protected RowsToColumnRouteStage(GraphManager graphManager, Pipe<RowSchema<M>> rowPipeInput, Pipe<ColumnSchema<M>>[] columnPipeOutput) { super(graphManager, rowPipeInput, columnPipeOutput); M matrixSchema = (M) rowPipeInput.config().schema().rootSchema(); this.rowPipeInput = rowPipeInput; this.columnPipeOutput = columnPipeOutput; this.matrixSchema = matrixSchema; this.rowLimit = matrixSchema.getRows(); this.remainingRows = rowLimit; this.sizeOf = Pipe.sizeOf(columnPipeOutput[0], matrixSchema.columnId); if (matrixSchema.columns != columnPipeOutput.length) { throw new UnsupportedOperationException(matrixSchema.columns+" was expected to match "+columnPipeOutput.length); } }
public DecimalSchema(MatrixSchema<M> matrixSchema) { super(matrixSchema.getColumns(), 1, MatrixTypes.Decimals, FieldReferenceOffsetManager.buildSingleNumberBlockFrom(matrixSchema.columns, MatrixTypes.Decimals.typeMask, "Matrix")); }
protected ColumnSchema(MatrixSchema<M> matrixSchema) { super(matrixSchema.getRows(), 1, matrixSchema.type, FieldReferenceOffsetManager.buildSingleNumberBlockFrom(matrixSchema.rows, matrixSchema.type.typeMask, "Matrix")); this.root = matrixSchema; }
@Override public void run() { while (Pipe.hasContentToRead(input) && Pipe.hasRoomForWrite(output)) { int msgIn = Pipe.takeMsgIdx(input); if (msgIn<0) { Pipe.publishEOF(output); requestShutdown(); return; } int msgSize = Pipe.addMsgIdx(output, msgIn);//WARNING: using the same id as we just took in, inputType.convertToDecimal(blockSize, input, output); Pipe.confirmLowLevelWrite(output, msgSize); Pipe.publishWrites(output); Pipe.confirmLowLevelRead(input, Pipe.sizeOf(input, msgIn)); Pipe.releaseReadLock(input); } }
public static <M extends MatrixSchema<M>> MatrixSchema<M> buildSchema(int rows, int columns, MatrixTypes type) { return new MatrixSchema<M>(rows, columns, type); }
public static HistogramSelectPeakStage newInstance(GraphManager gm, Pipe<HistogramSchema> input, Pipe<ProbabilitySchema> output) { return new HistogramSelectPeakStage(gm,input,output); }
public static void consume(Pipe<ProbabilitySchema> input) { while (PipeReader.tryReadFragment(input)) { int msgIdx = PipeReader.getMsgIdx(input); switch(msgIdx) { case MSG_SELECTION_1: consumeSelection(input); break; case -1: //requestShutdown(); break; } PipeReader.releaseReadLock(input); } }
public static void consume(Pipe<HistogramSchema> input) { while (PipeReader.tryReadFragment(input)) { int msgIdx = PipeReader.getMsgIdx(input); switch(msgIdx) { case MSG_HISTOGRAM_1: consumeHistogram(input); break; case -1: //requestShutdown(); break; } PipeReader.releaseReadLock(input); } }
private void vectorOperations() { long rowSourceLoc = Pipe.getWorkingTailPosition(rowInput); int i = colInput.length; while (--i>=0) { long sourceLoc = Pipe.getWorkingTailPosition(colInput[i]); Pipe.setWorkingTailPosition(rowInput, rowSourceLoc); //add one value to the output pipe //value taken from full rowInput and full inputPipe input type.computeColumn(rRows, colInput[i], rowInput, colOutput[i]); if (remainingRows>0) { //restore for next pass but not for the very last one. Pipe.setWorkingTailPosition(colInput[i],sourceLoc); } } }
public RowSchema(MatrixSchema<M> matrixSchema) { super(matrixSchema.getColumns(), 1, matrixSchema.type, FieldReferenceOffsetManager.buildSingleNumberBlockFrom(matrixSchema.columns, matrixSchema.type.typeMask, "Matrix")); this.root = matrixSchema; }