Package com.gotometrics.orderly

Examples of com.gotometrics.orderly.StructRowKey


            throw new RuntimeException("QueryResult.getIndexField() is being called but there is no current result.");
        }
    }

    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");
View Full Code Here


        return decodeIdentifierFrom(rowKey);
    }

    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();
        }
View Full Code Here

        return ReturnCode.INCLUDE; // not skipped
    }

    @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) {
View Full Code Here

     * <pre>
     * ([encoded value][terminator for variable length fields])*[identifier]
     * </pre>
     */
    private byte[] buildRowKey(IndexEntry entry) throws IOException {
        final StructRowKey indexEntryRowKeySerializer = definition.asStructRowKey();

        return indexEntryRowKeySerializer.serialize(entry.getFieldValuesInSerializationOrder());
    }
View Full Code Here

                    checkQueryValueType(fieldDef, toValue);
                    toKeyComponents.add(toValue);
                    toKeyStructBuilder.add(fieldDef.asRowKeyWithoutTermination());
                }

                final StructRowKey frk = fromKeyStructBuilder.toRowKey();
                fromKey = frk.serialize(fromKeyComponents.toArray());
                final StructRowKey trk = toKeyStructBuilder.toRowKey();
                toKey = trk.serialize(toKeyComponents.toArray());

                rangeCondSet = true;
                usedConditionsCount++;

                break;
            } else {
                // we're done
                break;
            }
        }

        // Check if we have used all conditions defined in the query
        if (definedFieldsIndex < definition.getFields().size() &&
                usedConditionsCount < query.getEqConditions().size() + (rangeCond != null ? 1 : 0)) {
            StringBuilder message = new StringBuilder();
            message.append("The query contains conditions on fields which either did not follow immediately on ");
            message.append(
                    "the previous equals condition or followed after a range condition on a field. The fields are: ");
            for (; definedFieldsIndex < definition.getFields().size(); definedFieldsIndex++) {
                IndexFieldDefinition fieldDef = definition.getFields().get(definedFieldsIndex);
                if (query.getCondition(fieldDef.getName()) != null) {
                    message.append(fieldDef.getName());
                } else if (rangeCond != null && rangeCond.getName().equals(fieldDef.getName())) {
                    message.append(fieldDef.getName());
                }
                message.append(" ");
            }
            throw new MalformedQueryException(message.toString());
        }

        if (!rangeCondSet) {
            // Construct fromKey/toKey for the case there were only equals conditions
            final StructRowKey rk = fromKeyStructBuilder.toRowKey();
            rk.setTermination(Termination.MUST);
            fromKey = rk.serialize(fromKeyComponents.toArray());
            toKey = fromKey;
        }

        Scan scan = new Scan(fromKey);
View Full Code Here

TOP

Related Classes of com.gotometrics.orderly.StructRowKey

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.