Package com.gotometrics.orderly

Examples of com.gotometrics.orderly.StructIterator


    private Object decodeIndexFieldFrom(String fieldName, byte[] rowKey) throws IOException {
        final StructRowKey structRowKey = definition.asStructRowKey();
        structRowKey.iterateOver(rowKey);

        final StructIterator iterator = structRowKey.iterator();

        int fieldPosition = definition.getFieldPosition(fieldName);

        if (fieldPosition == -1) {
            throw new MalformedQueryException("field [" + fieldName + "] is not part of the index");
        }

        // skip all fields up to fieldPosition
        for (int i = 0; i < fieldPosition; i++) {
            iterator.skip();
        }

        // return the requested field
        return iterator.next();
    }
View Full Code Here


    private byte[] decodeIdentifierFrom(byte[] rowKey) throws IOException {
        final StructRowKey structRowKey = definition.asStructRowKey();
        structRowKey.iterateOver(rowKey);

        final StructIterator iterator = structRowKey.iterator();

        int nbrFields = structRowKey.getFields().length;
        // ignore all but last field (i.e. the identifier)
        for (int i = 0; i < nbrFields - 1; i++) {
            iterator.skip();
        }

        // read the last field (i.e. the identifier)
        return (byte[]) iterator.next();
    }
View Full Code Here

    @Override
    public boolean filterRowKey(byte[] buffer, int offset, int length) {
        final StructRowKey structRowKey = indexDefinition.asStructRowKey();
        structRowKey.iterateOver(buffer, offset);

        final StructIterator fieldsIterator = structRowKey.iterator();

        final List<IndexFieldDefinition> fieldDefinitions = indexDefinition.getFields();

        // for all defined field definitions
        for (IndexFieldDefinition field : fieldDefinitions) {
            // check if the field should be filtered
            if (indexFilter.getFields().contains(field.getName())) {
                final Object nextField = fieldsIterator.next();
                if (indexFilter.filterField(field.getName(), nextField)) {
                    return true; // this result is ignored
                }
            } else {
                try {
                    fieldsIterator.skip();
                } catch (IOException e) {
                    throw new RuntimeException("failed to skip, index inconsistency?", e);
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.gotometrics.orderly.StructIterator

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.