Package freenet.support.compress.Compressor

Examples of freenet.support.compress.Compressor.COMPRESSOR_TYPE


      hashes = origHashes; // Inherit so it goes all the way to the top.
    }
    RandomAccessBucket bestCompressedData = output.data;
    long bestCompressedDataSize = bestCompressedData.size();
    RandomAccessBucket data = bestCompressedData;
    COMPRESSOR_TYPE bestCodec = output.bestCodec;
   
    boolean shouldFreeData = freeData;
    if(bestCodec != null) {
      if(logMINOR) Logger.minor(this, "The best compression algorithm is "+bestCodec+ " we have gained"+ (100-(bestCompressedDataSize*100/origSize)) +"% ! ("+origSize+'/'+bestCompressedDataSize+')');
      shouldFreeData = true; // must be freed regardless of whether the original data was to be freed
View Full Code Here


            else
              len = ((((((input[0] & 0xff) << 8) + (input[1] & 0xff)) << 8) + (input[2] & 0xff)) << 8) +
                (input[3] & 0xff);
            if(len > maxLength)
                throw new TooBigException("Invalid precompressed size: "+len + " maxlength="+maxLength);
            COMPRESSOR_TYPE decompressor = COMPRESSOR_TYPE.getCompressorByMetadataID(compressionAlgorithm);
            if (decompressor==null)
              throw new CHKDecodeException("Unknown compression algorithm: "+compressionAlgorithm);
            InputStream inputStream = null;
            OutputStream outputStream = null;
            Bucket inputBucket = new SimpleReadOnlyArrayBucket(input, inputOffset, inputLength-inputOffset);
            Bucket outputBucket = bf.makeBucket(maxLength);
            outputStream = outputBucket.getOutputStream();
            inputStream = inputBucket.getInputStream();
            try {
              decompressor.decompress(inputStream, outputStream, maxLength, -1);
      catch (CompressionOutputSizeException e) {
        throw new TooBigException("Too big");
      } finally {
            inputStream.close();
            outputStream.close();
View Full Code Here

            if(decompressorCount < 0)
                throw new StorageFormatException("Invalid decompressor count "+decompressorCount);
            decompressors = new ArrayList<COMPRESSOR_TYPE>(decompressorCount);
            for(int i=0;i<decompressorCount;i++) {
                short type = dis.readShort();
                COMPRESSOR_TYPE d = COMPRESSOR_TYPE.getCompressorByMetadataID(type);
                if(d == null) throw new StorageFormatException("Invalid decompressor ID "+type);
                decompressors.add(d);
            }
            offsetKeyList = dis.readLong();
            if(offsetKeyList < 0 || offsetKeyList > rafLength)
View Full Code Here

  }

  @Override
  public void tryCompress(final ClientContext context) throws InsertException {
    long origSize = origData.size();
    COMPRESSOR_TYPE bestCodec = null;
    RandomAccessBucket bestCompressedData = origData;
    long bestCompressedDataSize = origSize;
   
    HashResult[] hashes = null;
   
View Full Code Here

              !((ClientCHK)redirectedKey).isCompressed(),
              true, true,
              context);
        }
        if(metadata.isCompressed()) {
          COMPRESSOR_TYPE codec = metadata.getCompressionCodec();
          f.addDecompressor(codec);
        }
        parent.onTransition(this, f, context);
        f.schedule(context);
        // All done! No longer our problem!
        archiveMetadata = null; // passed on
        return;
      } else if(metadata.isSplitfile()) {
        if(logMINOR) Logger.minor(this, "Fetching splitfile");
       
        clientMetadata.mergeNoOverwrite(metadata.getClientMetadata()); // even splitfiles can have mime types!
       
        String mimeType = clientMetadata.getMIMETypeNoParams();
        if(mimeType != null && ArchiveManager.ARCHIVE_TYPE.isUsableArchiveType(mimeType) && metaStrings.size() > 0) {
          // Looks like an implicit archive, handle as such
          metadata.setArchiveManifest();
          // Pick up MIME type from inside archive
          clientMetadata.clear();
          if(logMINOR) Logger.minor(this, "Handling implicit container... (splitfile)");
          continue;
        } else {
          if(clientMetadata != null && !clientMetadata.isTrivial())
            rcb.onExpectedMIME(clientMetadata, context);
        }
       
        if(metaStrings.isEmpty() && isFinal && mimeType != null && ctx.allowedMIMETypes != null &&
            !ctx.allowedMIMETypes.contains(mimeType)) {
          // Just in case...
          long len = metadata.uncompressedDataLength();
          throw new FetchException(FetchExceptionMode.WRONG_MIME_TYPE, len, false, clientMetadata.getMIMEType());
        }
       
        // Splitfile (possibly compressed)
       
        if(metadata.isCompressed()) {
          COMPRESSOR_TYPE codec = metadata.getCompressionCodec();
          addDecompressor(codec);
        }
       
        if(isFinal && !ctx.ignoreTooManyPathComponents) {
          if(!metaStrings.isEmpty()) {
View Full Code Here

TOP

Related Classes of freenet.support.compress.Compressor.COMPRESSOR_TYPE

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.