Skip to content

Commit

Permalink
Merge branch 'ts-1.5-features' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmoore committed Dec 13, 2016
2 parents bcad0c8 + 5740e80 commit bc9e18c
Show file tree
Hide file tree
Showing 27 changed files with 2,108 additions and 554 deletions.
6 changes: 6 additions & 0 deletions RELNOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
=============

### 2.1.1

Following issues / PRs addressed:

* [Added TS 1.5 Feature Support](https://github.com/basho/riak-java-client/pull/691)

### 2.1.0

**Notes**
Expand Down
2 changes: 1 addition & 1 deletion riak_pb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static OtpOutputStream encodeTsQueryRequest(String queryText, byte[] cove
final OtpOutputStream os = new OtpOutputStream();
os.write(OtpExternal.versionTag); // NB: this is the reqired 0x83 (131) value

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

Expand Down Expand Up @@ -171,6 +171,10 @@ else if (cell.hasDouble())
{
stream.write_double(cell.getDouble());
}
else if(cell.hasBlob())
{
stream.write_binary(cell.getBlob());
}
else
{
logger.error("Unknown TS cell type encountered.");
Expand All @@ -181,11 +185,9 @@ else if (cell.hasDouble())
private static QueryResult decodeTsResponse(byte[] response)
throws OtpErlangDecodeException, InvalidTermToBinaryException
{
QueryResult result = null;

OtpInputStream is = new OtpInputStream(response);
final OtpInputStream is = new OtpInputStream(response);

int firstByte = is.read1skip_version();
final int firstByte = is.read1skip_version();
is.reset();

if (firstByte != OtpExternal.smallTupleTag && firstByte != OtpExternal.largeTupleTag)
Expand Down Expand Up @@ -213,7 +215,7 @@ private static QueryResult parseAtomResult(OtpInputStream is)
private static QueryResult parseTupleResult(OtpInputStream is)
throws OtpErlangDecodeException, InvalidTermToBinaryException
{
QueryResult result;
final QueryResult result;
final int msgArity = is.read_tuple_head();
// Response is:
// {'rpberrorresp', ErrMsg, ErrCode}
Expand Down Expand Up @@ -322,30 +324,55 @@ private static Cell parseCell(List<RiakTsPB.TsColumnDescription> columnDescripti
{
if (cell instanceof OtpErlangBinary)
{
OtpErlangBinary v = (OtpErlangBinary) cell;
String s = new String(v.binaryValue(), StandardCharsets.UTF_8);
return new Cell(s);
final OtpErlangBinary v = (OtpErlangBinary) cell;
final RiakTsPB.TsColumnType type = columnDescriptions.get(j).getType();
switch (type)
{
case VARCHAR:
final String s = new String(v.binaryValue(), StandardCharsets.UTF_8);
return new Cell(s);

case BLOB:
return new Cell(v.binaryValue());

default:
throw new IllegalStateException(
String.format(
"Type '%s' from the provided ColumnDescription contradicts to the actual OtpErlangBinary value",
type.name()
)
);
}
}
else if (cell instanceof OtpErlangLong)
{
OtpErlangLong v = (OtpErlangLong) cell;
if (columnDescriptions.get(j).getType() == RiakTsPB.TsColumnType.TIMESTAMP)
final OtpErlangLong v = (OtpErlangLong) cell;
final RiakTsPB.TsColumnType type = columnDescriptions.get(j).getType();
switch (type)
{
return Cell.newTimestamp(v.longValue());
}
else
{
return new Cell(v.longValue());
case TIMESTAMP:
return Cell.newTimestamp(v.longValue());

case SINT64:
return new Cell(v.longValue());

default:
throw new IllegalStateException(
String.format(
"Type '%s' from the provided ColumnDescription contradicts to the actual OtpErlangLong value",
type.name()
)
);
}
}
else if (cell instanceof OtpErlangDouble)
{
OtpErlangDouble v = (OtpErlangDouble) cell;
final OtpErlangDouble v = (OtpErlangDouble) cell;
return new Cell(v.doubleValue());
}
else if (cell instanceof OtpErlangAtom)
{
OtpErlangAtom v = (OtpErlangAtom) cell;
final OtpErlangAtom v = (OtpErlangAtom) cell;
return new Cell(v.booleanValue());
}
else if (cell instanceof OtpErlangList)
Expand All @@ -354,10 +381,8 @@ else if (cell instanceof OtpErlangList)
assert (l.arity() == 0);
return null;
}
else
{
throw new InvalidTermToBinaryException("Unknown cell type encountered: " + cell.toString() + ", unable to" +
" continue parsing.");
}

throw new InvalidTermToBinaryException("Unknown cell type encountered: " + cell.toString() +
", unable to continue parsing.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
*/
public class CreateTableOperation extends PBFutureOperation<Void, RiakTsPB.TsQueryResp, String>
{
private final RiakTsPB.TsQueryReq.Builder reqBuilder;
private final String queryText;

private CreateTableOperation(AbstractBuilder builder)
Expand All @@ -46,7 +45,6 @@ private CreateTableOperation(AbstractBuilder builder)
builder.reqBuilder,
RiakTsPB.TsQueryResp.PARSER);

this.reqBuilder = builder.reqBuilder;
this.queryText = builder.queryText;
}

Expand Down Expand Up @@ -205,6 +203,12 @@ private static StringBuilder generateKeys(TableDefinition tableDefinition, int q
{
sb.append(", ")
.append(lk.getName());

if (lk.hasKeyOrder())
{
sb.append(" ");
sb.append(lk.getKeyOrder().toString());
}
}

return sb;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.basho.riak.client.core.query;

import com.basho.riak.protobuf.RiakTsPB;

import java.util.Iterator;

/**
* @author Sergey Galkin <srggal at gmail dot com>
* @author Alex Moore <amoore at basho dot com>
* @since 2.0.3
*/
public abstract class ConvertibleIterator<S,D> implements Iterator<D> {
private final Iterator<S> iterator;
public abstract class ConvertibleIterator<S,D> implements Iterator<D>
{
protected final Iterator<S> iterator;

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

@Override
public final boolean hasNext() {
public boolean hasNext() {
return iterator.hasNext();
}

@Override
public final D next() {
public D next() {
return convert(iterator.next());
}

@Override
public final void remove() {
throw new UnsupportedOperationException();
}
}
}

0 comments on commit bc9e18c

Please sign in to comment.