This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Here is HelloJNI.java | |
public class HelloJNI { | |
static { | |
try { | |
Class c = HelloJNI.class; | |
URL location = | |
c.getProtectionDomain().getCodeSource().getLocation(); | |
ZipFile zf = new ZipFile(location.getPath()); | |
// libhellojni.so is put in the lib folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// code snippet in nutch | |
Injector injector = new Injector(getConf()); | |
Generator generator = new Generator(getConf()); | |
Fetcher fetcher = new Fetcher(getConf()); | |
ParseSegment parseSegment = new ParseSegment(getConf()); | |
CrawlDb crawlDbTool = new CrawlDb(getConf()); | |
LinkDb linkDbTool = new LinkDb(getConf()); | |
injector.inject(crawlDb, rootUrlDir); | |
int i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linkDbTool.invert(linkDb, segments, true, true, false); // invert links | |
if (solrUrl != null) { | |
// index, dedup & merge | |
FileStatus[] fstats = fs.listStatus(segments, HadoopFSUtil.getPassDirectoriesFilter(fs)); | |
SolrIndexer indexer = new SolrIndexer(getConf()); | |
indexer.indexSolr(solrUrl, crawlDb, linkDb, | |
Arrays.asList(HadoopFSUtil.getPaths(fstats))); | |
SolrDeleteDuplicates dedup = new SolrDeleteDuplicates(); | |
dedup.setConf(getConf()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (LOG.isInfoEnabled()) { | |
LOG.info("Injector: Converting injected urls to crawl db entries."); | |
} | |
JobConf sortJob = new NutchJob(getConf()); | |
sortJob.setJobName("inject " + urlDir); | |
FileInputFormat.addInputPath(sortJob, urlDir); | |
sortJob.setMapperClass(InjectMapper.class); | |
FileOutputFormat.setOutputPath(sortJob, tempDir); | |
sortJob.setOutputFormat(SequenceFileOutputFormat.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static JobConf createJob(Configuration config, Path crawlDb) | |
throws IOException { | |
Path newCrawlDb = new Path(crawlDb, | |
Integer.toString(new Random().nextInt(Integer.MAX_VALUE))); | |
JobConf job = new NutchJob(config); | |
job.setJobName("crawldb " + crawlDb); | |
Path current = new Path(crawlDb, CURRENT_NAME); | |
if (FileSystem.get(job).exists(current)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void install(JobConf job, Path crawlDb) throws IOException { | |
Path newCrawlDb = FileOutputFormat.getOutputPath(job); | |
FileSystem fs = new JobClient(job).getFs(); | |
Path old = new Path(crawlDb, "old"); | |
Path current = new Path(crawlDb, CURRENT_NAME); | |
if (fs.exists(current)) { | |
if (fs.exists(old)) fs.delete(old, true); | |
fs.rename(current, old); | |
} | |
fs.mkdirs(crawlDb); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CVJNI.java | |
import java.io.*; | |
public class CVJNI { | |
//Load jni library | |
static { | |
try { | |
System.loadLibrary("cvjni"); | |
} catch (Exception e) { | |
e.printStackTrace(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//cvjni.cpp | |
#include "cvjni.h" | |
#include <opencv2/opencv.hpp> | |
#include <vector> | |
#include <iostream> | |
using namespace std; | |
using namespace cv; | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile | |
# FOR MAC | |
CC=g++ | |
SEARCH_LIB=-lopencv_core -lopencv_highgui | |
INCLUDE=-I/usr/local/include -I$(JAVA_INCLUDE) | |
LIBRARY=-L/usr/local/lib | |
FLAGS= -m64 -dynamiclib -fPIC | |
OUT=libcvjni.jnilib | |
SRC=cvjni.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -m64 -shared -fPIC cvjni.cpp /usr/local/lib/libopencv_core.so \ | |
/usr/local/lib/libopencv_highgui.so -o libcvjni.so \ | |
-I/usr/local/include -I/usr/lib/jvm/jdk1.6.0_35/include \ | |
-I/usr/lib/jvm/jdk1.6.0_35/include/linux |
OlderNewer