本文整理汇总了Java中io.github.htools.lib.PrintTools.sprintf方法的典型用法代码示例。如果您正苦于以下问题:Java PrintTools.sprintf方法的具体用法?Java PrintTools.sprintf怎么用?Java PrintTools.sprintf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.github.htools.lib.PrintTools
的用法示例。
在下文中一共展示了PrintTools.sprintf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOutfile
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public static String getOutfile(Context context) {
try {
if (HashPartitioner.class.isAssignableFrom(context.getPartitionerClass())) {
String outpath = context.getConfiguration().get(HPCONFIG);
if (outpath != null) {
int partition = Job.getReducerId(context);
return PrintTools.sprintf("%s/partition.%5d", outpath, partition);
} else {
log.info("must use setOutPath on HashPartitioner");
}
}
} catch (ClassNotFoundException ex) {
log.exception(ex, "HashPartitioner");
}
throw new RuntimeException("fatal");
}
示例2: list
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public static void list(ModelSpeed f, String settings[]) {
f.openRead();
ArrayMap<Integer, String> sorted = new ArrayMap();
NOTOK:
for (Record r : f.getKeys()) {
String qid = PrintTools.sprintf("%.6f", r.time);
if (settings != null) {
OK:
for (String s : settings) {
if (s.equals(Integer.toString(r.query))) {
continue OK;
}
if (s.equals(r.strategy))
continue OK;
}
continue NOTOK;
}
sorted.add(r.query, r.time + " " + r.strategy);
}
for (Map.Entry<Integer,String> e : sorted.ascending()) {
log.printf("%03d %s", e.getKey(), e.getValue());
}
}
示例3: remove
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public static void remove(ModelParameters f, String settings[]) {
f.openRead();
ArrayList<Record> sorted = new ArrayList<Record>();
NOTOK:
for (Record r : f.getKeys()) {
String map = PrintTools.sprintf("%.6f", r.map);
OK:
for (String s : settings) {
if (map.equalsIgnoreCase(s)) {
continue OK;
}
for (Map.Entry<String, String> e : r.parameters.entrySet()) {
if (e.getKey().equals(s) || e.getValue().equals(s)) {
continue OK;
}
}
continue NOTOK;
}
sorted.add(r);
}
f.remove(sorted);
}
示例4: waitForUnlock
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public void waitForUnlock() {
if (lockIsMine) {
throw new RuntimeException(PrintTools.sprintf("Cannot wait for unlock I have: %s", this.filename));
}
if (this.fs != null) {
HDFSOut.waitForUnlock(fs, filename, lockfile);
} else {
FSFileOutBuffer.waitForUnlock(filename, lockfile);
}
}
示例5: printf
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public void printf(String format, Object... args) {
if (!isWriteOpen()) {
this.openWrite();
}
String s = PrintTools.sprintf(format, args);
//log.info("printf( %s )", s);
rwbuffer.print(s);
}
示例6: openRead
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
@Override
public void openRead() throws FileIntegrityException {
if (residenttable == null) {
if (super.getLength() > 0) {
R closingrecord = closingRecord();
boolean isproperlyclosed = false;
int attempt = 0;
do {
if (residenttable != null) {
log.sleep(RandomTools.getInt(10000));
}
residenttable = new HashMap<R, R>();
super.openRead();
if (isReadOpen()) {
setOffset(0);
while (nextRecord()) {
R r = newRecord();
r.read(this);
if (r.equals(closingrecord)) {
isproperlyclosed = true;
} else {
residenttable.put(r, r);
isproperlyclosed = false;
}
}
}
super.closeRead();
} while (attempt++ <= 20 && !isproperlyclosed);
if (!isproperlyclosed) {
throw new FileIntegrityException(PrintTools.sprintf("File integrity, file not ended properly: %s", this.getDatafile().getCanonicalPath()));
}
} else {
residenttable = new HashMap<R, R>();
}
}
}
示例7: unlock
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public void unlock() {
if (!lockIsMine) {
throw new RuntimeException(PrintTools.sprintf("Cannot unlock a file I havnt locked: %s", this.filename));
}
if (this.fs != null) {
HDFSOut.unlock(fs, lockfile);
} else {
FSFileOutBuffer.unlock(lockfile);
}
lockIsMine = false;
}
示例8: openRead
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
@Override
public void openRead() {
if (residenttable == null) {
if (super.getLength() > 0) {
R closingrecord = closingRecord();
boolean isproperlyclosed = false;
boolean containsdata = false;
//for (int attempt = 0; !isclosed && attempt < 10; attempt++) {
int attempt = 0;
do {
if (residenttable != null) {
log.sleep(RandomTools.getInt(10000));
}
residenttable = new HashMap<R, R>();
super.openRead();
if (isReadOpen()) {
setOffset(0);
while (nextRecord()) {
containsdata = true;
R r = newRecord();
r.read(this);
if (r.equals(closingrecord)) {
isproperlyclosed = true;
} else {
residenttable.put(r, r);
isproperlyclosed = false;
}
}
}
super.closeRead();
} while (attempt++ <= 20 && !isproperlyclosed);
if (containsdata && !isproperlyclosed) {
throw new FileIntegrityException(PrintTools.sprintf("File integrity, file not ended properly: %s", this.getDatafile().getCanonicalPath()));
}
} else {
residenttable = new HashMap<R, R>();
}
datastorage = createDatafile(new Datafile(getDatafile().getSubFile(".data")));
}
}
示例9: openAppend
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
@Override
public void openAppend() {
if (!getDatafile().hasLock())
throw new RuntimeException(PrintTools.sprintf("Should lock file before append: %s", getDatafile().getName()));
if (residenttable == null) {
openRead();
}
this.resetNextField();
datastorage.openAppend();
}
示例10: lock
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public boolean lock() {
if (lockIsMine) {
throw new RuntimeException(PrintTools.sprintf("Cannot Double lock a file: %s", this.filename));
}
if (this.fs != null) {
lockIsMine = HDFSOut.lock(fs, filename, lockfile);
} else {
lockIsMine = FSFileOutBuffer.lock(filename, lockfile);
}
return lockIsMine;
}
示例11: postReform
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
/**
* Unless set manually, phrases need a pre-pass to determine their corpus
* statistics, in the reformulation the obtained corpus statistics are
* included in the query. If the obtained cf is 0, the featureproximity is
* left out.
* <p/>
* @return
*/
@Override
public String postReform() {
String rf = postReformUnweighted();
if (queryweight != 1 && queryweight != 0) {
return PrintTools.sprintf("%s#%e", rf, queryweight);
} else {
return rf;
}
}
示例12: postReform
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
@Override
public String postReform() {
String rf = postReformUnweighted();
if (getQueryWeight() != 1 && getQueryWeight() != 0) {
return PrintTools.sprintf("%s#%e", rf, getQueryWeight());
} else
return rf;
}
示例13: reformulate
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public static String reformulate(Operator r) {
String rf = reformulateUnweighted(r);
if (r.getQueryWeight() != 1 && r.getQueryWeight() != 0) {
rf = PrintTools.sprintf("%s#%g", rf, r.getQueryWeight());
}
return rf;
}
示例14: getStoredFeatureFile
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public Datafile getStoredFeatureFile(int segment) {
if (segment == -1)
log.crash();
Datafile datafile;
String name = getCanonicalName();
name = name.replaceFirst(":", ".");
String path = repository.configuredString(name.toLowerCase() + ".path");
if (path != null && path.length() > 0)
datafile = new Datafile( repository.fs, PrintTools.sprintf("%s.%04d", path, segment));
else
datafile = repository.basedir.getFile(PrintTools.sprintf("%s/%s.%s.%04d", getFeatureFolder(), repository.getPrefix(), getFileNameSuffix(), segment));
return datafile;
}
示例15: reportString
import io.github.htools.lib.PrintTools; //导入方法依赖的package包/类
public String reportString() {
return PrintTools.sprintf("Section( content %s start %d innerstart %d innerend %d end %d endreached %b found %b)",
ByteTools.toString(haystack, start, end), start, innerstart, innerend, end, endreached, found());
}