@Test public void multipleShardGroups() { final long delta = 10000; Shard firstShard = new Shard( 1000, 10000, false ); Shard secondShard = new Shard( 999, 9000, false ); Shard compactedShard1 = new Shard( 900, 8000, true ); Shard compactedShard2 = new Shard( 800, 7000, true ); ShardEntryGroup shardEntryGroup = new ShardEntryGroup( delta ); boolean result = shardEntryGroup.addShard( firstShard ); assertTrue( "Shard added", result ); result = shardEntryGroup.addShard( secondShard ); assertTrue( " Shard added", result ); result = shardEntryGroup.addShard( compactedShard1 ); assertTrue( "Shard added", result ); result = shardEntryGroup.addShard( compactedShard2 ); assertFalse( "Shouldn't add since it's compacted", result ); ShardEntryGroup secondGroup = new ShardEntryGroup( delta ); result = secondGroup.addShard( compactedShard2 ); assertTrue( "Added successfully", 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();  }