@Test public void shardEntryAddList() { final long delta = 10000; Shard highShard = new Shard( 30000, 1000, false ); Shard midShard = new Shard( 20000, 1000, true ); Shard lowShard = new Shard( 10000, 1000, false ); ShardEntryGroup shardEntryGroup = new ShardEntryGroup( delta ); boolean result = shardEntryGroup.addShard( highShard ); assertTrue( "Shard added", result ); result = shardEntryGroup.addShard( midShard ); assertTrue( "Shard added", result ); result = shardEntryGroup.addShard( lowShard ); assertFalse( "Shard added", result ); }
public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } ShardEntryGroup( final long delta ); }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } ShardEntryGroup( final long delta ); boolean addShard( final Shard shard ); Shard getMinShard(); Collection<Shard> getReadShards(); Collection<Shard> getWriteShards( long currentTime ); boolean isCompactionPending(); Shard getCompactionTarget(); int entrySize(); boolean shouldCompact( final long currentTime ); boolean isNew(final long currentTime); boolean canBeDeleted( final Shard shard ); @Override String toString(); }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } ShardEntryGroup( final long delta ); boolean addShard( final Shard shard ); Shard getMinShard(); Collection<Shard> getReadShards(); Collection<Shard> getWriteShards( long currentTime ); boolean isCompactionPending(); Shard getCompactionTarget(); int entrySize(); boolean shouldCompact( final long currentTime ); boolean isNew(final long currentTime); boolean canBeDeleted( final Shard shard ); @Override String toString();  }