mirror of https://github.com/apache/cassandra
Fix the output of FQL dump tool to properly separate entries
patch by N V Harikrishna; reviewed by Stefan Miklosovic and Brandon Williams for CASSANDRA-18215
This commit is contained in:
parent
0c58fbb8dd
commit
b74c86404a
|
|
@ -1,4 +1,5 @@
|
|||
4.0.8
|
||||
* Fix the output of FQL dump tool to properly separate entries (CASSANDRA-18215)
|
||||
* Add cache type information for maximum memory usage warning message (CASSANDRA-18184)
|
||||
* Fix NPE in fqltool dump on null value (CASSANDRA-18113)
|
||||
* Improve unit tests performance (CASSANDRA-17427)
|
||||
|
|
|
|||
|
|
@ -219,7 +219,6 @@ public class Dump implements Runnable
|
|||
|
||||
private static void appendValuesToStringBuilder(List<ByteBuffer> values, StringBuilder sb)
|
||||
{
|
||||
boolean first = true;
|
||||
for (ByteBuffer value : values)
|
||||
{
|
||||
if (null == value)
|
||||
|
|
@ -237,16 +236,9 @@ public class Dump implements Runnable
|
|||
}
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("-----").append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//This is from net.openhft.chronicle.bytes, need to pass in the StringBuilder so had to copy
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -90,4 +90,57 @@ public class DumpTest
|
|||
|
||||
Assert.assertEquals(values.stream().filter(Objects::isNull).count(), nullcount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDumpQueryValuesShouldHaveSeperator()
|
||||
{
|
||||
String keyspace = "ks1";
|
||||
int value = 1;
|
||||
List<ByteBuffer> values = Arrays.asList(ByteBuffer.wrap(new byte[]{ (byte) value }),
|
||||
ByteBuffer.wrap(new byte[]{ (byte) value }),
|
||||
ByteBuffer.wrap(new byte[]{ (byte) value }));
|
||||
|
||||
QueryOptions queryOptions = QueryOptions.create(
|
||||
ConsistencyLevel.LOCAL_QUORUM,
|
||||
values,
|
||||
true,
|
||||
1,
|
||||
null,
|
||||
null,
|
||||
ProtocolVersion.CURRENT,
|
||||
keyspace
|
||||
);
|
||||
|
||||
ValueIn mockValueIn = Mockito.mock(ValueIn.class);
|
||||
Mockito.when(mockValueIn.text()).thenReturn("INSERT INTO ks1.t1 (k, v1, v2) VALUES (?, ?, ?)");
|
||||
|
||||
WireIn mockWireIn = Mockito.mock(WireIn.class);
|
||||
Mockito.when(mockWireIn.read(FullQueryLogger.QUERY)).thenReturn(mockValueIn);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Dump.dumpQuery(queryOptions, mockWireIn, sb);
|
||||
|
||||
String[] lines = sb.toString().split(System.lineSeparator());
|
||||
boolean valuesStarted = false;
|
||||
int valueCount = 0;
|
||||
int separatorCount = 0;
|
||||
for (String line : lines)
|
||||
{
|
||||
if (!valuesStarted && line.startsWith("Values:"))
|
||||
{
|
||||
valuesStarted = true;
|
||||
continue;
|
||||
}
|
||||
if (valuesStarted)
|
||||
{
|
||||
valueCount++;
|
||||
if (valueCount % 2 == 0)
|
||||
{
|
||||
Assert.assertEquals("-----", line);
|
||||
separatorCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(values.size(), separatorCount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue