repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.insideSpan | public static DMatrixRMaj insideSpan(DMatrixRMaj[] span , double min , double max , Random rand ) {
DMatrixRMaj A = new DMatrixRMaj(span.length,1);
DMatrixRMaj B = new DMatrixRMaj(span[0].getNumElements(),1);
for( int i = 0; i < span.length; i++ ) {
B.set(span[i]);
double val = rand.nextDouble()*(max-min)+min;
CommonOps_DDRM.scale(val,B);
CommonOps_DDRM.add(A,B,A);
}
return A;
} | java | public static DMatrixRMaj insideSpan(DMatrixRMaj[] span , double min , double max , Random rand ) {
DMatrixRMaj A = new DMatrixRMaj(span.length,1);
DMatrixRMaj B = new DMatrixRMaj(span[0].getNumElements(),1);
for( int i = 0; i < span.length; i++ ) {
B.set(span[i]);
double val = rand.nextDouble()*(max-min)+min;
CommonOps_DDRM.scale(val,B);
CommonOps_DDRM.add(A,B,A);
}
return A;
} | [
"public",
"static",
"DMatrixRMaj",
"insideSpan",
"(",
"DMatrixRMaj",
"[",
"]",
"span",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"DMatrixRMaj",
"A",
"=",
"new",
"DMatrixRMaj",
"(",
"span",
".",
"length",
",",
"1",
")",
... | Creates a random vector that is inside the specified span.
@param span The span the random vector belongs in.
@param rand RNG
@return A random vector within the specified span. | [
"Creates",
"a",
"random",
"vector",
"that",
"is",
"inside",
"the",
"specified",
"span",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L110-L125 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.diagonal | public static DMatrixRMaj diagonal(int N , double min , double max , Random rand ) {
return diagonal(N,N,min,max,rand);
} | java | public static DMatrixRMaj diagonal(int N , double min , double max , Random rand ) {
return diagonal(N,N,min,max,rand);
} | [
"public",
"static",
"DMatrixRMaj",
"diagonal",
"(",
"int",
"N",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"return",
"diagonal",
"(",
"N",
",",
"N",
",",
"min",
",",
"max",
",",
"rand",
")",
";",
"}"
] | Creates a random diagonal matrix where the diagonal elements are selected from a uniform
distribution that goes from min to max.
@param N Dimension of the matrix.
@param min Minimum value of a diagonal element.
@param max Maximum value of a diagonal element.
@param rand Random number generator.
@return A random diagonal matrix. | [
"Creates",
"a",
"random",
"diagonal",
"matrix",
"where",
"the",
"diagonal",
"elements",
"are",
"selected",
"from",
"a",
"uniform",
"distribution",
"that",
"goes",
"from",
"min",
"to",
"max",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L163-L165 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.diagonal | public static DMatrixRMaj diagonal(int numRows , int numCols , double min , double max , Random rand ) {
if( max < min )
throw new IllegalArgumentException("The max must be >= the min");
DMatrixRMaj ret = new DMatrixRMaj(numRows,numCols);
int N = Math.min(numRows,numCols);
double r = max-min;
for( int i = 0; i < N; i++ ) {
ret.set(i,i, rand.nextDouble()*r+min);
}
return ret;
} | java | public static DMatrixRMaj diagonal(int numRows , int numCols , double min , double max , Random rand ) {
if( max < min )
throw new IllegalArgumentException("The max must be >= the min");
DMatrixRMaj ret = new DMatrixRMaj(numRows,numCols);
int N = Math.min(numRows,numCols);
double r = max-min;
for( int i = 0; i < N; i++ ) {
ret.set(i,i, rand.nextDouble()*r+min);
}
return ret;
} | [
"public",
"static",
"DMatrixRMaj",
"diagonal",
"(",
"int",
"numRows",
",",
"int",
"numCols",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"if",
"(",
"max",
"<",
"min",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
... | Creates a random matrix where all elements are zero but diagonal elements. Diagonal elements
randomly drawn from a uniform distribution from min to max, inclusive.
@param numRows Number of rows in the returned matrix..
@param numCols Number of columns in the returned matrix.
@param min Minimum value of a diagonal element.
@param max Maximum value of a diagonal element.
@param rand Random number generator.
@return A random diagonal matrix. | [
"Creates",
"a",
"random",
"matrix",
"where",
"all",
"elements",
"are",
"zero",
"but",
"diagonal",
"elements",
".",
"Diagonal",
"elements",
"randomly",
"drawn",
"from",
"a",
"uniform",
"distribution",
"from",
"min",
"to",
"max",
"inclusive",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L178-L193 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.symmetricWithEigenvalues | public static DMatrixRMaj symmetricWithEigenvalues(int num, Random rand , double ...eigenvalues ) {
DMatrixRMaj V = RandomMatrices_DDRM.orthogonal(num,num,rand);
DMatrixRMaj D = CommonOps_DDRM.diag(eigenvalues);
DMatrixRMaj temp = new DMatrixRMaj(num,num);
CommonOps_DDRM.mult(V,D,temp);
CommonOps_DDRM.multTransB(temp,V,D);
return D;
} | java | public static DMatrixRMaj symmetricWithEigenvalues(int num, Random rand , double ...eigenvalues ) {
DMatrixRMaj V = RandomMatrices_DDRM.orthogonal(num,num,rand);
DMatrixRMaj D = CommonOps_DDRM.diag(eigenvalues);
DMatrixRMaj temp = new DMatrixRMaj(num,num);
CommonOps_DDRM.mult(V,D,temp);
CommonOps_DDRM.multTransB(temp,V,D);
return D;
} | [
"public",
"static",
"DMatrixRMaj",
"symmetricWithEigenvalues",
"(",
"int",
"num",
",",
"Random",
"rand",
",",
"double",
"...",
"eigenvalues",
")",
"{",
"DMatrixRMaj",
"V",
"=",
"RandomMatrices_DDRM",
".",
"orthogonal",
"(",
"num",
",",
"num",
",",
"rand",
")",... | Creates a new random symmetric matrix that will have the specified real eigenvalues.
@param num Dimension of the resulting matrix.
@param rand Random number generator.
@param eigenvalues Set of real eigenvalues that the matrix will have.
@return A random matrix with the specified eigenvalues. | [
"Creates",
"a",
"new",
"random",
"symmetric",
"matrix",
"that",
"will",
"have",
"the",
"specified",
"real",
"eigenvalues",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L247-L257 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.randomBinary | public static BMatrixRMaj randomBinary(int numRow , int numCol , Random rand ) {
BMatrixRMaj mat = new BMatrixRMaj(numRow,numCol);
setRandomB(mat, rand);
return mat;
} | java | public static BMatrixRMaj randomBinary(int numRow , int numCol , Random rand ) {
BMatrixRMaj mat = new BMatrixRMaj(numRow,numCol);
setRandomB(mat, rand);
return mat;
} | [
"public",
"static",
"BMatrixRMaj",
"randomBinary",
"(",
"int",
"numRow",
",",
"int",
"numCol",
",",
"Random",
"rand",
")",
"{",
"BMatrixRMaj",
"mat",
"=",
"new",
"BMatrixRMaj",
"(",
"numRow",
",",
"numCol",
")",
";",
"setRandomB",
"(",
"mat",
",",
"rand",
... | Returns new boolean matrix with true or false values selected with equal probability.
@param numRow Number of rows in the new matrix.
@param numCol Number of columns in the new matrix.
@param rand Random number generator used to fill the matrix.
@return The randomly generated matrix. | [
"Returns",
"new",
"boolean",
"matrix",
"with",
"true",
"or",
"false",
"values",
"selected",
"with",
"equal",
"probability",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L284-L290 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.symmetric | public static DMatrixRMaj symmetric(int length, double min, double max, Random rand) {
DMatrixRMaj A = new DMatrixRMaj(length,length);
symmetric(A,min,max,rand);
return A;
} | java | public static DMatrixRMaj symmetric(int length, double min, double max, Random rand) {
DMatrixRMaj A = new DMatrixRMaj(length,length);
symmetric(A,min,max,rand);
return A;
} | [
"public",
"static",
"DMatrixRMaj",
"symmetric",
"(",
"int",
"length",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"DMatrixRMaj",
"A",
"=",
"new",
"DMatrixRMaj",
"(",
"length",
",",
"length",
")",
";",
"symmetric",
"(",
"A... | Creates a random symmetric matrix whose values are selected from an uniform distribution
from min to max, inclusive.
@param length Width and height of the matrix.
@param min Minimum value an element can have.
@param max Maximum value an element can have.
@param rand Random number generator.
@return A symmetric matrix. | [
"Creates",
"a",
"random",
"symmetric",
"matrix",
"whose",
"values",
"are",
"selected",
"from",
"an",
"uniform",
"distribution",
"from",
"min",
"to",
"max",
"inclusive",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L467-L473 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.symmetric | public static void symmetric(DMatrixRMaj A, double min, double max, Random rand) {
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be a square matrix");
double range = max-min;
int length = A.numRows;
for( int i = 0; i < length; i++ ) {
for( int j = i; j < length; j++ ) {
double val = rand.nextDouble()*range + min;
A.set(i,j,val);
A.set(j,i,val);
}
}
} | java | public static void symmetric(DMatrixRMaj A, double min, double max, Random rand) {
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be a square matrix");
double range = max-min;
int length = A.numRows;
for( int i = 0; i < length; i++ ) {
for( int j = i; j < length; j++ ) {
double val = rand.nextDouble()*range + min;
A.set(i,j,val);
A.set(j,i,val);
}
}
} | [
"public",
"static",
"void",
"symmetric",
"(",
"DMatrixRMaj",
"A",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"("... | Sets the provided square matrix to be a random symmetric matrix whose values are selected from an uniform distribution
from min to max, inclusive.
@param A The matrix that is to be modified. Must be square. Modified.
@param min Minimum value an element can have.
@param max Maximum value an element can have.
@param rand Random number generator. | [
"Sets",
"the",
"provided",
"square",
"matrix",
"to",
"be",
"a",
"random",
"symmetric",
"matrix",
"whose",
"values",
"are",
"selected",
"from",
"an",
"uniform",
"distribution",
"from",
"min",
"to",
"max",
"inclusive",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L484-L499 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java | RandomMatrices_DDRM.triangularUpper | public static DMatrixRMaj triangularUpper(int dimen , int hessenberg , double min , double max , Random rand )
{
if( hessenberg < 0 )
throw new RuntimeException("hessenberg must be more than or equal to 0");
double range = max-min;
DMatrixRMaj A = new DMatrixRMaj(dimen,dimen);
for( int i = 0; i < dimen; i++ ) {
int start = i <= hessenberg ? 0 : i-hessenberg;
for( int j = start; j < dimen; j++ ) {
A.set(i,j, rand.nextDouble()*range+min);
}
}
return A;
} | java | public static DMatrixRMaj triangularUpper(int dimen , int hessenberg , double min , double max , Random rand )
{
if( hessenberg < 0 )
throw new RuntimeException("hessenberg must be more than or equal to 0");
double range = max-min;
DMatrixRMaj A = new DMatrixRMaj(dimen,dimen);
for( int i = 0; i < dimen; i++ ) {
int start = i <= hessenberg ? 0 : i-hessenberg;
for( int j = start; j < dimen; j++ ) {
A.set(i,j, rand.nextDouble()*range+min);
}
}
return A;
} | [
"public",
"static",
"DMatrixRMaj",
"triangularUpper",
"(",
"int",
"dimen",
",",
"int",
"hessenberg",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"if",
"(",
"hessenberg",
"<",
"0",
")",
"throw",
"new",
"RuntimeException",
"(... | Creates an upper triangular matrix whose values are selected from a uniform distribution. If hessenberg
is greater than zero then a hessenberg matrix of the specified degree is created instead.
@param dimen Number of rows and columns in the matrix..
@param hessenberg 0 for triangular matrix and > 0 for hessenberg matrix.
@param min minimum value an element can be.
@param max maximum value an element can be.
@param rand random number generator used.
@return The randomly generated matrix. | [
"Creates",
"an",
"upper",
"triangular",
"matrix",
"whose",
"values",
"are",
"selected",
"from",
"a",
"uniform",
"distribution",
".",
"If",
"hessenberg",
"is",
"greater",
"than",
"zero",
"then",
"a",
"hessenberg",
"matrix",
"of",
"the",
"specified",
"degree",
"... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/RandomMatrices_DDRM.java#L512-L531 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CovarianceRandomDraw_DDRM.java | CovarianceRandomDraw_DDRM.computeLikelihoodP | public double computeLikelihoodP() {
double ret = 1.0;
for( int i = 0; i < r.numRows; i++ ) {
double a = r.get(i,0);
ret *= Math.exp(-a*a/2.0);
}
return ret;
} | java | public double computeLikelihoodP() {
double ret = 1.0;
for( int i = 0; i < r.numRows; i++ ) {
double a = r.get(i,0);
ret *= Math.exp(-a*a/2.0);
}
return ret;
} | [
"public",
"double",
"computeLikelihoodP",
"(",
")",
"{",
"double",
"ret",
"=",
"1.0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"r",
".",
"numRows",
";",
"i",
"++",
")",
"{",
"double",
"a",
"=",
"r",
".",
"get",
"(",
"i",
",",
"0"... | Computes the likelihood of the random draw
@return The likelihood. | [
"Computes",
"the",
"likelihood",
"of",
"the",
"random",
"draw"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CovarianceRandomDraw_DDRM.java#L73-L83 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/SymmetricQRAlgorithmDecomposition_DDRM.java | SymmetricQRAlgorithmDecomposition_DDRM.decompose | @Override
public boolean decompose(DMatrixRMaj orig) {
if( orig.numCols != orig.numRows )
throw new IllegalArgumentException("Matrix must be square.");
if( orig.numCols <= 0 )
return false;
int N = orig.numRows;
// compute a similar tridiagonal matrix
if( !decomp.decompose(orig) )
return false;
if( diag == null || diag.length < N) {
diag = new double[N];
off = new double[N-1];
}
decomp.getDiagonal(diag,off);
// Tell the helper to work with this matrix
helper.init(diag,off,N);
if( computeVectors ) {
if( computeVectorsWithValues ) {
return extractTogether();
} else {
return extractSeparate(N);
}
} else {
return computeEigenValues();
}
} | java | @Override
public boolean decompose(DMatrixRMaj orig) {
if( orig.numCols != orig.numRows )
throw new IllegalArgumentException("Matrix must be square.");
if( orig.numCols <= 0 )
return false;
int N = orig.numRows;
// compute a similar tridiagonal matrix
if( !decomp.decompose(orig) )
return false;
if( diag == null || diag.length < N) {
diag = new double[N];
off = new double[N-1];
}
decomp.getDiagonal(diag,off);
// Tell the helper to work with this matrix
helper.init(diag,off,N);
if( computeVectors ) {
if( computeVectorsWithValues ) {
return extractTogether();
} else {
return extractSeparate(N);
}
} else {
return computeEigenValues();
}
} | [
"@",
"Override",
"public",
"boolean",
"decompose",
"(",
"DMatrixRMaj",
"orig",
")",
"{",
"if",
"(",
"orig",
".",
"numCols",
"!=",
"orig",
".",
"numRows",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Matrix must be square.\"",
")",
";",
"if",
"(",
... | Decomposes the matrix using the QR algorithm. Care was taken to minimize unnecessary memory copying
and cache skipping.
@param orig The matrix which is being decomposed. Not modified.
@return true if it decomposed the matrix or false if an error was detected. This will not catch all errors. | [
"Decomposes",
"the",
"matrix",
"using",
"the",
"QR",
"algorithm",
".",
"Care",
"was",
"taken",
"to",
"minimize",
"unnecessary",
"memory",
"copying",
"and",
"cache",
"skipping",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/SymmetricQRAlgorithmDecomposition_DDRM.java#L133-L164 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/SymmetricQRAlgorithmDecomposition_DDRM.java | SymmetricQRAlgorithmDecomposition_DDRM.computeEigenValues | private boolean computeEigenValues() {
// make a copy of the internal tridiagonal matrix data for later use
diagSaved = helper.copyDiag(diagSaved);
offSaved = helper.copyOff(offSaved);
vector.setQ(null);
vector.setFastEigenvalues(true);
// extract the eigenvalues
if( !vector.process(-1,null,null) )
return false;
// save a copy of them since this data structure will be recycled next
values = helper.copyEigenvalues(values);
return true;
} | java | private boolean computeEigenValues() {
// make a copy of the internal tridiagonal matrix data for later use
diagSaved = helper.copyDiag(diagSaved);
offSaved = helper.copyOff(offSaved);
vector.setQ(null);
vector.setFastEigenvalues(true);
// extract the eigenvalues
if( !vector.process(-1,null,null) )
return false;
// save a copy of them since this data structure will be recycled next
values = helper.copyEigenvalues(values);
return true;
} | [
"private",
"boolean",
"computeEigenValues",
"(",
")",
"{",
"// make a copy of the internal tridiagonal matrix data for later use",
"diagSaved",
"=",
"helper",
".",
"copyDiag",
"(",
"diagSaved",
")",
";",
"offSaved",
"=",
"helper",
".",
"copyOff",
"(",
"offSaved",
")",
... | Computes eigenvalues only
@return | [
"Computes",
"eigenvalues",
"only"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/SymmetricQRAlgorithmDecomposition_DDRM.java#L226-L241 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/lu/LUDecompositionBase_ZDRM.java | LUDecompositionBase_ZDRM.solveL | protected void solveL(double[] vv) {
int ii = 0;
for( int i = 0; i < n; i++ ) {
int ip = indx[i];
double sumReal = vv[ip*2];
double sumImg = vv[ip*2+1];
vv[ip*2] = vv[i*2];
vv[ip*2+1] = vv[i*2+1];
if( ii != 0 ) {
// for( int j = ii-1; j < i; j++ )
// sum -= dataLU[i* n +j]*vv[j];
int index = i*stride + (ii-1)*2;
for( int j = ii-1; j < i; j++ ){
double luReal = dataLU[index++];
double luImg = dataLU[index++];
double vvReal = vv[j*2];
double vvImg = vv[j*2+1];
sumReal -= luReal*vvReal - luImg*vvImg;
sumImg -= luReal*vvImg + luImg*vvReal;
}
} else if( sumReal*sumReal + sumImg*sumImg != 0.0 ) {
ii=i+1;
}
vv[i*2] = sumReal;
vv[i*2+1] = sumImg;
}
} | java | protected void solveL(double[] vv) {
int ii = 0;
for( int i = 0; i < n; i++ ) {
int ip = indx[i];
double sumReal = vv[ip*2];
double sumImg = vv[ip*2+1];
vv[ip*2] = vv[i*2];
vv[ip*2+1] = vv[i*2+1];
if( ii != 0 ) {
// for( int j = ii-1; j < i; j++ )
// sum -= dataLU[i* n +j]*vv[j];
int index = i*stride + (ii-1)*2;
for( int j = ii-1; j < i; j++ ){
double luReal = dataLU[index++];
double luImg = dataLU[index++];
double vvReal = vv[j*2];
double vvImg = vv[j*2+1];
sumReal -= luReal*vvReal - luImg*vvImg;
sumImg -= luReal*vvImg + luImg*vvReal;
}
} else if( sumReal*sumReal + sumImg*sumImg != 0.0 ) {
ii=i+1;
}
vv[i*2] = sumReal;
vv[i*2+1] = sumImg;
}
} | [
"protected",
"void",
"solveL",
"(",
"double",
"[",
"]",
"vv",
")",
"{",
"int",
"ii",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"int",
"ip",
"=",
"indx",
"[",
"i",
"]",
";",
"double",
"s... | Solve the using the lower triangular matrix in LU. Diagonal elements are assumed
to be 1 | [
"Solve",
"the",
"using",
"the",
"lower",
"triangular",
"matrix",
"in",
"LU",
".",
"Diagonal",
"elements",
"are",
"assumed",
"to",
"be",
"1"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/lu/LUDecompositionBase_ZDRM.java#L259-L291 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/chol/CholeskyBlockHelper_DDRM.java | CholeskyBlockHelper_DDRM.decompose | public boolean decompose(DMatrixRMaj mat , int indexStart , int n ) {
double m[] = mat.data;
double el_ii;
double div_el_ii=0;
for( int i = 0; i < n; i++ ) {
for( int j = i; j < n; j++ ) {
double sum = m[indexStart+i*mat.numCols+j];
int iEl = i*n;
int jEl = j*n;
int end = iEl+i;
// k = 0:i-1
for( ; iEl<end; iEl++,jEl++ ) {
// sum -= el[i*n+k]*el[j*n+k];
sum -= el[iEl]*el[jEl];
}
if( i == j ) {
// is it positive-definate?
if( sum <= 0.0 )
return false;
el_ii = Math.sqrt(sum);
el[i*n+i] = el_ii;
m[indexStart+i*mat.numCols+i] = el_ii;
div_el_ii = 1.0/el_ii;
} else {
double v = sum*div_el_ii;
el[j*n+i] = v;
m[indexStart+j*mat.numCols+i] = v;
}
}
}
return true;
} | java | public boolean decompose(DMatrixRMaj mat , int indexStart , int n ) {
double m[] = mat.data;
double el_ii;
double div_el_ii=0;
for( int i = 0; i < n; i++ ) {
for( int j = i; j < n; j++ ) {
double sum = m[indexStart+i*mat.numCols+j];
int iEl = i*n;
int jEl = j*n;
int end = iEl+i;
// k = 0:i-1
for( ; iEl<end; iEl++,jEl++ ) {
// sum -= el[i*n+k]*el[j*n+k];
sum -= el[iEl]*el[jEl];
}
if( i == j ) {
// is it positive-definate?
if( sum <= 0.0 )
return false;
el_ii = Math.sqrt(sum);
el[i*n+i] = el_ii;
m[indexStart+i*mat.numCols+i] = el_ii;
div_el_ii = 1.0/el_ii;
} else {
double v = sum*div_el_ii;
el[j*n+i] = v;
m[indexStart+j*mat.numCols+i] = v;
}
}
}
return true;
} | [
"public",
"boolean",
"decompose",
"(",
"DMatrixRMaj",
"mat",
",",
"int",
"indexStart",
",",
"int",
"n",
")",
"{",
"double",
"m",
"[",
"]",
"=",
"mat",
".",
"data",
";",
"double",
"el_ii",
";",
"double",
"div_el_ii",
"=",
"0",
";",
"for",
"(",
"int",
... | Decomposes a submatrix. The results are written to the submatrix
and to its internal matrix L.
@param mat A matrix which has a submatrix that needs to be inverted
@param indexStart the first index of the submatrix
@param n The width of the submatrix that is to be inverted.
@return True if it was able to finish the decomposition. | [
"Decomposes",
"a",
"submatrix",
".",
"The",
"results",
"are",
"written",
"to",
"the",
"submatrix",
"and",
"to",
"its",
"internal",
"matrix",
"L",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/chol/CholeskyBlockHelper_DDRM.java#L59-L96 | train |
lessthanoptimal/ejml | main/ejml-experimental/src/org/ejml/dense/row/misc/PermuteArray.java | PermuteArray.createList | public static List<int[]> createList( int N )
{
int data[] = new int[ N ];
for( int i = 0; i < data.length; i++ ) {
data[i] = -1;
}
List<int[]> ret = new ArrayList<int[]>();
createList(data,0,-1,ret);
return ret;
} | java | public static List<int[]> createList( int N )
{
int data[] = new int[ N ];
for( int i = 0; i < data.length; i++ ) {
data[i] = -1;
}
List<int[]> ret = new ArrayList<int[]>();
createList(data,0,-1,ret);
return ret;
} | [
"public",
"static",
"List",
"<",
"int",
"[",
"]",
">",
"createList",
"(",
"int",
"N",
")",
"{",
"int",
"data",
"[",
"]",
"=",
"new",
"int",
"[",
"N",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i"... | Creates a list of all permutations for a set with N elements.
@param N Number of elements in the list being permuted.
@return A list containing all the permutations. | [
"Creates",
"a",
"list",
"of",
"all",
"permutations",
"for",
"a",
"set",
"with",
"N",
"elements",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/src/org/ejml/dense/row/misc/PermuteArray.java#L107-L119 | train |
lessthanoptimal/ejml | main/ejml-experimental/src/org/ejml/dense/row/misc/PermuteArray.java | PermuteArray.createList | private static void createList( int data[], int k , int level , List<int[]> ret )
{
data[k] = level;
if( level < data.length-1 ) {
for( int i = 0; i < data.length; i++ ) {
if( data[i] == -1 ) {
createList(data,i,level+1,ret);
}
}
} else {
int []copy = new int[data.length];
System.arraycopy(data,0,copy,0,data.length);
ret.add(copy);
}
data[k] = -1;
} | java | private static void createList( int data[], int k , int level , List<int[]> ret )
{
data[k] = level;
if( level < data.length-1 ) {
for( int i = 0; i < data.length; i++ ) {
if( data[i] == -1 ) {
createList(data,i,level+1,ret);
}
}
} else {
int []copy = new int[data.length];
System.arraycopy(data,0,copy,0,data.length);
ret.add(copy);
}
data[k] = -1;
} | [
"private",
"static",
"void",
"createList",
"(",
"int",
"data",
"[",
"]",
",",
"int",
"k",
",",
"int",
"level",
",",
"List",
"<",
"int",
"[",
"]",
">",
"ret",
")",
"{",
"data",
"[",
"k",
"]",
"=",
"level",
";",
"if",
"(",
"level",
"<",
"data",
... | Internal function that uses recursion to create the list | [
"Internal",
"function",
"that",
"uses",
"recursion",
"to",
"create",
"the",
"list"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/src/org/ejml/dense/row/misc/PermuteArray.java#L125-L141 | train |
lessthanoptimal/ejml | main/ejml-experimental/src/org/ejml/dense/row/misc/PermuteArray.java | PermuteArray.next | public int[] next()
{
boolean hasNewPerm = false;
escape:while( level >= 0) {
// boolean foundZero = false;
for( int i = iter[level]; i < data.length; i = iter[level] ) {
iter[level]++;
if( data[i] == -1 ) {
level++;
data[i] = level-1;
if( level >= data.length ) {
// a new permutation has been created return the results.
hasNewPerm = true;
System.arraycopy(data,0,ret,0,ret.length);
level = level-1;
data[i] = -1;
break escape;
} else {
valk[level] = i;
}
}
}
data[valk[level]] = -1;
iter[level] = 0;
level = level-1;
}
if( hasNewPerm )
return ret;
return null;
} | java | public int[] next()
{
boolean hasNewPerm = false;
escape:while( level >= 0) {
// boolean foundZero = false;
for( int i = iter[level]; i < data.length; i = iter[level] ) {
iter[level]++;
if( data[i] == -1 ) {
level++;
data[i] = level-1;
if( level >= data.length ) {
// a new permutation has been created return the results.
hasNewPerm = true;
System.arraycopy(data,0,ret,0,ret.length);
level = level-1;
data[i] = -1;
break escape;
} else {
valk[level] = i;
}
}
}
data[valk[level]] = -1;
iter[level] = 0;
level = level-1;
}
if( hasNewPerm )
return ret;
return null;
} | [
"public",
"int",
"[",
"]",
"next",
"(",
")",
"{",
"boolean",
"hasNewPerm",
"=",
"false",
";",
"escape",
":",
"while",
"(",
"level",
">=",
"0",
")",
"{",
"// boolean foundZero = false;",
"for",
"(",
"int",
"i",
"=",
"iter",
"[",
"level",
"]",
... | Creates the next permutation in the sequence.
@return An array containing the permutation. The returned array is modified each time this function is called. | [
"Creates",
"the",
"next",
"permutation",
"in",
"the",
"sequence",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/src/org/ejml/dense/row/misc/PermuteArray.java#L148-L183 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/triplet/RandomMatrices_DSTL.java | RandomMatrices_DSTL.uniform | public static DMatrixSparseTriplet uniform(int numRows , int numCols , int nz_total ,
double min , double max , Random rand ) {
// Create a list of all the possible element values
int N = numCols*numRows;
if( N < 0 )
throw new IllegalArgumentException("matrix size is too large");
nz_total = Math.min(N,nz_total);
int selected[] = new int[N];
for (int i = 0; i < N; i++) {
selected[i] = i;
}
for (int i = 0; i < nz_total; i++) {
int s = rand.nextInt(N);
int tmp = selected[s];
selected[s] = selected[i];
selected[i] = tmp;
}
// Create a sparse matrix
DMatrixSparseTriplet ret = new DMatrixSparseTriplet(numRows,numCols,nz_total);
for (int i = 0; i < nz_total; i++) {
int row = selected[i]/numCols;
int col = selected[i]%numCols;
double value = rand.nextDouble()*(max-min)+min;
ret.addItem(row,col, value);
}
return ret;
} | java | public static DMatrixSparseTriplet uniform(int numRows , int numCols , int nz_total ,
double min , double max , Random rand ) {
// Create a list of all the possible element values
int N = numCols*numRows;
if( N < 0 )
throw new IllegalArgumentException("matrix size is too large");
nz_total = Math.min(N,nz_total);
int selected[] = new int[N];
for (int i = 0; i < N; i++) {
selected[i] = i;
}
for (int i = 0; i < nz_total; i++) {
int s = rand.nextInt(N);
int tmp = selected[s];
selected[s] = selected[i];
selected[i] = tmp;
}
// Create a sparse matrix
DMatrixSparseTriplet ret = new DMatrixSparseTriplet(numRows,numCols,nz_total);
for (int i = 0; i < nz_total; i++) {
int row = selected[i]/numCols;
int col = selected[i]%numCols;
double value = rand.nextDouble()*(max-min)+min;
ret.addItem(row,col, value);
}
return ret;
} | [
"public",
"static",
"DMatrixSparseTriplet",
"uniform",
"(",
"int",
"numRows",
",",
"int",
"numCols",
",",
"int",
"nz_total",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"// Create a list of all the possible element values",
"int",
... | Randomly generates matrix with the specified number of matrix elements filled with values from min to max.
@param numRows Number of rows
@param numCols Number of columns
@param nz_total Total number of non-zero elements in the matrix
@param min Minimum value
@param max maximum value
@param rand Random number generated
@return Randomly generated matrix | [
"Randomly",
"generates",
"matrix",
"with",
"the",
"specified",
"number",
"of",
"matrix",
"elements",
"filled",
"with",
"values",
"from",
"min",
"to",
"max",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/triplet/RandomMatrices_DSTL.java#L40-L73 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/BlockHouseHolder_DDRB.java | BlockHouseHolder_DDRB.decomposeQR_block_col | public static boolean decomposeQR_block_col( final int blockLength ,
final DSubmatrixD1 Y ,
final double gamma[] )
{
int width = Y.col1-Y.col0;
int height = Y.row1-Y.row0;
int min = Math.min(width,height);
for( int i = 0; i < min; i++ ) {
// compute the householder vector
if (!computeHouseHolderCol(blockLength, Y, gamma, i))
return false;
// apply to rest of the columns in the block
rank1UpdateMultR_Col(blockLength,Y,i,gamma[Y.col0+i]);
}
return true;
} | java | public static boolean decomposeQR_block_col( final int blockLength ,
final DSubmatrixD1 Y ,
final double gamma[] )
{
int width = Y.col1-Y.col0;
int height = Y.row1-Y.row0;
int min = Math.min(width,height);
for( int i = 0; i < min; i++ ) {
// compute the householder vector
if (!computeHouseHolderCol(blockLength, Y, gamma, i))
return false;
// apply to rest of the columns in the block
rank1UpdateMultR_Col(blockLength,Y,i,gamma[Y.col0+i]);
}
return true;
} | [
"public",
"static",
"boolean",
"decomposeQR_block_col",
"(",
"final",
"int",
"blockLength",
",",
"final",
"DSubmatrixD1",
"Y",
",",
"final",
"double",
"gamma",
"[",
"]",
")",
"{",
"int",
"width",
"=",
"Y",
".",
"col1",
"-",
"Y",
".",
"col0",
";",
"int",
... | Performs a standard QR decomposition on the specified submatrix that is one block wide.
@param blockLength
@param Y
@param gamma | [
"Performs",
"a",
"standard",
"QR",
"decomposition",
"on",
"the",
"specified",
"submatrix",
"that",
"is",
"one",
"block",
"wide",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/BlockHouseHolder_DDRB.java#L50-L67 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/BlockHouseHolder_DDRB.java | BlockHouseHolder_DDRB.divideElementsCol | public static void divideElementsCol(final int blockLength ,
final DSubmatrixD1 Y , final int col , final double val ) {
final int width = Math.min(blockLength,Y.col1-Y.col0);
final double dataY[] = Y.original.data;
for( int i = Y.row0; i < Y.row1; i += blockLength ) {
int height = Math.min( blockLength , Y.row1 - i );
int index = i*Y.original.numCols + height*Y.col0 + col;
if( i == Y.row0 ) {
index += width*(col+1);
for( int k = col+1; k < height; k++ , index += width ) {
dataY[index] /= val;
}
} else {
int endIndex = index + width*height;
//for( int k = 0; k < height; k++
for( ; index != endIndex; index += width ) {
dataY[index] /= val;
}
}
}
} | java | public static void divideElementsCol(final int blockLength ,
final DSubmatrixD1 Y , final int col , final double val ) {
final int width = Math.min(blockLength,Y.col1-Y.col0);
final double dataY[] = Y.original.data;
for( int i = Y.row0; i < Y.row1; i += blockLength ) {
int height = Math.min( blockLength , Y.row1 - i );
int index = i*Y.original.numCols + height*Y.col0 + col;
if( i == Y.row0 ) {
index += width*(col+1);
for( int k = col+1; k < height; k++ , index += width ) {
dataY[index] /= val;
}
} else {
int endIndex = index + width*height;
//for( int k = 0; k < height; k++
for( ; index != endIndex; index += width ) {
dataY[index] /= val;
}
}
}
} | [
"public",
"static",
"void",
"divideElementsCol",
"(",
"final",
"int",
"blockLength",
",",
"final",
"DSubmatrixD1",
"Y",
",",
"final",
"int",
"col",
",",
"final",
"double",
"val",
")",
"{",
"final",
"int",
"width",
"=",
"Math",
".",
"min",
"(",
"blockLength... | Divides the elements at the specified column by 'val'. Takes in account
leading zeros and one. | [
"Divides",
"the",
"elements",
"at",
"the",
"specified",
"column",
"by",
"val",
".",
"Takes",
"in",
"account",
"leading",
"zeros",
"and",
"one",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/BlockHouseHolder_DDRB.java#L478-L503 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/BlockHouseHolder_DDRB.java | BlockHouseHolder_DDRB.multAdd_zeros | public static void multAdd_zeros(final int blockLength ,
final DSubmatrixD1 Y , final DSubmatrixD1 B ,
final DSubmatrixD1 C )
{
int widthY = Y.col1 - Y.col0;
for( int i = Y.row0; i < Y.row1; i += blockLength ) {
int heightY = Math.min( blockLength , Y.row1 - i );
for( int j = B.col0; j < B.col1; j += blockLength ) {
int widthB = Math.min( blockLength , B.col1 - j );
int indexC = (i-Y.row0+C.row0)*C.original.numCols + (j-B.col0+C.col0)*heightY;
for( int k = Y.col0; k < Y.col1; k += blockLength ) {
int indexY = i*Y.original.numCols + k*heightY;
int indexB = (k-Y.col0+B.row0)*B.original.numCols + j*widthY;
if( i == Y.row0 ) {
multBlockAdd_zerosone(Y.original.data,B.original.data,C.original.data,
indexY,indexB,indexC,heightY,widthY,widthB);
} else {
InnerMultiplication_DDRB.blockMultPlus(Y.original.data,B.original.data,C.original.data,
indexY,indexB,indexC,heightY,widthY,widthB);
}
}
}
}
} | java | public static void multAdd_zeros(final int blockLength ,
final DSubmatrixD1 Y , final DSubmatrixD1 B ,
final DSubmatrixD1 C )
{
int widthY = Y.col1 - Y.col0;
for( int i = Y.row0; i < Y.row1; i += blockLength ) {
int heightY = Math.min( blockLength , Y.row1 - i );
for( int j = B.col0; j < B.col1; j += blockLength ) {
int widthB = Math.min( blockLength , B.col1 - j );
int indexC = (i-Y.row0+C.row0)*C.original.numCols + (j-B.col0+C.col0)*heightY;
for( int k = Y.col0; k < Y.col1; k += blockLength ) {
int indexY = i*Y.original.numCols + k*heightY;
int indexB = (k-Y.col0+B.row0)*B.original.numCols + j*widthY;
if( i == Y.row0 ) {
multBlockAdd_zerosone(Y.original.data,B.original.data,C.original.data,
indexY,indexB,indexC,heightY,widthY,widthB);
} else {
InnerMultiplication_DDRB.blockMultPlus(Y.original.data,B.original.data,C.original.data,
indexY,indexB,indexC,heightY,widthY,widthB);
}
}
}
}
} | [
"public",
"static",
"void",
"multAdd_zeros",
"(",
"final",
"int",
"blockLength",
",",
"final",
"DSubmatrixD1",
"Y",
",",
"final",
"DSubmatrixD1",
"B",
",",
"final",
"DSubmatrixD1",
"C",
")",
"{",
"int",
"widthY",
"=",
"Y",
".",
"col1",
"-",
"Y",
".",
"co... | Special multiplication that takes in account the zeros and one in Y, which
is the matrix that stores the householder vectors. | [
"Special",
"multiplication",
"that",
"takes",
"in",
"account",
"the",
"zeros",
"and",
"one",
"in",
"Y",
"which",
"is",
"the",
"matrix",
"that",
"stores",
"the",
"householder",
"vectors",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/BlockHouseHolder_DDRB.java#L919-L947 | train |
lessthanoptimal/ejml | examples/src/org/ejml/example/EquationCustomFunction.java | EquationCustomFunction.createMultTransA | public static ManagerFunctions.InputN createMultTransA() {
return (inputs, manager) -> {
if( inputs.size() != 2 )
throw new RuntimeException("Two inputs required");
final Variable varA = inputs.get(0);
final Variable varB = inputs.get(1);
Operation.Info ret = new Operation.Info();
if( varA instanceof VariableMatrix && varB instanceof VariableMatrix ) {
// The output matrix or scalar variable must be created with the provided manager
final VariableMatrix output = manager.createMatrix();
ret.output = output;
ret.op = new Operation("multTransA-mm") {
@Override
public void process() {
DMatrixRMaj mA = ((VariableMatrix)varA).matrix;
DMatrixRMaj mB = ((VariableMatrix)varB).matrix;
CommonOps_DDRM.multTransA(mA,mB,output.matrix);
}
};
} else {
throw new IllegalArgumentException("Expected both inputs to be a matrix");
}
return ret;
};
} | java | public static ManagerFunctions.InputN createMultTransA() {
return (inputs, manager) -> {
if( inputs.size() != 2 )
throw new RuntimeException("Two inputs required");
final Variable varA = inputs.get(0);
final Variable varB = inputs.get(1);
Operation.Info ret = new Operation.Info();
if( varA instanceof VariableMatrix && varB instanceof VariableMatrix ) {
// The output matrix or scalar variable must be created with the provided manager
final VariableMatrix output = manager.createMatrix();
ret.output = output;
ret.op = new Operation("multTransA-mm") {
@Override
public void process() {
DMatrixRMaj mA = ((VariableMatrix)varA).matrix;
DMatrixRMaj mB = ((VariableMatrix)varB).matrix;
CommonOps_DDRM.multTransA(mA,mB,output.matrix);
}
};
} else {
throw new IllegalArgumentException("Expected both inputs to be a matrix");
}
return ret;
};
} | [
"public",
"static",
"ManagerFunctions",
".",
"InputN",
"createMultTransA",
"(",
")",
"{",
"return",
"(",
"inputs",
",",
"manager",
")",
"->",
"{",
"if",
"(",
"inputs",
".",
"size",
"(",
")",
"!=",
"2",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Two... | Create the function. Be sure to handle all possible input types and combinations correctly and provide
meaningful error messages. The output matrix should be resized to fit the inputs. | [
"Create",
"the",
"function",
".",
"Be",
"sure",
"to",
"handle",
"all",
"possible",
"input",
"types",
"and",
"combinations",
"correctly",
"and",
"provide",
"meaningful",
"error",
"messages",
".",
"The",
"output",
"matrix",
"should",
"be",
"resized",
"to",
"fit"... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/EquationCustomFunction.java#L60-L90 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java | SpecializedOps_DDRM.copyChangeRow | public static DMatrixRMaj copyChangeRow(int order[] , DMatrixRMaj src , DMatrixRMaj dst )
{
if( dst == null ) {
dst = new DMatrixRMaj(src.numRows,src.numCols);
} else if( src.numRows != dst.numRows || src.numCols != dst.numCols ) {
throw new IllegalArgumentException("src and dst must have the same dimensions.");
}
for( int i = 0; i < src.numRows; i++ ) {
int indexDst = i*src.numCols;
int indexSrc = order[i]*src.numCols;
System.arraycopy(src.data,indexSrc,dst.data,indexDst,src.numCols);
}
return dst;
} | java | public static DMatrixRMaj copyChangeRow(int order[] , DMatrixRMaj src , DMatrixRMaj dst )
{
if( dst == null ) {
dst = new DMatrixRMaj(src.numRows,src.numCols);
} else if( src.numRows != dst.numRows || src.numCols != dst.numCols ) {
throw new IllegalArgumentException("src and dst must have the same dimensions.");
}
for( int i = 0; i < src.numRows; i++ ) {
int indexDst = i*src.numCols;
int indexSrc = order[i]*src.numCols;
System.arraycopy(src.data,indexSrc,dst.data,indexDst,src.numCols);
}
return dst;
} | [
"public",
"static",
"DMatrixRMaj",
"copyChangeRow",
"(",
"int",
"order",
"[",
"]",
",",
"DMatrixRMaj",
"src",
",",
"DMatrixRMaj",
"dst",
")",
"{",
"if",
"(",
"dst",
"==",
"null",
")",
"{",
"dst",
"=",
"new",
"DMatrixRMaj",
"(",
"src",
".",
"numRows",
"... | Creates a copy of a matrix but swaps the rows as specified by the order array.
@param order Specifies which row in the dest corresponds to a row in the src. Not modified.
@param src The original matrix. Not modified.
@param dst A Matrix that is a row swapped copy of src. Modified. | [
"Creates",
"a",
"copy",
"of",
"a",
"matrix",
"but",
"swaps",
"the",
"rows",
"as",
"specified",
"by",
"the",
"order",
"array",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java#L97-L113 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java | SpecializedOps_DDRM.copyTriangle | public static DMatrixRMaj copyTriangle(DMatrixRMaj src , DMatrixRMaj dst , boolean upper ) {
if( dst == null ) {
dst = new DMatrixRMaj(src.numRows,src.numCols);
} else if( src.numRows != dst.numRows || src.numCols != dst.numCols ) {
throw new IllegalArgumentException("src and dst must have the same dimensions.");
}
if( upper ) {
int N = Math.min(src.numRows,src.numCols);
for( int i = 0; i < N; i++ ) {
int index = i*src.numCols+i;
System.arraycopy(src.data,index,dst.data,index,src.numCols-i);
}
} else {
for( int i = 0; i < src.numRows; i++ ) {
int length = Math.min(i+1,src.numCols);
int index = i*src.numCols;
System.arraycopy(src.data,index,dst.data,index,length);
}
}
return dst;
} | java | public static DMatrixRMaj copyTriangle(DMatrixRMaj src , DMatrixRMaj dst , boolean upper ) {
if( dst == null ) {
dst = new DMatrixRMaj(src.numRows,src.numCols);
} else if( src.numRows != dst.numRows || src.numCols != dst.numCols ) {
throw new IllegalArgumentException("src and dst must have the same dimensions.");
}
if( upper ) {
int N = Math.min(src.numRows,src.numCols);
for( int i = 0; i < N; i++ ) {
int index = i*src.numCols+i;
System.arraycopy(src.data,index,dst.data,index,src.numCols-i);
}
} else {
for( int i = 0; i < src.numRows; i++ ) {
int length = Math.min(i+1,src.numCols);
int index = i*src.numCols;
System.arraycopy(src.data,index,dst.data,index,length);
}
}
return dst;
} | [
"public",
"static",
"DMatrixRMaj",
"copyTriangle",
"(",
"DMatrixRMaj",
"src",
",",
"DMatrixRMaj",
"dst",
",",
"boolean",
"upper",
")",
"{",
"if",
"(",
"dst",
"==",
"null",
")",
"{",
"dst",
"=",
"new",
"DMatrixRMaj",
"(",
"src",
".",
"numRows",
",",
"src"... | Copies just the upper or lower triangular portion of a matrix.
@param src Matrix being copied. Not modified.
@param dst Where just a triangle from src is copied. If null a new one will be created. Modified.
@param upper If the upper or lower triangle should be copied.
@return The copied matrix. | [
"Copies",
"just",
"the",
"upper",
"or",
"lower",
"triangular",
"portion",
"of",
"a",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java#L123-L145 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java | SpecializedOps_DDRM.splitIntoVectors | public static DMatrixRMaj[] splitIntoVectors(DMatrix1Row A , boolean column )
{
int w = column ? A.numCols : A.numRows;
int M = column ? A.numRows : 1;
int N = column ? 1 : A.numCols;
int o = Math.max(M,N);
DMatrixRMaj[] ret = new DMatrixRMaj[w];
for( int i = 0; i < w; i++ ) {
DMatrixRMaj a = new DMatrixRMaj(M,N);
if( column )
subvector(A,0,i,o,false,0,a);
else
subvector(A,i,0,o,true,0,a);
ret[i] = a;
}
return ret;
} | java | public static DMatrixRMaj[] splitIntoVectors(DMatrix1Row A , boolean column )
{
int w = column ? A.numCols : A.numRows;
int M = column ? A.numRows : 1;
int N = column ? 1 : A.numCols;
int o = Math.max(M,N);
DMatrixRMaj[] ret = new DMatrixRMaj[w];
for( int i = 0; i < w; i++ ) {
DMatrixRMaj a = new DMatrixRMaj(M,N);
if( column )
subvector(A,0,i,o,false,0,a);
else
subvector(A,i,0,o,true,0,a);
ret[i] = a;
}
return ret;
} | [
"public",
"static",
"DMatrixRMaj",
"[",
"]",
"splitIntoVectors",
"(",
"DMatrix1Row",
"A",
",",
"boolean",
"column",
")",
"{",
"int",
"w",
"=",
"column",
"?",
"A",
".",
"numCols",
":",
"A",
".",
"numRows",
";",
"int",
"M",
"=",
"column",
"?",
"A",
"."... | Takes a matrix and splits it into a set of row or column vectors.
@param A original matrix.
@param column If true then column vectors will be created.
@return Set of vectors. | [
"Takes",
"a",
"matrix",
"and",
"splits",
"it",
"into",
"a",
"set",
"of",
"row",
"or",
"column",
"vectors",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java#L339-L362 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java | SpecializedOps_DDRM.diagProd | public static double diagProd( DMatrix1Row T )
{
double prod = 1.0;
int N = Math.min(T.numRows,T.numCols);
for( int i = 0; i < N; i++ ) {
prod *= T.unsafe_get(i,i);
}
return prod;
} | java | public static double diagProd( DMatrix1Row T )
{
double prod = 1.0;
int N = Math.min(T.numRows,T.numCols);
for( int i = 0; i < N; i++ ) {
prod *= T.unsafe_get(i,i);
}
return prod;
} | [
"public",
"static",
"double",
"diagProd",
"(",
"DMatrix1Row",
"T",
")",
"{",
"double",
"prod",
"=",
"1.0",
";",
"int",
"N",
"=",
"Math",
".",
"min",
"(",
"T",
".",
"numRows",
",",
"T",
".",
"numCols",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
... | Computes the product of the diagonal elements. For a diagonal or triangular
matrix this is the determinant.
@param T A matrix.
@return product of the diagonal elements. | [
"Computes",
"the",
"product",
"of",
"the",
"diagonal",
"elements",
".",
"For",
"a",
"diagonal",
"or",
"triangular",
"matrix",
"this",
"is",
"the",
"determinant",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java#L410-L419 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java | SpecializedOps_DDRM.elementSumSq | public static double elementSumSq( DMatrixD1 m ) {
// minimize round off error
double maxAbs = CommonOps_DDRM.elementMaxAbs(m);
if( maxAbs == 0)
return 0;
double total = 0;
int N = m.getNumElements();
for( int i = 0; i < N; i++ ) {
double d = m.data[i]/maxAbs;
total += d*d;
}
return maxAbs*total*maxAbs;
} | java | public static double elementSumSq( DMatrixD1 m ) {
// minimize round off error
double maxAbs = CommonOps_DDRM.elementMaxAbs(m);
if( maxAbs == 0)
return 0;
double total = 0;
int N = m.getNumElements();
for( int i = 0; i < N; i++ ) {
double d = m.data[i]/maxAbs;
total += d*d;
}
return maxAbs*total*maxAbs;
} | [
"public",
"static",
"double",
"elementSumSq",
"(",
"DMatrixD1",
"m",
")",
"{",
"// minimize round off error",
"double",
"maxAbs",
"=",
"CommonOps_DDRM",
".",
"elementMaxAbs",
"(",
"m",
")",
";",
"if",
"(",
"maxAbs",
"==",
"0",
")",
"return",
"0",
";",
"doubl... | Sums up the square of each element in the matrix. This is equivalent to the
Frobenius norm squared.
@param m Matrix.
@return Sum of elements squared. | [
"Sums",
"up",
"the",
"square",
"of",
"each",
"element",
"in",
"the",
"matrix",
".",
"This",
"is",
"equivalent",
"to",
"the",
"Frobenius",
"norm",
"squared",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SpecializedOps_DDRM.java#L480-L496 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java | SymmetricQREigenHelper_DDRM.init | public void init( double diag[] ,
double off[],
int numCols ) {
reset(numCols);
this.diag = diag;
this.off = off;
} | java | public void init( double diag[] ,
double off[],
int numCols ) {
reset(numCols);
this.diag = diag;
this.off = off;
} | [
"public",
"void",
"init",
"(",
"double",
"diag",
"[",
"]",
",",
"double",
"off",
"[",
"]",
",",
"int",
"numCols",
")",
"{",
"reset",
"(",
"numCols",
")",
";",
"this",
".",
"diag",
"=",
"diag",
";",
"this",
".",
"off",
"=",
"off",
";",
"}"
] | Sets up and declares internal data structures.
@param diag Diagonal elements from tridiagonal matrix. Modified.
@param off Off diagonal elements from tridiagonal matrix. Modified.
@param numCols number of columns (and rows) in the matrix. | [
"Sets",
"up",
"and",
"declares",
"internal",
"data",
"structures",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java#L106-L113 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java | SymmetricQREigenHelper_DDRM.reset | public void reset( int N ) {
this.N = N;
this.diag = null;
this.off = null;
if( splits.length < N ) {
splits = new int[N];
}
numSplits = 0;
x1 = 0;
x2 = N-1;
steps = numExceptional = lastExceptional = 0;
this.Q = null;
} | java | public void reset( int N ) {
this.N = N;
this.diag = null;
this.off = null;
if( splits.length < N ) {
splits = new int[N];
}
numSplits = 0;
x1 = 0;
x2 = N-1;
steps = numExceptional = lastExceptional = 0;
this.Q = null;
} | [
"public",
"void",
"reset",
"(",
"int",
"N",
")",
"{",
"this",
".",
"N",
"=",
"N",
";",
"this",
".",
"diag",
"=",
"null",
";",
"this",
".",
"off",
"=",
"null",
";",
"if",
"(",
"splits",
".",
"length",
"<",
"N",
")",
"{",
"splits",
"=",
"new",
... | Sets the size of the matrix being decomposed, declares new memory if needed,
and sets all helper functions to their initial value. | [
"Sets",
"the",
"size",
"of",
"the",
"matrix",
"being",
"decomposed",
"declares",
"new",
"memory",
"if",
"needed",
"and",
"sets",
"all",
"helper",
"functions",
"to",
"their",
"initial",
"value",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java#L139-L157 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java | SymmetricQREigenHelper_DDRM.isZero | protected boolean isZero( int index ) {
double bottom = Math.abs(diag[index])+Math.abs(diag[index+1]);
return( Math.abs(off[index]) <= bottom*UtilEjml.EPS);
} | java | protected boolean isZero( int index ) {
double bottom = Math.abs(diag[index])+Math.abs(diag[index+1]);
return( Math.abs(off[index]) <= bottom*UtilEjml.EPS);
} | [
"protected",
"boolean",
"isZero",
"(",
"int",
"index",
")",
"{",
"double",
"bottom",
"=",
"Math",
".",
"abs",
"(",
"diag",
"[",
"index",
"]",
")",
"+",
"Math",
".",
"abs",
"(",
"diag",
"[",
"index",
"+",
"1",
"]",
")",
";",
"return",
"(",
"Math",... | Checks to see if the specified off diagonal element is zero using a relative metric. | [
"Checks",
"to",
"see",
"if",
"the",
"specified",
"off",
"diagonal",
"element",
"is",
"zero",
"using",
"a",
"relative",
"metric",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java#L202-L206 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java | SymmetricQREigenHelper_DDRM.createBulge | protected void createBulge( int x1 , double p , boolean byAngle ) {
double a11 = diag[x1];
double a22 = diag[x1+1];
double a12 = off[x1];
double a23 = off[x1+1];
if( byAngle ) {
c = Math.cos(p);
s = Math.sin(p);
c2 = c*c;
s2 = s*s;
cs = c*s;
} else {
computeRotation(a11-p, a12);
}
// multiply the rotator on the top left.
diag[x1] = c2*a11 + 2.0*cs*a12 + s2*a22;
diag[x1+1] = c2*a22 - 2.0*cs*a12 + s2*a11;
off[x1] = a12*(c2-s2) + cs*(a22 - a11);
off[x1+1] = c*a23;
bulge = s*a23;
if( Q != null )
updateQ(x1,x1+1,c,s);
} | java | protected void createBulge( int x1 , double p , boolean byAngle ) {
double a11 = diag[x1];
double a22 = diag[x1+1];
double a12 = off[x1];
double a23 = off[x1+1];
if( byAngle ) {
c = Math.cos(p);
s = Math.sin(p);
c2 = c*c;
s2 = s*s;
cs = c*s;
} else {
computeRotation(a11-p, a12);
}
// multiply the rotator on the top left.
diag[x1] = c2*a11 + 2.0*cs*a12 + s2*a22;
diag[x1+1] = c2*a22 - 2.0*cs*a12 + s2*a11;
off[x1] = a12*(c2-s2) + cs*(a22 - a11);
off[x1+1] = c*a23;
bulge = s*a23;
if( Q != null )
updateQ(x1,x1+1,c,s);
} | [
"protected",
"void",
"createBulge",
"(",
"int",
"x1",
",",
"double",
"p",
",",
"boolean",
"byAngle",
")",
"{",
"double",
"a11",
"=",
"diag",
"[",
"x1",
"]",
";",
"double",
"a22",
"=",
"diag",
"[",
"x1",
"+",
"1",
"]",
";",
"double",
"a12",
"=",
"... | Performs a similar transform on A-pI | [
"Performs",
"a",
"similar",
"transform",
"on",
"A",
"-",
"pI"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java#L247-L273 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java | SymmetricQREigenHelper_DDRM.eigenvalue2by2 | protected void eigenvalue2by2( int x1 ) {
double a = diag[x1];
double b = off[x1];
double c = diag[x1+1];
// normalize to reduce overflow
double absA = Math.abs(a);
double absB = Math.abs(b);
double absC = Math.abs(c);
double scale = absA > absB ? absA : absB;
if( absC > scale ) scale = absC;
// see if it is a pathological case. the diagonal must already be zero
// and the eigenvalues are all zero. so just return
if( scale == 0 ) {
off[x1] = 0;
diag[x1] = 0;
diag[x1+1] = 0;
return;
}
a /= scale;
b /= scale;
c /= scale;
eigenSmall.symm2x2_fast(a,b,c);
off[x1] = 0;
diag[x1] = scale*eigenSmall.value0.real;
diag[x1+1] = scale*eigenSmall.value1.real;
} | java | protected void eigenvalue2by2( int x1 ) {
double a = diag[x1];
double b = off[x1];
double c = diag[x1+1];
// normalize to reduce overflow
double absA = Math.abs(a);
double absB = Math.abs(b);
double absC = Math.abs(c);
double scale = absA > absB ? absA : absB;
if( absC > scale ) scale = absC;
// see if it is a pathological case. the diagonal must already be zero
// and the eigenvalues are all zero. so just return
if( scale == 0 ) {
off[x1] = 0;
diag[x1] = 0;
diag[x1+1] = 0;
return;
}
a /= scale;
b /= scale;
c /= scale;
eigenSmall.symm2x2_fast(a,b,c);
off[x1] = 0;
diag[x1] = scale*eigenSmall.value0.real;
diag[x1+1] = scale*eigenSmall.value1.real;
} | [
"protected",
"void",
"eigenvalue2by2",
"(",
"int",
"x1",
")",
"{",
"double",
"a",
"=",
"diag",
"[",
"x1",
"]",
";",
"double",
"b",
"=",
"off",
"[",
"x1",
"]",
";",
"double",
"c",
"=",
"diag",
"[",
"x1",
"+",
"1",
"]",
";",
"// normalize to reduce o... | Computes the eigenvalue of the 2 by 2 matrix. | [
"Computes",
"the",
"eigenvalue",
"of",
"the",
"2",
"by",
"2",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQREigenHelper_DDRM.java#L378-L409 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/linsol/LinearSolver_DDRB_to_DDRM.java | LinearSolver_DDRB_to_DDRM.solve | @Override
public void solve(DMatrixRMaj B, DMatrixRMaj X) {
X.reshape(blockA.numCols,B.numCols);
blockB.reshape(B.numRows,B.numCols,false);
blockX.reshape(X.numRows,X.numCols,false);
MatrixOps_DDRB.convert(B,blockB);
alg.solve(blockB,blockX);
MatrixOps_DDRB.convert(blockX,X);
} | java | @Override
public void solve(DMatrixRMaj B, DMatrixRMaj X) {
X.reshape(blockA.numCols,B.numCols);
blockB.reshape(B.numRows,B.numCols,false);
blockX.reshape(X.numRows,X.numCols,false);
MatrixOps_DDRB.convert(B,blockB);
alg.solve(blockB,blockX);
MatrixOps_DDRB.convert(blockX,X);
} | [
"@",
"Override",
"public",
"void",
"solve",
"(",
"DMatrixRMaj",
"B",
",",
"DMatrixRMaj",
"X",
")",
"{",
"X",
".",
"reshape",
"(",
"blockA",
".",
"numCols",
",",
"B",
".",
"numCols",
")",
";",
"blockB",
".",
"reshape",
"(",
"B",
".",
"numRows",
",",
... | Converts B and X into block matrices and calls the block matrix solve routine.
@param B A matrix ℜ <sup>m × p</sup>. Not modified.
@param X A matrix ℜ <sup>n × p</sup>, where the solution is written to. Modified. | [
"Converts",
"B",
"and",
"X",
"into",
"block",
"matrices",
"and",
"calls",
"the",
"block",
"matrix",
"solve",
"routine",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/linsol/LinearSolver_DDRB_to_DDRM.java#L75-L85 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/linsol/LinearSolver_DDRB_to_DDRM.java | LinearSolver_DDRB_to_DDRM.invert | @Override
public void invert(DMatrixRMaj A_inv) {
blockB.reshape(A_inv.numRows,A_inv.numCols,false);
alg.invert(blockB);
MatrixOps_DDRB.convert(blockB,A_inv);
} | java | @Override
public void invert(DMatrixRMaj A_inv) {
blockB.reshape(A_inv.numRows,A_inv.numCols,false);
alg.invert(blockB);
MatrixOps_DDRB.convert(blockB,A_inv);
} | [
"@",
"Override",
"public",
"void",
"invert",
"(",
"DMatrixRMaj",
"A_inv",
")",
"{",
"blockB",
".",
"reshape",
"(",
"A_inv",
".",
"numRows",
",",
"A_inv",
".",
"numCols",
",",
"false",
")",
";",
"alg",
".",
"invert",
"(",
"blockB",
")",
";",
"MatrixOps_... | Creates a block matrix the same size as A_inv, inverts the matrix and copies the results back
onto A_inv.
@param A_inv Where the inverted matrix saved. Modified. | [
"Creates",
"a",
"block",
"matrix",
"the",
"same",
"size",
"as",
"A_inv",
"inverts",
"the",
"matrix",
"and",
"copies",
"the",
"results",
"back",
"onto",
"A_inv",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/linsol/LinearSolver_DDRB_to_DDRM.java#L93-L100 | train |
lessthanoptimal/ejml | main/ejml-ddense/generate/org/ejml/dense/row/misc/GenerateInverseFromMinor.java | GenerateInverseFromMinor.printMinors | public void printMinors(int matrix[], int N, PrintStream stream) {
this.N = N;
this.stream = stream;
// compute all the minors
int index = 0;
for( int i = 1; i <= N; i++ ) {
for( int j = 1; j <= N; j++ , index++) {
stream.print(" double m"+i+""+j+" = ");
if( (i+j) % 2 == 1 )
stream.print("-( ");
printTopMinor(matrix,i-1,j-1,N);
if( (i+j) % 2 == 1 )
stream.print(")");
stream.print(";\n");
}
}
stream.println();
// compute the determinant
stream.print(" double det = (a11*m11");
for( int i = 2; i <= N; i++ ) {
stream.print(" + "+a(i-1)+"*m"+1+""+i);
}
stream.println(")/scale;");
} | java | public void printMinors(int matrix[], int N, PrintStream stream) {
this.N = N;
this.stream = stream;
// compute all the minors
int index = 0;
for( int i = 1; i <= N; i++ ) {
for( int j = 1; j <= N; j++ , index++) {
stream.print(" double m"+i+""+j+" = ");
if( (i+j) % 2 == 1 )
stream.print("-( ");
printTopMinor(matrix,i-1,j-1,N);
if( (i+j) % 2 == 1 )
stream.print(")");
stream.print(";\n");
}
}
stream.println();
// compute the determinant
stream.print(" double det = (a11*m11");
for( int i = 2; i <= N; i++ ) {
stream.print(" + "+a(i-1)+"*m"+1+""+i);
}
stream.println(")/scale;");
} | [
"public",
"void",
"printMinors",
"(",
"int",
"matrix",
"[",
"]",
",",
"int",
"N",
",",
"PrintStream",
"stream",
")",
"{",
"this",
".",
"N",
"=",
"N",
";",
"this",
".",
"stream",
"=",
"stream",
";",
"// compute all the minors",
"int",
"index",
"=",
"0",... | Put the core auto-code algorithm here so an external class can call it | [
"Put",
"the",
"core",
"auto",
"-",
"code",
"algorithm",
"here",
"so",
"an",
"external",
"class",
"can",
"call",
"it"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/generate/org/ejml/dense/row/misc/GenerateInverseFromMinor.java#L147-L173 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/linsol/qr/QrHouseHolderSolver_DDRB.java | QrHouseHolderSolver_DDRB.setA | @Override
public boolean setA(DMatrixRBlock A) {
if( A.numRows < A.numCols )
throw new IllegalArgumentException("Number of rows must be more than or equal to the number of columns. " +
"Can't solve an underdetermined system.");
if( !decomposer.decompose(A))
return false;
this.QR = decomposer.getQR();
return true;
} | java | @Override
public boolean setA(DMatrixRBlock A) {
if( A.numRows < A.numCols )
throw new IllegalArgumentException("Number of rows must be more than or equal to the number of columns. " +
"Can't solve an underdetermined system.");
if( !decomposer.decompose(A))
return false;
this.QR = decomposer.getQR();
return true;
} | [
"@",
"Override",
"public",
"boolean",
"setA",
"(",
"DMatrixRBlock",
"A",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"<",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Number of rows must be more than or equal to the number of columns. \... | Computes the QR decomposition of A and store the results in A.
@param A The A matrix in the linear equation. Modified. Reference saved.
@return true if the decomposition was successful. | [
"Computes",
"the",
"QR",
"decomposition",
"of",
"A",
"and",
"store",
"the",
"results",
"in",
"A",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/linsol/qr/QrHouseHolderSolver_DDRB.java#L68-L80 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/linsol/qr/QrHouseHolderSolver_DDRB.java | QrHouseHolderSolver_DDRB.invert | @Override
public void invert(DMatrixRBlock A_inv) {
int M = Math.min(QR.numRows,QR.numCols);
if( A_inv.numRows != M || A_inv.numCols != M )
throw new IllegalArgumentException("A_inv must be square an have dimension "+M);
// Solve for A^-1
// Q*R*A^-1 = I
// Apply householder reflectors to the identity matrix
// y = Q^T*I = Q^T
MatrixOps_DDRB.setIdentity(A_inv);
decomposer.applyQTran(A_inv);
// Solve using upper triangular R matrix
// R*A^-1 = y
// A^-1 = R^-1*y
TriangularSolver_DDRB.solve(QR.blockLength,true,
new DSubmatrixD1(QR,0,M,0,M),new DSubmatrixD1(A_inv),false);
} | java | @Override
public void invert(DMatrixRBlock A_inv) {
int M = Math.min(QR.numRows,QR.numCols);
if( A_inv.numRows != M || A_inv.numCols != M )
throw new IllegalArgumentException("A_inv must be square an have dimension "+M);
// Solve for A^-1
// Q*R*A^-1 = I
// Apply householder reflectors to the identity matrix
// y = Q^T*I = Q^T
MatrixOps_DDRB.setIdentity(A_inv);
decomposer.applyQTran(A_inv);
// Solve using upper triangular R matrix
// R*A^-1 = y
// A^-1 = R^-1*y
TriangularSolver_DDRB.solve(QR.blockLength,true,
new DSubmatrixD1(QR,0,M,0,M),new DSubmatrixD1(A_inv),false);
} | [
"@",
"Override",
"public",
"void",
"invert",
"(",
"DMatrixRBlock",
"A_inv",
")",
"{",
"int",
"M",
"=",
"Math",
".",
"min",
"(",
"QR",
".",
"numRows",
",",
"QR",
".",
"numCols",
")",
";",
"if",
"(",
"A_inv",
".",
"numRows",
"!=",
"M",
"||",
"A_inv",... | Invert by solving for against an identity matrix.
@param A_inv Where the inverted matrix saved. Modified. | [
"Invert",
"by",
"solving",
"for",
"against",
"an",
"identity",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/linsol/qr/QrHouseHolderSolver_DDRB.java#L124-L144 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Sequence.java | Sequence.perform | public void perform() {
for (int i = 0; i < operations.size(); i++) {
operations.get(i).process();
}
} | java | public void perform() {
for (int i = 0; i < operations.size(); i++) {
operations.get(i).process();
}
} | [
"public",
"void",
"perform",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"operations",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"operations",
".",
"get",
"(",
"i",
")",
".",
"process",
"(",
")",
";",
"}",
"}"
] | Executes the sequence of operations | [
"Executes",
"the",
"sequence",
"of",
"operations"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Sequence.java#L44-L48 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/chol/CholeskyDecompositionBlock_DDRM.java | CholeskyDecompositionBlock_DDRM.setExpectedMaxSize | @Override
public void setExpectedMaxSize( int numRows , int numCols ) {
super.setExpectedMaxSize(numRows,numCols);
// if the matrix that is being decomposed is smaller than the block we really don't
// see the B matrix.
if( numRows < blockWidth)
B = new DMatrixRMaj(0,0);
else
B = new DMatrixRMaj(blockWidth,maxWidth);
chol = new CholeskyBlockHelper_DDRM(blockWidth);
} | java | @Override
public void setExpectedMaxSize( int numRows , int numCols ) {
super.setExpectedMaxSize(numRows,numCols);
// if the matrix that is being decomposed is smaller than the block we really don't
// see the B matrix.
if( numRows < blockWidth)
B = new DMatrixRMaj(0,0);
else
B = new DMatrixRMaj(blockWidth,maxWidth);
chol = new CholeskyBlockHelper_DDRM(blockWidth);
} | [
"@",
"Override",
"public",
"void",
"setExpectedMaxSize",
"(",
"int",
"numRows",
",",
"int",
"numCols",
")",
"{",
"super",
".",
"setExpectedMaxSize",
"(",
"numRows",
",",
"numCols",
")",
";",
"// if the matrix that is being decomposed is smaller than the block we really do... | Declares additional internal data structures. | [
"Declares",
"additional",
"internal",
"data",
"structures",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/chol/CholeskyDecompositionBlock_DDRM.java#L54-L66 | train |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/ConvertDMatrixStruct.java | ConvertDMatrixStruct.convert | public static DMatrixSparseCSC convert(DMatrixSparseTriplet src , DMatrixSparseCSC dst , int hist[] ) {
if( dst == null )
dst = new DMatrixSparseCSC(src.numRows, src.numCols , src.nz_length);
else
dst.reshape(src.numRows, src.numCols, src.nz_length);
if( hist == null )
hist = new int[ src.numCols ];
else if( hist.length >= src.numCols )
Arrays.fill(hist,0,src.numCols, 0);
else
throw new IllegalArgumentException("Length of hist must be at least numCols");
// compute the number of elements in each columns
for (int i = 0; i < src.nz_length; i++) {
hist[src.nz_rowcol.data[i*2+1]]++;
}
// define col_idx
dst.histogramToStructure(hist);
System.arraycopy(dst.col_idx,0,hist,0,dst.numCols);
// now write the row indexes and the values
for (int i = 0; i < src.nz_length; i++) {
int row = src.nz_rowcol.data[i*2];
int col = src.nz_rowcol.data[i*2+1];
double value = src.nz_value.data[i];
int index = hist[col]++;
dst.nz_rows[index] = row;
dst.nz_values[index] = value;
}
dst.indicesSorted = false;
return dst;
} | java | public static DMatrixSparseCSC convert(DMatrixSparseTriplet src , DMatrixSparseCSC dst , int hist[] ) {
if( dst == null )
dst = new DMatrixSparseCSC(src.numRows, src.numCols , src.nz_length);
else
dst.reshape(src.numRows, src.numCols, src.nz_length);
if( hist == null )
hist = new int[ src.numCols ];
else if( hist.length >= src.numCols )
Arrays.fill(hist,0,src.numCols, 0);
else
throw new IllegalArgumentException("Length of hist must be at least numCols");
// compute the number of elements in each columns
for (int i = 0; i < src.nz_length; i++) {
hist[src.nz_rowcol.data[i*2+1]]++;
}
// define col_idx
dst.histogramToStructure(hist);
System.arraycopy(dst.col_idx,0,hist,0,dst.numCols);
// now write the row indexes and the values
for (int i = 0; i < src.nz_length; i++) {
int row = src.nz_rowcol.data[i*2];
int col = src.nz_rowcol.data[i*2+1];
double value = src.nz_value.data[i];
int index = hist[col]++;
dst.nz_rows[index] = row;
dst.nz_values[index] = value;
}
dst.indicesSorted = false;
return dst;
} | [
"public",
"static",
"DMatrixSparseCSC",
"convert",
"(",
"DMatrixSparseTriplet",
"src",
",",
"DMatrixSparseCSC",
"dst",
",",
"int",
"hist",
"[",
"]",
")",
"{",
"if",
"(",
"dst",
"==",
"null",
")",
"dst",
"=",
"new",
"DMatrixSparseCSC",
"(",
"src",
".",
"num... | Converts SMatrixTriplet_64 into a SMatrixCC_64.
@param src Original matrix which is to be copied. Not modified.
@param dst Destination. Will be a copy. Modified.
@param hist Workspace. Should be at least as long as the number of columns. Can be null. | [
"Converts",
"SMatrixTriplet_64",
"into",
"a",
"SMatrixCC_64",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/ConvertDMatrixStruct.java#L858-L893 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QRColPivDecompositionHouseholderColumn_DDRM.java | QRColPivDecompositionHouseholderColumn_DDRM.setupPivotInfo | protected void setupPivotInfo() {
for( int col = 0; col < numCols; col++ ) {
pivots[col] = col;
double c[] = dataQR[col];
double norm = 0;
for( int row = 0; row < numRows; row++ ) {
double element = c[row];
norm += element*element;
}
normsCol[col] = norm;
}
} | java | protected void setupPivotInfo() {
for( int col = 0; col < numCols; col++ ) {
pivots[col] = col;
double c[] = dataQR[col];
double norm = 0;
for( int row = 0; row < numRows; row++ ) {
double element = c[row];
norm += element*element;
}
normsCol[col] = norm;
}
} | [
"protected",
"void",
"setupPivotInfo",
"(",
")",
"{",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"numCols",
";",
"col",
"++",
")",
"{",
"pivots",
"[",
"col",
"]",
"=",
"col",
";",
"double",
"c",
"[",
"]",
"=",
"dataQR",
"[",
"col",
"]... | Sets the initial pivot ordering and compute the F-norm squared for each column | [
"Sets",
"the",
"initial",
"pivot",
"ordering",
"and",
"compute",
"the",
"F",
"-",
"norm",
"squared",
"for",
"each",
"column"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QRColPivDecompositionHouseholderColumn_DDRM.java#L173-L184 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QRColPivDecompositionHouseholderColumn_DDRM.java | QRColPivDecompositionHouseholderColumn_DDRM.updateNorms | protected void updateNorms( int j ) {
boolean foundNegative = false;
for( int col = j; col < numCols; col++ ) {
double e = dataQR[col][j-1];
double v = normsCol[col] -= e*e;
if( v < 0 ) {
foundNegative = true;
break;
}
}
// if a negative sum has been found then clearly too much precision has been lost
// and it should recompute the column norms from scratch
if( foundNegative ) {
for( int col = j; col < numCols; col++ ) {
double u[] = dataQR[col];
double actual = 0;
for( int i=j; i < numRows; i++ ) {
double v = u[i];
actual += v*v;
}
normsCol[col] = actual;
}
}
} | java | protected void updateNorms( int j ) {
boolean foundNegative = false;
for( int col = j; col < numCols; col++ ) {
double e = dataQR[col][j-1];
double v = normsCol[col] -= e*e;
if( v < 0 ) {
foundNegative = true;
break;
}
}
// if a negative sum has been found then clearly too much precision has been lost
// and it should recompute the column norms from scratch
if( foundNegative ) {
for( int col = j; col < numCols; col++ ) {
double u[] = dataQR[col];
double actual = 0;
for( int i=j; i < numRows; i++ ) {
double v = u[i];
actual += v*v;
}
normsCol[col] = actual;
}
}
} | [
"protected",
"void",
"updateNorms",
"(",
"int",
"j",
")",
"{",
"boolean",
"foundNegative",
"=",
"false",
";",
"for",
"(",
"int",
"col",
"=",
"j",
";",
"col",
"<",
"numCols",
";",
"col",
"++",
")",
"{",
"double",
"e",
"=",
"dataQR",
"[",
"col",
"]",... | Performs an efficient update of each columns' norm | [
"Performs",
"an",
"efficient",
"update",
"of",
"each",
"columns",
"norm"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QRColPivDecompositionHouseholderColumn_DDRM.java#L190-L215 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QRColPivDecompositionHouseholderColumn_DDRM.java | QRColPivDecompositionHouseholderColumn_DDRM.swapColumns | protected void swapColumns( int j ) {
// find the column with the largest norm
int largestIndex = j;
double largestNorm = normsCol[j];
for( int col = j+1; col < numCols; col++ ) {
double n = normsCol[col];
if( n > largestNorm ) {
largestNorm = n;
largestIndex = col;
}
}
// swap the columns
double []tempC = dataQR[j];
dataQR[j] = dataQR[largestIndex];
dataQR[largestIndex] = tempC;
double tempN = normsCol[j];
normsCol[j] = normsCol[largestIndex];
normsCol[largestIndex] = tempN;
int tempP = pivots[j];
pivots[j] = pivots[largestIndex];
pivots[largestIndex] = tempP;
} | java | protected void swapColumns( int j ) {
// find the column with the largest norm
int largestIndex = j;
double largestNorm = normsCol[j];
for( int col = j+1; col < numCols; col++ ) {
double n = normsCol[col];
if( n > largestNorm ) {
largestNorm = n;
largestIndex = col;
}
}
// swap the columns
double []tempC = dataQR[j];
dataQR[j] = dataQR[largestIndex];
dataQR[largestIndex] = tempC;
double tempN = normsCol[j];
normsCol[j] = normsCol[largestIndex];
normsCol[largestIndex] = tempN;
int tempP = pivots[j];
pivots[j] = pivots[largestIndex];
pivots[largestIndex] = tempP;
} | [
"protected",
"void",
"swapColumns",
"(",
"int",
"j",
")",
"{",
"// find the column with the largest norm",
"int",
"largestIndex",
"=",
"j",
";",
"double",
"largestNorm",
"=",
"normsCol",
"[",
"j",
"]",
";",
"for",
"(",
"int",
"col",
"=",
"j",
"+",
"1",
";"... | Finds the column with the largest normal and makes that the first column
@param j Current column being inspected | [
"Finds",
"the",
"column",
"with",
"the",
"largest",
"normal",
"and",
"makes",
"that",
"the",
"first",
"column"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QRColPivDecompositionHouseholderColumn_DDRM.java#L222-L244 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/config/HiveRunnerConfig.java | HiveRunnerConfig.getHiveExecutionEngine | public String getHiveExecutionEngine() {
String executionEngine = hiveConfSystemOverride.get(HiveConf.ConfVars.HIVE_EXECUTION_ENGINE.varname);
return executionEngine == null ? HiveConf.ConfVars.HIVE_EXECUTION_ENGINE.getDefaultValue() : executionEngine;
} | java | public String getHiveExecutionEngine() {
String executionEngine = hiveConfSystemOverride.get(HiveConf.ConfVars.HIVE_EXECUTION_ENGINE.varname);
return executionEngine == null ? HiveConf.ConfVars.HIVE_EXECUTION_ENGINE.getDefaultValue() : executionEngine;
} | [
"public",
"String",
"getHiveExecutionEngine",
"(",
")",
"{",
"String",
"executionEngine",
"=",
"hiveConfSystemOverride",
".",
"get",
"(",
"HiveConf",
".",
"ConfVars",
".",
"HIVE_EXECUTION_ENGINE",
".",
"varname",
")",
";",
"return",
"executionEngine",
"==",
"null",
... | Get the configured hive.execution.engine. If not set it will default to the default value of HiveConf | [
"Get",
"the",
"configured",
"hive",
".",
"execution",
".",
"engine",
".",
"If",
"not",
"set",
"it",
"will",
"default",
"to",
"the",
"default",
"value",
"of",
"HiveConf"
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/config/HiveRunnerConfig.java#L145-L148 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/config/HiveRunnerConfig.java | HiveRunnerConfig.override | public void override(HiveRunnerConfig hiveRunnerConfig) {
config.putAll(hiveRunnerConfig.config);
hiveConfSystemOverride.putAll(hiveRunnerConfig.hiveConfSystemOverride);
} | java | public void override(HiveRunnerConfig hiveRunnerConfig) {
config.putAll(hiveRunnerConfig.config);
hiveConfSystemOverride.putAll(hiveRunnerConfig.hiveConfSystemOverride);
} | [
"public",
"void",
"override",
"(",
"HiveRunnerConfig",
"hiveRunnerConfig",
")",
"{",
"config",
".",
"putAll",
"(",
"hiveRunnerConfig",
".",
"config",
")",
";",
"hiveConfSystemOverride",
".",
"putAll",
"(",
"hiveRunnerConfig",
".",
"hiveConfSystemOverride",
")",
";",... | Copy values from the inserted config to this config. Note that if properties has not been explicitly set,
the defaults will apply. | [
"Copy",
"values",
"from",
"the",
"inserted",
"config",
"to",
"this",
"config",
".",
"Note",
"that",
"if",
"properties",
"has",
"not",
"been",
"explicitly",
"set",
"the",
"defaults",
"will",
"apply",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/config/HiveRunnerConfig.java#L186-L189 | train |
klarna/HiveRunner | src/main/java/com/klarna/reflection/ReflectionUtils.java | ReflectionUtils.getField | public static Optional<Field> getField(Class<?> type, final String fieldName) {
Optional<Field> field = Iterables.tryFind(newArrayList(type.getDeclaredFields()), havingFieldName(fieldName));
if (!field.isPresent() && type.getSuperclass() != null){
field = getField(type.getSuperclass(), fieldName);
}
return field;
} | java | public static Optional<Field> getField(Class<?> type, final String fieldName) {
Optional<Field> field = Iterables.tryFind(newArrayList(type.getDeclaredFields()), havingFieldName(fieldName));
if (!field.isPresent() && type.getSuperclass() != null){
field = getField(type.getSuperclass(), fieldName);
}
return field;
} | [
"public",
"static",
"Optional",
"<",
"Field",
">",
"getField",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"String",
"fieldName",
")",
"{",
"Optional",
"<",
"Field",
">",
"field",
"=",
"Iterables",
".",
"tryFind",
"(",
"newArrayList",
"(",
"type",... | Finds the first Field with given field name in the Class and in its super classes.
@param type The Class type
@param fieldName The field name to get
@return an {@code Optional}. Use isPresent() to find out if the field name was found. | [
"Finds",
"the",
"first",
"Field",
"with",
"given",
"field",
"name",
"in",
"the",
"Class",
"and",
"in",
"its",
"super",
"classes",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/reflection/ReflectionUtils.java#L72-L80 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/HiveServerContainer.java | HiveServerContainer.init | public void init(Map<String, String> testConfig, Map<String, String> hiveVars) {
context.init();
HiveConf hiveConf = context.getHiveConf();
// merge test case properties with hive conf before HiveServer is started.
for (Map.Entry<String, String> property : testConfig.entrySet()) {
hiveConf.set(property.getKey(), property.getValue());
}
try {
hiveServer2 = new HiveServer2();
hiveServer2.init(hiveConf);
// Locate the ClIService in the HiveServer2
for (Service service : hiveServer2.getServices()) {
if (service instanceof CLIService) {
client = (CLIService) service;
}
}
Preconditions.checkNotNull(client, "ClIService was not initialized by HiveServer2");
sessionHandle = client.openSession("noUser", "noPassword", null);
SessionState sessionState = client.getSessionManager().getSession(sessionHandle).getSessionState();
currentSessionState = sessionState;
currentSessionState.setHiveVariables(hiveVars);
} catch (Exception e) {
throw new IllegalStateException("Failed to create HiveServer :" + e.getMessage(), e);
}
// Ping hive server before we do anything more with it! If validation
// is switched on, this will fail if metastorage is not set up properly
pingHiveServer();
} | java | public void init(Map<String, String> testConfig, Map<String, String> hiveVars) {
context.init();
HiveConf hiveConf = context.getHiveConf();
// merge test case properties with hive conf before HiveServer is started.
for (Map.Entry<String, String> property : testConfig.entrySet()) {
hiveConf.set(property.getKey(), property.getValue());
}
try {
hiveServer2 = new HiveServer2();
hiveServer2.init(hiveConf);
// Locate the ClIService in the HiveServer2
for (Service service : hiveServer2.getServices()) {
if (service instanceof CLIService) {
client = (CLIService) service;
}
}
Preconditions.checkNotNull(client, "ClIService was not initialized by HiveServer2");
sessionHandle = client.openSession("noUser", "noPassword", null);
SessionState sessionState = client.getSessionManager().getSession(sessionHandle).getSessionState();
currentSessionState = sessionState;
currentSessionState.setHiveVariables(hiveVars);
} catch (Exception e) {
throw new IllegalStateException("Failed to create HiveServer :" + e.getMessage(), e);
}
// Ping hive server before we do anything more with it! If validation
// is switched on, this will fail if metastorage is not set up properly
pingHiveServer();
} | [
"public",
"void",
"init",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"testConfig",
",",
"Map",
"<",
"String",
",",
"String",
">",
"hiveVars",
")",
"{",
"context",
".",
"init",
"(",
")",
";",
"HiveConf",
"hiveConf",
"=",
"context",
".",
"getHiveConf... | Will start the HiveServer.
@param testConfig Specific test case properties. Will be merged with the HiveConf of the context
@param hiveVars HiveVars to pass on to the HiveServer for this session | [
"Will",
"start",
"the",
"HiveServer",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/HiveServerContainer.java#L72-L108 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/data/InsertIntoTable.java | InsertIntoTable.addRowsFromDelimited | public InsertIntoTable addRowsFromDelimited(File file, String delimiter, Object nullValue) {
builder.addRowsFromDelimited(file, delimiter, nullValue);
return this;
} | java | public InsertIntoTable addRowsFromDelimited(File file, String delimiter, Object nullValue) {
builder.addRowsFromDelimited(file, delimiter, nullValue);
return this;
} | [
"public",
"InsertIntoTable",
"addRowsFromDelimited",
"(",
"File",
"file",
",",
"String",
"delimiter",
",",
"Object",
"nullValue",
")",
"{",
"builder",
".",
"addRowsFromDelimited",
"(",
"file",
",",
"delimiter",
",",
"nullValue",
")",
";",
"return",
"this",
";",
... | Adds all rows from the TSV file specified, using the provided delimiter and null value.
@param file The file to read the data from.
@param delimiter A column delimiter.
@param nullValue Value to be treated as null in the source data.
@return {@code this} | [
"Adds",
"all",
"rows",
"from",
"the",
"TSV",
"file",
"specified",
"using",
"the",
"provided",
"delimiter",
"and",
"null",
"value",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/data/InsertIntoTable.java#L160-L163 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/data/InsertIntoTable.java | InsertIntoTable.addRowsFrom | public InsertIntoTable addRowsFrom(File file, FileParser fileParser) {
builder.addRowsFrom(file, fileParser);
return this;
} | java | public InsertIntoTable addRowsFrom(File file, FileParser fileParser) {
builder.addRowsFrom(file, fileParser);
return this;
} | [
"public",
"InsertIntoTable",
"addRowsFrom",
"(",
"File",
"file",
",",
"FileParser",
"fileParser",
")",
"{",
"builder",
".",
"addRowsFrom",
"(",
"file",
",",
"fileParser",
")",
";",
"return",
"this",
";",
"}"
] | Adds all rows from the file specified, using the provided parser.
@param file File to read the data from.
@param fileParser Parser to be used to parse the file.
@return {@code this} | [
"Adds",
"all",
"rows",
"from",
"the",
"file",
"specified",
"using",
"the",
"provided",
"parser",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/data/InsertIntoTable.java#L172-L175 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/data/InsertIntoTable.java | InsertIntoTable.set | public InsertIntoTable set(String name, Object value) {
builder.set(name, value);
return this;
} | java | public InsertIntoTable set(String name, Object value) {
builder.set(name, value);
return this;
} | [
"public",
"InsertIntoTable",
"set",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"builder",
".",
"set",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Set the given column name to the given value.
@param name The column name to set.
@param value the value to set.
@return {@code this}
@throws IllegalArgumentException if a column name does not exist in the table. | [
"Set",
"the",
"given",
"column",
"name",
"to",
"the",
"given",
"value",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/data/InsertIntoTable.java#L195-L198 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/StandaloneHiveRunner.java | StandaloneHiveRunner.evaluateStatement | public HiveShellContainer evaluateStatement(List<? extends Script> scripts, Object target, TemporaryFolder temporaryFolder, Statement base) throws Throwable {
container = null;
FileUtil.setPermission(temporaryFolder.getRoot(), FsPermission.getDirDefault());
try {
LOGGER.info("Setting up {} in {}", getName(), temporaryFolder.getRoot().getAbsolutePath());
container = createHiveServerContainer(scripts, target, temporaryFolder);
base.evaluate();
return container;
} finally {
tearDown();
}
} | java | public HiveShellContainer evaluateStatement(List<? extends Script> scripts, Object target, TemporaryFolder temporaryFolder, Statement base) throws Throwable {
container = null;
FileUtil.setPermission(temporaryFolder.getRoot(), FsPermission.getDirDefault());
try {
LOGGER.info("Setting up {} in {}", getName(), temporaryFolder.getRoot().getAbsolutePath());
container = createHiveServerContainer(scripts, target, temporaryFolder);
base.evaluate();
return container;
} finally {
tearDown();
}
} | [
"public",
"HiveShellContainer",
"evaluateStatement",
"(",
"List",
"<",
"?",
"extends",
"Script",
">",
"scripts",
",",
"Object",
"target",
",",
"TemporaryFolder",
"temporaryFolder",
",",
"Statement",
"base",
")",
"throws",
"Throwable",
"{",
"container",
"=",
"null"... | Drives the unit test. | [
"Drives",
"the",
"unit",
"test",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/StandaloneHiveRunner.java#L160-L171 | train |
klarna/HiveRunner | src/main/java/com/klarna/hiverunner/StandaloneHiveRunner.java | StandaloneHiveRunner.createHiveServerContainer | private HiveShellContainer createHiveServerContainer(final List<? extends Script> scripts, final Object testCase, TemporaryFolder baseDir)
throws IOException {
HiveServerContext context = new StandaloneHiveServerContext(baseDir, config);
final HiveServerContainer hiveTestHarness = new HiveServerContainer(context);
HiveShellBuilder hiveShellBuilder = new HiveShellBuilder();
hiveShellBuilder.setCommandShellEmulation(config.getCommandShellEmulator());
HiveShellField shellSetter = loadScriptUnderTest(testCase, hiveShellBuilder);
if (scripts != null) {
hiveShellBuilder.overrideScriptsUnderTest(scripts);
}
hiveShellBuilder.setHiveServerContainer(hiveTestHarness);
loadAnnotatedResources(testCase, hiveShellBuilder);
loadAnnotatedProperties(testCase, hiveShellBuilder);
loadAnnotatedSetupScripts(testCase, hiveShellBuilder);
// Build shell
final HiveShellContainer shell = hiveShellBuilder.buildShell();
// Set shell
shellSetter.setShell(shell);
if (shellSetter.isAutoStart()) {
shell.start();
}
return shell;
} | java | private HiveShellContainer createHiveServerContainer(final List<? extends Script> scripts, final Object testCase, TemporaryFolder baseDir)
throws IOException {
HiveServerContext context = new StandaloneHiveServerContext(baseDir, config);
final HiveServerContainer hiveTestHarness = new HiveServerContainer(context);
HiveShellBuilder hiveShellBuilder = new HiveShellBuilder();
hiveShellBuilder.setCommandShellEmulation(config.getCommandShellEmulator());
HiveShellField shellSetter = loadScriptUnderTest(testCase, hiveShellBuilder);
if (scripts != null) {
hiveShellBuilder.overrideScriptsUnderTest(scripts);
}
hiveShellBuilder.setHiveServerContainer(hiveTestHarness);
loadAnnotatedResources(testCase, hiveShellBuilder);
loadAnnotatedProperties(testCase, hiveShellBuilder);
loadAnnotatedSetupScripts(testCase, hiveShellBuilder);
// Build shell
final HiveShellContainer shell = hiveShellBuilder.buildShell();
// Set shell
shellSetter.setShell(shell);
if (shellSetter.isAutoStart()) {
shell.start();
}
return shell;
} | [
"private",
"HiveShellContainer",
"createHiveServerContainer",
"(",
"final",
"List",
"<",
"?",
"extends",
"Script",
">",
"scripts",
",",
"final",
"Object",
"testCase",
",",
"TemporaryFolder",
"baseDir",
")",
"throws",
"IOException",
"{",
"HiveServerContext",
"context",... | Traverses the test case annotations. Will inject a HiveShell in the test case that envelopes the HiveServer. | [
"Traverses",
"the",
"test",
"case",
"annotations",
".",
"Will",
"inject",
"a",
"HiveShell",
"in",
"the",
"test",
"case",
"that",
"envelopes",
"the",
"HiveServer",
"."
] | c8899237db6122127f16e3d8a740c1f8657c2ae3 | https://github.com/klarna/HiveRunner/blob/c8899237db6122127f16e3d8a740c1f8657c2ae3/src/main/java/com/klarna/hiverunner/StandaloneHiveRunner.java#L187-L221 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newInsert | public static Command newInsert(Object object,
String outIdentifier) {
return getCommandFactoryProvider().newInsert( object,
outIdentifier );
} | java | public static Command newInsert(Object object,
String outIdentifier) {
return getCommandFactoryProvider().newInsert( object,
outIdentifier );
} | [
"public",
"static",
"Command",
"newInsert",
"(",
"Object",
"object",
",",
"String",
"outIdentifier",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newInsert",
"(",
"object",
",",
"outIdentifier",
")",
";",
"}"
] | Inserts a new instance but references via the outIdentifier, which is returned as part of the ExecutionResults
@param object
@param outIdentifier
@return | [
"Inserts",
"a",
"new",
"instance",
"but",
"references",
"via",
"the",
"outIdentifier",
"which",
"is",
"returned",
"as",
"part",
"of",
"the",
"ExecutionResults"
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L69-L73 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newInsert | public static Command newInsert(Object object,
String outIdentifier,
boolean returnObject,
String entryPoint ) {
return getCommandFactoryProvider().newInsert( object,
outIdentifier,
returnObject,
entryPoint );
} | java | public static Command newInsert(Object object,
String outIdentifier,
boolean returnObject,
String entryPoint ) {
return getCommandFactoryProvider().newInsert( object,
outIdentifier,
returnObject,
entryPoint );
} | [
"public",
"static",
"Command",
"newInsert",
"(",
"Object",
"object",
",",
"String",
"outIdentifier",
",",
"boolean",
"returnObject",
",",
"String",
"entryPoint",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newInsert",
"(",
"object",
",",
"ou... | Inserts a new instance but references via the outIdentifier, which is returned as part of the ExecutionResults
The outIdentifier can be null.
The entryPoint, which can also be null, specifies the entrypoint the object is inserted into.
@param object
@param outIdentifier
@param entryPoint
@return | [
"Inserts",
"a",
"new",
"instance",
"but",
"references",
"via",
"the",
"outIdentifier",
"which",
"is",
"returned",
"as",
"part",
"of",
"the",
"ExecutionResults",
"The",
"outIdentifier",
"can",
"be",
"null",
".",
"The",
"entryPoint",
"which",
"can",
"also",
"be"... | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L85-L93 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newInsertElements | public static Command newInsertElements(Collection objects, String outIdentifier, boolean returnObject, String entryPoint) {
return getCommandFactoryProvider().newInsertElements( objects, outIdentifier, returnObject, entryPoint );
} | java | public static Command newInsertElements(Collection objects, String outIdentifier, boolean returnObject, String entryPoint) {
return getCommandFactoryProvider().newInsertElements( objects, outIdentifier, returnObject, entryPoint );
} | [
"public",
"static",
"Command",
"newInsertElements",
"(",
"Collection",
"objects",
",",
"String",
"outIdentifier",
",",
"boolean",
"returnObject",
",",
"String",
"entryPoint",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newInsertElements",
"(",
"... | Iterate and insert each of the elements of the Collection.
@param objects
The objects to insert
@param outIdentifier
Identifier to lookup the returned objects
@param returnObject
boolean to specify whether the inserted Collection is part of the ExecutionResults
@param entryPoint
Optional EntryPoint for the insertions
@return | [
"Iterate",
"and",
"insert",
"each",
"of",
"the",
"elements",
"of",
"the",
"Collection",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L120-L122 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newSetGlobal | public static Command newSetGlobal(String identifier,
Object object) {
return getCommandFactoryProvider().newSetGlobal( identifier,
object );
} | java | public static Command newSetGlobal(String identifier,
Object object) {
return getCommandFactoryProvider().newSetGlobal( identifier,
object );
} | [
"public",
"static",
"Command",
"newSetGlobal",
"(",
"String",
"identifier",
",",
"Object",
"object",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newSetGlobal",
"(",
"identifier",
",",
"object",
")",
";",
"}"
] | Sets the global. Does not add the global to the ExecutionResults.
@param identifier
The identifier of the global
@param object
The instance to be set as the global.
@return | [
"Sets",
"the",
"global",
".",
"Does",
"not",
"add",
"the",
"global",
"to",
"the",
"ExecutionResults",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L185-L189 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newGetGlobal | public static Command newGetGlobal(String identifier,
String outIdentifier) {
return getCommandFactoryProvider().newGetGlobal( identifier,
outIdentifier );
} | java | public static Command newGetGlobal(String identifier,
String outIdentifier) {
return getCommandFactoryProvider().newGetGlobal( identifier,
outIdentifier );
} | [
"public",
"static",
"Command",
"newGetGlobal",
"(",
"String",
"identifier",
",",
"String",
"outIdentifier",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newGetGlobal",
"(",
"identifier",
",",
"outIdentifier",
")",
";",
"}"
] | Gets the global and adds it ot the BatchExecutionresults using the alternative outIdentifier.
@param identifier
The identifier of the global
@param outIdentifier
The identifier used in the ExecutionResults to store the global.
@return | [
"Gets",
"the",
"global",
"and",
"adds",
"it",
"ot",
"the",
"BatchExecutionresults",
"using",
"the",
"alternative",
"outIdentifier",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L248-L252 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newStartProcess | public static Command newStartProcess(String processId,
Map<String, Object> parameters) {
return getCommandFactoryProvider().newStartProcess( processId,
parameters );
} | java | public static Command newStartProcess(String processId,
Map<String, Object> parameters) {
return getCommandFactoryProvider().newStartProcess( processId,
parameters );
} | [
"public",
"static",
"Command",
"newStartProcess",
"(",
"String",
"processId",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newStartProcess",
"(",
"processId",
",",
"parameters",
")"... | Start a process using the given parameters.
@param processId
@param parameters
@return | [
"Start",
"a",
"process",
"using",
"the",
"given",
"parameters",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L283-L287 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newQuery | public static Command newQuery(String identifier,
String name) {
return getCommandFactoryProvider().newQuery( identifier,
name );
} | java | public static Command newQuery(String identifier,
String name) {
return getCommandFactoryProvider().newQuery( identifier,
name );
} | [
"public",
"static",
"Command",
"newQuery",
"(",
"String",
"identifier",
",",
"String",
"name",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newQuery",
"(",
"identifier",
",",
"name",
")",
";",
"}"
] | Executes a query. The query results will be added to the ExecutionResults using the
given identifier.
@param identifier
The identifier to be used for the results when added to the ExecutionResults
@param name
The name of the query to execute
@return | [
"Executes",
"a",
"query",
".",
"The",
"query",
"results",
"will",
"be",
"added",
"to",
"the",
"ExecutionResults",
"using",
"the",
"given",
"identifier",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L329-L334 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java | CommandFactory.newQuery | public static Command newQuery(String identifier,
String name,
Object[] arguments) {
return getCommandFactoryProvider().newQuery( identifier,
name,
arguments );
} | java | public static Command newQuery(String identifier,
String name,
Object[] arguments) {
return getCommandFactoryProvider().newQuery( identifier,
name,
arguments );
} | [
"public",
"static",
"Command",
"newQuery",
"(",
"String",
"identifier",
",",
"String",
"name",
",",
"Object",
"[",
"]",
"arguments",
")",
"{",
"return",
"getCommandFactoryProvider",
"(",
")",
".",
"newQuery",
"(",
"identifier",
",",
"name",
",",
"arguments",
... | Executes a query using the given parameters. The query results will be added to the
ExecutionResults using the given identifier.
@param identifier
The identifier to be used for the results when added to the ExecutionResults
@param name
The name of the query to execute
@param arguments
The arguments to be used for the query parameters
@return | [
"Executes",
"a",
"query",
"using",
"the",
"given",
"parameters",
".",
"The",
"query",
"results",
"will",
"be",
"added",
"to",
"the",
"ExecutionResults",
"using",
"the",
"given",
"identifier",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/command/CommandFactory.java#L348-L354 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/builder/KnowledgeBuilderFactory.java | KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration | public static KnowledgeBuilderConfiguration newKnowledgeBuilderConfiguration(Properties properties,
ClassLoader... classLoaders) {
return FactoryServiceHolder.factoryService.newKnowledgeBuilderConfiguration( properties, classLoaders );
} | java | public static KnowledgeBuilderConfiguration newKnowledgeBuilderConfiguration(Properties properties,
ClassLoader... classLoaders) {
return FactoryServiceHolder.factoryService.newKnowledgeBuilderConfiguration( properties, classLoaders );
} | [
"public",
"static",
"KnowledgeBuilderConfiguration",
"newKnowledgeBuilderConfiguration",
"(",
"Properties",
"properties",
",",
"ClassLoader",
"...",
"classLoaders",
")",
"{",
"return",
"FactoryServiceHolder",
".",
"factoryService",
".",
"newKnowledgeBuilderConfiguration",
"(",
... | Create a KnowledgeBuilderConfiguration on which properties can be set. Use
the given properties file and ClassLoader - either of which can be null.
@return
The KnowledgeBuilderConfiguration. | [
"Create",
"a",
"KnowledgeBuilderConfiguration",
"on",
"which",
"properties",
"can",
"be",
"set",
".",
"Use",
"the",
"given",
"properties",
"file",
"and",
"ClassLoader",
"-",
"either",
"of",
"which",
"can",
"be",
"null",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/builder/KnowledgeBuilderFactory.java#L84-L87 | train |
kiegroup/droolsjbpm-knowledge | kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java | OSGiLocator.unregister | public static synchronized void unregister(final String serviceName,
final Callable<Class< ? >> factory) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
if ( factories != null ) {
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l != null ) {
l.remove( factory );
}
}
} | java | public static synchronized void unregister(final String serviceName,
final Callable<Class< ? >> factory) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
if ( factories != null ) {
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l != null ) {
l.remove( factory );
}
}
} | [
"public",
"static",
"synchronized",
"void",
"unregister",
"(",
"final",
"String",
"serviceName",
",",
"final",
"Callable",
"<",
"Class",
"<",
"?",
">",
">",
"factory",
")",
"{",
"if",
"(",
"serviceName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgu... | Removes the given service provider factory from the set of
providers for the service.
@param serviceName
The fully qualified name of the service interface.
@param factory
A factory for creating a specific type of service
provider. May be <tt>null</tt> in which case this
method does nothing.
@throws IllegalArgumentException if serviceName is <tt>null</tt> | [
"Removes",
"the",
"given",
"service",
"provider",
"factory",
"from",
"the",
"set",
"of",
"providers",
"for",
"the",
"service",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java#L68-L79 | train |
kiegroup/droolsjbpm-knowledge | kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java | OSGiLocator.register | public static synchronized void register(final String serviceName,
final Callable<Class< ? >> factory) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
if ( factory != null ) {
if ( factories == null ) {
factories = new HashMap<String, List<Callable<Class< ? >>>>();
}
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l == null ) {
l = new ArrayList<Callable<Class< ? >>>();
factories.put( serviceName,
l );
}
l.add( factory );
}
} | java | public static synchronized void register(final String serviceName,
final Callable<Class< ? >> factory) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
if ( factory != null ) {
if ( factories == null ) {
factories = new HashMap<String, List<Callable<Class< ? >>>>();
}
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l == null ) {
l = new ArrayList<Callable<Class< ? >>>();
factories.put( serviceName,
l );
}
l.add( factory );
}
} | [
"public",
"static",
"synchronized",
"void",
"register",
"(",
"final",
"String",
"serviceName",
",",
"final",
"Callable",
"<",
"Class",
"<",
"?",
">",
">",
"factory",
")",
"{",
"if",
"(",
"serviceName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgume... | Adds the given service provider factory to the set of
providers for the service.
@param serviceName
The fully qualified name of the service interface.
@param factory
A factory for creating a specific type of service
provider. May be <tt>null</tt> in which case this
method does nothing.
@throws IllegalArgumentException if serviceName is <tt>null</tt> | [
"Adds",
"the",
"given",
"service",
"provider",
"factory",
"to",
"the",
"set",
"of",
"providers",
"for",
"the",
"service",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java#L93-L110 | train |
kiegroup/droolsjbpm-knowledge | kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java | OSGiLocator.locate | public static synchronized Class< ? > locate(final String serviceName) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
if ( factories != null ) {
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l != null && !l.isEmpty() ) {
Callable<Class< ? >> c = l.get( l.size() - 1 );
try {
return c.call();
} catch ( Exception e ) {
}
}
}
return null;
} | java | public static synchronized Class< ? > locate(final String serviceName) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
if ( factories != null ) {
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l != null && !l.isEmpty() ) {
Callable<Class< ? >> c = l.get( l.size() - 1 );
try {
return c.call();
} catch ( Exception e ) {
}
}
}
return null;
} | [
"public",
"static",
"synchronized",
"Class",
"<",
"?",
">",
"locate",
"(",
"final",
"String",
"serviceName",
")",
"{",
"if",
"(",
"serviceName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"serviceName cannot be null\"",
")",
";",
... | Finds the preferred provider for the given service. The preferred
provider is the last one added to the set of providers.
@param serviceName
The fully qualified name of the service interface.
@return
The last provider added for the service if any exists.
Otherwise, it returns <tt>null</tt>.
@throws IllegalArgumentException if serviceName is <tt>null</tt> | [
"Finds",
"the",
"preferred",
"provider",
"for",
"the",
"given",
"service",
".",
"The",
"preferred",
"provider",
"is",
"the",
"last",
"one",
"added",
"to",
"the",
"set",
"of",
"providers",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java#L123-L138 | train |
kiegroup/droolsjbpm-knowledge | kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java | OSGiLocator.locateAll | public static synchronized List<Class< ? >> locateAll(final String serviceName) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
List<Class< ? >> classes = new ArrayList<Class< ? >>();
if ( factories != null ) {
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l != null ) {
for ( Callable<Class< ? >> c : l ) {
try {
classes.add( c.call() );
} catch ( Exception e ) {
}
}
}
}
return classes;
} | java | public static synchronized List<Class< ? >> locateAll(final String serviceName) {
if ( serviceName == null ) {
throw new IllegalArgumentException( "serviceName cannot be null" );
}
List<Class< ? >> classes = new ArrayList<Class< ? >>();
if ( factories != null ) {
List<Callable<Class< ? >>> l = factories.get( serviceName );
if ( l != null ) {
for ( Callable<Class< ? >> c : l ) {
try {
classes.add( c.call() );
} catch ( Exception e ) {
}
}
}
}
return classes;
} | [
"public",
"static",
"synchronized",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"locateAll",
"(",
"final",
"String",
"serviceName",
")",
"{",
"if",
"(",
"serviceName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"serviceName cannot... | Finds all providers for the given service.
@param serviceName
The fully qualified name of the service interface.
@return
The ordered set of providers for the service if any exists.
Otherwise, it returns an empty list.
@throws IllegalArgumentException if serviceName is <tt>null</tt> | [
"Finds",
"all",
"providers",
"for",
"the",
"given",
"service",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-api/src/main/java/org/kie/api/internal/utils/OSGiLocator.java#L150-L167 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/logger/KnowledgeRuntimeLoggerFactory.java | KnowledgeRuntimeLoggerFactory.newFileLogger | public static KieRuntimeLogger newFileLogger(KieRuntimeEventManager session,
String fileName) {
return getKnowledgeRuntimeLoggerProvider().newFileLogger( session,
fileName );
} | java | public static KieRuntimeLogger newFileLogger(KieRuntimeEventManager session,
String fileName) {
return getKnowledgeRuntimeLoggerProvider().newFileLogger( session,
fileName );
} | [
"public",
"static",
"KieRuntimeLogger",
"newFileLogger",
"(",
"KieRuntimeEventManager",
"session",
",",
"String",
"fileName",
")",
"{",
"return",
"getKnowledgeRuntimeLoggerProvider",
"(",
")",
".",
"newFileLogger",
"(",
"session",
",",
"fileName",
")",
";",
"}"
] | Creates a file logger in the current thread. The file is in XML format, suitable for interpretation by Eclipse's Drools Audit View
or other tools. Note that while events are written as they happen, the file will not be flushed until it is closed or the underlying
file buffer is filled. If you need real time logging then use a Console Logger or a Threaded File Logger.
@param session
@param fileName - .log is appended to this.
@return | [
"Creates",
"a",
"file",
"logger",
"in",
"the",
"current",
"thread",
".",
"The",
"file",
"is",
"in",
"XML",
"format",
"suitable",
"for",
"interpretation",
"by",
"Eclipse",
"s",
"Drools",
"Audit",
"View",
"or",
"other",
"tools",
".",
"Note",
"that",
"while",... | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/logger/KnowledgeRuntimeLoggerFactory.java#L52-L56 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorIO.java | DeploymentDescriptorIO.toXml | public static String toXml(DeploymentDescriptor descriptor) {
try {
Marshaller marshaller = getContext().createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.jboss.org/jbpm deployment-descriptor.xsd");
marshaller.setSchema(schema);
StringWriter stringWriter = new StringWriter();
// clone the object and cleanup transients
DeploymentDescriptor clone = ((DeploymentDescriptorImpl) descriptor).clearClone();
marshaller.marshal(clone, stringWriter);
String output = stringWriter.toString();
return output;
} catch (Exception e) {
throw new RuntimeException("Unable to generate xml from deployment descriptor", e);
}
} | java | public static String toXml(DeploymentDescriptor descriptor) {
try {
Marshaller marshaller = getContext().createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.jboss.org/jbpm deployment-descriptor.xsd");
marshaller.setSchema(schema);
StringWriter stringWriter = new StringWriter();
// clone the object and cleanup transients
DeploymentDescriptor clone = ((DeploymentDescriptorImpl) descriptor).clearClone();
marshaller.marshal(clone, stringWriter);
String output = stringWriter.toString();
return output;
} catch (Exception e) {
throw new RuntimeException("Unable to generate xml from deployment descriptor", e);
}
} | [
"public",
"static",
"String",
"toXml",
"(",
"DeploymentDescriptor",
"descriptor",
")",
"{",
"try",
"{",
"Marshaller",
"marshaller",
"=",
"getContext",
"(",
")",
".",
"createMarshaller",
"(",
")",
";",
"marshaller",
".",
"setProperty",
"(",
"Marshaller",
".",
"... | Serializes descriptor instance to XML
@param descriptor descriptor to be serialized
@return xml representation of descriptor as string | [
"Serializes",
"descriptor",
"instance",
"to",
"XML"
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorIO.java#L68-L87 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/runtime/conf/ObjectModelResolverProvider.java | ObjectModelResolverProvider.getResolvers | public static List<ObjectModelResolver> getResolvers() {
if (resolvers == null) {
synchronized (serviceLoader) {
if (resolvers == null) {
List<ObjectModelResolver> foundResolvers = new ArrayList<ObjectModelResolver>();
for (ObjectModelResolver resolver : serviceLoader) {
foundResolvers.add(resolver);
}
resolvers = foundResolvers;
}
}
}
return resolvers;
} | java | public static List<ObjectModelResolver> getResolvers() {
if (resolvers == null) {
synchronized (serviceLoader) {
if (resolvers == null) {
List<ObjectModelResolver> foundResolvers = new ArrayList<ObjectModelResolver>();
for (ObjectModelResolver resolver : serviceLoader) {
foundResolvers.add(resolver);
}
resolvers = foundResolvers;
}
}
}
return resolvers;
} | [
"public",
"static",
"List",
"<",
"ObjectModelResolver",
">",
"getResolvers",
"(",
")",
"{",
"if",
"(",
"resolvers",
"==",
"null",
")",
"{",
"synchronized",
"(",
"serviceLoader",
")",
"{",
"if",
"(",
"resolvers",
"==",
"null",
")",
"{",
"List",
"<",
"Obje... | Returns all found resolvers
@return | [
"Returns",
"all",
"found",
"resolvers"
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/runtime/conf/ObjectModelResolverProvider.java#L36-L50 | train |
kiegroup/droolsjbpm-knowledge | kie-internal/src/main/java/org/kie/internal/runtime/conf/ObjectModelResolverProvider.java | ObjectModelResolverProvider.get | public static ObjectModelResolver get(String resolverId) {
List<ObjectModelResolver> resolvers = getResolvers();
for (ObjectModelResolver resolver : resolvers) {
if (resolver.accept(resolverId)) {
return resolver;
}
}
return null;
} | java | public static ObjectModelResolver get(String resolverId) {
List<ObjectModelResolver> resolvers = getResolvers();
for (ObjectModelResolver resolver : resolvers) {
if (resolver.accept(resolverId)) {
return resolver;
}
}
return null;
} | [
"public",
"static",
"ObjectModelResolver",
"get",
"(",
"String",
"resolverId",
")",
"{",
"List",
"<",
"ObjectModelResolver",
">",
"resolvers",
"=",
"getResolvers",
"(",
")",
";",
"for",
"(",
"ObjectModelResolver",
"resolver",
":",
"resolvers",
")",
"{",
"if",
... | Returns first resolver that accepts the given resolverId.
In case none is found null is returned.
@param resolverId identifier of the resolver
@return found resolver or null otherwise | [
"Returns",
"first",
"resolver",
"that",
"accepts",
"the",
"given",
"resolverId",
".",
"In",
"case",
"none",
"is",
"found",
"null",
"is",
"returned",
"."
] | fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5 | https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/runtime/conf/ObjectModelResolverProvider.java#L58-L68 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/QueuePoller.java | QueuePoller.reset | void reset()
{
if (!hasStopped)
{
throw new IllegalStateException("cannot reset a non stopped queue poller");
}
hasStopped = false;
run = true;
lastLoop = null;
loop = new Semaphore(0);
} | java | void reset()
{
if (!hasStopped)
{
throw new IllegalStateException("cannot reset a non stopped queue poller");
}
hasStopped = false;
run = true;
lastLoop = null;
loop = new Semaphore(0);
} | [
"void",
"reset",
"(",
")",
"{",
"if",
"(",
"!",
"hasStopped",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"cannot reset a non stopped queue poller\"",
")",
";",
"}",
"hasStopped",
"=",
"false",
";",
"run",
"=",
"true",
";",
"lastLoop",
"=",
"nu... | Will make the thread ready to run once again after it has stopped. | [
"Will",
"make",
"the",
"thread",
"ready",
"to",
"run",
"once",
"again",
"after",
"it",
"has",
"stopped",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/QueuePoller.java#L87-L97 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/QueuePoller.java | QueuePoller.releaseResources | void releaseResources(JobInstance ji)
{
this.peremption.remove(ji.getId());
this.actualNbThread.decrementAndGet();
for (ResourceManagerBase rm : this.resourceManagers)
{
rm.releaseResource(ji);
}
if (!this.strictPollingPeriod)
{
// Force a new loop at once. This makes queues more fluid.
loop.release(1);
}
this.engine.signalEndOfRun();
} | java | void releaseResources(JobInstance ji)
{
this.peremption.remove(ji.getId());
this.actualNbThread.decrementAndGet();
for (ResourceManagerBase rm : this.resourceManagers)
{
rm.releaseResource(ji);
}
if (!this.strictPollingPeriod)
{
// Force a new loop at once. This makes queues more fluid.
loop.release(1);
}
this.engine.signalEndOfRun();
} | [
"void",
"releaseResources",
"(",
"JobInstance",
"ji",
")",
"{",
"this",
".",
"peremption",
".",
"remove",
"(",
"ji",
".",
"getId",
"(",
")",
")",
";",
"this",
".",
"actualNbThread",
".",
"decrementAndGet",
"(",
")",
";",
"for",
"(",
"ResourceManagerBase",
... | Called when a payload thread has ended. This also notifies the poller to poll once again. | [
"Called",
"when",
"a",
"payload",
"thread",
"has",
"ended",
".",
"This",
"also",
"notifies",
"the",
"poller",
"to",
"poll",
"once",
"again",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/QueuePoller.java#L409-L425 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JqmEngineFactory.java | JqmEngineFactory.startEngine | public static JqmEngineOperations startEngine(String name, JqmEngineHandler handler)
{
JqmEngine e = new JqmEngine();
e.start(name, handler);
return e;
} | java | public static JqmEngineOperations startEngine(String name, JqmEngineHandler handler)
{
JqmEngine e = new JqmEngine();
e.start(name, handler);
return e;
} | [
"public",
"static",
"JqmEngineOperations",
"startEngine",
"(",
"String",
"name",
",",
"JqmEngineHandler",
"handler",
")",
"{",
"JqmEngine",
"e",
"=",
"new",
"JqmEngine",
"(",
")",
";",
"e",
".",
"start",
"(",
"name",
",",
"handler",
")",
";",
"return",
"e"... | Creates and start an engine representing the node named as the given parameter.
@param name
name of the node, as present in the configuration (case sensitive)
@param handler
can be null. A set of callbacks hooked on different engine life cycle events.
@return an object allowing to stop the engine. | [
"Creates",
"and",
"start",
"an",
"engine",
"representing",
"the",
"node",
"named",
"as",
"the",
"given",
"parameter",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JqmEngineFactory.java#L23-L28 | train |
enioka/jqm | jqm-all/jqm-ws/src/main/java/com/enioka/jqm/api/ErrorHandler.java | ErrorHandler.toResponse | @Override
public Response toResponse(ErrorDto e)
{
// String type = headers.getContentType() == null ? MediaType.APPLICATION_JSON : headers.getContentType();
return Response.status(e.httpStatus).entity(e).type(MediaType.APPLICATION_JSON).build();
} | java | @Override
public Response toResponse(ErrorDto e)
{
// String type = headers.getContentType() == null ? MediaType.APPLICATION_JSON : headers.getContentType();
return Response.status(e.httpStatus).entity(e).type(MediaType.APPLICATION_JSON).build();
} | [
"@",
"Override",
"public",
"Response",
"toResponse",
"(",
"ErrorDto",
"e",
")",
"{",
"// String type = headers.getContentType() == null ? MediaType.APPLICATION_JSON : headers.getContentType();",
"return",
"Response",
".",
"status",
"(",
"e",
".",
"httpStatus",
")",
".",
"en... | private HttpServletResponse headers; | [
"private",
"HttpServletResponse",
"headers",
";"
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-ws/src/main/java/com/enioka/jqm/api/ErrorHandler.java#L29-L34 | train |
enioka/jqm | jqm-all/jqm-client/jqm-api-client-core/src/main/java/com/enioka/jqm/api/JqmClientFactory.java | JqmClientFactory.getClient | public static JqmClient getClient(String name, Properties p, boolean cached)
{
Properties p2 = null;
if (binder == null)
{
bind();
}
if (p == null)
{
p2 = props;
}
else
{
p2 = new Properties(props);
p2.putAll(p);
}
return binder.getClientFactory().getClient(name, p2, cached);
} | java | public static JqmClient getClient(String name, Properties p, boolean cached)
{
Properties p2 = null;
if (binder == null)
{
bind();
}
if (p == null)
{
p2 = props;
}
else
{
p2 = new Properties(props);
p2.putAll(p);
}
return binder.getClientFactory().getClient(name, p2, cached);
} | [
"public",
"static",
"JqmClient",
"getClient",
"(",
"String",
"name",
",",
"Properties",
"p",
",",
"boolean",
"cached",
")",
"{",
"Properties",
"p2",
"=",
"null",
";",
"if",
"(",
"binder",
"==",
"null",
")",
"{",
"bind",
"(",
")",
";",
"}",
"if",
"(",... | Return a new client that may be cached or not. Given properties are always use when not cached, and only used at creation time for
cached clients.
@param name
if null, default client. Otherwise, helpful to retrieve cached clients later.
@param p
a set of properties. Implementation specific. Unknown properties are silently ignored.
@param cached
if false, the client will not be cached and subsequent calls with the same name will return different objects. | [
"Return",
"a",
"new",
"client",
"that",
"may",
"be",
"cached",
"or",
"not",
".",
"Given",
"properties",
"are",
"always",
"use",
"when",
"not",
"cached",
"and",
"only",
"used",
"at",
"creation",
"time",
"for",
"cached",
"clients",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-client/jqm-api-client-core/src/main/java/com/enioka/jqm/api/JqmClientFactory.java#L157-L174 | train |
enioka/jqm | jqm-all/jqm-admin/src/main/java/com/enioka/api/admin/ScheduledJob.java | ScheduledJob.create | public static ScheduledJob create(String cronExpression)
{
ScheduledJob res = new ScheduledJob();
res.cronExpression = cronExpression;
return res;
} | java | public static ScheduledJob create(String cronExpression)
{
ScheduledJob res = new ScheduledJob();
res.cronExpression = cronExpression;
return res;
} | [
"public",
"static",
"ScheduledJob",
"create",
"(",
"String",
"cronExpression",
")",
"{",
"ScheduledJob",
"res",
"=",
"new",
"ScheduledJob",
"(",
")",
";",
"res",
".",
"cronExpression",
"=",
"cronExpression",
";",
"return",
"res",
";",
"}"
] | Fluent API builder.
@param cronExpression
@return | [
"Fluent",
"API",
"builder",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-admin/src/main/java/com/enioka/api/admin/ScheduledJob.java#L37-L42 | train |
enioka/jqm | jqm-all/jqm-xml/src/main/java/com/enioka/jqm/tools/XmlQueueExporter.java | XmlQueueExporter.export | static void export(String path, String queueName, DbConn cnx) throws JqmXmlException
{
// Argument tests
if (queueName == null)
{
throw new IllegalArgumentException("queue name cannot be null");
}
if (cnx == null)
{
throw new IllegalArgumentException("database connection cannot be null");
}
Queue q = CommonXml.findQueue(queueName, cnx);
if (q == null)
{
throw new IllegalArgumentException("there is no queue named " + queueName);
}
List<Queue> l = new ArrayList<>();
l.add(q);
export(path, l, cnx);
} | java | static void export(String path, String queueName, DbConn cnx) throws JqmXmlException
{
// Argument tests
if (queueName == null)
{
throw new IllegalArgumentException("queue name cannot be null");
}
if (cnx == null)
{
throw new IllegalArgumentException("database connection cannot be null");
}
Queue q = CommonXml.findQueue(queueName, cnx);
if (q == null)
{
throw new IllegalArgumentException("there is no queue named " + queueName);
}
List<Queue> l = new ArrayList<>();
l.add(q);
export(path, l, cnx);
} | [
"static",
"void",
"export",
"(",
"String",
"path",
",",
"String",
"queueName",
",",
"DbConn",
"cnx",
")",
"throws",
"JqmXmlException",
"{",
"// Argument tests",
"if",
"(",
"queueName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\... | Exports a single queue to an XML file. | [
"Exports",
"a",
"single",
"queue",
"to",
"an",
"XML",
"file",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-xml/src/main/java/com/enioka/jqm/tools/XmlQueueExporter.java#L41-L61 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java | Helpers.createMessage | static void createMessage(String textMessage, JobInstance jobInstance, DbConn cnx)
{
cnx.runUpdate("message_insert", jobInstance.getId(), textMessage);
} | java | static void createMessage(String textMessage, JobInstance jobInstance, DbConn cnx)
{
cnx.runUpdate("message_insert", jobInstance.getId(), textMessage);
} | [
"static",
"void",
"createMessage",
"(",
"String",
"textMessage",
",",
"JobInstance",
"jobInstance",
",",
"DbConn",
"cnx",
")",
"{",
"cnx",
".",
"runUpdate",
"(",
"\"message_insert\"",
",",
"jobInstance",
".",
"getId",
"(",
")",
",",
"textMessage",
")",
";",
... | Create a text message that will be stored in the database. Must be called inside a transaction. | [
"Create",
"a",
"text",
"message",
"that",
"will",
"be",
"stored",
"in",
"the",
"database",
".",
"Must",
"be",
"called",
"inside",
"a",
"transaction",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java#L190-L193 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java | Helpers.createDeliverable | static int createDeliverable(String path, String originalFileName, String fileFamily, Integer jobId, DbConn cnx)
{
QueryResult qr = cnx.runUpdate("deliverable_insert", fileFamily, path, jobId, originalFileName, UUID.randomUUID().toString());
return qr.getGeneratedId();
} | java | static int createDeliverable(String path, String originalFileName, String fileFamily, Integer jobId, DbConn cnx)
{
QueryResult qr = cnx.runUpdate("deliverable_insert", fileFamily, path, jobId, originalFileName, UUID.randomUUID().toString());
return qr.getGeneratedId();
} | [
"static",
"int",
"createDeliverable",
"(",
"String",
"path",
",",
"String",
"originalFileName",
",",
"String",
"fileFamily",
",",
"Integer",
"jobId",
",",
"DbConn",
"cnx",
")",
"{",
"QueryResult",
"qr",
"=",
"cnx",
".",
"runUpdate",
"(",
"\"deliverable_insert\""... | Create a Deliverable inside the database that will track a file created by a JobInstance Must be called from inside a transaction
@param path
FilePath (relative to a root directory - cf. Node)
@param originalFileName
FileName
@param fileFamily
File family (may be null). E.g.: "daily report"
@param jobId
Job Instance ID
@param cnx
the DbConn to use. | [
"Create",
"a",
"Deliverable",
"inside",
"the",
"database",
"that",
"will",
"track",
"a",
"file",
"created",
"by",
"a",
"JobInstance",
"Must",
"be",
"called",
"from",
"inside",
"a",
"transaction"
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java#L209-L213 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java | Helpers.initSingleParam | static void initSingleParam(String key, String initValue, DbConn cnx)
{
try
{
cnx.runSelectSingle("globalprm_select_by_key", 2, String.class, key);
return;
}
catch (NoResultException e)
{
GlobalParameter.create(cnx, key, initValue);
}
catch (NonUniqueResultException e)
{
// It exists! Nothing to do...
}
} | java | static void initSingleParam(String key, String initValue, DbConn cnx)
{
try
{
cnx.runSelectSingle("globalprm_select_by_key", 2, String.class, key);
return;
}
catch (NoResultException e)
{
GlobalParameter.create(cnx, key, initValue);
}
catch (NonUniqueResultException e)
{
// It exists! Nothing to do...
}
} | [
"static",
"void",
"initSingleParam",
"(",
"String",
"key",
",",
"String",
"initValue",
",",
"DbConn",
"cnx",
")",
"{",
"try",
"{",
"cnx",
".",
"runSelectSingle",
"(",
"\"globalprm_select_by_key\"",
",",
"2",
",",
"String",
".",
"class",
",",
"key",
")",
";... | Checks if a parameter exists. If it exists, it is left untouched. If it doesn't, it is created. Only works for parameters which key
is unique. Must be called from within an open transaction. | [
"Checks",
"if",
"a",
"parameter",
"exists",
".",
"If",
"it",
"exists",
"it",
"is",
"left",
"untouched",
".",
"If",
"it",
"doesn",
"t",
"it",
"is",
"created",
".",
"Only",
"works",
"for",
"parameters",
"which",
"key",
"is",
"unique",
".",
"Must",
"be",
... | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java#L219-L234 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java | Helpers.setSingleParam | static void setSingleParam(String key, String value, DbConn cnx)
{
QueryResult r = cnx.runUpdate("globalprm_update_value_by_key", value, key);
if (r.nbUpdated == 0)
{
cnx.runUpdate("globalprm_insert", key, value);
}
cnx.commit();
} | java | static void setSingleParam(String key, String value, DbConn cnx)
{
QueryResult r = cnx.runUpdate("globalprm_update_value_by_key", value, key);
if (r.nbUpdated == 0)
{
cnx.runUpdate("globalprm_insert", key, value);
}
cnx.commit();
} | [
"static",
"void",
"setSingleParam",
"(",
"String",
"key",
",",
"String",
"value",
",",
"DbConn",
"cnx",
")",
"{",
"QueryResult",
"r",
"=",
"cnx",
".",
"runUpdate",
"(",
"\"globalprm_update_value_by_key\"",
",",
"value",
",",
"key",
")",
";",
"if",
"(",
"r"... | Checks if a parameter exists. If it exists, it is updated. If it doesn't, it is created. Only works for parameters which key is
unique. Will create a transaction on the given entity manager. | [
"Checks",
"if",
"a",
"parameter",
"exists",
".",
"If",
"it",
"exists",
"it",
"is",
"updated",
".",
"If",
"it",
"doesn",
"t",
"it",
"is",
"created",
".",
"Only",
"works",
"for",
"parameters",
"which",
"key",
"is",
"unique",
".",
"Will",
"create",
"a",
... | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/Helpers.java#L240-L248 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/DbConn.java | DbConn.close | public void close()
{
if (transac_open)
{
try
{
this._cnx.rollback();
}
catch (Exception e)
{
// Ignore.
}
}
for (Statement s : toClose)
{
closeQuietly(s);
}
toClose.clear();
closeQuietly(_cnx);
_cnx = null;
} | java | public void close()
{
if (transac_open)
{
try
{
this._cnx.rollback();
}
catch (Exception e)
{
// Ignore.
}
}
for (Statement s : toClose)
{
closeQuietly(s);
}
toClose.clear();
closeQuietly(_cnx);
_cnx = null;
} | [
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"transac_open",
")",
"{",
"try",
"{",
"this",
".",
"_cnx",
".",
"rollback",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Ignore.",
"}",
"}",
"for",
"(",
"Statement",
"s",
"... | Close all JDBC objects related to this connection. | [
"Close",
"all",
"JDBC",
"objects",
"related",
"to",
"this",
"connection",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/DbConn.java#L407-L429 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/RunningJobInstanceManager.java | RunningJobInstanceManager.killAll | void killAll()
{
for (RjiRegistration reg : this.instancesById.values().toArray(new RjiRegistration[] {}))
{
reg.rji.handleInstruction(Instruction.KILL);
}
} | java | void killAll()
{
for (RjiRegistration reg : this.instancesById.values().toArray(new RjiRegistration[] {}))
{
reg.rji.handleInstruction(Instruction.KILL);
}
} | [
"void",
"killAll",
"(",
")",
"{",
"for",
"(",
"RjiRegistration",
"reg",
":",
"this",
".",
"instancesById",
".",
"values",
"(",
")",
".",
"toArray",
"(",
"new",
"RjiRegistration",
"[",
"]",
"{",
"}",
")",
")",
"{",
"reg",
".",
"rji",
".",
"handleInstr... | Send a kill signal to all running instances and return as soon as the signal is sent. | [
"Send",
"a",
"kill",
"signal",
"to",
"all",
"running",
"instances",
"and",
"return",
"as",
"soon",
"as",
"the",
"signal",
"is",
"sent",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/RunningJobInstanceManager.java#L78-L84 | train |
enioka/jqm | jqm-all/jqm-ws/src/main/java/com/enioka/jqm/api/ServiceClient.java | ServiceClient.setJobQueue | @Override
public void setJobQueue(int jobId, Queue queue)
{
JqmClientFactory.getClient().setJobQueue(jobId, queue);
} | java | @Override
public void setJobQueue(int jobId, Queue queue)
{
JqmClientFactory.getClient().setJobQueue(jobId, queue);
} | [
"@",
"Override",
"public",
"void",
"setJobQueue",
"(",
"int",
"jobId",
",",
"Queue",
"queue",
")",
"{",
"JqmClientFactory",
".",
"getClient",
"(",
")",
".",
"setJobQueue",
"(",
"jobId",
",",
"queue",
")",
";",
"}"
] | No need to expose. Client side work. | [
"No",
"need",
"to",
"expose",
".",
"Client",
"side",
"work",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-ws/src/main/java/com/enioka/jqm/api/ServiceClient.java#L173-L177 | train |
enioka/jqm | jqm-all/jqm-ws/src/main/java/com/enioka/jqm/api/ServiceClient.java | ServiceClient.getJobs | @Override
public List<JobInstance> getJobs(Query query)
{
return JqmClientFactory.getClient().getJobs(query);
} | java | @Override
public List<JobInstance> getJobs(Query query)
{
return JqmClientFactory.getClient().getJobs(query);
} | [
"@",
"Override",
"public",
"List",
"<",
"JobInstance",
">",
"getJobs",
"(",
"Query",
"query",
")",
"{",
"return",
"JqmClientFactory",
".",
"getClient",
"(",
")",
".",
"getJobs",
"(",
"query",
")",
";",
"}"
] | Not exposed directly - the Query object passed as parameter actually contains results... | [
"Not",
"exposed",
"directly",
"-",
"the",
"Query",
"object",
"passed",
"as",
"parameter",
"actually",
"contains",
"results",
"..."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-ws/src/main/java/com/enioka/jqm/api/ServiceClient.java#L275-L279 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JqmEngine.java | JqmEngine.stop | @Override
public void stop()
{
synchronized (killHook)
{
jqmlogger.info("JQM engine " + this.node.getName() + " has received a stop order");
// Kill hook should be removed
try
{
if (!Runtime.getRuntime().removeShutdownHook(killHook))
{
jqmlogger.error("The engine could not unregister its shutdown hook");
}
}
catch (IllegalStateException e)
{
// This happens if the stop sequence is initiated by the shutdown hook itself.
jqmlogger.info("Stop order is due to an admin operation (KILL/INT)");
}
}
// Stop pollers
int pollerCount = pollers.size();
for (QueuePoller p : pollers.values())
{
p.stop();
}
// Scheduler
this.scheduler.stop();
// Jetty is closed automatically when all pollers are down
// Wait for the end of the world
if (pollerCount > 0)
{
try
{
this.ended.acquire();
}
catch (InterruptedException e)
{
jqmlogger.error("interrupted", e);
}
}
// Send a KILL signal to remaining job instances, and wait some more.
if (this.getCurrentlyRunningJobCount() > 0)
{
this.runningJobInstanceManager.killAll();
try
{
Thread.sleep(10000);
}
catch (InterruptedException e)
{
jqmlogger.error("interrupted", e);
}
}
jqmlogger.debug("Stop order was correctly handled. Engine for node " + this.node.getName() + " has stopped.");
} | java | @Override
public void stop()
{
synchronized (killHook)
{
jqmlogger.info("JQM engine " + this.node.getName() + " has received a stop order");
// Kill hook should be removed
try
{
if (!Runtime.getRuntime().removeShutdownHook(killHook))
{
jqmlogger.error("The engine could not unregister its shutdown hook");
}
}
catch (IllegalStateException e)
{
// This happens if the stop sequence is initiated by the shutdown hook itself.
jqmlogger.info("Stop order is due to an admin operation (KILL/INT)");
}
}
// Stop pollers
int pollerCount = pollers.size();
for (QueuePoller p : pollers.values())
{
p.stop();
}
// Scheduler
this.scheduler.stop();
// Jetty is closed automatically when all pollers are down
// Wait for the end of the world
if (pollerCount > 0)
{
try
{
this.ended.acquire();
}
catch (InterruptedException e)
{
jqmlogger.error("interrupted", e);
}
}
// Send a KILL signal to remaining job instances, and wait some more.
if (this.getCurrentlyRunningJobCount() > 0)
{
this.runningJobInstanceManager.killAll();
try
{
Thread.sleep(10000);
}
catch (InterruptedException e)
{
jqmlogger.error("interrupted", e);
}
}
jqmlogger.debug("Stop order was correctly handled. Engine for node " + this.node.getName() + " has stopped.");
} | [
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"{",
"synchronized",
"(",
"killHook",
")",
"{",
"jqmlogger",
".",
"info",
"(",
"\"JQM engine \"",
"+",
"this",
".",
"node",
".",
"getName",
"(",
")",
"+",
"\" has received a stop order\"",
")",
";",
"// ... | Gracefully stop the engine | [
"Gracefully",
"stop",
"the",
"engine"
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JqmEngine.java#L266-L328 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JqmEngine.java | JqmEngine.purgeDeadJobInstances | private void purgeDeadJobInstances(DbConn cnx, Node node)
{
for (JobInstance ji : JobInstance.select(cnx, "ji_select_by_node", node.getId()))
{
try
{
cnx.runSelectSingle("history_select_state_by_id", String.class, ji.getId());
}
catch (NoResultException e)
{
History.create(cnx, ji, State.CRASHED, Calendar.getInstance());
Message.create(cnx,
"Job was supposed to be running at server startup - usually means it was killed along a server by an admin or a crash",
ji.getId());
}
cnx.runUpdate("ji_delete_by_id", ji.getId());
}
cnx.commit();
} | java | private void purgeDeadJobInstances(DbConn cnx, Node node)
{
for (JobInstance ji : JobInstance.select(cnx, "ji_select_by_node", node.getId()))
{
try
{
cnx.runSelectSingle("history_select_state_by_id", String.class, ji.getId());
}
catch (NoResultException e)
{
History.create(cnx, ji, State.CRASHED, Calendar.getInstance());
Message.create(cnx,
"Job was supposed to be running at server startup - usually means it was killed along a server by an admin or a crash",
ji.getId());
}
cnx.runUpdate("ji_delete_by_id", ji.getId());
}
cnx.commit();
} | [
"private",
"void",
"purgeDeadJobInstances",
"(",
"DbConn",
"cnx",
",",
"Node",
"node",
")",
"{",
"for",
"(",
"JobInstance",
"ji",
":",
"JobInstance",
".",
"select",
"(",
"cnx",
",",
"\"ji_select_by_node\"",
",",
"node",
".",
"getId",
"(",
")",
")",
")",
... | To be called at node startup - it purges all job instances associated to this node.
@param cnx
@param node | [
"To",
"be",
"called",
"at",
"node",
"startup",
"-",
"it",
"purges",
"all",
"job",
"instances",
"associated",
"to",
"this",
"node",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JqmEngine.java#L492-L511 | train |
enioka/jqm | jqm-all/jqm-runner/jqm-runner-java/src/main/java/com/enioka/jqm/tools/ClassloaderManager.java | ClassloaderManager.getClasspath | private URL[] getClasspath(JobInstance ji, JobRunnerCallback cb) throws JqmPayloadException
{
switch (ji.getJD().getPathType())
{
case MAVEN:
return mavenResolver.resolve(ji);
case MEMORY:
return new URL[0];
case FS:
default:
return fsResolver.getLibraries(ji.getNode(), ji.getJD());
}
} | java | private URL[] getClasspath(JobInstance ji, JobRunnerCallback cb) throws JqmPayloadException
{
switch (ji.getJD().getPathType())
{
case MAVEN:
return mavenResolver.resolve(ji);
case MEMORY:
return new URL[0];
case FS:
default:
return fsResolver.getLibraries(ji.getNode(), ji.getJD());
}
} | [
"private",
"URL",
"[",
"]",
"getClasspath",
"(",
"JobInstance",
"ji",
",",
"JobRunnerCallback",
"cb",
")",
"throws",
"JqmPayloadException",
"{",
"switch",
"(",
"ji",
".",
"getJD",
"(",
")",
".",
"getPathType",
"(",
")",
")",
"{",
"case",
"MAVEN",
":",
"r... | Returns all the URL that should be inside the classpath. This includes the jar itself if any.
@throws JqmPayloadException | [
"Returns",
"all",
"the",
"URL",
"that",
"should",
"be",
"inside",
"the",
"classpath",
".",
"This",
"includes",
"the",
"jar",
"itself",
"if",
"any",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-runner/jqm-runner-java/src/main/java/com/enioka/jqm/tools/ClassloaderManager.java#L222-L234 | train |
enioka/jqm | jqm-all/jqm-providers/src/main/java/com/enioka/jqm/providers/PayloadInterceptor.java | PayloadInterceptor.forceCleanup | public static int forceCleanup(Thread t)
{
int i = 0;
for (Map.Entry<ConnectionPool, Set<ConnPair>> e : conns.entrySet())
{
for (ConnPair c : e.getValue())
{
if (c.thread.equals(t))
{
try
{
// This will in turn remove it from the static Map.
c.conn.getHandler().invoke(c.conn, Connection.class.getMethod("close"), null);
}
catch (Throwable e1)
{
e1.printStackTrace();
}
i++;
}
}
}
return i;
} | java | public static int forceCleanup(Thread t)
{
int i = 0;
for (Map.Entry<ConnectionPool, Set<ConnPair>> e : conns.entrySet())
{
for (ConnPair c : e.getValue())
{
if (c.thread.equals(t))
{
try
{
// This will in turn remove it from the static Map.
c.conn.getHandler().invoke(c.conn, Connection.class.getMethod("close"), null);
}
catch (Throwable e1)
{
e1.printStackTrace();
}
i++;
}
}
}
return i;
} | [
"public",
"static",
"int",
"forceCleanup",
"(",
"Thread",
"t",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"ConnectionPool",
",",
"Set",
"<",
"ConnPair",
">",
">",
"e",
":",
"conns",
".",
"entrySet",
"(",
")",
")",
... | Called by the engine to trigger the cleanup at the end of a payload thread. | [
"Called",
"by",
"the",
"engine",
"to",
"trigger",
"the",
"cleanup",
"at",
"the",
"end",
"of",
"a",
"payload",
"thread",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-providers/src/main/java/com/enioka/jqm/providers/PayloadInterceptor.java#L98-L121 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/model/GlobalParameter.java | GlobalParameter.create | public static GlobalParameter create(DbConn cnx, String key, String value)
{
QueryResult r = cnx.runUpdate("globalprm_insert", key, value);
GlobalParameter res = new GlobalParameter();
res.id = r.getGeneratedId();
res.key = key;
res.value = value;
return res;
} | java | public static GlobalParameter create(DbConn cnx, String key, String value)
{
QueryResult r = cnx.runUpdate("globalprm_insert", key, value);
GlobalParameter res = new GlobalParameter();
res.id = r.getGeneratedId();
res.key = key;
res.value = value;
return res;
} | [
"public",
"static",
"GlobalParameter",
"create",
"(",
"DbConn",
"cnx",
",",
"String",
"key",
",",
"String",
"value",
")",
"{",
"QueryResult",
"r",
"=",
"cnx",
".",
"runUpdate",
"(",
"\"globalprm_insert\"",
",",
"key",
",",
"value",
")",
";",
"GlobalParameter... | Create a new GP entry in the database. No commit performed. | [
"Create",
"a",
"new",
"GP",
"entry",
"in",
"the",
"database",
".",
"No",
"commit",
"performed",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/model/GlobalParameter.java#L110-L118 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/model/GlobalParameter.java | GlobalParameter.getParameter | public static String getParameter(DbConn cnx, String key, String defaultValue)
{
try
{
return cnx.runSelectSingle("globalprm_select_by_key", 3, String.class, key);
}
catch (NoResultException e)
{
return defaultValue;
}
} | java | public static String getParameter(DbConn cnx, String key, String defaultValue)
{
try
{
return cnx.runSelectSingle("globalprm_select_by_key", 3, String.class, key);
}
catch (NoResultException e)
{
return defaultValue;
}
} | [
"public",
"static",
"String",
"getParameter",
"(",
"DbConn",
"cnx",
",",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"cnx",
".",
"runSelectSingle",
"(",
"\"globalprm_select_by_key\"",
",",
"3",
",",
"String",
".",
"class",
... | Retrieve the value of a single-valued parameter.
@param key
@param defaultValue
@param cnx | [
"Retrieve",
"the",
"value",
"of",
"a",
"single",
"-",
"valued",
"parameter",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/model/GlobalParameter.java#L154-L164 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JndiContext.java | JndiContext.createJndiContext | static JndiContext createJndiContext() throws NamingException
{
try
{
if (!NamingManager.hasInitialContextFactoryBuilder())
{
JndiContext ctx = new JndiContext();
NamingManager.setInitialContextFactoryBuilder(ctx);
return ctx;
}
else
{
return (JndiContext) NamingManager.getInitialContext(null);
}
}
catch (Exception e)
{
jqmlogger.error("Could not create JNDI context: " + e.getMessage());
NamingException ex = new NamingException("Could not initialize JNDI Context");
ex.setRootCause(e);
throw ex;
}
} | java | static JndiContext createJndiContext() throws NamingException
{
try
{
if (!NamingManager.hasInitialContextFactoryBuilder())
{
JndiContext ctx = new JndiContext();
NamingManager.setInitialContextFactoryBuilder(ctx);
return ctx;
}
else
{
return (JndiContext) NamingManager.getInitialContext(null);
}
}
catch (Exception e)
{
jqmlogger.error("Could not create JNDI context: " + e.getMessage());
NamingException ex = new NamingException("Could not initialize JNDI Context");
ex.setRootCause(e);
throw ex;
}
} | [
"static",
"JndiContext",
"createJndiContext",
"(",
")",
"throws",
"NamingException",
"{",
"try",
"{",
"if",
"(",
"!",
"NamingManager",
".",
"hasInitialContextFactoryBuilder",
"(",
")",
")",
"{",
"JndiContext",
"ctx",
"=",
"new",
"JndiContext",
"(",
")",
";",
"... | Will create a JNDI Context and register it as the initial context factory builder
@return the context
@throws NamingException
on any issue during initial context factory builder registration | [
"Will",
"create",
"a",
"JNDI",
"Context",
"and",
"register",
"it",
"as",
"the",
"initial",
"context",
"factory",
"builder"
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JndiContext.java#L75-L97 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JndiContext.java | JndiContext.getParentCl | private static ClassLoader getParentCl()
{
try
{
Method m = ClassLoader.class.getMethod("getPlatformClassLoader");
return (ClassLoader) m.invoke(null);
}
catch (NoSuchMethodException e)
{
// Java < 9, just use the bootstrap CL.
return null;
}
catch (Exception e)
{
throw new JqmInitError("Could not fetch Platform Class Loader", e);
}
} | java | private static ClassLoader getParentCl()
{
try
{
Method m = ClassLoader.class.getMethod("getPlatformClassLoader");
return (ClassLoader) m.invoke(null);
}
catch (NoSuchMethodException e)
{
// Java < 9, just use the bootstrap CL.
return null;
}
catch (Exception e)
{
throw new JqmInitError("Could not fetch Platform Class Loader", e);
}
} | [
"private",
"static",
"ClassLoader",
"getParentCl",
"(",
")",
"{",
"try",
"{",
"Method",
"m",
"=",
"ClassLoader",
".",
"class",
".",
"getMethod",
"(",
"\"getPlatformClassLoader\"",
")",
";",
"return",
"(",
"ClassLoader",
")",
"m",
".",
"invoke",
"(",
"null",
... | A helper - in Java 9, the extension CL was renamed to platform CL and hosts all the JDK classes. Before 9, it was useless and we used
bootstrap CL instead.
@return the base CL to use. | [
"A",
"helper",
"-",
"in",
"Java",
"9",
"the",
"extension",
"CL",
"was",
"renamed",
"to",
"platform",
"CL",
"and",
"hosts",
"all",
"the",
"JDK",
"classes",
".",
"Before",
"9",
"it",
"was",
"useless",
"and",
"we",
"used",
"bootstrap",
"CL",
"instead",
".... | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/JndiContext.java#L413-L429 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java | Db.loadProperties | public static Properties loadProperties(String[] filesToLoad)
{
Properties p = new Properties();
InputStream fis = null;
for (String path : filesToLoad)
{
try
{
fis = Db.class.getClassLoader().getResourceAsStream(path);
if (fis != null)
{
p.load(fis);
jqmlogger.info("A jqm.properties file was found at {}", path);
}
}
catch (IOException e)
{
// We allow no configuration files, but not an unreadable configuration file.
throw new DatabaseException("META-INF/jqm.properties file is invalid", e);
}
finally
{
closeQuietly(fis);
}
}
// Overload the datasource name from environment variable if any (tests only).
String dbName = System.getenv("DB");
if (dbName != null)
{
p.put("com.enioka.jqm.jdbc.datasource", "jdbc/" + dbName);
}
// Done
return p;
} | java | public static Properties loadProperties(String[] filesToLoad)
{
Properties p = new Properties();
InputStream fis = null;
for (String path : filesToLoad)
{
try
{
fis = Db.class.getClassLoader().getResourceAsStream(path);
if (fis != null)
{
p.load(fis);
jqmlogger.info("A jqm.properties file was found at {}", path);
}
}
catch (IOException e)
{
// We allow no configuration files, but not an unreadable configuration file.
throw new DatabaseException("META-INF/jqm.properties file is invalid", e);
}
finally
{
closeQuietly(fis);
}
}
// Overload the datasource name from environment variable if any (tests only).
String dbName = System.getenv("DB");
if (dbName != null)
{
p.put("com.enioka.jqm.jdbc.datasource", "jdbc/" + dbName);
}
// Done
return p;
} | [
"public",
"static",
"Properties",
"loadProperties",
"(",
"String",
"[",
"]",
"filesToLoad",
")",
"{",
"Properties",
"p",
"=",
"new",
"Properties",
"(",
")",
";",
"InputStream",
"fis",
"=",
"null",
";",
"for",
"(",
"String",
"path",
":",
"filesToLoad",
")",... | Helper method to load a property file from class path.
@param filesToLoad
an array of paths (class path paths) designating where the files may be. All files are loaded, in the order
given. Missing files are silently ignored.
@return a Properties object, which may be empty but not null. | [
"Helper",
"method",
"to",
"load",
"a",
"property",
"file",
"from",
"class",
"path",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java#L225-L260 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java | Db.init | private void init(boolean upgrade)
{
initAdapter();
initQueries();
if (upgrade)
{
dbUpgrade();
}
// First contact with the DB is version checking (if no connection opened by pool).
// If DB is in wrong version or not available, just wait for it to be ready.
boolean versionValid = false;
while (!versionValid)
{
try
{
checkSchemaVersion();
versionValid = true;
}
catch (Exception e)
{
String msg = e.getLocalizedMessage();
if (e.getCause() != null)
{
msg += " - " + e.getCause().getLocalizedMessage();
}
jqmlogger.error("Database not ready: " + msg + ". Waiting for database...");
try
{
Thread.sleep(10000);
}
catch (Exception e2)
{
}
}
}
} | java | private void init(boolean upgrade)
{
initAdapter();
initQueries();
if (upgrade)
{
dbUpgrade();
}
// First contact with the DB is version checking (if no connection opened by pool).
// If DB is in wrong version or not available, just wait for it to be ready.
boolean versionValid = false;
while (!versionValid)
{
try
{
checkSchemaVersion();
versionValid = true;
}
catch (Exception e)
{
String msg = e.getLocalizedMessage();
if (e.getCause() != null)
{
msg += " - " + e.getCause().getLocalizedMessage();
}
jqmlogger.error("Database not ready: " + msg + ". Waiting for database...");
try
{
Thread.sleep(10000);
}
catch (Exception e2)
{
}
}
}
} | [
"private",
"void",
"init",
"(",
"boolean",
"upgrade",
")",
"{",
"initAdapter",
"(",
")",
";",
"initQueries",
"(",
")",
";",
"if",
"(",
"upgrade",
")",
"{",
"dbUpgrade",
"(",
")",
";",
"}",
"// First contact with the DB is version checking (if no connection opened ... | Main database initialization. To be called only when _ds is a valid DataSource. | [
"Main",
"database",
"initialization",
".",
"To",
"be",
"called",
"only",
"when",
"_ds",
"is",
"a",
"valid",
"DataSource",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java#L265-L301 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java | Db.dbUpgrade | private void dbUpgrade()
{
DbConn cnx = this.getConn();
Map<String, Object> rs = null;
int db_schema_version = 0;
try
{
rs = cnx.runSelectSingleRow("version_select_latest");
db_schema_version = (Integer) rs.get("VERSION_D1");
}
catch (Exception e)
{
// Database is to be created, so version 0 is OK.
}
cnx.rollback();
if (SCHEMA_VERSION > db_schema_version)
{
jqmlogger.warn("Database is being upgraded from version {} to version {}", db_schema_version, SCHEMA_VERSION);
// Upgrade scripts are named from_to.sql with 5 padding (e.g. 00000_00003.sql)
// We try to find the fastest path (e.g. a direct 00000_00005.sql for creating a version 5 schema from nothing)
// This is a simplistic and non-optimal algorithm as we try only a single path (no going back)
int loop_from = db_schema_version;
int to = db_schema_version;
List<String> toApply = new ArrayList<>();
toApply.addAll(adapter.preSchemaCreationScripts());
while (to != SCHEMA_VERSION)
{
boolean progressed = false;
for (int loop_to = SCHEMA_VERSION; loop_to > db_schema_version; loop_to--)
{
String migrationFileName = String.format("/sql/%05d_%05d.sql", loop_from, loop_to);
jqmlogger.debug("Trying migration script {}", migrationFileName);
if (Db.class.getResource(migrationFileName) != null)
{
toApply.add(migrationFileName);
to = loop_to;
loop_from = loop_to;
progressed = true;
break;
}
}
if (!progressed)
{
break;
}
}
if (to != SCHEMA_VERSION)
{
throw new DatabaseException(
"There is no migration path from version " + db_schema_version + " to version " + SCHEMA_VERSION);
}
for (String s : toApply)
{
jqmlogger.info("Running migration script {}", s);
ScriptRunner.run(cnx, s);
}
cnx.commit(); // Yes, really. For advanced DB!
cnx.close(); // HSQLDB does not refresh its schema without this.
cnx = getConn();
cnx.runUpdate("version_insert", SCHEMA_VERSION, SCHEMA_COMPATIBLE_VERSION);
cnx.commit();
jqmlogger.info("Database is now up to date");
}
else
{
jqmlogger.info("Database is already up to date");
}
cnx.close();
} | java | private void dbUpgrade()
{
DbConn cnx = this.getConn();
Map<String, Object> rs = null;
int db_schema_version = 0;
try
{
rs = cnx.runSelectSingleRow("version_select_latest");
db_schema_version = (Integer) rs.get("VERSION_D1");
}
catch (Exception e)
{
// Database is to be created, so version 0 is OK.
}
cnx.rollback();
if (SCHEMA_VERSION > db_schema_version)
{
jqmlogger.warn("Database is being upgraded from version {} to version {}", db_schema_version, SCHEMA_VERSION);
// Upgrade scripts are named from_to.sql with 5 padding (e.g. 00000_00003.sql)
// We try to find the fastest path (e.g. a direct 00000_00005.sql for creating a version 5 schema from nothing)
// This is a simplistic and non-optimal algorithm as we try only a single path (no going back)
int loop_from = db_schema_version;
int to = db_schema_version;
List<String> toApply = new ArrayList<>();
toApply.addAll(adapter.preSchemaCreationScripts());
while (to != SCHEMA_VERSION)
{
boolean progressed = false;
for (int loop_to = SCHEMA_VERSION; loop_to > db_schema_version; loop_to--)
{
String migrationFileName = String.format("/sql/%05d_%05d.sql", loop_from, loop_to);
jqmlogger.debug("Trying migration script {}", migrationFileName);
if (Db.class.getResource(migrationFileName) != null)
{
toApply.add(migrationFileName);
to = loop_to;
loop_from = loop_to;
progressed = true;
break;
}
}
if (!progressed)
{
break;
}
}
if (to != SCHEMA_VERSION)
{
throw new DatabaseException(
"There is no migration path from version " + db_schema_version + " to version " + SCHEMA_VERSION);
}
for (String s : toApply)
{
jqmlogger.info("Running migration script {}", s);
ScriptRunner.run(cnx, s);
}
cnx.commit(); // Yes, really. For advanced DB!
cnx.close(); // HSQLDB does not refresh its schema without this.
cnx = getConn();
cnx.runUpdate("version_insert", SCHEMA_VERSION, SCHEMA_COMPATIBLE_VERSION);
cnx.commit();
jqmlogger.info("Database is now up to date");
}
else
{
jqmlogger.info("Database is already up to date");
}
cnx.close();
} | [
"private",
"void",
"dbUpgrade",
"(",
")",
"{",
"DbConn",
"cnx",
"=",
"this",
".",
"getConn",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"rs",
"=",
"null",
";",
"int",
"db_schema_version",
"=",
"0",
";",
"try",
"{",
"rs",
"=",
"cnx",
... | Updates the database. Never call this during normal operations, upgrade is a user-controlled operation. | [
"Updates",
"the",
"database",
".",
"Never",
"call",
"this",
"during",
"normal",
"operations",
"upgrade",
"is",
"a",
"user",
"-",
"controlled",
"operation",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java#L359-L435 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java | Db.initAdapter | private void initAdapter()
{
Connection tmp = null;
DatabaseMetaData meta = null;
try
{
tmp = _ds.getConnection();
meta = tmp.getMetaData();
product = meta.getDatabaseProductName().toLowerCase();
}
catch (SQLException e)
{
throw new DatabaseException("Cannot connect to the database", e);
}
finally
{
try
{
if (tmp != null)
{
tmp.close();
}
}
catch (SQLException e)
{
// Nothing to do.
}
}
DbAdapter newAdpt = null;
for (String s : ADAPTERS)
{
try
{
Class<? extends DbAdapter> clazz = Db.class.getClassLoader().loadClass(s).asSubclass(DbAdapter.class);
newAdpt = clazz.newInstance();
if (newAdpt.compatibleWith(meta))
{
adapter = newAdpt;
break;
}
}
catch (Exception e)
{
throw new DatabaseException("Issue when loading database adapter named: " + s, e);
}
}
if (adapter == null)
{
throw new DatabaseException("Unsupported database! There is no JQM database adapter compatible with product name " + product);
}
else
{
jqmlogger.info("Using database adapter {}", adapter.getClass().getCanonicalName());
}
} | java | private void initAdapter()
{
Connection tmp = null;
DatabaseMetaData meta = null;
try
{
tmp = _ds.getConnection();
meta = tmp.getMetaData();
product = meta.getDatabaseProductName().toLowerCase();
}
catch (SQLException e)
{
throw new DatabaseException("Cannot connect to the database", e);
}
finally
{
try
{
if (tmp != null)
{
tmp.close();
}
}
catch (SQLException e)
{
// Nothing to do.
}
}
DbAdapter newAdpt = null;
for (String s : ADAPTERS)
{
try
{
Class<? extends DbAdapter> clazz = Db.class.getClassLoader().loadClass(s).asSubclass(DbAdapter.class);
newAdpt = clazz.newInstance();
if (newAdpt.compatibleWith(meta))
{
adapter = newAdpt;
break;
}
}
catch (Exception e)
{
throw new DatabaseException("Issue when loading database adapter named: " + s, e);
}
}
if (adapter == null)
{
throw new DatabaseException("Unsupported database! There is no JQM database adapter compatible with product name " + product);
}
else
{
jqmlogger.info("Using database adapter {}", adapter.getClass().getCanonicalName());
}
} | [
"private",
"void",
"initAdapter",
"(",
")",
"{",
"Connection",
"tmp",
"=",
"null",
";",
"DatabaseMetaData",
"meta",
"=",
"null",
";",
"try",
"{",
"tmp",
"=",
"_ds",
".",
"getConnection",
"(",
")",
";",
"meta",
"=",
"tmp",
".",
"getMetaData",
"(",
")",
... | Creates the adapter for the target database. | [
"Creates",
"the",
"adapter",
"for",
"the",
"target",
"database",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java#L440-L496 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java | Db.getConn | public DbConn getConn()
{
Connection cnx = null;
try
{
Thread.interrupted(); // this is VERY sad. Needed for Oracle driver which otherwise fails spectacularly.
cnx = _ds.getConnection();
if (cnx.getAutoCommit())
{
cnx.setAutoCommit(false);
cnx.rollback(); // To ensure no open transaction created by the pool before changing TX mode
}
if (cnx.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED)
{
cnx.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
}
return new DbConn(this, cnx);
}
catch (SQLException e)
{
DbHelper.closeQuietly(cnx); // May have been left open when the pool has given us a failed connection.
throw new DatabaseException(e);
}
} | java | public DbConn getConn()
{
Connection cnx = null;
try
{
Thread.interrupted(); // this is VERY sad. Needed for Oracle driver which otherwise fails spectacularly.
cnx = _ds.getConnection();
if (cnx.getAutoCommit())
{
cnx.setAutoCommit(false);
cnx.rollback(); // To ensure no open transaction created by the pool before changing TX mode
}
if (cnx.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED)
{
cnx.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
}
return new DbConn(this, cnx);
}
catch (SQLException e)
{
DbHelper.closeQuietly(cnx); // May have been left open when the pool has given us a failed connection.
throw new DatabaseException(e);
}
} | [
"public",
"DbConn",
"getConn",
"(",
")",
"{",
"Connection",
"cnx",
"=",
"null",
";",
"try",
"{",
"Thread",
".",
"interrupted",
"(",
")",
";",
"// this is VERY sad. Needed for Oracle driver which otherwise fails spectacularly.",
"cnx",
"=",
"_ds",
".",
"getConnection",... | A connection to the database. Should be short-lived. No transaction active by default.
@return a new open connection. | [
"A",
"connection",
"to",
"the",
"database",
".",
"Should",
"be",
"short",
"-",
"lived",
".",
"No",
"transaction",
"active",
"by",
"default",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java#L513-L538 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java | Db.getQuery | String getQuery(String key)
{
String res = this.adapter.getSqlText(key);
if (res == null)
{
throw new DatabaseException("Query " + key + " does not exist");
}
return res;
} | java | String getQuery(String key)
{
String res = this.adapter.getSqlText(key);
if (res == null)
{
throw new DatabaseException("Query " + key + " does not exist");
}
return res;
} | [
"String",
"getQuery",
"(",
"String",
"key",
")",
"{",
"String",
"res",
"=",
"this",
".",
"adapter",
".",
"getSqlText",
"(",
"key",
")",
";",
"if",
"(",
"res",
"==",
"null",
")",
"{",
"throw",
"new",
"DatabaseException",
"(",
"\"Query \"",
"+",
"key",
... | Gets the interpolated text of a query from cache. If key does not exist, an exception is thrown.
@param key
name of the query
@return the query text | [
"Gets",
"the",
"interpolated",
"text",
"of",
"a",
"query",
"from",
"cache",
".",
"If",
"key",
"does",
"not",
"exist",
"an",
"exception",
"is",
"thrown",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/jdbc/Db.java#L547-L555 | train |
enioka/jqm | jqm-all/jqm-model/src/main/java/com/enioka/jqm/model/JobInstance.java | JobInstance.addParameter | public RuntimeParameter addParameter(String key, String value)
{
RuntimeParameter jp = new RuntimeParameter();
jp.setJi(this.getId());
jp.setKey(key);
jp.setValue(value);
return jp;
} | java | public RuntimeParameter addParameter(String key, String value)
{
RuntimeParameter jp = new RuntimeParameter();
jp.setJi(this.getId());
jp.setKey(key);
jp.setValue(value);
return jp;
} | [
"public",
"RuntimeParameter",
"addParameter",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"RuntimeParameter",
"jp",
"=",
"new",
"RuntimeParameter",
"(",
")",
";",
"jp",
".",
"setJi",
"(",
"this",
".",
"getId",
"(",
")",
")",
";",
"jp",
".",
... | Helper method to add a parameter without having to create it explicitely. The created parameter should be persisted afterwards.
@param key
name of the parameter to add
@param value
value of the parameter to create
@return the newly created parameter | [
"Helper",
"method",
"to",
"add",
"a",
"parameter",
"without",
"having",
"to",
"create",
"it",
"explicitely",
".",
"The",
"created",
"parameter",
"should",
"be",
"persisted",
"afterwards",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-model/src/main/java/com/enioka/jqm/model/JobInstance.java#L89-L96 | train |
enioka/jqm | jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/RunningJobInstance.java | RunningJobInstance.endOfRunDb | void endOfRunDb()
{
DbConn cnx = null;
try
{
cnx = Helpers.getNewDbSession();
// Done: put inside history & remove instance from queue.
History.create(cnx, this.ji, this.resultStatus, endDate);
jqmlogger.trace("An History was just created for job instance " + this.ji.getId());
cnx.runUpdate("ji_delete_by_id", this.ji.getId());
cnx.commit();
}
catch (RuntimeException e)
{
endBlockDbFailureAnalysis(e);
}
finally
{
Helpers.closeQuietly(cnx);
}
} | java | void endOfRunDb()
{
DbConn cnx = null;
try
{
cnx = Helpers.getNewDbSession();
// Done: put inside history & remove instance from queue.
History.create(cnx, this.ji, this.resultStatus, endDate);
jqmlogger.trace("An History was just created for job instance " + this.ji.getId());
cnx.runUpdate("ji_delete_by_id", this.ji.getId());
cnx.commit();
}
catch (RuntimeException e)
{
endBlockDbFailureAnalysis(e);
}
finally
{
Helpers.closeQuietly(cnx);
}
} | [
"void",
"endOfRunDb",
"(",
")",
"{",
"DbConn",
"cnx",
"=",
"null",
";",
"try",
"{",
"cnx",
"=",
"Helpers",
".",
"getNewDbSession",
"(",
")",
";",
"// Done: put inside history & remove instance from queue.",
"History",
".",
"create",
"(",
"cnx",
",",
"this",
".... | Part of the endOfRun process that needs the database. May be deferred if the database is not available. | [
"Part",
"of",
"the",
"endOfRun",
"process",
"that",
"needs",
"the",
"database",
".",
"May",
"be",
"deferred",
"if",
"the",
"database",
"is",
"not",
"available",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-engine/src/main/java/com/enioka/jqm/tools/RunningJobInstance.java#L292-L314 | train |
enioka/jqm | jqm-all/jqm-client/jqm-api-client-jdbc/src/main/java/com/enioka/jqm/api/JdbcClient.java | JdbcClient.highlanderMode | private Integer highlanderMode(JobDef jd, DbConn cnx)
{
if (!jd.isHighlander())
{
return null;
}
try
{
Integer existing = cnx.runSelectSingle("ji_select_existing_highlander", Integer.class, jd.getId());
return existing;
}
catch (NoResultException ex)
{
// Just continue, this means no existing waiting JI in queue.
}
// Now we need to actually synchronize through the database to avoid double posting
// TODO: use a dedicated table, not the JobDef one. Will avoid locking the configuration.
ResultSet rs = cnx.runSelect(true, "jd_select_by_id", jd.getId());
// Now we have a lock, just retry - some other client may have created a job instance recently.
try
{
Integer existing = cnx.runSelectSingle("ji_select_existing_highlander", Integer.class, jd.getId());
rs.close();
cnx.commit(); // Do not keep the lock!
return existing;
}
catch (NoResultException ex)
{
// Just continue, this means no existing waiting JI in queue. We keep the lock!
}
catch (SQLException e)
{
// Who cares.
jqmlogger.warn("Issue when closing a ResultSet. Transaction or session leak is possible.", e);
}
jqmlogger.trace("Highlander mode analysis is done: nor existing JO, must create a new one. Lock is hold.");
return null;
} | java | private Integer highlanderMode(JobDef jd, DbConn cnx)
{
if (!jd.isHighlander())
{
return null;
}
try
{
Integer existing = cnx.runSelectSingle("ji_select_existing_highlander", Integer.class, jd.getId());
return existing;
}
catch (NoResultException ex)
{
// Just continue, this means no existing waiting JI in queue.
}
// Now we need to actually synchronize through the database to avoid double posting
// TODO: use a dedicated table, not the JobDef one. Will avoid locking the configuration.
ResultSet rs = cnx.runSelect(true, "jd_select_by_id", jd.getId());
// Now we have a lock, just retry - some other client may have created a job instance recently.
try
{
Integer existing = cnx.runSelectSingle("ji_select_existing_highlander", Integer.class, jd.getId());
rs.close();
cnx.commit(); // Do not keep the lock!
return existing;
}
catch (NoResultException ex)
{
// Just continue, this means no existing waiting JI in queue. We keep the lock!
}
catch (SQLException e)
{
// Who cares.
jqmlogger.warn("Issue when closing a ResultSet. Transaction or session leak is possible.", e);
}
jqmlogger.trace("Highlander mode analysis is done: nor existing JO, must create a new one. Lock is hold.");
return null;
} | [
"private",
"Integer",
"highlanderMode",
"(",
"JobDef",
"jd",
",",
"DbConn",
"cnx",
")",
"{",
"if",
"(",
"!",
"jd",
".",
"isHighlander",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"Integer",
"existing",
"=",
"cnx",
".",
"runSelectSingle... | Helper. Current transaction is committed in some cases. | [
"Helper",
".",
"Current",
"transaction",
"is",
"committed",
"in",
"some",
"cases",
"."
] | 391733b8e291404b97c714c3727a241c4a861f98 | https://github.com/enioka/jqm/blob/391733b8e291404b97c714c3727a241c4a861f98/jqm-all/jqm-client/jqm-api-client-jdbc/src/main/java/com/enioka/jqm/api/JdbcClient.java#L374-L415 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.