@Override public Record read(RecordId recordId, Long version, QName... fieldNames) throws RepositoryException, InterruptedException { FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot(); List<FieldType> fields = getFieldTypesFromNames(fieldTypes, fieldNames); return read(recordId, version, fields, fieldTypes); }
@Override public List<Record> read(List<RecordId> recordIds, QName... fieldNames) throws RepositoryException, InterruptedException { FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot(); List<FieldType> fields = getFieldTypesFromNames(fieldTypes, fieldNames); return read(recordIds, fields, fieldTypes); }
@Override public IdRecord readWithIds(RecordId recordId, Long version, List<SchemaId> fieldIds) throws RepositoryException, InterruptedException { FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot(); List<FieldType> fields = getFieldTypesFromIds(fieldIds, fieldTypes); return readWithIds(recordId, version, fields, fieldTypes); }
BulkIngester(LilyClient lilyClient, HBaseRepository hbaseRepo, HTableInterface recordTable, boolean bulkMode) throws InterruptedException { this.lilyClient = lilyClient; this.hbaseRepo = hbaseRepo; this.recordFactory = hbaseRepo.getRecordFactory(); this.recordTable = recordTable; this.fieldTypes = hbaseRepo.getTypeManager().getFieldTypesSnapshot(); this.bulkMode = bulkMode; }
/** * Decode the given HBase result into a Lily Record assuming it contains the state of the latest version of * the record (if the record has any versions, otherwise it only contains non-versioned fields). */ public Record decodeRecord(Result result) throws InterruptedException, RepositoryException { Long latestVersion = getLatestVersion(result); RecordId recordId = idGenerator.fromBytes(result.getRow()); return decodeRecord(recordId, latestVersion, null, result, typeManager.getFieldTypesSnapshot()); }
/** * Version of #decodeRecord() which returns an {@link IdRecord} instance rather than a {@link Record} instance. */ public IdRecord decodeRecordWithIds(Result result) throws InterruptedException, RepositoryException { Long latestVersion = getLatestVersion(result); RecordId recordId = idGenerator.fromBytes(result.getRow()); return decodeRecordWithIds(recordId, latestVersion, result, typeManager.getFieldTypesSnapshot()); }
@Override public List<Record> readVersions(RecordId recordId, List<Long> versions, QName... fieldNames) throws RepositoryException, InterruptedException { ArgumentValidator.notNull(recordId, "recordId"); ArgumentValidator.notNull(versions, "versions"); if (versions.isEmpty()) { return new ArrayList<Record>(); } Collections.sort(versions); FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot(); List<FieldType> fields = getFieldTypesFromNames(fieldTypes, fieldNames); Long lowestRequestedVersion = versions.get(0); Long highestRequestedVersion = versions.get(versions.size() - 1); int numberOfVersionsToRetrieve = (int) (highestRequestedVersion - lowestRequestedVersion + 1); Result result = getRow(recordId, highestRequestedVersion, numberOfVersionsToRetrieve, fields); Long latestVersion = recdec.getLatestVersion(result); // Drop the versions that are higher than the latestVersion List<Long> validVersions = new ArrayList<Long>(); for (Long version : versions) { if (version > latestVersion) { break; } validVersions.add(version); } return recdec.decodeRecords(recordId, validVersions, result, fieldTypes); }
@Override public List<Record> readVersions(RecordId recordId, Long fromVersion, Long toVersion, QName... fieldNames) throws RepositoryException, InterruptedException { ArgumentValidator.notNull(recordId, "recordId"); ArgumentValidator.notNull(fromVersion, "fromVersion"); ArgumentValidator.notNull(toVersion, "toVersion"); if (fromVersion > toVersion) { throw new IllegalArgumentException("fromVersion '" + fromVersion + "' must be smaller or equal to toVersion '" + toVersion + "'"); } FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot(); List<FieldType> fields = getFieldTypesFromNames(fieldTypes, fieldNames); int numberOfVersionsToRetrieve = (int) (toVersion - fromVersion + 1); Result result = getRow(recordId, toVersion, numberOfVersionsToRetrieve, fields); if (fromVersion < 1L) { fromVersion = 1L; // Put the fromVersion to a sensible value } List<Long> versionsToRead = new ArrayList<Long>(); Long latestVersion = recdec.getLatestVersion(result); if (latestVersion != null) { if (latestVersion < toVersion) { toVersion = latestVersion; // Limit the toVersion to the highest possible version } for (long version = fromVersion; version <= toVersion; version++) { versionsToRead.add(version); } } return recdec.decodeRecords(recordId, versionsToRead, result, fieldTypes); }
@Override public Record update(Record record, boolean updateVersion, boolean useLatestRecordType, List<MutationCondition> conditions) throws RepositoryException, InterruptedException { long before = System.currentTimeMillis(); RecordId recordId = record.getId(); try { if (recordId == null) { throw new InvalidRecordException("The recordId cannot be null for a record to be updated.", record.getId()); } FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot(); // Check if the update is an update of mutable fields if (updateVersion) { try { return updateMutableFields(record, useLatestRecordType, conditions, fieldTypes); } catch (BlobException e) { throw new RecordException("Exception occurred while updating record '" + record.getId() + "'", e); } } else { return updateRecord(record, useLatestRecordType, conditions, fieldTypes); } } finally { metrics.report(Action.UPDATE, System.currentTimeMillis() - before); } }
FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot();
FieldTypes fieldTypes = repository.getTypeManager().getFieldTypesSnapshot(); output.writeVInt(record.getFields().size()); for (Map.Entry<QName, Object> entry : record.getFields().entrySet()) {
FieldTypes fieldTypes = typeManager.getFieldTypesSnapshot();