Package org.toubassi.femtozip.models

Examples of org.toubassi.femtozip.models.FemtoZipCompressionModel


    @Test
    public void testThreading() throws IOException, InterruptedException {
       
        testThreadedCompressionModel(new VerboseStringCompressionModel());
        testThreadedCompressionModel(new FemtoZipCompressionModel());
        testThreadedCompressionModel(new GZipDictionaryCompressionModel());
        testThreadedCompressionModel(new GZipCompressionModel());
        testThreadedCompressionModel(new PureHuffmanCompressionModel());
        testThreadedCompressionModel(new VariableIntCompressionModel());
    }
View Full Code Here


   
   
    @Test
    public void testDictionaryOptimizer() throws IOException {
       
        CompressionModel compressionModel = new FemtoZipCompressionModel();
        compressionModel.build(new ArrayDocumentList(PreambleString.getBytes()));
       
        String dictionary = dictionaryToString(compressionModel.getDictionary());
        Assert.assertEquals(" our to , ince, sticure and , proity, s of e the for the establish the United States", dictionary);

        compressionModel = new FemtoZipCompressionModel();
        compressionModel.build(new ArrayDocumentList(PanamaString.getBytes()));
       
        dictionary = dictionaryToString(compressionModel.getDictionary());
        Assert.assertEquals("an a ", dictionary);
    }
View Full Code Here

    @Test
    public void testCompressionModels() throws IOException {
        String[][] testPairs = {{PreambleString, PreambleDictionary}, {"",""}};
        for (String[] testPair : testPairs) {
            testModel(testPair[0], testPair[1], new VerboseStringCompressionModel(), testPair[0].length() == 0 ? -1 : 363);
            testModel(testPair[0], testPair[1], new FemtoZipCompressionModel(), testPair[0].length() == 0 ? -1 : 205);
            testModel(testPair[0], testPair[1], new GZipDictionaryCompressionModel(), testPair[0].length() == 0 ? -1 : 204);
            testModel(testPair[0], testPair[1], new GZipCompressionModel(), testPair[0].length() == 0 ? -1 : 210);
            testModel(testPair[0], testPair[1], new PureHuffmanCompressionModel(), testPair[0].length() == 0 ? -1 : 211);
            testModel(testPair[0], testPair[1], new VariableIntCompressionModel(), testPair[0].length() == 0 ? -1 : 333);
        }
View Full Code Here

        Assert.assertArrayEquals(sourceBytes, decompressedBytes);
    }

    @Test
    public void testDocumentUniquenessScoring() throws IOException {
        CompressionModel model = new FemtoZipCompressionModel();
        ArrayList<byte[]> documents = new ArrayList<byte[]>();
        documents.add((new String("garrick1garrick2garrick3garrick4garrick")).getBytes("UTF-8"));
        documents.add((new String("xtoubassigarrick")).getBytes("UTF-8"));
        documents.add((new String("ytoubassi")).getBytes("UTF-8"));
        documents.add((new String("ztoubassi")).getBytes("UTF-8"));
       
        model.build(new ArrayDocumentList(documents));
       
        String dictionary = dictionaryToString(model.getDictionary());
        Assert.assertEquals("garricktoubassi", dictionary);
    }
View Full Code Here

        Assert.assertEquals("garricktoubassi", dictionary);
    }

    @Test
    public void testNonexistantStrings() throws IOException {
        CompressionModel model = new FemtoZipCompressionModel();
        ArrayList<byte[]> documents = new ArrayList<byte[]>();
        documents.add((new String("http://espn.de")).getBytes("UTF-8"));
        documents.add((new String("http://popsugar.de")).getBytes("UTF-8"));
        documents.add((new String("http://google.de")).getBytes("UTF-8"));
        documents.add((new String("http://yahoo.de")).getBytes("UTF-8"));
        documents.add((new String("gtoubassi")).getBytes("UTF-8"));
        documents.add((new String("gtoubassi")).getBytes("UTF-8"));
       
        model.build(new ArrayDocumentList(documents));
       
        String dictionary = dictionaryToString(model.getDictionary());
        // Make sure it doesn't think .dehttp:// is a good one
        Assert.assertEquals("gtoubassihttp://", dictionary);
    }
View Full Code Here

   
    public static CompressionModel buildOptimalModel(DocumentList documents, List<ModelOptimizationResult> results, CompressionModel[] competingModels, boolean verify) throws IOException {
       
        if (competingModels == null || competingModels.length == 0) {
            competingModels = new CompressionModel[5];
            competingModels[0] = new FemtoZipCompressionModel();
            competingModels[1] = new PureHuffmanCompressionModel();
            competingModels[2] = new GZipCompressionModel();
            competingModels[3] = new GZipDictionaryCompressionModel();
            competingModels[4] = new VariableIntCompressionModel();
        }
View Full Code Here

TOP

Related Classes of org.toubassi.femtozip.models.FemtoZipCompressionModel

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.