@NotNull private static ThrowableComputable<PersistentHashMap<String, Record>, IOException> getComputable(final File file) { return new ThrowableComputable<PersistentHashMap<String, Record>, IOException>() { @Override public PersistentHashMap<String, Record> compute() throws IOException { return new PersistentHashMap<String, Record>(file, new EnumeratorStringDescriptor(), new DataExternalizer<Record>() { @Override public void save(@NotNull DataOutput out, Record value) throws IOException { out.writeInt(value.magnitude); out.writeLong(value.date.getTime()); } @Override public Record read(@NotNull DataInput in) throws IOException { return new Record(in.readInt(), new Date(in.readLong())); } }); } }; }
PersistentHolder(final File file) { myLock = new Object(); myPersistentMap = new SmallMapSerializer<String, TreeMap<String, BranchCopyData>>( file, new EnumeratorStringDescriptor(), new BranchDataExternalizer()); // list for values by default myForSearchMap = new MultiMap<String, String>(); for (String s : myPersistentMap.keySet()) { final TreeMap<String, BranchCopyData> map = myPersistentMap.get(s); if (map != null) { myForSearchMap.put(s, new ArrayList<String>(map.keySet())); } } for (String key : myForSearchMap.keySet()) { Collections.sort((List<String>) myForSearchMap.get(key)); } }
public static DataExternalizer<MethodShortSignature> createDataExternalizer() { final EnumeratorStringDescriptor stringDescriptor = new EnumeratorStringDescriptor(); return new DataExternalizer<MethodShortSignature>() { @Override public void save(final DataOutput out, final MethodShortSignature value) throws IOException { stringDescriptor.save(out, value.getName()); stringDescriptor.save(out, value.getSignature()); } @Override public MethodShortSignature read(final DataInput in) throws IOException { return new MethodShortSignature(stringDescriptor.read(in), stringDescriptor.read(in)); } }; }
@Nonnull private static ThrowableComputable<PersistentHashMap<String, Record>, IOException> getComputable(final File file) { return () -> new PersistentHashMap<>(file, EnumeratorStringDescriptor.INSTANCE, new DataExternalizer<Record>() { @Override public void save(@Nonnull DataOutput out, Record value) throws IOException { out.writeInt(value.magnitude); out.writeLong(value.date.getTime()); out.writeLong(value.configurationHash); } @Override public Record read(@Nonnull DataInput in) throws IOException { return new Record(in.readInt(), new Date(in.readLong()), in.readLong()); } }, 4096, CURRENT_VERSION); }
public synchronized void save(@NotNull DataOutput out, Set<String> value) throws IOException { out.writeInt(value.size()); Iterator var3 = value.iterator(); while(var3.hasNext()) { String s = (String)var3.next(); EnumeratorStringDescriptor.INSTANCE.save(out, s); } }
public synchronized Set<String> read(@NotNull DataInput in) throws IOException { THashSet set = new THashSet(); for(int r = in.readInt(); r > 0; --r) { set.add(EnumeratorStringDescriptor.INSTANCE.read(in)); } return set; }
private PersistentHashMap<String, T> createMap(final File file) throws IOException { return new PersistentHashMap<String,T>(file, new EnumeratorStringDescriptor(), new DataExternalizer<T>() { public void save(@NotNull final DataOutput out, final T value) throws IOException { StateCache.this.write(value, out); } public T read(@NotNull final DataInput in) throws IOException { return StateCache.this.read(in); } }); }
private void initTimestampIndex(final boolean needReindex) { if (needReindex) { FileUtil.delete(IndexInfrastructure.getIndexRootDir(getFileTimestampsIndexId())); } for (int attempts = 0; attempts < 2; attempts++) { try { myFileTimestampsIndex = new PersistentHashMap<String, Long>(IndexInfrastructure.getStorageFile(getFileTimestampsIndexId()), new EnumeratorStringDescriptor(), new DataExternalizer<Long>() { @Override public void save(final DataOutput out, final Long value) throws IOException { out.writeLong(value); } @Override public Long read(final DataInput in) throws IOException { return in.readLong(); } }); } catch (IOException e) { FileUtil.delete(IndexInfrastructure.getIndexRootDir(getFileTimestampsIndexId())); } if (myFileTimestampsIndex != null) { return; } } throw new RuntimeException("Timestamps index not initialized"); }
private PersistentHashMap<String, T> createMap(final File file) throws IOException { return new PersistentHashMap<String,T>(file, new EnumeratorStringDescriptor(), new DataExternalizer<T>() { public void save(final DataOutput out, final T value) throws IOException { StateCache.this.write(value, out); } public T read(final DataInput in) throws IOException { return StateCache.this.read(in); } }); }
public void activate() { synchronized (myLock) { if (myState == null) { myState = new SmallMapSerializer<String, String>(myListFile, new EnumeratorStringDescriptor(), createExternalizer()); } } }
public synchronized void save(@NotNull DataOutput out, Set<String> value) throws IOException { out.writeInt(value.size()); Iterator var = value.iterator(); while(var.hasNext()) { String s = (String)var.next(); EnumeratorStringDescriptor.INSTANCE.save(out, s); } }
public synchronized Set<String> read(@NotNull DataInput in) throws IOException { Set<String> set = new THashSet<>(); for(int r = in.readInt(); r > 0; --r) { set.add(EnumeratorStringDescriptor.INSTANCE.read(in)); } return set; }
@NotNull @Override public KeyDescriptor<String> getKeyDescriptor() { return new EnumeratorStringDescriptor(); }
@NotNull @Override public KeyDescriptor<String> getKeyDescriptor() { return EnumeratorStringDescriptor.INSTANCE; }
@NotNull public DataExternalizer<String> getValueExternalizer() { return EnumeratorStringDescriptor.INSTANCE; }
public synchronized void save(@NotNull DataOutput out, String value) throws IOException { EnumeratorStringDescriptor.INSTANCE.save(out, value); }
public synchronized String read(@NotNull DataInput in) throws IOException { return EnumeratorStringDescriptor.INSTANCE.read(in); }
@NotNull public KeyDescriptor<String> getKeyDescriptor() { return new EnumeratorStringDescriptor(); }
private AndroidAptStateStorage(@NotNull File dataStorageRoot) throws IOException { super(AndroidJpsUtil.getStorageFile(dataStorageRoot, RESOURCE_NAMES_STORAGE), new EnumeratorStringDescriptor(), new MyDataExternalizer()); }
private AndroidBuildConfigStateStorage(@NotNull File dataStorageRoot) throws IOException { super(AndroidJpsUtil.getStorageFile(dataStorageRoot, BUILD_CONFIG_STORAGE), new EnumeratorStringDescriptor(), new MyDataExternalizer()); }
private AndroidApkBuilderConfigStateStorage(@NotNull File dataStorageRoot, @NotNull String storageName) throws IOException { super(AndroidJpsUtil.getStorageFile(dataStorageRoot, storageName), new EnumeratorStringDescriptor(), new MyDataExternalizer()); }
private PersistentHashMap<String, Set<String>> createPersistentMap(final File f) throws IOException { return new PersistentHashMap<String, Set<String>>(f, new EnumeratorStringDescriptor(), new SetDescriptor()); }
public void activate() { synchronized (myLock) { myState = new SmallMapSerializer<String, Map<String, Collection<SvnBranchItem>>>(myFile, new EnumeratorStringDescriptor(), createExternalizer()); } }