Package voldemort.store.compress

Examples of voldemort.store.compress.CompressionStrategy


            final SerializerDefinition serializerDef = storeDef.getKeySerializer();
            final SerializerFactory serializerFactory = new DefaultSerializerFactory();
            @SuppressWarnings("unchecked")
            final Serializer<Object> serializer = (Serializer<Object>) serializerFactory.getSerializer(serializerDef);

            final CompressionStrategy keysCompressionStrategy;
            if(serializerDef != null && serializerDef.hasCompression()) {
                keysCompressionStrategy = new CompressionStrategyFactory().get(serializerDef.getCompression());
            } else {
                keysCompressionStrategy = null;
            }
            final Iterator<ByteArray> keyIterator = keyIteratorRef;
            while(keyIterator.hasNext()) {

                byte[] keyBytes = keyIterator.next().get();
                try {
                    Object keyObject = serializer.toObject((null == keysCompressionStrategy) ? keyBytes
                                                                                            : keysCompressionStrategy.inflate(keyBytes));
                    fetchedKeysForNode.add((String) keyObject);

                } catch(IOException e) {

                    e.printStackTrace();
View Full Code Here


                final Serializer<Object> keySerializer = (Serializer<Object>) serializerFactory.getSerializer(keySerializerDef);
                @SuppressWarnings("unchecked")
                final Serializer<Object> valueSerializer = (Serializer<Object>) serializerFactory.getSerializer(valueSerializerDef);

                // compression strategy
                final CompressionStrategy keyCompressionStrategy;
                final CompressionStrategy valueCompressionStrategy;
                if(keySerializerDef != null && keySerializerDef.hasCompression()) {
                    keyCompressionStrategy = new CompressionStrategyFactory().get(keySerializerDef.getCompression());
                } else {
                    keyCompressionStrategy = null;
                }
                if(valueSerializerDef != null && valueSerializerDef.hasCompression()) {
                    valueCompressionStrategy = new CompressionStrategyFactory().get(valueSerializerDef.getCompression());
                } else {
                    valueCompressionStrategy = null;
                }

                writeAscii(outputFile, new Writable() {

                    @Override
                    public void writeTo(BufferedWriter out) throws IOException {

                        while(entriesIterator.hasNext()) {
                            final JsonGenerator generator = new JsonFactory(new ObjectMapper()).createJsonGenerator(out);
                            Pair<ByteArray, Versioned<byte[]>> kvPair = entriesIterator.next();
                            byte[] keyBytes = kvPair.getFirst().get();
                            byte[] valueBytes = kvPair.getSecond().getValue();
                            VectorClock version = (VectorClock) kvPair.getSecond().getVersion();

                            Object keyObject = keySerializer.toObject((null == keyCompressionStrategy) ? keyBytes
                                                                                                      : keyCompressionStrategy.inflate(keyBytes));
                            Object valueObject = valueSerializer.toObject((null == valueCompressionStrategy) ? valueBytes
                                                                                                            : valueCompressionStrategy.inflate(valueBytes));
                            if(keyObject instanceof GenericRecord) {
                                out.write(keyObject.toString());
                            } else {
                                generator.writeObject(keyObject);
                            }
View Full Code Here

                final SerializerDefinition serializerDef = storeDefinition.getKeySerializer();
                final SerializerFactory serializerFactory = new DefaultSerializerFactory();
                @SuppressWarnings("unchecked")
                final Serializer<Object> serializer = (Serializer<Object>) serializerFactory.getSerializer(serializerDef);

                final CompressionStrategy keysCompressionStrategy;
                if(serializerDef != null && serializerDef.hasCompression()) {
                    keysCompressionStrategy = new CompressionStrategyFactory().get(serializerDef.getCompression());
                } else {
                    keysCompressionStrategy = null;
                }

                writeAscii(outputFile, new Writable() {

                    @Override
                    public void writeTo(BufferedWriter out) throws IOException {

                        while(keyIterator.hasNext()) {
                            final JsonGenerator generator = new JsonFactory(new ObjectMapper()).createJsonGenerator(out);

                            byte[] keyBytes = keyIterator.next().get();
                            Object keyObject = serializer.toObject((null == keysCompressionStrategy) ? keyBytes
                                                                                                    : keysCompressionStrategy.inflate(keyBytes));

                            if(keyObject instanceof GenericRecord) {
                                out.write(keyObject.toString());
                            } else {
                                generator.writeObject(keyObject);
View Full Code Here

            final Serializer<Object> keySerializer = (Serializer<Object>) serializerFactory.getSerializer(keySerializerDef);
            @SuppressWarnings("unchecked")
            final Serializer<Object> valueSerializer = (Serializer<Object>) serializerFactory.getSerializer(valueSerializerDef);

            // compression strategy
            final CompressionStrategy keyCompressionStrategy;
            final CompressionStrategy valueCompressionStrategy;
            if(keySerializerDef != null && keySerializerDef.hasCompression()) {
                keyCompressionStrategy = new CompressionStrategyFactory().get(keySerializerDef.getCompression());
            } else {
                keyCompressionStrategy = null;
            }
            if(valueSerializerDef != null && valueSerializerDef.hasCompression()) {
                valueCompressionStrategy = new CompressionStrategyFactory().get(valueSerializerDef.getCompression());
            } else {
                valueCompressionStrategy = null;
            }

            if(keyCompressionStrategy == null) {
                out.write("KEY_COMPRESSION_STRATEGY: None\n");
            } else {
                out.write("KEY_COMPRESSION_STRATEGY: " + keyCompressionStrategy.getType() + "\n");
            }
            out.write("KEY_SERIALIZER_NAME: " + keySerializerDef.getName() + "\n");
            for(Map.Entry<Integer, String> entry: keySerializerDef.getAllSchemaInfoVersions()
                                                                  .entrySet()) {
                out.write(String.format("KEY_SCHEMA VERSION=%d\n", entry.getKey()));
                out.write("====================================\n");
                out.write(entry.getValue());
                out.write("\n====================================\n");
            }
            out.write("\n");
            if(valueCompressionStrategy == null) {
                out.write("VALUE_COMPRESSION_STRATEGY: None\n");
            } else {
                out.write("VALUE_COMPRESSION_STRATEGY: " + valueCompressionStrategy.getType()
                          + "\n");
            }
            out.write("VALUE_SERIALIZER_NAME: " + valueSerializerDef.getName() + "\n");
            for(Map.Entry<Integer, String> entry: valueSerializerDef.getAllSchemaInfoVersions()
                                                                    .entrySet()) {
View Full Code Here

            currNode.deleteOnExit();
            Utils.move(new File(outputDir, "node-" + Integer.toString(i)), new File(currNode,
                                                                                    "version-0"));

            CompressionStrategyFactory comppressionStrategyFactory = new CompressionStrategyFactory();
            CompressionStrategy keyCompressionStrat = comppressionStrategyFactory.get(keySerDef.getCompression());
            CompressionStrategy valueCompressionStrat = comppressionStrategyFactory.get(valueSerDef.getCompression());
            ReadOnlyStorageEngine readOnlyStorageEngine = new ReadOnlyStorageEngine("test",
                                                                                    strategy,
                                                                                    router,
                                                                                    i,
                                                                                    currNode,
View Full Code Here

                    final SerializerDefinition serializerDef = storeDefinition.getKeySerializer();
                    final SerializerFactory serializerFactory = new DefaultSerializerFactory();
                    @SuppressWarnings("unchecked")
                    final Serializer<Object> serializer = (Serializer<Object>) serializerFactory.getSerializer(serializerDef);

                    final CompressionStrategy keysCompressionStrategy;
                    if(serializerDef != null && serializerDef.hasCompression()) {
                        keysCompressionStrategy = new CompressionStrategyFactory().get(serializerDef.getCompression());
                    } else {
                        keysCompressionStrategy = null;
                    }

                    writeAscii(outFile, new Writable() {

                        @Override
                        public void writeTo(BufferedWriter out) throws IOException {

                            while(keyIterator.hasNext()) {
                                final JsonGenerator generator = new JsonFactory(new ObjectMapper()).createJsonGenerator(out);

                                byte[] keyBytes = keyIterator.next().get();
                                Object keyObject = serializer.toObject((null == keysCompressionStrategy) ? keyBytes
                                                                                                        : keysCompressionStrategy.inflate(keyBytes));

                                if(keyObject instanceof GenericRecord) {
                                    out.write(keyObject.toString());
                                } else {
                                    generator.writeObject(keyObject);
View Full Code Here

        if(factoryName == null)
            factory = new DefaultSerializerFactory();
        else
            factory = loadSerializerFactory(factoryName);

        CompressionStrategy valueCompressionStrategy = null;
        if(targetDef.getValueSerializer().hasCompression()) {
            valueCompressionStrategy = new CompressionStrategyFactory().get(targetDef.getValueSerializer()
                                                                                     .getCompression());
        }
View Full Code Here

                    final Serializer<Object> keySerializer = (Serializer<Object>) serializerFactory.getSerializer(keySerializerDef);
                    @SuppressWarnings("unchecked")
                    final Serializer<Object> valueSerializer = (Serializer<Object>) serializerFactory.getSerializer(valueSerializerDef);

                    // compression strategy
                    final CompressionStrategy keyCompressionStrategy;
                    final CompressionStrategy valueCompressionStrategy;
                    if(keySerializerDef != null && keySerializerDef.hasCompression()) {
                        keyCompressionStrategy = new CompressionStrategyFactory().get(keySerializerDef.getCompression());
                    } else {
                        keyCompressionStrategy = null;
                    }
                    if(valueSerializerDef != null && valueSerializerDef.hasCompression()) {
                        valueCompressionStrategy = new CompressionStrategyFactory().get(valueSerializerDef.getCompression());
                    } else {
                        valueCompressionStrategy = null;
                    }

                    writeAscii(outFile, new Writable() {

                        @Override
                        public void writeTo(BufferedWriter out) throws IOException {

                            while(entryIterator.hasNext()) {
                                final JsonGenerator generator = new JsonFactory(new ObjectMapper()).createJsonGenerator(out);
                                Pair<ByteArray, Versioned<byte[]>> kvPair = entryIterator.next();
                                byte[] keyBytes = kvPair.getFirst().get();
                                byte[] valueBytes = kvPair.getSecond().getValue();
                                VectorClock version = (VectorClock) kvPair.getSecond().getVersion();

                                Object keyObject = keySerializer.toObject((null == keyCompressionStrategy) ? keyBytes
                                                                                                          : keyCompressionStrategy.inflate(keyBytes));
                                Object valueObject = valueSerializer.toObject((null == valueCompressionStrategy) ? valueBytes
                                                                                                                : valueCompressionStrategy.inflate(valueBytes));
                                if(keyObject instanceof GenericRecord) {
                                    out.write(keyObject.toString());
                                } else {
                                    generator.writeObject(keyObject);
                                }
View Full Code Here

                final Serializer<Object> keySerializer = (Serializer<Object>) serializerFactory.getSerializer(keySerializerDef);
                @SuppressWarnings("unchecked")
                final Serializer<Object> valueSerializer = (Serializer<Object>) serializerFactory.getSerializer(valueSerializerDef);

                // compression strategy
                final CompressionStrategy keyCompressionStrategy;
                final CompressionStrategy valueCompressionStrategy;
                if(keySerializerDef != null && keySerializerDef.hasCompression()) {
                    keyCompressionStrategy = new CompressionStrategyFactory().get(keySerializerDef.getCompression());
                } else {
                    keyCompressionStrategy = null;
                }
                if(valueSerializerDef != null && valueSerializerDef.hasCompression()) {
                    valueCompressionStrategy = new CompressionStrategyFactory().get(valueSerializerDef.getCompression());
                } else {
                    valueCompressionStrategy = null;
                }

                if(keyCompressionStrategy == null) {
                    out.write("KEY_COMPRESSION_STRATEGY: None\n");
                } else {
                    out.write("KEY_COMPRESSION_STRATEGY: " + keyCompressionStrategy.getType()
                              + "\n");
                }
                out.write("KEY_SERIALIZER_NAME: " + keySerializerDef.getName() + "\n");
                for(Map.Entry<Integer, String> entry: keySerializerDef.getAllSchemaInfoVersions()
                                                                      .entrySet()) {
                    out.write(String.format("KEY_SCHEMA VERSION=%d\n", entry.getKey()));
                    out.write("====================================\n");
                    out.write(entry.getValue());
                    out.write("\n====================================\n");
                }
                out.write("\n");
                if(valueCompressionStrategy == null) {
                    out.write("VALUE_COMPRESSION_STRATEGY: None\n");
                } else {
                    out.write("VALUE_COMPRESSION_STRATEGY: " + valueCompressionStrategy.getType()
                              + "\n");
                }
                out.write("VALUE_SERIALIZER_NAME: " + valueSerializerDef.getName() + "\n");
                for(Map.Entry<Integer, String> entry: valueSerializerDef.getAllSchemaInfoVersions()
                                                                        .entrySet()) {
View Full Code Here

TOP

Related Classes of voldemort.store.compress.CompressionStrategy

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.