Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.ReturnFields


                    RecordFilterJsonConverters.INSTANCE));
        }

        ObjectNode returnFieldsNode = JsonUtil.getObject(node, "returnFields", null);
        if (returnFieldsNode != null) {
            ReturnFields returnFields = new ReturnFields();
            returnFields.setType(ReturnFields.Type.valueOf(JsonUtil.getString(returnFieldsNode, "type")));

            ArrayNode fieldsArray = JsonUtil.getArray(returnFieldsNode, "fields", null);
            if (fieldsArray != null) {
                List<QName> fields = new ArrayList<QName>();
                for (JsonNode subFilterNode : fieldsArray) {
                    if (!subFilterNode.isTextual()) {
                        throw new JsonFormatException("ReturnFields.fields should be a string array, found: "
                                + subFilterNode.getClass().getName());
                    }
                    fields.add(QNameConverter.fromJson(subFilterNode.getTextValue(), namespaces));
                }
                returnFields.setFields(fields);
            }

            scan.setReturnFields(returnFields);
        }
View Full Code Here



        // Test ALL filter
        RecordScan scan = new RecordScan();
        scan.setRecordFilter(new RecordTypeFilter(rt.getName()));
        scan.setReturnFields(new ReturnFields(ReturnFields.Type.ALL));
        Record record = repository.getScanner(scan).next();
        assertEquals(3, record.getFields().size());

        // Test NONE filter
        scan = new RecordScan();
        scan.setRecordFilter(new RecordTypeFilter(rt.getName()));
        scan.setReturnFields(new ReturnFields(ReturnFields.Type.NONE));
        record = repository.getScanner(scan).next();
        assertEquals(0, record.getFields().size());

        // Test ENUM filter
        scan = new RecordScan();
        scan.setRecordFilter(new RecordTypeFilter(rt.getName()));
        scan.setReturnFields(new ReturnFields(f1.getName(), f2.getName()));
        record = repository.getScanner(scan).next();
        assertEquals(2, record.getFields().size());
        assertTrue(record.hasField(f1.getName()));
        assertTrue(record.hasField(f2.getName()));
        assertFalse(record.hasField(f3.getName()));

        // Test scanning on filtered field, should not work
        scan = new RecordScan();
        RecordFilterList filterList = new RecordFilterList();
        filterList.addFilter(new RecordTypeFilter(rt.getName()));
        filterList.addFilter(new FieldValueFilter(f1.getName(), "A"));
        scan.setRecordFilter(filterList);
        // without ReturnFields, we get a result
        assertNotNull(repository.getScanner(scan).next());
        // with ReturnFields that doesn't include f1, we don't get a result
        scan.setReturnFields(new ReturnFields(f2.getName()));
        // TODO disabled this test as it was sometimes failing, and sometimes not
        //      In the cases where it failed, it did bring up the row which is
        //      correct according to the filters, but which we didn't expect to
        //      receive because a filter was applied on a non-read column.
        //      The conclusion could be that while HBase can't guarantee the filter
View Full Code Here


        // Test ALL filter
        RecordScan scan = new RecordScan();
        scan.setRecordFilter(new RecordTypeFilter(rt.getName()));
        scan.setReturnFields(new ReturnFields(ReturnFields.Type.ALL));
        Record record = repository.getScanner(scan).next();
        assertNotNull(record.getRecordTypeName());
        assertEquals(ns, record.getRecordTypeName().getNamespace());

        // Test NONE filter
        scan = new RecordScan();
        scan.setRecordFilter(new RecordTypeFilter(rt.getName()));
        scan.setReturnFields(new ReturnFields(ReturnFields.Type.NONE));
        record = repository.getScanner(scan).next();
        assertNotNull(record.getRecordTypeName());
        assertEquals(ns, record.getRecordTypeName().getNamespace());

        // Test ENUM filter
        scan = new RecordScan();
        scan.setRecordFilter(new RecordTypeFilter(rt.getName()));
        scan.setReturnFields(new ReturnFields(f1.getName(), f2.getName()));
        record = repository.getScanner(scan).next();
        assertNotNull(record.getRecordTypeName());
        assertEquals(ns, record.getRecordTypeName().getNamespace());
    }
View Full Code Here

        hbaseScan.setCaching(scan.getCaching());

        hbaseScan.setCacheBlocks(scan.getCacheBlocks());

        ReturnFields returnFields = scan.getReturnFields();
        if (returnFields != null && returnFields.getType() != ReturnFields.Type.ALL) {
            RecordDecoder.addSystemColumnsToScan(hbaseScan);
            switch (returnFields.getType()) {
                case ENUM:
                    for (QName field : returnFields.getFields()) {
                        FieldTypeImpl fieldType = (FieldTypeImpl) typeManager.getFieldTypeByName(field);
                        hbaseScan.addColumn(RecordCf.DATA.bytes, fieldType.getQualifier());
                    }
                    break;
                case NONE:
                    // nothing to add
                    break;
                default:
                    throw new RuntimeException("Unrecognized ReturnFields type: " + returnFields.getType());
            }
        } else {
            hbaseScan.addFamily(RecordCf.DATA.bytes);
        }
View Full Code Here

        RecordScan parsedScan = scanFromBytes(data);

        assertEquals(ReturnFields.NONE.getType(), parsedScan.getReturnFields().getType());

        // Test with enumeration of fields to return
        scan.setReturnFields(new ReturnFields(new QName("ns", "f1"), new QName("ns", "f2")));
        data = scanToBytes(scan);
        parsedScan = scanFromBytes(data);

        assertEquals(ReturnFields.Type.ENUM, parsedScan.getReturnFields().getType());
        assertEquals(Lists.newArrayList(new QName("ns", "f1"), new QName("ns", "f2")),
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.ReturnFields

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.