FDBTypedRecordStore implements FDBRecordStoreBase<M> { @Nonnull public static <M extends Message> Builder<M> newBuilder() { return new Builder<>(); } protected  FDBTypedRecordStore(@Nonnull FDBRecordStore untypedStore, @Nonnull RecordSerializer<M> typedSerializer); @Override FDBRecordStore getUntypedRecordStore(); @Nonnull @Override RecordMetaData getRecordMetaData(); @Nonnull @Override FDBRecordContext getContext(); @Nullable @Override SubspaceProvider getSubspaceProvider(); @Nonnull @Override RecordSerializer<M> getSerializer(); @Nonnull @Override CompletableFuture<FDBStoredRecord<M>> saveRecordAsync(@Nonnull M record, @Nonnull RecordExistenceCheck existenceCheck, @Nullable FDBRecordVersion version, @Nonnull VersionstampSaveBehavior behavior); @Nonnull @Override CompletableFuture<FDBStoredRecord<M>> loadRecordInternal(@Nonnull Tuple primaryKey, @Nonnull ExecuteState executeState, boolean snapshot); @Nonnull @Override CompletableFuture<Void> preloadRecordAsync(@Nonnull Tuple primaryKey); @Nonnull @Override CompletableFuture<Boolean> recordExistsAsync(@Nonnull Tuple primaryKey, @Nonnull final IsolationLevel isolationLevel); @Override void addRecordReadConflict(@Nonnull Tuple primaryKey); @Override void addRecordWriteConflict(@Nonnull Tuple primaryKey); @Nonnull @Override RecordCursor<FDBStoredRecord<M>> scanRecords(@Nullable Tuple low, @Nullable Tuple high, @Nonnull EndpointType lowEndpoint, @Nonnull EndpointType highEndpoint, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties); @Nonnull @Override CompletableFuture<Integer> countRecords(@Nullable Tuple low, @Nullable Tuple high, @Nonnull EndpointType lowEndpoint, @Nonnull EndpointType highEndpoint, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties); @Nonnull @Override RecordCursor<IndexEntry> scanIndex(@Nonnull Index index, @Nonnull IndexScanType scanType, @Nonnull TupleRange range, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties); @Nonnull @Override RecordCursor<RecordIndexUniquenessViolation> scanUniquenessViolations(@Nonnull Index index, @Nonnull TupleRange range, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties); @Nonnull @Override CompletableFuture<Void> resolveUniquenessViolation(@Nonnull Index index, @Nonnull Tuple valueKey, @Nullable Tuple primaryKey); @Nonnull @Override CompletableFuture<Boolean> deleteRecordAsync(@Nonnull Tuple primaryKey); @Override void deleteAllRecords(); @Nonnull @Override CompletableFuture<Void> deleteRecordsWhereAsync(@Nonnull QueryComponent component); @Nonnull @Override PipelineSizer getPipelineSizer(); @Nonnull @Override CompletableFuture<Long> getSnapshotRecordCount(@Nonnull KeyExpression key, @Nonnull Key.Evaluated value); @Nonnull @Override CompletableFuture<Long> getSnapshotRecordCountForRecordType(@Nonnull String recordTypeName); @Nonnull @Override CompletableFuture<T> evaluateIndexRecordFunction(@Nonnull EvaluationContext evaluationContext, @Nonnull IndexRecordFunction<T> function, @Nonnull FDBRecord<M> record); @Nonnull @Override CompletableFuture<T> evaluateStoreFunction(@Nonnull EvaluationContext evaluationContext, @Nonnull StoreRecordFunction<T> function, @Nonnull FDBRecord<M> record); @Nonnull @Override CompletableFuture<Tuple> evaluateAggregateFunction(@Nonnull List<String> recordTypeNames, @Nonnull IndexAggregateFunction aggregateFunction, @Nonnull TupleRange range, @Nonnull IsolationLevel isolationLevel); @Nonnull @Override RecordQueryPlan planQuery(@Nonnull RecordQuery query); @Nonnull static Builder<M> newBuilder(); @Nonnull static Builder<M> newBuilder(@Nonnull RecordSerializer<M> serializer); @Nonnull static Builder<M> newBuilder(@Nonnull Descriptors.FieldDescriptor fieldDescriptor,
                                                                                                          @Nonnull Supplier<B> builderSupplier,
                                                                                                          @Nonnull Predicate<U> tester,
                                                                                                          @Nonnull Function<U, M> getter,
                                                                                                          @Nonnull BiConsumer<B, M> setter); @Nonnull static Builder<M> newBuilder(@Nonnull Descriptors.FileDescriptor fileDescriptor,
                                                                                                          @Nonnull Descriptors.FieldDescriptor fieldDescriptor,
                                                                                                          @Nonnull Supplier<B> builderSupplier,
                                                                                                          @Nonnull Predicate<U> tester,
                                                                                                          @Nonnull Function<U, M> getter,
                                                                                                          @Nonnull BiConsumer<B, M> setter); @Nonnull Builder<M> asBuilder();  }
@Test public void writeRead() throws Exception { try (FDBRecordContext context = fdb.openContext()) { openTypedRecordStore(context); TestRecords1Proto.MySimpleRecord.Builder recBuilder = TestRecords1Proto.MySimpleRecord.newBuilder(); recBuilder.setRecNo(1); recBuilder.setStrValueIndexed("abc"); recBuilder.setNumValueUnique(123); recordStore.saveRecord(recBuilder.build()); context.commit(); } try (FDBRecordContext context = fdb.openContext()) { openTypedRecordStore(context); TestRecords1Proto.MySimpleRecord myrec1 = recordStore.loadRecord(Tuple.from(1L)).getRecord(); assertNotNull(myrec1); assertEquals("abc", myrec1.getStrValueIndexed()); assertEquals(123, myrec1.getNumValueUnique()); context.commit(); } }
@Test public void query() throws Exception { try (FDBRecordContext context = fdb.openContext()) { openTypedRecordStore(context); for (int i = 0; i < 100; i++) { TestRecords1Proto.MySimpleRecord.Builder recBuilder = TestRecords1Proto.MySimpleRecord.newBuilder(); recBuilder.setRecNo(i); recBuilder.setStrValueIndexed((i & 1) == 1 ? "odd" : "even"); recBuilder.setNumValueUnique(i + 1000); recordStore.saveRecord(recBuilder.build()); } context.commit(); } RecordQuery query = RecordQuery.newBuilder() .setRecordType("MySimpleRecord") .setFilter(Query.field("str_value_indexed").equalsValue("even")) .build(); try (FDBRecordContext context = fdb.openContext()) { openTypedRecordStore(context); int i = 0; try (RecordCursorIterator<FDBQueriedRecord<TestRecords1Proto.MySimpleRecord>> cursor = recordStore.executeQuery(query).asIterator()) { while (cursor.hasNext()) { TestRecords1Proto.MySimpleRecord myrec = cursor.next().getRecord(); assertTrue((myrec.getNumValueUnique() % 2) == 0); i++; } } assertEquals(50, i); } }