Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
01ea018c
Commit
01ea018c
authored
Sep 15, 2017
by
antirez
Browse files
Streams: export iteration API.
parent
9ed40f0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/server.h
View file @
01ea018c
...
@@ -1425,11 +1425,6 @@ void listTypeConvert(robj *subject, int enc);
...
@@ -1425,11 +1425,6 @@ void listTypeConvert(robj *subject, int enc);
void
unblockClientWaitingData
(
client
*
c
);
void
unblockClientWaitingData
(
client
*
c
);
void
popGenericCommand
(
client
*
c
,
int
where
);
void
popGenericCommand
(
client
*
c
,
int
where
);
/* Stream data type. */
stream
*
streamNew
(
void
);
void
freeStream
(
stream
*
s
);
size_t
streamReplyWithRange
(
client
*
c
,
stream
*
s
,
streamID
*
start
,
streamID
*
end
,
size_t
count
);
/* MULTI/EXEC/WATCH... */
/* MULTI/EXEC/WATCH... */
void
unwatchAllKeys
(
client
*
c
);
void
unwatchAllKeys
(
client
*
c
);
void
initClientMultiState
(
client
*
c
);
void
initClientMultiState
(
client
*
c
);
...
...
src/stream.h
View file @
01ea018c
...
@@ -19,4 +19,35 @@ typedef struct stream {
...
@@ -19,4 +19,35 @@ typedef struct stream {
streamID
last_id
;
/* Zero if there are yet no items. */
streamID
last_id
;
/* Zero if there are yet no items. */
}
stream
;
}
stream
;
/* We define an iterator to iterate stream items in an abstract way, without
* caring about the radix tree + listpack representation. Technically speaking
* the iterator is only used inside streamReplyWithRange(), so could just
* be implemented inside the function, but practically there is the AOF
* rewriting code that also needs to iterate the stream to emit the XADD
* commands. */
typedef
struct
streamIterator
{
uint64_t
start_key
[
2
];
/* Start key as 128 bit big endian. */
uint64_t
end_key
[
2
];
/* End key as 128 bit big endian. */
raxIterator
ri
;
/* Rax iterator. */
unsigned
char
*
lp
;
/* Current listpack. */
unsigned
char
*
lp_ele
;
/* Current listpack cursor. */
/* Buffers used to hold the string of lpGet() when the element is
* integer encoded, so that there is no string representation of the
* element inside the listpack itself. */
unsigned
char
field_buf
[
LP_INTBUF_SIZE
];
unsigned
char
value_buf
[
LP_INTBUF_SIZE
];
}
streamIterator
;
/* Prototypes of exported APIs. */
struct
client
;
stream
*
streamNew
(
void
);
void
freeStream
(
stream
*
s
);
size_t
streamReplyWithRange
(
struct
client
*
c
,
stream
*
s
,
streamID
*
start
,
streamID
*
end
,
size_t
count
);
void
streamIteratorStart
(
streamIterator
*
si
,
stream
*
s
,
streamID
*
start
,
streamID
*
end
);
int
streamIteratorGetID
(
streamIterator
*
si
,
streamID
*
id
,
int64_t
*
numfields
);
void
streamIteratorGetField
(
streamIterator
*
si
,
unsigned
char
**
fieldptr
,
unsigned
char
**
valueptr
,
int64_t
*
fieldlen
,
int64_t
*
valuelen
);
void
streamIteratorStop
(
streamIterator
*
si
);
#endif
#endif
src/t_stream.c
View file @
01ea018c
...
@@ -196,25 +196,6 @@ int streamAppendItem(stream *s, robj **argv, int numfields, streamID *added_id,
...
@@ -196,25 +196,6 @@ int streamAppendItem(stream *s, robj **argv, int numfields, streamID *added_id,
return
C_OK
;
return
C_OK
;
}
}
/* We define an iterator to iterate stream items in an abstract way, without
* caring about the radix tree + listpack representation. Technically speaking
* the iterator is only used inside streamReplyWithRange(), so could just
* be implemented inside the function, but practically there is the AOF
* rewriting code that also needs to iterate the stream to emit the XADD
* commands. */
typedef
struct
streamIterator
{
uint64_t
start_key
[
2
];
/* Start key as 128 bit big endian. */
uint64_t
end_key
[
2
];
/* End key as 128 bit big endian. */
raxIterator
ri
;
/* Rax iterator. */
unsigned
char
*
lp
;
/* Current listpack. */
unsigned
char
*
lp_ele
;
/* Current listpack cursor. */
/* Buffers used to hold the string of lpGet() when the element is
* integer encoded, so that there is no string representation of the
* element inside the listpack itself. */
unsigned
char
field_buf
[
LP_INTBUF_SIZE
];
unsigned
char
value_buf
[
LP_INTBUF_SIZE
];
}
streamIterator
;
/* Initialize the stream iterator, so that we can call iterating functions
/* Initialize the stream iterator, so that we can call iterating functions
* to get the next items. This requires a corresponding streamIteratorStop()
* to get the next items. This requires a corresponding streamIteratorStop()
* at the end.
* at the end.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment