Package org.lilyproject.repository.impl.id

Examples of org.lilyproject.repository.impl.id.SchemaIdImpl


            throws RepositoryException, InterruptedException {
        byte flags = prefixedValue[0];
        if (FieldFlags.isDeletedField(flags)) {
            return null;
        }
        FieldType fieldType = fieldTypes.getFieldType(new SchemaIdImpl(Bytes.tail(key, key.length - 1)));
        if (context != null) {
            context.addFieldType(fieldType);
        }
        ValueType valueType = fieldType.getValueType();
View Full Code Here


        byte[] idBytes = getLatest(result, RecordCf.DATA.bytes, RECORD_TYPE_ID_QUALIFIERS.get(scope));
        byte[] versionBytes = getLatest(result, RecordCf.DATA.bytes, RECORD_TYPE_VERSION_QUALIFIERS.get(scope));
        if ((idBytes == null || idBytes.length == 0) || (versionBytes == null || versionBytes.length == 0)) {
            return null; // No record type was found
        }
        return new Pair<SchemaId, Long>(new SchemaIdImpl(idBytes), Bytes.toLong(versionBytes));
    }
View Full Code Here

        }
        SchemaId recordTypeId;
        if (idCeilingEntry == null) {
            return null; // No record type was found
        }
        recordTypeId = new SchemaIdImpl(idCeilingEntry.getValue());

        // Get recordTypeVersion
        Long recordTypeVersion;
        Map.Entry<Long, byte[]> versionCeilingEntry = null;
        NavigableMap<Long, byte[]> recordTypeVersionMap = allColumnsAllVersionsMap.get(recordTypeVersionColumnName);
View Full Code Here

        FieldType fieldType = typeManager.newFieldType(valueType, name, scope);

        String idString = getString(node, "id", null);
        SchemaId id = null;
        if (idString != null) {
            id = new SchemaIdImpl(idString);
        }
        fieldType.setId(id);

        // Some sanity checks for version tag fields
        if (fieldType.getName().getNamespace().equals(VersionTag.NAMESPACE)) {
View Full Code Here

    }

    @Test
    public void testIndexRecordFilterData_JsonRoundtrip() {
        IndexRecordFilterData recordFilterData = new IndexRecordFilterData();
        SchemaId newTypeSchemaId = new SchemaIdImpl("newtype".getBytes());
        SchemaId oldTypeSchemaId = new SchemaIdImpl("oldtype".getBytes());
        SchemaId changedFieldId = new SchemaIdImpl("changedfield".getBytes());
        byte[] oldFieldValue = new byte[] { 1 };
        byte[] newFieldValue = new byte[] { 2 };

        recordFilterData.setNewRecordExists(true);
        recordFilterData.setOldRecordExists(true);
View Full Code Here

        RecordType recordType = typeManager.newRecordType(name);

        String id = getString(node, "id", null);
        if (id != null) {
            recordType.setId(new SchemaIdImpl(id));
        }

        if (node.get("fields") != null) {
            ArrayNode fields = getArray(node, "fields");
            for (int i = 0; i < fields.size(); i++) {
                JsonNode field = fields.get(i);

                boolean mandatory = getBoolean(field, "mandatory", false);

                String fieldIdString = getString(field, "id", null);
                String fieldName = getString(field, "name", null);

                if (fieldIdString != null) {
                    recordType.addFieldTypeEntry(new SchemaIdImpl(fieldIdString), mandatory);
                } else if (fieldName != null) {
                    QName fieldQName = QNameConverter.fromJson(fieldName, namespaces);

                    try {
                        SchemaId fieldId = typeManager.getFieldTypeByName(fieldQName).getId();
                        recordType.addFieldTypeEntry(fieldId, mandatory);
                    } catch (RepositoryException e) {
                        throw new JsonFormatException("Record type " + name + ": error looking up field type with name: " +
                                fieldQName, e);
                    }
                } else {
                    throw new JsonFormatException("Record type " + name + ": field entry should specify an id or name");
                }
            }
        }

        if (node.get("supertypes") != null && node.get("mixins") != null) {
            throw new JsonFormatException("Only one of 'supertypes' or 'mixins' can be specified " +
                    "(they are synonyms, and mixins is deprecated).");
        }

        if (node.get("supertypes") != null) {
            ArrayNode supertypes = getArray(node, "supertypes", null);
            for (int i = 0; i < supertypes.size(); i++) {
                JsonNode supertype = supertypes.get(i);

                String rtIdString = getString(supertype, "id", null);
                String rtName = getString(supertype, "name", null);
                Long rtVersion = getLong(supertype, "version", null);

                if (rtIdString != null) {
                    recordType.addSupertype(new SchemaIdImpl(rtIdString), rtVersion);
                } else if (rtName != null) {
                    QName rtQName = QNameConverter.fromJson(rtName, namespaces);

                    try {
                        SchemaId rtId = typeManager.getRecordTypeByName(rtQName, null).getId();
                        recordType.addSupertype(rtId, rtVersion);
                    } catch (RepositoryException e) {
                        throw new JsonFormatException("Record type " + name +
                                ": error looking up supertype record type with name: " + rtQName, e);
                    }
                } else {
                    throw new JsonFormatException("Record type " + name + ": supertype should specify an id or name");
                }
            }
        } else if (node.get("mixins") != null) {
            // This was deprecated in 2.2, and can be removed in 2.4
            LogFactory.getLog("lily.deprecation").warn("The use of 'mixins' is deprecated, please use supertypes instead");
            ArrayNode mixins = getArray(node, "mixins", null);
            for (int i = 0; i < mixins.size(); i++) {
                JsonNode mixin = mixins.get(i);

                String rtIdString = getString(mixin, "id", null);
                String rtName = getString(mixin, "name", null);
                Long rtVersion = getLong(mixin, "version", null);

                if (rtIdString != null) {
                    recordType.addMixin(new SchemaIdImpl(rtIdString), rtVersion);
                } else if (rtName != null) {
                    QName rtQName = QNameConverter.fromJson(rtName, namespaces);

                    try {
                        SchemaId rtId = typeManager.getRecordTypeByName(rtQName, null).getId();
View Full Code Here

                    NavigableMap<byte[], NavigableMap<Long, byte[]>> columnsSet = family.getValue();
                    for (Entry<byte[], NavigableMap<Long, byte[]>> column : columnsSet.entrySet()) {
                        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) {
View Full Code Here

            log.debug("Stop run blob incubator monitor");
        }

        private void checkResult(Result result) throws IOException, RepositoryException, InterruptedException {
            byte[] recordIdBytes = result.getValue(BlobIncubatorCf.REF.bytes, BlobIncubatorColumn.RECORD.bytes);
            SchemaId recordId = new SchemaIdImpl(recordIdBytes);
            byte[] blobKey = result.getRow();
            if (Arrays.equals(recordIdBytes,BlobManagerImpl.INCUBATE)) {
                    deleteBlob(blobKey, recordId, null);
            } else {
                SchemaId fieldId = new SchemaIdImpl(result.getValue(BlobIncubatorCf.REF.bytes, BlobIncubatorColumn.FIELD.bytes));
                Result blobUsage;
                try {
                    blobUsage = getBlobUsage(blobKey, recordId, fieldId);
                    if (blobUsage == null || blobUsage.isEmpty()) {
                        deleteBlob(blobKey, recordId, fieldId); // Delete blob and reference
View Full Code Here

        }
        byte[] idBytes = null;
        if (avroSchemaId.getIdBytes() != null) {
            idBytes = avroSchemaId.getIdBytes().array();
        }
        return new SchemaIdImpl(idBytes);
    }
View Full Code Here

        control.verify();
    }

    @Test
    public void testFieldTypeEntry() {
        SchemaId id = new SchemaIdImpl(UUID.randomUUID());
        FieldTypeEntry fieldTypeEntry = new FieldTypeEntryImpl(id, true);
        typeManager.newFieldTypeEntry(id, true);
        expectLastCall().andReturn(fieldTypeEntry);

        control.replay();
        converter = new AvroConverter();
        AvroFieldTypeEntry avroFieldTypeEntry = new AvroFieldTypeEntry();
        AvroSchemaId avroSchemaId = new AvroSchemaId();
        avroSchemaId.idBytes = ByteBuffer.wrap(id.getBytes());
        avroFieldTypeEntry.id = avroSchemaId;
        avroFieldTypeEntry.mandatory = true;
        assertEquals(fieldTypeEntry, converter.convert(avroFieldTypeEntry, typeManager));
        assertEquals(avroFieldTypeEntry, converter.convert(fieldTypeEntry));
        control.verify();
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.impl.id.SchemaIdImpl

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.