当前位置: 首页>>代码示例>>Java>>正文


Java PrintTools类代码示例

本文整理汇总了Java中io.github.htools.lib.PrintTools的典型用法代码示例。如果您正苦于以下问题:Java PrintTools类的具体用法?Java PrintTools怎么用?Java PrintTools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrintTools类属于io.github.htools.lib包,在下文中一共展示了PrintTools类的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");
}
 
开发者ID:htools,项目名称:htools,代码行数:17,代码来源:HashPartitioner.java

示例2: toString

import io.github.htools.lib.PrintTools; //导入依赖的package包/类
public String toString() {
   StringBuilder sb = new StringBuilder();
   int rows = getRows();
   int columns = getColumns();
   sb.append("Matrix( ").append(rows).append(", ").append(columns).append(")\n");
   for (int row = 0; row < rows; row++) {
      for (int column = 0; column < columns; column++) {
         if (column > 0) {
            sb.append(", ");
         }
         sb.append(PrintTools.sprintf("%6f", value[this instanceof MatrixTransposed ? column : row][this instanceof MatrixTransposed ? row : column]));
      }
      sb.append("\n");
   }
   return sb.toString();
}
 
开发者ID:htools,项目名称:htools,代码行数:17,代码来源:Matrix.java

示例3: 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());
   }
}
 
开发者ID:repir,项目名称:repirproximity,代码行数:25,代码来源:listspeed.java

示例4: 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);
}
 
开发者ID:repir,项目名称:repirproximity,代码行数:23,代码来源:rmtune.java

示例5: postReformUnweighted

import io.github.htools.lib.PrintTools; //导入依赖的package包/类
@Override
public String postReformUnweighted() {
   StringBuilder sb = new StringBuilder();
   if (span != Integer.MAX_VALUE) {
      sb.append("span=").append(span).append(" ");
   }
   if (keepstopwords) {
      sb.append("keepstopwords=1 ");
   }
   if (cf > -1) {
      sb.append(PrintTools.sprintf("cf=%d ", cf));
   }
   if (df > -1) {
      sb.append(PrintTools.sprintf("df=%d ", df));
   }
   for (Operator f : containednodes) {
      sb.append(f.postReformUnweighted()).append(" ");
   }
   return sb.toString();
}
 
开发者ID:repir,项目名称:repir,代码行数:21,代码来源:ProximityOperator.java

示例6: setJobName

import io.github.htools.lib.PrintTools; //导入依赖的package包/类
public void setJobName(Object... params) {
    if (params.length > 0) {
        StringBuilder sb = new StringBuilder();
        sb.append(ClassTools.getMainClass().getCanonicalName()).append(" ");
        for (Object o : params) {
            sb.append(PrintTools.sprintf("[%s]", o));
        }
        setJobName(sb.toString());
    }
}
 
开发者ID:htools,项目名称:htools,代码行数:11,代码来源:Job.java

示例7: getDatafile

import io.github.htools.lib.PrintTools; //导入依赖的package包/类
public Datafile getDatafile(TaskAttemptContext context, String folder) throws IOException {
    int task = ContextTools.getTaskID(context);
    Configuration conf = context.getConfiguration();
    String filename = conf.get(SINGLEFILE);
    if (filename == null || context.getNumReduceTasks() > 1) {
        HDFSPath dir = new HDFSPath(conf, folder);
        filename = dir.getFilename(PrintTools.sprintf("%s.%05d", "part", task));
    }
    return new Datafile(conf, filename);
}
 
开发者ID:htools,项目名称:htools,代码行数:11,代码来源:OutputFormat.java

示例8: print

import io.github.htools.lib.PrintTools; //导入依赖的package包/类
@Override
public void print(String s, Object... p) {
   FileWriter filewriter = getFileWriter();
   try {
      if (p.length == 0) {
         filewriter.write(s);
      } else {
         filewriter.write(PrintTools.sprintf(s, p));
      }
   } catch (IOException ex) {
      log.exception(ex, "print( %s ) when writing file %s", s, filewriter);
   }
}
 
开发者ID:htools,项目名称:htools,代码行数:14,代码来源:FSFile.java

示例9: 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>();
      }
   }
}
 
开发者ID:htools,项目名称:htools,代码行数:37,代码来源:StructuredFileKeyValue.java

示例10: 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()));
   openRead();
   this.resetNextField();
}
 
开发者ID:htools,项目名称:htools,代码行数:8,代码来源:StructuredFileKeyValue.java

示例11: 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")));
   }
}
 
开发者ID:htools,项目名称:htools,代码行数:41,代码来源:StructuredFileKey.java

示例12: 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();
}
 
开发者ID:htools,项目名称:htools,代码行数:11,代码来源:StructuredFileKey.java

示例13: xmlCloseNode

import io.github.htools.lib.PrintTools; //导入依赖的package包/类
private static ByteSearch xmlCloseNode(String label, FolderNode parent) {
   ByteRegex closeNode = new ByteRegex(PrintTools.sprintf("</%s\\s*>", label));
   if (parent == null)
      return closeNode;
   ByteRegex closeParent = new ByteRegex(PrintTools.sprintf("</%s\\s*>", parent.label));
   ByteRegex closeCombi = ByteRegex.combine(closeNode, closeParent);
   return closeCombi;
}
 
开发者ID:htools,项目名称:htools,代码行数:9,代码来源:StructuredTextXML.java

示例14: 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;
}
 
开发者ID:htools,项目名称:htools,代码行数:12,代码来源:Datafile.java

示例15: 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;
}
 
开发者ID:htools,项目名称:htools,代码行数:12,代码来源:Datafile.java


注:本文中的io.github.htools.lib.PrintTools类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。