Skip to content

Commit bc9e18c

Browse files
committed
Merge branch 'ts-1.5-features' into develop
2 parents bcad0c8 + 5740e80 commit bc9e18c

27 files changed

Lines changed: 2108 additions & 554 deletions

RELNOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Release Notes
22
=============
33

4+
### 2.1.1
5+
6+
Following issues / PRs addressed:
7+
8+
* [Added TS 1.5 Feature Support](https://github.com/basho/riak-java-client/pull/691)
9+
410
### 2.1.0
511

612
**Notes**

src/main/java/com/basho/riak/client/core/codec/TermToBinaryCodec.java

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static OtpOutputStream encodeTsQueryRequest(String queryText, byte[] cove
6464
final OtpOutputStream os = new OtpOutputStream();
6565
os.write(OtpExternal.versionTag); // NB: this is the reqired 0x83 (131) value
6666

67-
// TsQueryReq is a 4-tuple: {'tsqueryreq', TsInt, boolIsStreaming, bytesCoverContext}
67+
// TsQueryReq is a 4-tuple: {'tsqueryreq', TsInterpolation, boolIsStreaming, bytesCoverContext}
6868
os.write_tuple_head(4);
6969
os.write_atom(TS_QUERY_REQ);
7070

@@ -171,6 +171,10 @@ else if (cell.hasDouble())
171171
{
172172
stream.write_double(cell.getDouble());
173173
}
174+
else if(cell.hasBlob())
175+
{
176+
stream.write_binary(cell.getBlob());
177+
}
174178
else
175179
{
176180
logger.error("Unknown TS cell type encountered.");
@@ -181,11 +185,9 @@ else if (cell.hasDouble())
181185
private static QueryResult decodeTsResponse(byte[] response)
182186
throws OtpErlangDecodeException, InvalidTermToBinaryException
183187
{
184-
QueryResult result = null;
185-
186-
OtpInputStream is = new OtpInputStream(response);
188+
final OtpInputStream is = new OtpInputStream(response);
187189

188-
int firstByte = is.read1skip_version();
190+
final int firstByte = is.read1skip_version();
189191
is.reset();
190192

191193
if (firstByte != OtpExternal.smallTupleTag && firstByte != OtpExternal.largeTupleTag)
@@ -213,7 +215,7 @@ private static QueryResult parseAtomResult(OtpInputStream is)
213215
private static QueryResult parseTupleResult(OtpInputStream is)
214216
throws OtpErlangDecodeException, InvalidTermToBinaryException
215217
{
216-
QueryResult result;
218+
final QueryResult result;
217219
final int msgArity = is.read_tuple_head();
218220
// Response is:
219221
// {'rpberrorresp', ErrMsg, ErrCode}
@@ -322,30 +324,55 @@ private static Cell parseCell(List<RiakTsPB.TsColumnDescription> columnDescripti
322324
{
323325
if (cell instanceof OtpErlangBinary)
324326
{
325-
OtpErlangBinary v = (OtpErlangBinary) cell;
326-
String s = new String(v.binaryValue(), StandardCharsets.UTF_8);
327-
return new Cell(s);
327+
final OtpErlangBinary v = (OtpErlangBinary) cell;
328+
final RiakTsPB.TsColumnType type = columnDescriptions.get(j).getType();
329+
switch (type)
330+
{
331+
case VARCHAR:
332+
final String s = new String(v.binaryValue(), StandardCharsets.UTF_8);
333+
return new Cell(s);
334+
335+
case BLOB:
336+
return new Cell(v.binaryValue());
337+
338+
default:
339+
throw new IllegalStateException(
340+
String.format(
341+
"Type '%s' from the provided ColumnDescription contradicts to the actual OtpErlangBinary value",
342+
type.name()
343+
)
344+
);
345+
}
328346
}
329347
else if (cell instanceof OtpErlangLong)
330348
{
331-
OtpErlangLong v = (OtpErlangLong) cell;
332-
if (columnDescriptions.get(j).getType() == RiakTsPB.TsColumnType.TIMESTAMP)
349+
final OtpErlangLong v = (OtpErlangLong) cell;
350+
final RiakTsPB.TsColumnType type = columnDescriptions.get(j).getType();
351+
switch (type)
333352
{
334-
return Cell.newTimestamp(v.longValue());
335-
}
336-
else
337-
{
338-
return new Cell(v.longValue());
353+
case TIMESTAMP:
354+
return Cell.newTimestamp(v.longValue());
355+
356+
case SINT64:
357+
return new Cell(v.longValue());
358+
359+
default:
360+
throw new IllegalStateException(
361+
String.format(
362+
"Type '%s' from the provided ColumnDescription contradicts to the actual OtpErlangLong value",
363+
type.name()
364+
)
365+
);
339366
}
340367
}
341368
else if (cell instanceof OtpErlangDouble)
342369
{
343-
OtpErlangDouble v = (OtpErlangDouble) cell;
370+
final OtpErlangDouble v = (OtpErlangDouble) cell;
344371
return new Cell(v.doubleValue());
345372
}
346373
else if (cell instanceof OtpErlangAtom)
347374
{
348-
OtpErlangAtom v = (OtpErlangAtom) cell;
375+
final OtpErlangAtom v = (OtpErlangAtom) cell;
349376
return new Cell(v.booleanValue());
350377
}
351378
else if (cell instanceof OtpErlangList)
@@ -354,10 +381,8 @@ else if (cell instanceof OtpErlangList)
354381
assert (l.arity() == 0);
355382
return null;
356383
}
357-
else
358-
{
359-
throw new InvalidTermToBinaryException("Unknown cell type encountered: " + cell.toString() + ", unable to" +
360-
" continue parsing.");
361-
}
384+
385+
throw new InvalidTermToBinaryException("Unknown cell type encountered: " + cell.toString() +
386+
", unable to continue parsing.");
362387
}
363388
}

src/main/java/com/basho/riak/client/core/operations/ts/CreateTableOperation.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
*/
3737
public class CreateTableOperation extends PBFutureOperation<Void, RiakTsPB.TsQueryResp, String>
3838
{
39-
private final RiakTsPB.TsQueryReq.Builder reqBuilder;
4039
private final String queryText;
4140

4241
private CreateTableOperation(AbstractBuilder builder)
@@ -46,7 +45,6 @@ private CreateTableOperation(AbstractBuilder builder)
4645
builder.reqBuilder,
4746
RiakTsPB.TsQueryResp.PARSER);
4847

49-
this.reqBuilder = builder.reqBuilder;
5048
this.queryText = builder.queryText;
5149
}
5250

@@ -205,6 +203,12 @@ private static StringBuilder generateKeys(TableDefinition tableDefinition, int q
205203
{
206204
sb.append(", ")
207205
.append(lk.getName());
206+
207+
if (lk.hasKeyOrder())
208+
{
209+
sb.append(" ");
210+
sb.append(lk.getKeyOrder().toString());
211+
}
208212
}
209213

210214
return sb;
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package com.basho.riak.client.core.query;
22

3-
import com.basho.riak.protobuf.RiakTsPB;
4-
53
import java.util.Iterator;
64

75
/**
86
* @author Sergey Galkin <srggal at gmail dot com>
97
* @author Alex Moore <amoore at basho dot com>
108
* @since 2.0.3
119
*/
12-
public abstract class ConvertibleIterator<S,D> implements Iterator<D> {
13-
private final Iterator<S> iterator;
10+
public abstract class ConvertibleIterator<S,D> implements Iterator<D>
11+
{
12+
protected final Iterator<S> iterator;
1413

1514
public ConvertibleIterator(Iterator<S> iterator) {
1615
this.iterator = iterator;
@@ -19,17 +18,17 @@ public ConvertibleIterator(Iterator<S> iterator) {
1918
abstract protected D convert(S source);
2019

2120
@Override
22-
public final boolean hasNext() {
21+
public boolean hasNext() {
2322
return iterator.hasNext();
2423
}
2524

2625
@Override
27-
public final D next() {
26+
public D next() {
2827
return convert(iterator.next());
2928
}
3029

3130
@Override
3231
public final void remove() {
3332
throw new UnsupportedOperationException();
3433
}
35-
}
34+
}

0 commit comments

Comments
 (0)