Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.ValueType


            .field(fieldType1.getId(), false)
            .field(fieldType1b.getId(), false)
            .create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
View Full Code Here


            .name(new QName(ns, "rt1"))
            .field(fieldType1.getId(), false)
            .create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT1 = typeManager.getValueType("RECORD");

        // Create a fieldType with as value type a RecordValueType
        FieldType fieldType2 = typeManager.createFieldType(typeManager.newFieldType(recordVT1, new QName(ns, "field2"), Scope.NON_VERSIONED));
        // Create a recordType with a field of this field type
        RecordType rt2 = typeManager.recordTypeBuilder()
View Full Code Here

        FieldType fieldType1 = typeManager.createFieldType(typeManager.newFieldType(typeManager.getValueType("STRING"), new QName(ns, "field1"), Scope.NON_VERSIONED));
        // Create a record type to be used as the type for a RecordValueType
        RecordType rt1 = typeManager.recordTypeBuilder().name(new QName(ns, "rt1")).field(fieldType1.getId(), false).create();

        // Make a RecordValueType without the record type specified
        ValueType recordVT = typeManager.getValueType("RECORD");


        RecordType rt2 = typeManager.recordTypeBuilder()
            .name(new QName(ns, "rt2"))
            .supertype().id(rt1.getId()).add()
            .create();



        // Create a record with a record as field
        Record createdRecord = repository.recordBuilder()
                .recordType(new QName(ns, "rt2"))
                .field(new QName(ns,"field1"), "def")
                .create();


        DataOutput dataOutput = new DataOutputImpl();

        // Do a write and lets not get exceptions
        recordVT.write(createdRecord, dataOutput, new IdentityRecordStack());

        DataInput dataInput = new DataInputImpl(dataOutput.toByteArray());

        // Do a read and lets not get exceptions
        Record readRecord = recordVT.read(dataInput);

        assertEquals(createdRecord.getFields(), readRecord.getFields());
    }
View Full Code Here

    protected static boolean avro = false;

    @Test
    public void testCreate() throws Exception {
        QName name = new QName(namespace, "testCreate");
        ValueType valueType = typeManager.getValueType("STRING");
        FieldType fieldType = typeManager.newFieldType(valueType , name, Scope.NON_VERSIONED);
        fieldType = typeManager.createFieldType(fieldType);
        assertEquals(fieldType, typeManager.getFieldTypeById(fieldType.getId()));
        assertEquals(fieldType, typeManager.getFieldTypeByName(fieldType.getName()));
        assertEquals(typeManager.getFieldTypeById(fieldType.getId()), typeManager.getFieldTypeByName(name));
View Full Code Here

    }

    @Test
    public void testCreateIgnoresGivenId() throws Exception {
        SchemaId id = new SchemaIdImpl(UUID.randomUUID());
        ValueType valueType = typeManager.getValueType("STRING");
        FieldType fieldType = typeManager.newFieldType(id, valueType , new QName(namespace, "aName"), Scope.VERSIONED_MUTABLE);
        fieldType = typeManager.createFieldType(fieldType);
        assertFalse(fieldType.getId().equals(id));
    }
View Full Code Here

                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e); // rare enough
                }
                SchemaId schemaId = idGenerator.getSchemaId(id);

                ValueType valueType;
                try {
                    valueType = field.multiValue ? typeManager.getValueType("LIST<"+field.type+">") : typeManager.getValueType(field.type);
                } catch (RepositoryException e) {
                    throw new RuntimeException(e); // unlikely to occur
                } catch (InterruptedException e) {
View Full Code Here

        complexFields();
    }

    public void createRecordType() throws Exception {
        // (1)
        ValueType stringValueType = typeManager.getValueType("STRING");

        // (2)
        FieldType title = typeManager.newFieldType(stringValueType, new QName(BNS, "title"), Scope.VERSIONED);

        // (3)
View Full Code Here

        }

        if (field != null && fieldValue != null) {
            QName fieldQName = QNameConverter.fromJson(field, namespaces);
            filter.setField(fieldQName);
            ValueType valueType = repository.getTypeManager().getFieldTypeByName(fieldQName).getValueType();
            Object value = RecordReader.INSTANCE.readValue(
                    new RecordReader.ValueHandle(fieldValue, "fieldValue", valueType),
                    new RecordReader.ReadContext(repository, new NamespacesImpl(), defaultLinkTransformer));
            filter.setFieldValue(value);
        }
View Full Code Here

        }

        if (filter.getField() != null && filter.getFieldValue() != null) {
            node.put("field", QNameConverter.toJson(filter.getField(), namespaces));

            ValueType valueType = repository.getTypeManager().getFieldTypeByName(filter.getField()).getValueType();
            JsonNode valueAsJson = RecordWriter.INSTANCE.valueToJson(filter.getFieldValue(), valueType,
                    new WriteOptions(), namespaces, repository);

            node.put("fieldValue", valueAsJson);
            node.putObject("value");
View Full Code Here

                        try {
                            byte[] columnQualifier = column.getKey();
                            SchemaId schemaId =
                                    new SchemaIdImpl(Bytes.tail(columnQualifier, columnQualifier.length - 1));
                            FieldType fieldType = typeManager.getFieldTypeById(schemaId);
                            ValueType valueType = fieldType.getValueType();
                            NavigableMap<Long, byte[]> cells = column.getValue();
                            Set<Entry<Long, byte[]>> cellsSet = cells.entrySet();
                            for (Entry<Long, byte[]> cell : cellsSet) {
                                // Get blobs to delete
                                if (valueType.getDeepestValueType() instanceof BlobValueType) {
                                    Object blobValue = null;
                                    if (fieldType.getScope() == Scope.NON_VERSIONED) {
                                        // Read the blob value from the original record,
                                        // since the delete marker has already been put in the field by the delete call
                                        if (originalRecord != null) {
                                            blobValue = originalRecord.getField(fieldType.getName());
                                        }
                                    } else {
                                        byte[] value = cell.getValue();
                                        if (!isDeleteMarker(value)) {
                                            blobValue = valueType.read(EncodingUtil.stripPrefix(value));
                                        }
                                    }
                                    try {
                                        if (blobValue != null) {
                                            blobsToDelete
View Full Code Here

TOP

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

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.