code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
void findErrorEvaluator( GrowQueue_I8 syndromes , GrowQueue_I8 errorLocator ,
GrowQueue_I8 evaluator )
{
math.polyMult_flipA(syndromes,errorLocator,evaluator);
int N = errorLocator.size-1;
int offset = evaluator.size-N;
for (int i = 0; i < N; i++) {
evaluator.data[i] = evaluator.data[i+offset];
}
... | java |
public static <O extends ImageGray<O>>
O[] declareOutput( ImagePyramid<?> pyramid , Class<O> outputType ) {
O[] ret = (O[])Array.newInstance(outputType,pyramid.getNumLayers());
for( int i = 0; i < ret.length; i++ ) {
int w = pyramid.getWidth(i);
int h = pyramid.getHeight(i);
ret[i] = GeneralizedImageOps.... | java |
public static <O extends ImageGray<O>>
void reshapeOutput( ImagePyramid<?> pyramid , O[] output ) {
for( int i = 0; i < output.length; i++ ) {
int w = pyramid.getWidth(i);
int h = pyramid.getHeight(i);
output[i].reshape(w, h);
}
} | java |
public static void histogram(GrayU8 image , int maxPixelValue , TupleDesc_F64 histogram )
{
int numBins = histogram.size();
int divisor = maxPixelValue+1;
histogram.fill(0);
for( int y = 0; y < image.height; y++ ) {
int index = image.startIndex + y*image.stride;
for( int x = 0; x < image.width; x++ , ... | java |
public static <T> T convertGenericToSpecificType(Class<?> type) {
if (type == GrayI8.class)
return (T) GrayU8.class;
if (type == GrayI16.class)
return (T) GrayS16.class;
if (type == InterleavedI8.class)
return (T) InterleavedU8.class;
if (type == InterleavedI16.class)
return (T) InterleavedS16.class... | java |
public static List<LineParametric2D_F32>
pruneSimilarLines( List<LineParametric2D_F32> lines ,
float intensity[] ,
float toleranceAngle ,
float toleranceDist ,
int imgWidth ,
int imgHeight )
{
int indexSort[] = new int[ intensity.length ];
QuickSort_F32 sort = new QuickSor... | java |
public static LineSegment2D_F32 convert(LineParametric2D_F32 l,
int width, int height) {
double t0 = (0-l.p.x)/l.getSlopeX();
double t1 = (0-l.p.y)/l.getSlopeY();
double t2 = (width-l.p.x)/l.getSlopeX();
double t3 = (height-l.p.y)/l.getSlopeY();
Point2D_F32 a = computePoint(l, t0);
Point2D_F32 b ... | java |
public static void applyMask(GrayF32 disparity , GrayU8 mask , int radius ) {
if( disparity.isSubimage() || mask.isSubimage() )
throw new RuntimeException("Input is subimage. Currently not support but no reason why it can't be. Ask for it");
int N = disparity.width*disparity.height;
for (int i = 0; i < N; i++... | java |
public boolean fitAnchored( int anchor0 , int anchor1 , GrowQueue_I32 corners , GrowQueue_I32 output )
{
this.anchor0 = anchor0;
this.anchor1 = anchor1;
int numLines = anchor0==anchor1? corners.size() : CircularIndex.distanceP(anchor0,anchor1,corners.size);
if( numLines < 2 ) {
throw new RuntimeException("... | java |
boolean sanityCheckCornerOrder( int numLines, GrowQueue_I32 corners ) {
int contourAnchor0 = corners.get(anchor0);
int previous = 0;
for (int i = 1; i < numLines; i++) {
int contourIndex = corners.get(CircularIndex.addOffset(anchor0, i, corners.size()));
int pixelsFromAnchor0 = CircularIndex.distanceP(conto... | java |
boolean fitLinesUsingCorners( int numLines , GrowQueue_I32 cornerIndexes) {
for (int i = 1; i <= numLines; i++) {
int index0 = cornerIndexes.get(CircularIndex.addOffset(anchor0, i - 1, cornerIndexes.size));
int index1 = cornerIndexes.get(CircularIndex.addOffset(anchor0, i, cornerIndexes.size));
if( index0 =... | java |
boolean fitLine( int contourIndex0 , int contourIndex1 , LineGeneral2D_F64 line ) {
int numPixels = CircularIndex.distanceP(contourIndex0,contourIndex1,contour.size());
// if its too small
if( numPixels < minimumLineLength )
return false;
Point2D_I32 c0 = contour.get(contourIndex0);
Point2D_I32 c1 = cont... | java |
int closestPoint( Point2D_F64 target ) {
double bestDistance = Double.MAX_VALUE;
int bestIndex = -1;
for (int i = 0; i < contour.size(); i++) {
Point2D_I32 c = contour.get(i);
double d = UtilPoint2D_F64.distanceSq(target.x,target.y,c.x,c.y);
if( d < bestDistance ) {
bestDistance = d;
bestIndex =... | java |
public void setTransformFromLinesSquare( QrCode qr ) {
// clear old points
storagePairs2D.reset();
storagePairs3D.reset();
// use 3 of the corners to set the coordinate system
// set(0, 0, qr.ppCorner,0); <-- prone to damage. Significantly degrades results if used
set(0, 7, qr.ppCorner,1);
set(7, 7, qr.pp... | java |
public void removeOutsideCornerFeatures() {
if( pairs2D.size() != storagePairs2D.size )
throw new RuntimeException("This can only be called when all the features have been added");
pairs2D.remove(11);
pairs2D.remove(5);
pairs2D.remove(0);
} | java |
public static <T extends ImageGray<T>>
SearchLocalPeak<T> meanShiftUniform( int maxIterations, float convergenceTol , Class<T> imageType ) {
WeightPixel_F32 weights = new WeightPixelUniform_F32();
MeanShiftPeak<T> alg = new MeanShiftPeak<>(maxIterations, convergenceTol, weights, imageType);
return new MeanShiftP... | java |
public static <T extends ImageGray<T>>
SearchLocalPeak<T> meanShiftGaussian( int maxIterations, float convergenceTol , Class<T> imageType) {
WeightPixel_F32 weights = new WeightPixelGaussian_F32();
MeanShiftPeak<T> alg = new MeanShiftPeak<>(maxIterations, convergenceTol, weights, imageType);
return new MeanShift... | java |
public static void loopBlocks(int start , int endExclusive , int minBlock,
IntRangeConsumer consumer ) {
final ForkJoinPool pool = BoofConcurrency.pool;
int numThreads = pool.getParallelism();
int range = endExclusive-start;
if( range == 0 ) // nothing to do here!
return;
if( range < 0 )
thro... | java |
public static void loopBlocks(int start , int endExclusive , IntRangeConsumer consumer ) {
final ForkJoinPool pool = BoofConcurrency.pool;
int numThreads = pool.getParallelism();
int range = endExclusive-start;
if( range == 0 ) // nothing to do here!
return;
if( range < 0 )
throw new IllegalArgumentExc... | java |
public static Number sum(int start , int endExclusive , Class type, IntProducerNumber producer ) {
try {
return pool.submit(new IntOperatorTask.Sum(start,endExclusive,type,producer)).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
} | java |
public synchronized T pop() {
if( list.isEmpty() ) {
return factory.newInstance();
} else {
return list.remove(list.size()-1);
}
} | java |
private void printGrid(PDPageContentStream pcs, float offsetX , float offsetY,
int numRows, int numCols , float sizeBox ) throws IOException {
float pageWidth = (float)paper.convertWidth(units)*UNIT_TO_POINTS;
float pageHeight = (float)paper.convertHeight(units)*UNIT_TO_POINTS;
// pcs.setLineCapStyle(1);... | java |
public void setInput( I input ) {
this.inputImage = input;
// reset the state flag so that everything need sto be computed
if( stale != null ) {
for( int i = 0; i < stale.length; i++) {
boolean a[] = stale[i];
for( int j = 0; j < a.length; j++ ) {
a[j] = true;
}
}
}
} | java |
public void configure( double descriptorRegionScale , double periodX, double periodY) {
this.radius = descriptorRegionScale*scaleToRadius;
this.periodX = (int)(periodX+0.5);
this.periodY = (int)(periodY+0.5);
this.featureWidth = (int)(alg.getCanonicalWidth()*descriptorRegionScale + 0.5);
descriptions = new F... | java |
public void setPoint( int which , double x , double y , double z ) {
points[which].set(x,y,z);
} | java |
public void connectPointToView( int pointIndex , int viewIndex ) {
SceneStructureMetric.Point p = points[pointIndex];
for (int i = 0; i < p.views.size; i++) {
if( p.views.data[i] == viewIndex )
throw new IllegalArgumentException("Tried to add the same view twice. viewIndex="+viewIndex);
}
p.views.add(vi... | java |
public void removePoints( GrowQueue_I32 which ) {
SceneStructureMetric.Point results[] = new SceneStructureMetric.Point[points.length-which.size];
int indexWhich = 0;
for (int i = 0; i < points.length ; i++) {
if( indexWhich < which.size && which.data[indexWhich] == i ) {
indexWhich++;
} else {
res... | java |
public void select(List<Se3_F64> candidatesAtoB,
List<AssociatedPair> observations ,
Se3_F64 model ) {
// use positive depth constraint to select the best one
Se3_F64 bestModel = null;
int bestCount = -1;
for( int i = 0; i < candidatesAtoB.size(); i++ ) {
Se3_F64 s = candidatesAtoB.get(i);
... | java |
public float get(int x, int y) {
if (!isInBounds(x, y))
throw new ImageAccessException("Requested pixel is out of bounds: ( " + x + " , " + y + " )");
return unsafe_get(x,y);
} | java |
public void apply(GrayU8 binary , int maxLoops) {
this.binary = binary;
inputBorder.setImage(binary);
ones0.reset();
zerosOut.reset();
findOnePixels(ones0);
for (int loop = 0; (loop < maxLoops || maxLoops == -1) && ones0.size > 0; loop++) {
boolean changed = false;
// do one cycle through all the... | java |
protected void findOnePixels(GrowQueue_I32 ones) {
for (int y = 0; y < binary.height; y++) {
int index = binary.startIndex + y* binary.stride;
for (int x = 0; x < binary.width; x++, index++) {
if( binary.data[index] != 0 ) {
ones.add(index);
}
}
}
} | java |
public void pruneObservationsBehindCamera() {
Point3D_F64 X = new Point3D_F64();
for (int viewIndex = 0; viewIndex < observations.views.length; viewIndex++) {
SceneObservations.View v = observations.views[viewIndex];
SceneStructureMetric.View view = structure.views[viewIndex];
for (int pointIndex = 0; po... | java |
public void prunePoints(int neighbors , double distance ) {
// Use a nearest neighbor search to find near by points
Point3D_F64 worldX = new Point3D_F64();
List<Point3D_F64> cloud = new ArrayList<>();
for (int i = 0; i < structure.points.length; i++) {
SceneStructureMetric.Point structureP = structure.point... | java |
public void pruneViews( int count ) {
List<SceneStructureMetric.View> remainingS = new ArrayList<>();
List<SceneObservations.View> remainingO = new ArrayList<>();
for (int viewId = 0; viewId < structure.views.length; viewId++) {
SceneObservations.View view = observations.views[viewId];
// See if has enoug... | java |
public void pruneUnusedCameras() {
// Count how many views are used by each camera
int histogram[] = new int[structure.cameras.length];
for (int i = 0; i < structure.views.length; i++) {
histogram[structure.views[i].camera]++;
}
// See which cameras need to be removed and create a look up table from old ... | java |
public void setIntrinsic(CameraPinholeBrown intrinsic) {
planeProjection.setIntrinsic(intrinsic);
normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false,true);
pixelToNorm = LensDistortionFactory.narrow(intrinsic).undistort_F64(true,false);
// Find the change in angle caused by a pixel error i... | java |
public void setExtrinsic(Se3_F64 planeToCamera) {
this.planeToCamera = planeToCamera;
planeToCamera.invert(cameraToPlane);
planeProjection.setPlaneToCamera(planeToCamera, true);
} | java |
public void reset() {
tick = 0;
first = true;
tracker.reset();
keyToWorld.reset();
currToKey.reset();
currToWorld.reset();
worldToCurrCam3D.reset();
} | java |
private void addNewTracks() {
tracker.spawnTracks();
List<PointTrack> spawned = tracker.getNewTracks(null);
// estimate 3D coordinate using stereo vision
for (PointTrack t : spawned) {
// System.out.println("track spawn "+t.x+" "+t.y);
VoTrack p = t.getCookie();
if (p == null) {
t.cookie = p = new ... | java |
private void sortTracksForEstimation() {
// reset data structures
planeSamples.reset();
farAngles.reset();
tracksOnPlane.clear();
tracksFar.clear();
// list of active tracks
List<PointTrack> active = tracker.getActiveTracks(null);
for (PointTrack t : active) {
VoTrack p = t.getCookie();
// comp... | java |
protected boolean isRotationFromAxisY(PointTrack t, Vector3D_F64 pointing) {
VoTrack p = t.getCookie();
// remove rotations not along x-z plane
double normXZ = Math.sqrt(pointing.x * pointing.x + pointing.z * pointing.z);
pointingAdj.set(pointing.x / normXZ, p.pointingY, pointing.z / normXZ);
// Put pointin... | java |
private void computeAngleOfRotation(PointTrack t, Vector3D_F64 pointingPlane) {
VoTrack p = t.getCookie();
// Compute ground pointing vector
groundCurr.x = pointingPlane.z;
groundCurr.y = -pointingPlane.x;
double norm = groundCurr.norm();
groundCurr.x /= norm;
groundCurr.y /= norm;
// dot product. ve... | java |
private void estimateFar() {
// do nothing if there are objects at infinity
farInlierCount = 0;
if (farAngles.size == 0)
return;
farAnglesCopy.reset();
farAnglesCopy.addAll(farAngles);
// find angle which maximizes inlier set
farAngle = maximizeCountInSpread(farAnglesCopy.data, farAngles.size, 2 * t... | java |
private void fuseEstimates() {
// weighted average for angle
double x = closeMotionKeyToCurr.c * closeInlierCount + Math.cos(farAngle) * farInlierCount;
double y = closeMotionKeyToCurr.s * closeInlierCount + Math.sin(farAngle) * farInlierCount;
// update the motion estimate
closeMotionKeyToCurr.setYaw(Math.... | java |
public Se3_F64 getWorldToCurr3D() {
// compute transform in 2D space
Se2_F64 currToWorld = getCurrToWorld2D();
// 2D to 3D coordinates
currPlaneToWorld3D.getT().set(-currToWorld.T.y, 0, currToWorld.T.x);
DMatrixRMaj R = currPlaneToWorld3D.getR();
// set rotation around Y axis.
// Transpose the 2D trans... | java |
public static double maximizeCountInSpread(double[] data, int size, double maxSpread) {
if (size <= 0)
return 0;
Arrays.sort(data, 0, size);
int length = 0;
for (; length < size; length++) {
double s = UtilAngle.dist(data[0], data[length]);
if (s > maxSpread) {
break;
}
}
int bestStart = ... | java |
public boolean computeNextOctave() {
currentOctave += 1;
if( currentOctave > lastOctave ) {
return false;
}
if( octaveImages[numScales].width <= 5 || octaveImages[numScales].height <= 5)
return false;
// the 2nd image from the top of the stack has 2x the sigma as the first
PyramidOps.scaleDown2(octa... | java |
private void computeOctaveScales() {
octaveImages[0] = tempImage0;
for (int i = 1; i < numScales+3; i++) {
octaveImages[i].reshape(tempImage0.width, tempImage0.height);
applyGaussian(octaveImages[i - 1], octaveImages[i], kernelSigmaToK[i-1]);
}
for (int i = 1; i < numScales+3; i++) {
differenceOfGauss... | java |
void applyGaussian(GrayF32 input, GrayF32 output, Kernel1D kernel) {
tempBlur.reshape(input.width, input.height);
GConvolveImageOps.horizontalNormalized(kernel, input, tempBlur);
GConvolveImageOps.verticalNormalized(kernel, tempBlur,output);
} | java |
public double computeOverlap( ImageRectangle a , ImageRectangle b ) {
if( !a.intersection(b,work) )
return 0;
int areaI = work.area();
int bottom = a.area() + b.area() - areaI;
return areaI/ (double)bottom;
} | java |
public Point2D_F64 getCenter() {
Rectangle r = getVisibleRect();
double x = (r.x+r.width/2)/scale;
double y = (r.y+r.height/2)/scale;
return new Point2D_F64(x,y);
} | java |
public static boolean isValidVersion(final String version) {
return StringUtils.isNotBlank(version)
&& (ALTERNATE_PATTERN.matcher(version).matches() || STANDARD_PATTERN
.matcher(version).matches());
} | java |
public String featureVersion(final String featureName) {
String version = toString();
if (featureName != null) {
version = getReleaseVersionString() + "-" + featureName
+ (isSnapshot() ? "-" + Artifact.SNAPSHOT_VERSION : "");
}
return version;
} | java |
private void initExecutables() {
if (StringUtils.isBlank(cmdMvn.getExecutable())) {
if (StringUtils.isBlank(mvnExecutable)) {
mvnExecutable = "mvn";
}
cmdMvn.setExecutable(mvnExecutable);
}
if (StringUtils.isBlank(cmdGit.getExecutable())) {
... | java |
protected void validateConfiguration(String... params)
throws MojoFailureException {
if (StringUtils.isNotBlank(argLine)
&& MAVEN_DISALLOWED_PATTERN.matcher(argLine).find()) {
throw new MojoFailureException(
"The argLine doesn't match allowed pattern."... | java |
protected String getCurrentProjectVersion() throws MojoFailureException {
final Model model = readModel(mavenSession.getCurrentProject());
if (model.getVersion() == null) {
throw new MojoFailureException(
"Cannot get current project version. This plugin should be executed... | java |
private Model readModel(MavenProject project) throws MojoFailureException {
try {
// read pom.xml
Model model;
FileReader fileReader = new FileReader(project.getFile().getAbsoluteFile());
MavenXpp3Reader mavenReader = new MavenXpp3Reader();
try {
... | java |
protected boolean validBranchName(final String branchName)
throws MojoFailureException, CommandLineException {
CommandResult r = executeGitCommandExitCode("check-ref-format",
"--allow-onelevel", branchName);
return r.getExitCode() == SUCCESS_EXIT_CODE;
} | java |
private boolean executeGitHasUncommitted() throws MojoFailureException,
CommandLineException {
boolean uncommited = false;
// 1 if there were differences and 0 means no differences
// git diff --no-ext-diff --ignore-submodules --quiet --exit-code
final CommandResult diffCom... | java |
protected void initGitFlowConfig() throws MojoFailureException,
CommandLineException {
gitSetConfig("gitflow.branch.master",
gitFlowConfig.getProductionBranch());
gitSetConfig("gitflow.branch.develop",
gitFlowConfig.getDevelopmentBranch());
gitSetConf... | java |
private void gitSetConfig(final String name, String value)
throws MojoFailureException, CommandLineException {
if (value == null || value.isEmpty()) {
value = "\"\"";
}
// ignore error exit codes
executeGitCommandExitCode("config", name, value);
} | java |
protected String gitFindTags() throws MojoFailureException, CommandLineException {
String tags = executeGitCommandReturn("for-each-ref", "--sort=*authordate", "--format=\"%(refname:short)\"",
"refs/tags/");
// https://github.com/aleksandr-m/gitflow-maven-plugin/issues/3
tags = re... | java |
protected String gitFindLastTag() throws MojoFailureException, CommandLineException {
String tag = executeGitCommandReturn("for-each-ref", "--sort=-*authordate", "--count=1",
"--format=\"%(refname:short)\"", "refs/tags/");
// https://github.com/aleksandr-m/gitflow-maven-plugin/issues/3
... | java |
private String removeQuotes(String str) {
if (str != null && !str.isEmpty()) {
str = str.replaceAll("\"", "");
}
return str;
} | java |
protected boolean gitCheckBranchExists(final String branchName)
throws MojoFailureException, CommandLineException {
CommandResult commandResult = executeGitCommandExitCode("show-ref",
"--verify", "--quiet", "refs/heads/" + branchName);
return commandResult.getExitCode() == SU... | java |
protected boolean gitCheckTagExists(final String tagName) throws MojoFailureException, CommandLineException {
CommandResult commandResult = executeGitCommandExitCode("show-ref", "--verify", "--quiet",
"refs/tags/" + tagName);
return commandResult.getExitCode() == SUCCESS_EXIT_CODE;
} | java |
protected void gitCheckout(final String branchName)
throws MojoFailureException, CommandLineException {
getLog().info("Checking out '" + branchName + "' branch.");
executeGitCommand("checkout", branchName);
} | java |
protected void gitCreateAndCheckout(final String newBranchName,
final String fromBranchName) throws MojoFailureException,
CommandLineException {
getLog().info(
"Creating a new branch '" + newBranchName + "' from '"
+ fromBranchName + "' and checkin... | java |
private String replaceProperties(String message, Map<String, String> map) {
if (map != null) {
for (Entry<String, String> entr : map.entrySet()) {
message = StringUtils.replace(message, "@{" + entr.getKey() + "}", entr.getValue());
}
}
return message;
... | java |
protected void gitBranchDelete(final String branchName)
throws MojoFailureException, CommandLineException {
getLog().info("Deleting '" + branchName + "' branch.");
executeGitCommand("branch", "-d", branchName);
} | java |
protected void gitBranchDeleteForce(final String branchName)
throws MojoFailureException, CommandLineException {
getLog().info("Deleting (-D) '" + branchName + "' branch.");
executeGitCommand("branch", "-D", branchName);
} | java |
protected void gitFetchRemoteAndCreate(final String branchName)
throws MojoFailureException, CommandLineException {
if (!gitCheckBranchExists(branchName)) {
getLog().info(
"Local branch '"
+ branchName
+ "' doesn... | java |
protected void gitFetchRemoteAndCompare(final String branchName)
throws MojoFailureException, CommandLineException {
if (gitFetchRemote(branchName)) {
getLog().info(
"Comparing local branch '" + branchName + "' with remote '"
+ gitFlowConfi... | java |
private boolean gitFetchRemote(final String branchName)
throws MojoFailureException, CommandLineException {
getLog().info(
"Fetching remote branch '" + gitFlowConfig.getOrigin() + " "
+ branchName + "'.");
CommandResult result = executeGitCommandExitC... | java |
protected void mvnSetVersions(final String version) throws MojoFailureException, CommandLineException {
getLog().info("Updating version(s) to '" + version + "'.");
String newVersion = "-DnewVersion=" + version;
String g = "";
String a = "";
if (versionsForceUpdate) {
... | java |
protected void mvnRun(final String goals) throws Exception {
getLog().info("Running Maven goals: " + goals);
executeMvnCommand(CommandLineUtils.translateCommandline(goals));
} | java |
private String executeGitCommandReturn(final String... args)
throws CommandLineException, MojoFailureException {
return executeCommand(cmdGit, true, null, args).getOut();
} | java |
private CommandResult executeGitCommandExitCode(final String... args)
throws CommandLineException, MojoFailureException {
return executeCommand(cmdGit, false, null, args);
} | java |
private void executeGitCommand(final String... args)
throws CommandLineException, MojoFailureException {
executeCommand(cmdGit, true, null, args);
} | java |
private void executeMvnCommand(final String... args)
throws CommandLineException, MojoFailureException {
executeCommand(cmdMvn, true, argLine, args);
} | java |
private CommandResult executeCommand(final Commandline cmd,
final boolean failOnError, final String argStr,
final String... args) throws CommandLineException,
MojoFailureException {
// initialize executables
initExecutables();
if (getLog().isDebugEnabled()) {... | java |
public static ESVersion fromString(String version) {
String lVersion = version;
final boolean snapshot = lVersion.endsWith("-SNAPSHOT");
if (snapshot) {
lVersion = lVersion.substring(0, lVersion.length() - 9);
}
String[] parts = lVersion.split("[.-]");
if (par... | java |
public <V> V getValue() {
if (values == null || values.isEmpty()) {
return null;
}
return (V)values.get(0);
} | java |
private void updateFsJob(String jobName, LocalDateTime scanDate) throws Exception {
// We need to round that latest date to the lower second and
// remove 2 seconds.
// See #82: https://github.com/dadoonet/fscrawler/issues/82
scanDate = scanDate.minus(2, ChronoUnit.SECONDS);
FsJo... | java |
private void indexDirectory(String path) throws Exception {
fr.pilato.elasticsearch.crawler.fs.beans.Path pathObject = new fr.pilato.elasticsearch.crawler.fs.beans.Path();
// The real and complete path
pathObject.setReal(path);
String rootdir = path.substring(0, path.lastIndexOf(File.sep... | java |
private void removeEsDirectoryRecursively(final String path) throws Exception {
logger.debug("Delete folder [{}]", path);
Collection<String> listFile = getFileDirectory(path);
for (String esfile : listFile) {
esDelete(fsSettings.getElasticsearch().getIndex(), SignTool.sign(path.conc... | java |
private void esIndex(String index, String id, String json, String pipeline) {
logger.debug("Indexing {}/{}?pipeline={}", index, id, pipeline);
logger.trace("JSon indexed : {}", json);
if (!closed) {
esClient.index(index, id, json, pipeline);
} else {
logger.warn(... | java |
private void esDelete(String index, String id) {
logger.debug("Deleting {}/{}", index, id);
if (!closed) {
esClient.delete(index, id);
} else {
logger.warn("trying to remove a file while closing crawler. Document [{}]/[{}] has been ignored", index, id);
}
} | java |
@Override
public void checkVersion() throws IOException {
ESVersion esVersion = getVersion();
if (esVersion.major != compatibleVersion()) {
throw new RuntimeException("The Elasticsearch client version [" +
compatibleVersion() + "] is not compatible with the Elasticsea... | java |
public static void start(FsSettings settings, ElasticsearchClient esClient) {
// We create the service only one
if (httpServer == null) {
// create a resource config that scans for JAX-RS resources and providers
// in fr.pilato.elasticsearch.crawler.fs.rest package
fi... | java |
@SuppressWarnings("deprecation")
public boolean upgrade() throws Exception {
// We need to start a client so we can send requests to elasticsearch
try {
esClient.start();
} catch (Exception t) {
logger.fatal("We can not start Elasticsearch Client. Exiting.", t);
... | java |
public static String getOwnerName(final File file) {
try {
final Path path = Paths.get(file.getAbsolutePath());
final FileOwnerAttributeView ownerAttributeView = Files.getFileAttributeView(path, FileOwnerAttributeView.class);
return ownerAttributeView != null ? ownerAttribute... | java |
public static void copyDefaultResources(Path configPath) throws IOException {
Path targetResourceDir = configPath.resolve("_default");
for (String filename : MAPPING_RESOURCES) {
Path target = targetResourceDir.resolve(filename);
if (Files.exists(target)) {
logge... | java |
public static void copyResourceFile(String source, Path target) throws IOException {
InputStream resource = FsCrawlerUtil.class.getResourceAsStream(source);
FileUtils.copyInputStreamToFile(resource, target.toFile());
} | java |
public static Properties readPropertiesFromClassLoader(String resource) {
Properties properties = new Properties();
try {
properties.load(FsCrawlerUtil.class.getClassLoader().getResourceAsStream(resource));
} catch (IOException e) {
throw new RuntimeException(e);
... | java |
public static void copyDirs(Path source, Path target, CopyOption... options) throws IOException {
if (Files.notExists(target)) {
Files.createDirectory(target);
}
logger.debug(" --> Copying resources from [{}]", source);
if (Files.notExists(source)) {
throw new R... | java |
public static void unzip(String jarFile, Path destination) throws IOException {
Map<String, String> zipProperties = new HashMap<>();
/* We want to read an existing ZIP File, so we set this to false */
zipProperties.put("create", "false");
zipProperties.put("encoding", "UTF-8");
U... | java |
public static boolean isFileSizeUnderLimit(ByteSizeValue limit, long fileSizeAsBytes) {
boolean result = true;
if (limit != null) {
// We check the file size to avoid indexing too big files
ByteSizeValue fileSize = new ByteSizeValue(fileSizeAsBytes);
int compare = fil... | java |
private static Class<ElasticsearchClient> findClass(int version) throws ClassNotFoundException {
String className = "fr.pilato.elasticsearch.crawler.fs.client.v" + version + ".ElasticsearchClientV" + version;
logger.trace("Trying to find a class named [{}]", className);
Class<?> aClass = Class.f... | java |
public void setClassTag (String tag, Class type) {
if (tag == null) throw new IllegalArgumentException("tag cannot be null.");
if (type == null) throw new IllegalArgumentException("type cannot be null.");
classNameToTag.put(type.getName(), tag);
tagToClass.put(tag, type);
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.