Package net.agkn.hll.serialization

Examples of net.agkn.hll.serialization.IWordDeserializer


                break;
            default:
                throw new RuntimeException("Unsupported HLL type " + type);
        }

        final IWordDeserializer deserializer =
                schemaVersion.getDeserializer(type, wordLength, bytes);
        switch(type) {
            case EXPLICIT:
                // NOTE:  This should not exceed expthresh and this will always
                //        be exactly the number of words that were encoded,
                //        because the word length is at least a byte wide.
                // SEE:   IWordDeserializer#totalWordCount()
                for(int i=0; i<deserializer.totalWordCount(); i++) {
                    hll.explicitStorage.add(deserializer.readWord());
                }
                break;
            case SPARSE:
                // NOTE:  If the shortWordLength were smaller than 8 bits
                //        (1 byte) there would be a possibility (because of
                //        padding arithmetic) of having one or more extra
                //        registers read. However, this is not relevant as the
                //        extra registers will be all zeroes, which are ignored
                //        in the sparse representation.
                for(int i=0; i<deserializer.totalWordCount(); i++) {
                    final long shortWord = deserializer.readWord();
                    final byte registerValue = (byte)(shortWord & hll.valueMask);
                    // Only set non-zero registers.
                    if (registerValue != 0) {
                        hll.sparseProbabilisticStorage.put((int)(shortWord >>> hll.regwidth), registerValue);
                    }
                }
                break;
            case FULL:
                // NOTE:  Iteration is done using m (register count) and NOT
                //        deserializer#totalWordCount() because regwidth may be
                //        less than 8 and as such the padding on the 'last' byte
                //        may be larger than regwidth, causing an extra register
                //        to be read.
                // SEE: IWordDeserializer#totalWordCount()
                for(long i=0; i<hll.m; i++) {
                    hll.probabilisticStorage.setRegister(i, deserializer.readWord());
                }
                break;
            default:
                throw new RuntimeException("Unsupported HLL type " + type);
        }
View Full Code Here

TOP

Related Classes of net.agkn.hll.serialization.IWordDeserializer

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.