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


Java SnappyOutputStream类代码示例

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


SnappyOutputStream类属于org.xerial.snappy包,在下文中一共展示了SnappyOutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
@Override
public void process(Document document) throws IOException {
  ByteArrayOutputStream array = new ByteArrayOutputStream();
  ObjectOutputStream output;
  if (compressed) {
    output = new ObjectOutputStream(new SnappyOutputStream(array));
  } else {
    output = new ObjectOutputStream(array);
  }

  output.writeObject(document);
  output.close();

  byte[] key = Utility.fromLong(document.identifier);
  byte[] value = array.toByteArray();
  KeyValuePair pair = new KeyValuePair(key, value);
  processor.process(pair);

}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:20,代码来源:DocumentToKeyValuePair.java

示例2: toBytes

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
@Override
public byte[] toBytes(Document doc) throws IOException {
  ByteArrayOutputStream headerArray = new ByteArrayOutputStream();
  DataOutputStream output = new DataOutputStream(headerArray);
  // identifier
  output.writeLong(doc.identifier);
  // name
  SerializerCommon.writeString(output, doc.name);

  ByteArrayOutputStream metadataArray = SerializerCommon.writeMetadata(doc);
  ByteArrayOutputStream textArray = SerializerCommon.writeText(doc);

  ByteArrayOutputStream docArray = new ByteArrayOutputStream();
  output = new DataOutputStream(new SnappyOutputStream(docArray));

  output.writeInt(metadataArray.size());
  output.writeInt(textArray.size());

  output.write(headerArray.toByteArray());
  output.write(metadataArray.toByteArray());
  output.write(textArray.toByteArray());

  output.close();

  return docArray.toByteArray();
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:27,代码来源:WebDocumentSerializer.java

示例3: getStream

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
private static Stuff getStream(final String name) throws IOException {
    Stuff s = m_files.get(name);
    if (s == null) {
        File f = new VoltFile(path, name);
        f.delete();
        RandomAccessFile ras = new RandomAccessFile(f, "rw");
        ras.seek(8);
        SnappyOutputStream sos = new SnappyOutputStream(new FileOutputStream(ras.getFD()));
        DataOutputStream dos = new DataOutputStream(sos);
        s = new Stuff();
        s.dos = dos;
        s.count = ras.getChannel().map(MapMode.READ_WRITE, 0, 8);
        s.count.order(ByteOrder.nativeOrder());
        m_files.put(name, s);
    }
    return s;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:18,代码来源:OnDemandBinaryLogger.java

示例4: getConpressedOutputStream

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
public static DataOutputStream getConpressedOutputStream(MessageCompressionType type, OutputStream outputStream) throws IOException {
  switch (type) {
    case NONE:
      return new DataOutputStream(outputStream);
    case SNAPPY:
      return new DataOutputStream(new SnappyOutputStream(outputStream));
    case GZIP:
      try {
        return new DataOutputStream(new GZIPOutputStream(outputStream));
      } catch (IOException e) {
        LOG.error("Create Gzip OuputStream failed", e);
        throw e;
      }
    default:
      throw new RuntimeException("Unsupported Compression type: " + type);
  }
}
 
开发者ID:XiaoMi,项目名称:galaxy-sdk-java,代码行数:18,代码来源:CompressionFactory.java

示例5: openDictionary

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
public void openDictionary(String dir, String prefix, long unique_prefix)
		throws FileNotFoundException, IOException {
	String filename = prefix + "-";
	NumberFormat f = NumberFormat.getInstance();
	f.setMinimumIntegerDigits(5);
	f.setGroupingUsed(false);
	filename += f.format(unique_prefix);
	
	File fDir = new File(dir);
	if (!fDir.exists() || !fDir.isDirectory()) {
		fDir.mkdirs();
	}

	// Write the URIs in a file in the output dir
	stream = new DataOutputStream(new SnappyOutputStream(
			new FileOutputStream(new File(dir, filename))));
}
 
开发者ID:jrbn,项目名称:dynamite,代码行数:18,代码来源:Dictionary.java

示例6: serializeToByteArray

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
/**
 * Serializes the argument into an array of bytes, and returns it.
 *
 * @throws IllegalArgumentException if there are errors when serializing
 */
public static byte[] serializeToByteArray(Serializable value) {
  try {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(new SnappyOutputStream(buffer))) {
      oos.writeObject(value);
    }
    return buffer.toByteArray();
  } catch (IOException exn) {
    throw new IllegalArgumentException(
        "unable to serialize " + value,
        exn);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:19,代码来源:SerializableUtils.java

示例7: toBytes

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
@Override
public byte[] toBytes(Document doc) throws IOException {
  ByteArrayOutputStream headerArray = new ByteArrayOutputStream();
  DataOutputStream output = new DataOutputStream(headerArray);
  // identifier
  output.writeLong(doc.identifier);

  // name
  byte[] bytes = ByteUtil.fromString(doc.name);
  output.writeInt(bytes.length);
  output.write(bytes);
  output.close();

  ByteArrayOutputStream metadataArray = SerializerCommon.writeMetadata(doc);
  ByteArrayOutputStream textArray = SerializerCommon.writeText(doc);
  ByteArrayOutputStream termsArray = SerializerCommon.writeTerms(doc);

  ByteArrayOutputStream docArray = new ByteArrayOutputStream();
  output = new DataOutputStream(new SnappyOutputStream(docArray));


  output.write(headerArray.toByteArray());

  output.writeInt(metadataArray.size());
  output.writeInt(textArray.size());
  output.writeInt(termsArray.size());

  output.write(metadataArray.toByteArray());
  output.write(textArray.toByteArray());
  output.write(termsArray.toByteArray());

  output.close();

  return docArray.toByteArray();
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:36,代码来源:TokenizedDocumentSerializer.java

示例8: save

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
@Override
public void save(String saveFileName) throws IOException {
  Kryo kryo = CubeUtils.getKryoWithRegistrations();
  OutputStream zip = new SnappyOutputStream(new FileOutputStream(saveFileName));
  Output output = new Output(zip);
  kryo.writeClassAndObject(output, partitions);
  // zip.closeEntry();
  output.close();
  // zip.close();
}
 
开发者ID:cubedb,项目名称:cubedb,代码行数:11,代码来源:CubeImplTest.java

示例9: compress

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
@Override
public void compress(InputStream source, OutputStream target) {
    Validate.notNull(source);
    Validate.notNull(target);
    try (OutputStream os = new SnappyOutputStream(target)) {
        IOUtils.copy(source, os);
    }
    catch (IOException e) {
        throw new IllegalStateException(e);
    } finally {
        IOUtils.closeQuietly(source);
    }
}
 
开发者ID:kibertoad,项目名称:swampmachine,代码行数:14,代码来源:SnappyCodec.java

示例10: compactar

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
public static String compactar(String path) throws IOException {

        String compressed = path + ".cpt";

        FileOutputStream fos = new FileOutputStream(compressed);
        SnappyOutputStream sout = new SnappyOutputStream(fos);

        FileInputStream fis = new FileInputStream(path);
        BufferedInputStream input = new BufferedInputStream(fis);

        ByteArrayOutputStream orig = new ByteArrayOutputStream();
        byte[] tmp = new byte[1024];
        for (int readBytes = 0; (readBytes = input.read(tmp)) != -1;) {
            sout.write(tmp, 0, readBytes);
            orig.write(tmp, 0, readBytes);
        }
        input.close();
        sout.flush();
        sout.close();
        orig.flush();
        orig.close();
        fos.flush();
        fos.close();

        return compressed;

    }
 
开发者ID:bionimbuz,项目名称:Bionimbuz,代码行数:28,代码来源:Compactacao.java

示例11: create

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
public static OutputStream create(final CompressionCodec compressionCodec, final OutputStream stream) throws IOException {
    switch (compressionCodec) {
        case NONE:
            return stream;
        case GZIP:
            return new GZIPOutputStream(stream);
        case SNAPPY:
            return new SnappyOutputStream(stream);
        case LZ4:
            // TODO Implement KafkaLZ4BlockOutputStream
            //return new KafkaLZ4BlockOutputStream(stream);
        default:
            throw new UnknownCodecException("Unknown Codec: " + compressionCodec);
    }
}
 
开发者ID:bernd,项目名称:samsa,代码行数:16,代码来源:CompressionFactory.java

示例12: apply

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
public static OutputStream apply(CompressionCodec compressionCodec, OutputStream stream) {
    try {
        if (compressionCodec == DefaultCompressionCodec.instance) return new GZIPOutputStream(stream);
        if (compressionCodec == GZIPCompressionCodec.instance) return new GZIPOutputStream(stream);
        if (compressionCodec == SnappyCompressionCodec.instance) return new SnappyOutputStream(stream);
    } catch (IOException e) {
        throw new KafkaException(e);
    }
    throw new kafka.common.UnknownCodecException("Unknown Codec: " + compressionCodec);
}
 
开发者ID:bingoohuang,项目名称:buka,代码行数:11,代码来源:CompressionFactory.java

示例13: createSnappyInputStream

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
private SnappyInputStream createSnappyInputStream() throws IOException {
  // Create an in-memory ZIP output stream for use by the input stream (to avoid exceptions)
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  SnappyOutputStream sos = new SnappyOutputStream( baos );
  byte[] testBytes = "Test".getBytes();
  sos.write( testBytes );
  ByteArrayInputStream in = new ByteArrayInputStream( baos.toByteArray() );
  sos.close();

  return new SnappyInputStream( in );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:12,代码来源:SnappyCompressionProviderTest.java

示例14: wrapOut

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
@Override
@Nonnull
public OutputStream wrapOut(@Nonnull OutputStream out, int option) throws IOException {
	return option == -1 ? new SnappyOutputStream(out) : new SnappyOutputStream(out, option);
}
 
开发者ID:lithiumtech,项目名称:flow,代码行数:6,代码来源:SnappyCoder.java

示例15: SnappyCompression

import org.xerial.snappy.SnappyOutputStream; //导入依赖的package包/类
public SnappyCompression(InputStream inputStream, OutputStream outputStream) throws IOException {
	super(inputStream != null ? new SnappyInputStream(inputStream) : null, //
               outputStream != null ? new SnappyOutputStream(outputStream) : null);
}
 
开发者ID:bulldog2011,项目名称:luxun,代码行数:5,代码来源:SnappyCompression.java


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