本文整理汇总了Java中io.github.htools.lib.ArrayTools类的典型用法代码示例。如果您正苦于以下问题:Java ArrayTools类的具体用法?Java ArrayTools怎么用?Java ArrayTools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayTools类属于io.github.htools.lib包,在下文中一共展示了ArrayTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseArgs
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
/**
* Parses an args[], probably passed to main, and runs the
* GenericOptionsParser (e.g. setting libs to include for MR job), filter
* out key.name= style configuration settings, and maps the remaining input
* to the labels identified by the template (see {@link ArgsParser}).
*
* @param args
* @param template
*/
public void parseArgs(String args[], String template) {
try {
GenericOptionsParser p = new GenericOptionsParser(this, args);
args = p.getRemainingArgs();
} catch (IOException ex) {
log.fatalexception(ex, "Configuration(%s, %s)", ArrayTools.toString(args), template);
}
args = argsToConf(args);
ArgsParser argsparser = new ArgsParser(args, template);
for (ArgsParser.Parameter entry : argsparser.getParameters()) {
if (entry != null) {
if (entry.getValues().size() > 1) {
this.setStringList(entry.getName(), entry.getValues());
} else if (entry.getValues().size() == 1) {
set(entry.getName(), entry.getValues().get(0));
}
}
}
}
示例2: parseArgsConfFile
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
public void parseArgsConfFile(String args[], String template) {
try {
GenericOptionsParser p = new GenericOptionsParser(this, args);
args = p.getRemainingArgs();
//log.info("ramaining args %s", ArrayTools.concat(args));
} catch (IOException ex) {
log.fatalexception(ex, "Configuration(%s, %s)", ArrayTools.toString(args), template);
}
processConfigFile(configDatafile(args[0]));
args = argsToConf(args);
ArgsParser argsparser = new ArgsParser(args, "configurationfilename " + template);
for (ArgsParser.Parameter entry : argsparser.getParameters()) {
if (entry != null) {
if (entry.getValues().size() > 1) {
this.setStringList(entry.getName(), entry.getValues());
} else if (entry.getValues().size() == 1) {
set(entry.getName(), entry.getValues().get(0));
}
}
}
}
示例3: add
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
public void add(T t) {
if (array == null) {
array = (T[])ArrayTools.createArray(t.getClass(), k);
}
if (size < k) {
array[pointer] = t;
pointer = (pointer + 1) % k;
size++;
if (highest == null || comparator.compare(t, highest) > 0)
highest = t;
} else {
T remove = array[pointer];
array[pointer] = t;
pointer = (pointer + 1) % k;
if (comparator.compare(t, highest) > 0) {
highest = t;
} else if (comparator.compare(remove, highest) == 0) {
highest = array[0];
for (int i = 1; i < k; i++) {
if (comparator.compare(array[i], highest) > 0) {
highest = array[i];
}
}
}
}
}
示例4: value
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
@Override
public long[] value(ByteSearchSection section) {
long[] result = ArrayTools.emptyLongArray;
if (section.notEmpty()) {
String stringvalue = stringValue(section);
if (stringvalue.length() > 0) {
try {
String part[] = stringvalue.split(",");
result = new long[part.length];
for (int i = 0; i < part.length; i++) {
result[i] = Long.parseLong(part[i]);
}
} catch (NumberFormatException ex) {
log.fatalexception(ex, "value() offset %d section %s", StructuredTextFile.this.datafile.getOffset(), section.reportString());
}
}
}
return result;
}
示例5: main
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
public static void main(String... args) {
if (args[0].equals("-v")) {
verbose = true;
args = (String[])ArrayTools.subArray(args, 1);
log.info("%d", args.length);
}
String sourcedir, sourcefile, destdir, destfile;
if (args[0].contains("/")) {
sourcedir = args[0].substring(0, args[0].lastIndexOf('/'));
sourcefile = args[0].substring(args[0].lastIndexOf('/') + 1);
} else {
sourcedir = ".";
sourcefile = args[0];
}
if (args[1].contains("/")) {
destdir = args[1].substring(0, args[1].lastIndexOf('/'));
destfile = args[1].substring(args[1].lastIndexOf('/') + 1);
} else {
destdir = ".";
destfile = args[1];
}
FSPath sdir = new FSPath(sourcedir);
FSPath ddir = new FSPath(destdir);
sdir.move(ddir, sourcefile, destfile, verbose);
}
示例6: process
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
@Override
public void process(Document doc) {
frequency = 0;
TreeSet<Integer> list = new TreeSet<Integer>();
int size = 0;
for (Operator f : containednodes) {
f.process(doc);
frequency += f.getFrequency();
int fpos[] = f.getPos();
if (fpos != null && fpos.length > 0) {
for (int pos : fpos)
list.add(pos);
}
}
int p = 0;
pos = ArrayTools.toIntArray(list);
}
示例7: add
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
public void add(String pattern, Class fileclass, Class writableclass) {
String[] patterns = job.getConfiguration().getStrings(CLASSPATTERN, new String[0]);
String[] fileclasses = job.getConfiguration().getStrings(CLASSCLASS, new String[0]);
String[] writableclasses = job.getConfiguration().getStrings(MultiReduceWritable.CLASSCLASS, new String[0]);
job.getConfiguration().setStrings(CLASSPATTERN, ArrayTools.addArr(patterns, pattern));
job.getConfiguration().setStrings(CLASSCLASS, ArrayTools.addArr(fileclasses, fileclass.getCanonicalName()));
job.getConfiguration().setStrings(MultiReduceWritable.CLASSCLASS, ArrayTools.addArr(writableclasses, writableclass.getCanonicalName()));
}
示例8: firstAcceptedChar
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
public boolean[] firstAcceptedChar() {
if (this instanceof ByteRegex) {
return ArrayTools.clone(((ByteRegex) this).root.allowed);
}
if (this instanceof ByteSearchSingleClass) {
return ((ByteSearchSingleClass) this).getValid();
}
if (this instanceof ByteSearchSingle) {
return BoolTools.createASCIIAccept((char) ((ByteSearchSingle) this).b);
}
if (this instanceof ByteSearchString) {
return ArrayTools.clone(((ByteSearchString) this).pattern[0]);
}
return new boolean[256];
}
示例9: process
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
@Override
public void process(Content entity, ByteSearchSection pos, String attributename) {
//log.fatal("process channel %s %d", channel.channel, channel.size());
byte[] content = entity.getContent();
for (int wordstart = pos.innerstart; wordstart < pos.innerend - 1; wordstart++) {
// non-word position, meaning a new word may come
if (content[wordstart] != 0 && !isWord[content[wordstart] & 0xff]) {
// move to first word position
for (wordstart++; wordstart < pos.innerend && !isWord[content[wordstart] & 0xff]; wordstart++);
if (wordstart < pos.innerend) {
int wordend = wordstart + 1;
// find end of word
for (; wordend < pos.innerend && isWord[content[wordend] & 0xff]; wordend++);
byte[] word = ByteTools.toBytes(content, wordstart, wordend);
byte[] wordStemmed = translateStemmed.get(word);
if (wordStemmed == null) {
wordStemmed = ByteTools.toBytes(stemmer.stem(ByteTools.toString(word)));
if (ArrayTools.equals(word, wordStemmed))
wordStemmed = alreadyStemmed;
translateStemmed.put(word, wordStemmed);
}
if (wordStemmed != alreadyStemmed) {
System.arraycopy(wordStemmed, 0, content, wordstart, wordStemmed.length);
if (wordStemmed.length < word.length) {
Arrays.fill(content, wordstart + wordStemmed.length, wordend, (byte)0);
}
}
}
}
}
}
示例10: toString
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
@Override
public String toString(String[] value) {
String result = ArrayTools.toString(value, 0, value.length, ",");
if (StrTools.countIndexOf(result, ',') != value.length - 1) {
log.fatal("StringArrayField cannot contain , in '%s'", result);
}
return result;
}
示例11: setTDFDependencies
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
@Override
public void setTDFDependencies() {
ArrayList<TermDocumentFeature> list = new ArrayList<TermDocumentFeature>();
if (this.needsCollect() || !root.needsPrePass()) {
for (Operator g : containednodes) {
list.addAll(g.getRequiredTDF());
}
for (TermDocumentFeature f : list) {
f.setDependencies((TermDocumentFeature[]) ArrayTools.arrayOfOthers(list, f));
}
}
}
示例12: setDuplicateDependency
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
protected void setDuplicateDependency() {
ArrayList<ProximityTermDupl> list = first.dupl;
HashSet<Long> dep = new HashSet<Long>();
for (int i = (1 << first.dupl.size()) - 1; i > 0; i--) {
if (MathTools.numberOfSetBits(i) == (initshift + 1)) {
long pattern = 0;
int b = 1;
for (int j = 0; b <= i; j++, b <<= 1) {
if ((i & b) != 0) {
pattern |= ProximitySet.this.dependency[first.dupl.get(j).sequence];
}
}
dep.add(convertDuplicatesInPattern(pattern, sequence));
}
}
HashSet<Long> dep1 = new HashSet<Long>();
SKIP:
for (long d : dep) {
for (long m : dep) {
if (m != d && (d & m) == m) {
continue SKIP;
}
}
dep1.add(d);
}
dependency = ArrayTools.toLongArray(dep1);
}
示例13: getContent
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
public int[] getContent(ExtractChannel dc) {
ArrayList<Integer> r = new ArrayList<Integer>();
int p = 0;
if (dc != null) {
for (String chunk : dc) {
int termid = get(chunk.toString());
if (termid >= 0) {
r.add(termid);
} else {
//log.info("unknown word %s", chunk);
}
}
}
return ArrayTools.toIntArray(r);
}
示例14: setDependencies
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
/**
* Sets the TDF's dependencies. This is used to make retrieval more efficient by
* skipping documents that do not contain any scorable term combinations, e.g.
* for the query "albert-einstein" documents with only albert or only einstein can
* be omitted. Independent terms should call this with an array length zero
* overriding all other dependencies as documents containing this term are always
* scorable.
* @param dep
*/
public void setDependencies( TermDocumentFeature[] dep ) {
if (dep.length == 0)
dependencies = NODEPENDENCIES;
else if (dependencies == null || dependencies.length > 0) {
if (dependencies == null) {
dependencies = new TermDocumentFeature[1][];
dependencies[0] = dep;
} else {
ArrayTools.addObjectToArr(dependencies, dep);
}
}
}
示例15: getSettings
import io.github.htools.lib.ArrayTools; //导入依赖的package包/类
private String getSettings(ArrayList<Parameter> parameters, int settings[]) {
ArrayList<String> list = new ArrayList<String>();
for (Parameter p : parameters) {
String pstr = p.parameter + "=" + p.getPoints().get(settings[p.index]).toString();
list.add(pstr);
}
return ArrayTools.toString(list, ",");
}