@Override public JsonElement serialize( final FragmentSegmentAssignment src, final Type typeOfSrc, final JsonSerializationContext context ) { final JsonObject jsonLut = new JsonObject(); final TLongLongIterator lutIterator = src.lut.iterator(); while ( lutIterator.hasNext() ) { lutIterator.advance(); jsonLut.addProperty( Long.toString( lutIterator.key() ), lutIterator.value() ); } final JsonObject jsonObject = new JsonObject(); jsonObject.add( "lut", jsonLut ); return jsonObject; }
@Override public JsonElement serialize( final FragmentSegmentAssignment src, final Type typeOfSrc, final JsonSerializationContext context ) { final JsonArray fragments = new JsonArray(); final JsonArray segments = new JsonArray(); final TLongLongIterator lutIterator = src.lut.iterator(); while ( lutIterator.hasNext() ) { lutIterator.advance(); fragments.add( new JsonPrimitive( lutIterator.key() ) ); segments.add( new JsonPrimitive( lutIterator.value() ) ); } final JsonObject jsonObject = new JsonObject(); jsonObject.add( "fragments", fragments ); jsonObject.add( "segments", segments ); return jsonObject; }
/** * Synchronize the inverse Lookup (segment > [fragments]) with the current * forward lookup (fragment > segment)). The current state of the inverse * lookup will be cleared. */ protected void syncILut() { ilut.clear(); final TLongLongIterator lutIterator = lut.iterator(); while ( lutIterator.hasNext() ) { lutIterator.advance(); final long fragmentId = lutIterator.key(); final long segmentId = lutIterator.value(); long[] fragments = ilut.get( segmentId ); if ( fragments == null ) fragments = new long[]{ fragmentId }; else fragments = ArrayUtils.add( fragments, fragmentId ); ilut.put( segmentId, fragments); } }
public static void saveLongLongList(String listFile, TLongLongHashMap map) throws FileNotFoundException, IOException { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(listFile)))); TLongLongIterator iter = map.iterator(); while (iter.hasNext()) { iter.advance(); bw.append(iter.value() + SEP + iter.key()); bw.newLine(); } bw.flush(); bw.close(); }
private void switchDefaultProviders() { log.trace("update default providers"); dest.getEntityFactory().getCache().evictAll(); TLongArrayList exchangeIds = new TLongArrayList(); TLongArrayList providerIds = new TLongArrayList(); TLongLongIterator it = oldProviderMap.iterator(); while (it.hasNext()) { it.advance(); long exchangeId = it.key(); long newId = srcDestIdMap.get(it.value()); exchangeIds.add(exchangeId); providerIds.add(newId); } updateDefaultProviders(exchangeIds, providerIds); }
public TLongLongIterator iterator() { return container.iterator(); }