use of com.apple.foundationdb.record.RecordCoreArgumentException in project fdb-record-layer by FoundationDB.
the class ComposedBitmapIndexCursor method create.
@Nonnull
public static ComposedBitmapIndexCursor create(@Nonnull List<Function<byte[], RecordCursor<IndexEntry>>> cursorFunctions, @Nonnull Composer composer, @Nullable byte[] byteContinuation, @Nullable FDBStoreTimer timer) {
if (cursorFunctions.size() < 2) {
throw new RecordCoreArgumentException("not enough child cursors provided to ComposedBitmapIndexCursor").addLogInfo(LogMessageKeys.CHILD_COUNT, cursorFunctions.size());
}
final List<MergeCursorState<IndexEntry>> cursorStates = new ArrayList<>(cursorFunctions.size());
final ComposedBitmapIndexContinuation continuation = ComposedBitmapIndexContinuation.from(byteContinuation, cursorFunctions.size());
int i = 0;
for (Function<byte[], RecordCursor<IndexEntry>> cursorFunction : cursorFunctions) {
cursorStates.add(MergeCursorState.from(cursorFunction, continuation.getContinuation(i)));
i++;
}
return new ComposedBitmapIndexCursor(cursorStates, timer, composer);
}
use of com.apple.foundationdb.record.RecordCoreArgumentException in project fdb-record-layer by FoundationDB.
the class SplitHelper method saveWithSplit.
/**
* Save serialized representation using multiple keys if necessary, clearing only as much as needed.
* @param context write transaction
* @param subspace subspace to save in
* @param key key within subspace
* @param serialized serialized representation
* @param version the version to store inline with this record
* @param splitLongRecords <code>true</code> if multiple keys should be used; if <code>false</code>, <code>serialized</code> must fit in a single key
* @param omitUnsplitSuffix if <code>splitLongRecords</code> is <code>false</code>, then this will omit a suffix added to the end of the key if <code>true</code> for backwards-compatibility reasons
* @param clearBasedOnPreviousSizeInfo if <code>splitLongRecords</code>, whether to use <code>previousSizeInfo</code> to determine how much to clear
* @param previousSizeInfo if <code>clearBasedOnPreviousSizeInfo</code>, the {@link FDBStoredSizes} for any old record, or <code>null</code> if there was no old record
* @param sizeInfo optional size information to populate
*/
public static void saveWithSplit(@Nonnull final FDBRecordContext context, @Nonnull final Subspace subspace, @Nonnull final Tuple key, @Nonnull final byte[] serialized, @Nullable final FDBRecordVersion version, final boolean splitLongRecords, final boolean omitUnsplitSuffix, final boolean clearBasedOnPreviousSizeInfo, @Nullable final FDBStoredSizes previousSizeInfo, @Nullable SizeInfo sizeInfo) {
if (omitUnsplitSuffix && version != null) {
throw new RecordCoreArgumentException("Cannot include version in-line using old unsplit record format").addLogInfo(LogMessageKeys.KEY_TUPLE, key).addLogInfo(LogMessageKeys.SUBSPACE, ByteArrayUtil2.loggable(subspace.pack())).addLogInfo(LogMessageKeys.VERSION, version);
}
final Transaction tr = context.ensureActive();
if (serialized.length > SplitHelper.SPLIT_RECORD_SIZE) {
if (!splitLongRecords) {
throw new RecordCoreException("Record is too long to be stored in a single value; consider split_long_records").addLogInfo(LogMessageKeys.KEY_TUPLE, key).addLogInfo(LogMessageKeys.SUBSPACE, ByteArrayUtil2.loggable(subspace.pack())).addLogInfo(LogMessageKeys.VALUE_SIZE, serialized.length);
}
writeSplitRecord(context, subspace, key, serialized, clearBasedOnPreviousSizeInfo, previousSizeInfo, sizeInfo);
} else {
if (splitLongRecords || previousSizeInfo == null || previousSizeInfo.isVersionedInline()) {
clearPreviousSplitRecord(context, subspace, key, clearBasedOnPreviousSizeInfo, previousSizeInfo);
}
final Tuple recordKey;
if (splitLongRecords || !omitUnsplitSuffix) {
recordKey = key.add(SplitHelper.UNSPLIT_RECORD);
} else {
recordKey = key;
}
final byte[] keyBytes = subspace.pack(recordKey);
tr.set(keyBytes, serialized);
if (sizeInfo != null) {
sizeInfo.set(keyBytes, serialized);
sizeInfo.setSplit(false);
}
}
writeVersion(context, subspace, key, version, sizeInfo);
}
Aggregations