Package com.ebuddy.cassandra

Examples of com.ebuddy.cassandra.Path


     * Convert strings to paths and remove the start of the paths that match the inputPath.
     */
    private Map<Path,Object> getTerminalPathMap(Path inputPath, Map<String,Object> columnsMap) {
        Map<Path,Object> pathMap = new HashMap<Path,Object>(columnsMap.size());
        for (Map.Entry<String,Object> entry : columnsMap.entrySet()) {
            Path path = DefaultPath.fromEncodedPathString(entry.getKey());
            if (!path.startsWith(inputPath)) {
                throw new IllegalStateException("unexpected path found in database:" + path);
            }
            path = path.tail(inputPath.size());
            pathMap.put(path, entry.getValue());
        }
        return pathMap;
    }
View Full Code Here


        return composition;
    }

    @SuppressWarnings("unchecked")
    private void merge(Map.Entry<Path,Object> simpleEntry, Map<String,Object> compositionMap) {
        Path path = simpleEntry.getKey();
        String head = path.head();
        assert head != null;
        Object nextLevelComposition = compositionMap.get(head);
        Path tail = path.tail();
        Object simpleValue = simpleEntry.getValue();
        if (nextLevelComposition == null) {
            mergeEntryIntoEmptySlot(compositionMap, head, tail, simpleValue);
        } else if (Types.isSimple(nextLevelComposition)) {
            mergeEntryWithSimple(compositionMap, nextLevelComposition, head, tail, simpleValue);
View Full Code Here

        Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size());

        for (Map.Entry<Path,Object> entry : structures.entrySet()) {

            Object structure = entry.getValue();
            Path path = entry.getKey();

            // handle null specially by replacing with a Null token
            if (structure == null) {
                decomposed.put(path, NULL);
                continue;
            }

            if (Types.isSimple(structure)) {
                decomposed.put(path, structure);
                continue;
            }

            Map<Path,Object> decomposedMap = decomposeStructure(structure);

            for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) {
                decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue());
            }
        }
        return decomposed;
    }
View Full Code Here

            Object key = entry.getKey();
            if (!Types.isSimple(key)) {
                throw new IllegalArgumentException(String.format("map key of type %s not supported",
                                                                 key.getClass().getSimpleName()));
            }
            Path keyPath = key instanceof Path ? (Path)key : DefaultPath.fromStrings(key.toString());

            Object value = entry.getValue();
            normalized.put(keyPath, value);
        }
        return normalized;
View Full Code Here

    private Map<Path,Object> getPathMap(Path inputPath, Iterable<Row> resultSet) {
        Map<Path,Object> pathMap = new HashMap<Path,Object>();

        for (Row row : resultSet) {
            String valueString = row.getString(valueColumnName);
            Path path = DefaultPath.fromEncodedPathString(row.getString(pathColumnName));

            if (!path.startsWith(inputPath)) {
                throw new IllegalStateException("unexpected path found in database:" + path);
            }
            path = path.tail(inputPath.size());
            Object value = StructureConverter.get().fromString(valueString);
            // this can be a null converted from a JSON null
            pathMap.put(path, value);
        }
        return pathMap;
View Full Code Here

        int count = Integer.MAX_VALUE;
        boolean reversed = false;

        // converting from a string and back normalizes the path, e.g. makes sure ends with the delimiter character
        String superColumnName = path.head();
        Path rest = path.tail();
        String start = rest.toString();
        String finish = getFinishString(start);
        Map<String,Object> columnsMap = operations.readColumnsAsMap(rowKey,
                                                                    superColumnName,
                                                                    start,
                                                                    finish,
View Full Code Here

        validateArgs(rowKey, path);

        Object structure = writeMapper.convertValue(value, Object.class);

        String superColumnName = path.head();
        Path rest = path.tail();

        Map<Path,Object> pathMap = Collections.singletonMap(rest, structure);
        Map<Path,Object> objectMap = Decomposer.get().decompose(pathMap);

        Map<String,Object> stringMap = new HashMap<String,Object>();
View Full Code Here

        return composition;
    }

    @SuppressWarnings("unchecked")
    private void merge(Map.Entry<Path,Object> simpleEntry, Map<String,Object> compositionMap) {
        Path path = simpleEntry.getKey();
        String head = path.head();
        assert head != null;
        Object nextLevelComposition = compositionMap.get(head);
        Path tail = path.tail();
        Object simpleValue = simpleEntry.getValue();
        if (nextLevelComposition == null) {
            mergeEntryIntoEmptySlot(compositionMap, head, tail, simpleValue);
        } else if (Types.isSimple(nextLevelComposition)) {
            mergeEntryWithSimple(compositionMap, nextLevelComposition, head, tail, simpleValue);
View Full Code Here

        Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size());

        for (Map.Entry<Path,Object> entry : structures.entrySet()) {

            Object structure = entry.getValue();
            Path path = entry.getKey();

            // handle null specially by replacing with a Null token
            if (structure == null) {
                decomposed.put(path, NULL);
                continue;
            }

            if (Types.isSimple(structure)) {
                decomposed.put(path, structure);
                continue;
            }

            Map<Path,Object> decomposedMap = decomposeStructure(structure);

            for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) {
                decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue());
            }
        }
        return decomposed;
    }
View Full Code Here

            Object key = entry.getKey();
            if (!Types.isSimple(key)) {
                throw new IllegalArgumentException(String.format("map key of type %s not supported",
                                                                 key.getClass().getSimpleName()));
            }
            Path keyPath = key instanceof Path ? (Path)key : DefaultPath.fromStrings(key.toString());

            Object value = entry.getValue();
            normalized.put(keyPath, value);
        }
        return normalized;
View Full Code Here

TOP

Related Classes of com.ebuddy.cassandra.Path

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.