Tabnine Logo
Record.mergeWith
Code IndexAdd Tabnine to your IDE (free)

How to use
mergeWith
method
in
com.apollographql.apollo.cache.normalized.Record

Best Java code snippets using com.apollographql.apollo.cache.normalized.Record.mergeWith (Showing top 16 results out of 315)

origin: apollographql/apollo-android

/**
 * Commits new version of record to the history and invalidate snapshot version.
 */
Set<String> commit(Record record) {
 history.add(history.size(), record.clone());
 return snapshot.mergeWith(record);
}
origin: apollographql/apollo-android

 @NotNull @Override public Record apply(@NotNull Record record) {
  Record result = record.clone();
  result.mergeWith(journal.snapshot);
  return result;
 }
}).or(journal.snapshot.clone());
origin: apollographql/apollo-android

public Set<String> merge(Record apolloRecord) {
 final Record oldRecord = recordMap.get(apolloRecord.key());
 if (oldRecord == null) {
  recordMap.put(apolloRecord.key(), apolloRecord);
  return Collections.emptySet();
 } else {
  return oldRecord.mergeWith(apolloRecord);
 }
}
origin: apollographql/apollo-android

 /**
  * Lookups record by mutation id, if it's found removes it from the history and invalidates snapshot record.
  * Snapshot record is superposition of all record versions in the history.
  */
 Set<String> revert(UUID mutationId) {
  int recordIndex = -1;
  for (int i = 0; i < history.size(); i++) {
   if (mutationId.equals(history.get(i).mutationId())) {
    recordIndex = i;
    break;
   }
  }
  if (recordIndex == -1) {
   return Collections.emptySet();
  }
  Set<String> changedKeys = new HashSet<>();
  changedKeys.add(history.remove(recordIndex).key());
  for (int i = Math.max(0, recordIndex - 1); i < history.size(); i++) {
   Record record = history.get(i);
   if (i == Math.max(0, recordIndex - 1)) {
    snapshot = record.clone();
   } else {
    changedKeys.addAll(snapshot.mergeWith(record));
   }
  }
  return changedKeys;
 }
}
origin: apollographql/apollo-android

@NotNull
protected Set<String> performMerge(@NotNull final Record apolloRecord, @NotNull final CacheHeaders cacheHeaders) {
 final Record oldRecord = lruCache.getIfPresent(apolloRecord.key());
 if (oldRecord == null) {
  lruCache.put(apolloRecord.key(), apolloRecord);
  return apolloRecord.keys();
 } else {
  Set<String> changedKeys = oldRecord.mergeWith(apolloRecord);
  //re-insert to trigger new weight calculation
  lruCache.put(apolloRecord.key(), oldRecord);
  return changedKeys;
 }
}
origin: awslabs/aws-mobile-appsync-sdk-android

/**
 * Commits new version of record to the history and invalidate snapshot version.
 */
Set<String> commit(Record record) {
 history.addLast(record.clone());
 return snapshot.mergeWith(record);
}
origin: awslabs/aws-mobile-appsync-sdk-android

 @Nonnull @Override public Record apply(@Nonnull Record record) {
  Record result = record.clone();
  result.mergeWith(journal.snapshot);
  return result;
 }
}).or(journal.snapshot.clone());
origin: com.amazonaws/aws-android-sdk-appsync-runtime

 @Nonnull @Override public Record apply(@Nonnull Record record) {
  Record result = record.clone();
  result.mergeWith(journal.snapshot);
  return result;
 }
}).or(journal.snapshot.clone());
origin: com.amazonaws/aws-android-sdk-appsync-runtime

/**
 * Commits new version of record to the history and invalidate snapshot version.
 */
Set<String> commit(Record record) {
 history.addLast(record.clone());
 return snapshot.mergeWith(record);
}
origin: com.amazonaws/aws-android-sdk-appsync-runtime

public Set<String> merge(Record apolloRecord) {
 final Record oldRecord = recordMap.get(apolloRecord.key());
 if (oldRecord == null) {
  recordMap.put(apolloRecord.key(), apolloRecord);
  return Collections.emptySet();
 } else {
  return oldRecord.mergeWith(apolloRecord);
 }
}
origin: awslabs/aws-mobile-appsync-sdk-android

public Set<String> merge(Record apolloRecord) {
 final Record oldRecord = recordMap.get(apolloRecord.key());
 if (oldRecord == null) {
  recordMap.put(apolloRecord.key(), apolloRecord);
  return Collections.emptySet();
 } else {
  return oldRecord.mergeWith(apolloRecord);
 }
}
origin: com.amazonaws/aws-android-sdk-appsync-runtime

 /**
  * Lookups record by mutation id, if it's found removes it from the history and invalidates snapshot record.
  * Snapshot record is superposition of all record versions in the history.
  */
 Set<String> revert(UUID mutationId) {
  int recordIndex = -1;
  for (int i = 0; i < history.size(); i++) {
   if (mutationId.equals(history.get(i).mutationId())) {
    recordIndex = i;
    break;
   }
  }
  if (recordIndex == -1) {
   return Collections.emptySet();
  }
  Set<String> changedKeys = new HashSet<>();
  changedKeys.add(history.remove(recordIndex).key());
  for (int i = Math.max(0, recordIndex - 1); i < history.size(); i++) {
   Record record = history.get(i);
   if (i == Math.max(0, recordIndex - 1)) {
    snapshot = record.clone();
   } else {
    changedKeys.addAll(snapshot.mergeWith(record));
   }
  }
  return changedKeys;
 }
}
origin: awslabs/aws-mobile-appsync-sdk-android

 /**
  * Lookups record by mutation id, if it's found removes it from the history and invalidates snapshot record.
  * Snapshot record is superposition of all record versions in the history.
  */
 Set<String> revert(UUID mutationId) {
  int recordIndex = -1;
  for (int i = 0; i < history.size(); i++) {
   if (mutationId.equals(history.get(i).mutationId())) {
    recordIndex = i;
    break;
   }
  }
  if (recordIndex == -1) {
   return Collections.emptySet();
  }
  Set<String> changedKeys = new HashSet<>();
  changedKeys.add(history.remove(recordIndex).key());
  for (int i = Math.max(0, recordIndex - 1); i < history.size(); i++) {
   Record record = history.get(i);
   if (i == Math.max(0, recordIndex - 1)) {
    snapshot = record.clone();
   } else {
    changedKeys.addAll(snapshot.mergeWith(record));
   }
  }
  return changedKeys;
 }
}
origin: awslabs/aws-mobile-appsync-sdk-android

@Nonnull @Override
public Set<String> merge(@Nonnull final Record apolloRecord, @Nonnull final CacheHeaders cacheHeaders) {
 if (cacheHeaders.hasHeader(GraphQLCacheHeaders.DO_NOT_STORE)) {
  return Collections.emptySet();
 }
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.merge(apolloRecord, cacheHeaders);
  }
 });
 final Record oldRecord = lruCache.getIfPresent(apolloRecord.key());
 if (oldRecord == null) {
  lruCache.put(apolloRecord.key(), apolloRecord);
  return Collections.emptySet();
 } else {
  Set<String> changedKeys = oldRecord.mergeWith(apolloRecord);
  //re-insert to trigger new weight calculation
  lruCache.put(apolloRecord.key(), oldRecord);
  return changedKeys;
 }
}
origin: com.amazonaws/aws-android-sdk-appsync-runtime

@Nonnull @Override
public Set<String> merge(@Nonnull final Record apolloRecord, @Nonnull final CacheHeaders cacheHeaders) {
 if (cacheHeaders.hasHeader(GraphQLCacheHeaders.DO_NOT_STORE)) {
  return Collections.emptySet();
 }
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.merge(apolloRecord, cacheHeaders);
  }
 });
 final Record oldRecord = lruCache.getIfPresent(apolloRecord.key());
 if (oldRecord == null) {
  lruCache.put(apolloRecord.key(), apolloRecord);
  return Collections.emptySet();
 } else {
  Set<String> changedKeys = oldRecord.mergeWith(apolloRecord);
  //re-insert to trigger new weight calculation
  lruCache.put(apolloRecord.key(), oldRecord);
  return changedKeys;
 }
}
origin: awslabs/aws-mobile-appsync-sdk-android

@Nonnull public Set<String> merge(@Nonnull final Record apolloRecord, @Nonnull final CacheHeaders cacheHeaders) {
 if (cacheHeaders.hasHeader(DO_NOT_STORE)) {
  return Collections.emptySet();
 }
 //noinspection ResultOfMethodCallIgnored
 Optional<NormalizedCache> normalizedCacheOptional = nextCache().apply(new Action<NormalizedCache>() {
  @Override
  public void apply(@Nonnull NormalizedCache cache) {
   cache.merge(apolloRecord, cacheHeaders);
  }
 });
 Optional<Record> optionalOldRecord = selectRecordForKey(apolloRecord.key());
 Set<String> changedKeys;
 if (!optionalOldRecord.isPresent()) {
  createRecord(apolloRecord.key(), recordFieldAdapter.toJson(apolloRecord.fields()));
  changedKeys = Collections.emptySet();
 } else {
  Record oldRecord = optionalOldRecord.get();
  changedKeys = oldRecord.mergeWith(apolloRecord);
  if (!changedKeys.isEmpty()) {
   updateRecord(oldRecord.key(), recordFieldAdapter.toJson(oldRecord.fields()));
  }
 }
 return changedKeys;
}
com.apollographql.apollo.cache.normalizedRecordmergeWith

Popular methods of Record

  • builder
  • fields
  • key
  • field
  • sizeEstimateBytes
  • <init>
  • adjustSizeEstimate
  • clone
  • hasField
  • mutationId
  • toBuilder
  • findCacheReferences
  • toBuilder,
  • findCacheReferences,
  • keys,
  • referencedFields

Popular in Java

  • Start an intent from android
  • onRequestPermissionsResult (Fragment)
  • getResourceAsStream (ClassLoader)
  • getApplicationContext (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Notification (javax.management)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now