示例#1
0
 private boolean belowThreshold(final Source source) {
   if (source.getLength() < minSize) {
     getLogger().info("below size threshold ", source);
     return true;
   }
   return false;
 }
示例#2
0
    @Override
    public StoredScript load(final Source source, final String functionKey) {
      if (source.getLength() < minSize) {
        return null;
      }

      final File file = getCacheFile(source, functionKey);

      try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<StoredScript>() {
              @Override
              public StoredScript run() throws IOException, ClassNotFoundException {
                if (!file.exists()) {
                  return null;
                }
                try (ObjectInputStream in =
                    new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)))) {
                  final StoredScript storedScript = (StoredScript) in.readObject();
                  getLogger().info("loaded ", source, "-", functionKey);
                  return storedScript;
                }
              }
            });
      } catch (final PrivilegedActionException e) {
        getLogger().warning("failed to load ", source, "-", functionKey, ": ", e.getException());
        return null;
      }
    }
示例#3
0
 public void runCompress(int btid) {
   spec.harness.Context.getOut().println("Loop count = " + LOOP_COUNT);
   for (int i = 0; i < LOOP_COUNT; i++) {
     for (int j = 0; j < FILES_NUMBER; j++) {
       Source source = SOURCES[j];
       OutputBuffer comprBuffer, decomprBufer;
       comprBuffer =
           CB.performAction(
               source.getBuffer(), source.getLength(), CB.COMPRESS, COMPRESS_BUFFERS[btid - 1]);
       decomprBufer =
           CB.performAction(
               COMPRESS_BUFFERS[btid - 1],
               comprBuffer.getLength(),
               CB.UNCOMPRESS,
               DECOMPRESS_BUFFERS[btid - 1]);
       Context.getOut().print(source.getLength() + " " + source.getCRC() + " ");
       Context.getOut().print(comprBuffer.getLength() + comprBuffer.getCRC() + " ");
       Context.getOut().println(decomprBufer.getLength() + " " + decomprBufer.getCRC());
     }
   }
 }
示例#4
0
 static SubSourceImpl create(Source base, int baseIndex, int length) {
   if (baseIndex < 0 || length < 0 || baseIndex + length > base.getLength()) {
     throw new IllegalArgumentException("text positions out of range");
   }
   return new SubSourceImpl(base, baseIndex, length);
 }