-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
lettuce/src/main/java/com/lambdaworks/redis/output/ListOfMapsOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (C) 2011 - Will Glozer. All rights reserved. | ||
|
||
package com.lambdaworks.redis.output; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.lambdaworks.redis.codec.RedisCodec; | ||
import com.lambdaworks.redis.protocol.CommandOutput; | ||
|
||
/** | ||
* {@link java.util.List} of maps output. | ||
* | ||
* @param <K> Key type. | ||
* @param <V> Value type. | ||
* | ||
* @author Will Glozer | ||
*/ | ||
public class ListOfMapsOutput<K, V> extends CommandOutput<K, V, List<Map<K, V>>> { | ||
private MapOutput<K, V> nested; | ||
private int mapCount = -1; | ||
private List<Integer> counts = new ArrayList<Integer>(); | ||
|
||
public ListOfMapsOutput(RedisCodec<K, V> codec) { | ||
super(codec, new ArrayList<Map<K, V>>()); | ||
nested = new MapOutput<K, V>(codec); | ||
} | ||
|
||
@Override | ||
public void set(ByteBuffer bytes) { | ||
nested.set(bytes); | ||
} | ||
|
||
@Override | ||
public void complete(int depth) { | ||
|
||
if (counts.size() > 0) { | ||
int expectedSize = counts.get(0); | ||
|
||
if (nested.get().size() == expectedSize) { | ||
counts.remove(0); | ||
output.add(new HashMap<K, V>(nested.get())); | ||
nested.get().clear(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void multi(int count) { | ||
if (mapCount == -1) { | ||
mapCount = count; | ||
} else { | ||
// div 2 because of key value pair counts twice | ||
counts.add(count / 2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,4 +122,8 @@ public String toString() { | |
sb.append(']'); | ||
return sb.toString(); | ||
} | ||
|
||
public void multi(int count) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters