Examples of IWordSerializer


Examples of net.agkn.hll.serialization.IWordSerializer

        switch(type) {
            case EMPTY:
                bytes = new byte[schemaVersion.paddingBytes(type)];
                break;
            case EXPLICIT: {
                final IWordSerializer serializer =
                    schemaVersion.getSerializer(type, Long.SIZE, explicitStorage.size());

                final long[] values = explicitStorage.toLongArray();
                Arrays.sort(values);
                for(final long value : values) {
                    serializer.writeWord(value);
                }

                bytes = serializer.getBytes();
                break;
            }
            case SPARSE: {
                final IWordSerializer serializer =
                        schemaVersion.getSerializer(type, shortWordLength, sparseProbabilisticStorage.size());

                final int[] indices = sparseProbabilisticStorage.keySet().toIntArray();
                Arrays.sort(indices);
                for(final int registerIndex : indices) {
                    final long registerValue = sparseProbabilisticStorage.get(registerIndex);
                    // pack index and value into "short word"
                    final long shortWord = ((registerIndex << regwidth) | registerValue);
                    serializer.writeWord(shortWord);
                }

                bytes = serializer.getBytes();
                break;
            }
            case FULL: {
                final IWordSerializer serializer = schemaVersion.getSerializer(type, regwidth, m);
                probabilisticStorage.getRegisterContents(serializer);

                bytes = serializer.getBytes();
                break;
            }
            default:
                throw new RuntimeException("Unsupported HLL type " + type);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.