Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.RecordId



    private Record updateRecord(Record record, boolean useLatestRecordType, List<MutationCondition> conditions,
                                FieldTypes fieldTypes) throws RepositoryException {

        RecordId recordId = record.getId();

        try {
            Pair<Record, byte[]> recordAndOcc = readWithOcc(record.getId(), null, null, fieldTypes);
            Record originalRecord = new UnmodifiableRecord(recordAndOcc.getV1());
View Full Code Here


    private Record updateMutableFields(Record record, boolean latestRecordType, List<MutationCondition> conditions,
            FieldTypes fieldTypes) throws RepositoryException {

        Record newRecord = record.cloneRecord();

        RecordId recordId = record.getId();

        Long version = record.getVersion();
        if (version == null) {
            throw new InvalidRecordException("The version of the record cannot be null to update mutable fields",
                    record.getId());
        }

        try {
            Map<QName, Object> fields = getFieldsToUpdate(record);
            fields = filterMutableFields(fields, fieldTypes);

            Pair<Record, byte[]> recordAndOcc = readWithOcc(recordId, version, null, fieldTypes);
            Record originalRecord = new UnmodifiableRecord(recordAndOcc.getV1());

            byte[] oldOccBytes = recordAndOcc.getV2();

            Map<QName, Object> originalFields = filterMutableFields(originalRecord.getFields(), fieldTypes);

            Record originalNextRecord = null;
            Map<QName, Object> originalNextFields = null;
            try {
                originalNextRecord = read(recordId, version + 1, null, fieldTypes);
                originalNextFields = filterMutableFields(originalNextRecord.getFields(), fieldTypes);
            } catch (VersionNotFoundException e) {
                // There is no next version of the record
            }

            Put put = new Put(recordId.toBytes());
            Set<BlobReference> referencedBlobs = new HashSet<BlobReference>();
            Set<BlobReference> unReferencedBlobs = new HashSet<BlobReference>();

            RecordEvent recordEvent = new RecordEvent();
            recordEvent.setType(Type.UPDATE);
View Full Code Here

        try {
            ResultScanner scanner = recordTable.getScanner(scan);
            Result result;
            while ((result = scanner.next()) != null) {
                RecordId id = idGenerator.fromBytes(result.getRow());
                recordIds.add(id);
            }
            Closer.close(
                    scanner); // Not closed in finally block: avoid HBase contact when there could be connection problems.
        } catch (IOException e) {
View Full Code Here

    public void testStringFieldListMapping() throws Exception {
        byte[] mappingData = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream(BASE_PATH + "shardingconfig2.json"));
        ShardSelector selector = JsonShardSelectorBuilder.build(mappingData);

        IdGenerator idGenerator = new IdGeneratorImpl();
        RecordId recordId = idGenerator.newRecordId(Collections.singletonMap("transport", "car"));

        String shardName = selector.getShard(recordId);
        assertEquals("shard1", shardName);
    }
View Full Code Here

    public void testLongFieldRangeMapping() throws Exception {
        byte[] mappingData = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream(BASE_PATH + "shardingconfig3.json"));
        ShardSelector selector = JsonShardSelectorBuilder.build(mappingData);

        IdGenerator idGenerator = new IdGeneratorImpl();
        RecordId recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "400"));

        String shardName = selector.getShard(recordId);
        assertEquals("shard1", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1000"));
View Full Code Here

        // (5)
        PrintUtil.print(record, repository);
    }

    public void createRecordUserSpecifiedId() throws Exception {
        RecordId id = repository.getIdGenerator().newRecordId("lily-definitive-guide-3rd-edition");
        Record record = table.newRecord(id);
        record.setDefaultNamespace(BNS);
        record.setRecordType("Book");
        record.setField("title", "Lily, the definitive guide, 3rd edition");
        record = table.create(record);
View Full Code Here

        PrintUtil.print(record, repository);
    }

    public void updateRecord() throws Exception {
        RecordId id = repository.getIdGenerator().newRecordId("lily-definitive-guide-3rd-edition");
        Record record = table.newRecord(id);
        record.setDefaultNamespace(BNS);
        record.setField("title", "Lily, the definitive guide, third edition");
        record.setField("pages", Long.valueOf(912));
        record.setField("manager", "Manager M");
View Full Code Here

        PrintUtil.print(record, repository);
    }

    public void updateRecordViaRead() throws Exception {
        RecordId id = repository.getIdGenerator().newRecordId("lily-definitive-guide-3rd-edition");
        Record record = table.read(id);
        record.setDefaultNamespace(BNS);
        record.setField("released", new LocalDate());
        record.setField("authors", Arrays.asList("Author A", "Author B"));
        record.setField("review_status", "reviewed");
View Full Code Here

    public void updateRecordConditionally() throws Exception {
        List<MutationCondition> conditions = new ArrayList<MutationCondition>();
        conditions.add(new MutationCondition(new QName(BNS, "manager"), "Manager Z"));

        RecordId id = repository.getIdGenerator().newRecordId("lily-definitive-guide-3rd-edition");
        Record record = table.read(id);
        record.setField(new QName(BNS, "manager"), "Manager P");
        record = table.update(record, conditions);

        System.out.println(record.getResponseStatus());
View Full Code Here

        System.out.println(record.getResponseStatus());
    }

    public void readRecord() throws Exception {
        RecordId id = repository.getIdGenerator().newRecordId("lily-definitive-guide-3rd-edition");

        // (1)
        Record record = table.read(id);
        String title = (String) record.getField(new QName(BNS, "title"));
        System.out.println(title);
View Full Code Here

TOP

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

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.