Author: jbellis
Date: Wed Jan 19 16:35:00 2011
New Revision: 1060853
URL: http://svn.apache.org/viewvc?rev=1060853&view=rev
Log:
move and rename FBU.byteBufferToInt and toByteBuffer to BBU.toInt and BBU.bytes
patch by slebresne; reviewed by jbellis for CASSANDRA-2009
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DeletedColumn.java
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Table.java
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/LongType.java
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TableTest.java
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DeletedColumn.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DeletedColumn.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DeletedColumn.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/DeletedColumn.java
Wed Jan 19 16:35:00 2011
@@ -24,7 +24,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
public class DeletedColumn extends Column
{
@@ -32,7 +31,7 @@ public class DeletedColumn extends Colum
public DeletedColumn(ByteBuffer name, int localDeletionTime, long
timestamp)
{
- this(name, FBUtilities.toByteBuffer(localDeletionTime), timestamp);
+ this(name, ByteBufferUtil.bytes(localDeletionTime), timestamp);
}
public DeletedColumn(ByteBuffer name, ByteBuffer value, long timestamp)
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SystemTable.java
Wed Jan 19 16:35:00 2011
@@ -283,13 +283,13 @@ public class SystemTable
}
else
{
- generation =
Math.max(FBUtilities.byteBufferToInt(cf.getColumn(GENERATION).value()) + 1,
+ generation =
Math.max(ByteBufferUtil.toInt(cf.getColumn(GENERATION).value()) + 1,
(int) (System.currentTimeMillis() / 1000));
}
RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, LOCATION_KEY);
cf = ColumnFamily.create(Table.SYSTEM_TABLE, SystemTable.STATUS_CF);
- cf.addColumn(new Column(GENERATION,
FBUtilities.toByteBuffer(generation), FBUtilities.timestampMicros()));
+ cf.addColumn(new Column(GENERATION, ByteBufferUtil.bytes(generation),
FBUtilities.timestampMicros()));
rm.add(cf);
rm.apply();
forceBlockingFlush(STATUS_CF);
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Table.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Table.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Table.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Table.java
Wed Jan 19 16:35:00 2011
@@ -689,7 +689,7 @@ public class Table
Collection<IColumn> columns = columnFamily.getSortedColumns();
for (IColumn column : columns)
{
- ColumnFamilyStore cfStore =
columnFamilyStores.get(FBUtilities.byteBufferToInt(column.name()));
+ ColumnFamilyStore cfStore =
columnFamilyStores.get(ByteBufferUtil.toInt(column.name()));
cfStore.applyBinary(key, column.value());
}
}
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/LongType.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/LongType.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/LongType.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/marshal/LongType.java
Wed Jan 19 16:35:00 2011
@@ -24,7 +24,6 @@ package org.apache.cassandra.db.marshal;
import java.nio.ByteBuffer;
import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
public class LongType extends AbstractType
{
@@ -79,7 +78,7 @@ public class LongType extends AbstractTy
throw new RuntimeException("'" + source + "' could not be
translated into a LongType.");
}
- return FBUtilities.toByteBuffer(longType);
+ return ByteBufferUtil.bytes(longType);
}
public void validate(ByteBuffer bytes) throws MarshalException
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
Wed Jan 19 16:35:00 2011
@@ -267,4 +267,26 @@ public class ByteBufferUtil
throw new RuntimeException(e);
}
}
+
+ /**
+ * Convert a byte buffer to an integer.
+ * Does not change the byte buffer position.
+ *
+ * @param bytes byte buffer to convert to integer
+ * @return int representation of the byte buffer
+ */
+ public static int toInt(ByteBuffer bytes)
+ {
+ return bytes.getInt(bytes.position());
+ }
+
+ public static ByteBuffer bytes(int i)
+ {
+ return ByteBuffer.allocate(4).putInt(0, i);
+ }
+
+ public static ByteBuffer bytes(long n)
+ {
+ return ByteBuffer.allocate(8).putLong(0, n);
+ }
}
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
Wed Jan 19 16:35:00 2011
@@ -165,31 +165,6 @@ public class FBUtilities
return new Pair<BigInteger, Boolean>(midpoint, remainder);
}
- public static ByteBuffer toByteBuffer(int i)
- {
- byte[] bytes = new byte[4];
- bytes[0] = (byte)( ( i >>> 24 ) & 0xFF);
- bytes[1] = (byte)( ( i >>> 16 ) & 0xFF);
- bytes[2] = (byte)( ( i >>> 8 ) & 0xFF);
- bytes[3] = (byte)( i & 0xFF );
- return ByteBuffer.wrap(bytes);
- }
-
- public static int byteBufferToInt(ByteBuffer bytes)
- {
- if (bytes.remaining() < 4 )
- {
- throw new IllegalArgumentException("An integer must be 4 bytes in
size.");
- }
- int n = 0;
- for ( int i = 0; i < 4; ++i )
- {
- n <<= 8;
- n |= bytes.get(bytes.position() + i) & 0xFF;
- }
- return n;
- }
-
public static int compareUnsigned(byte[] bytes1, byte[] bytes2, int
offset1, int offset2, int len1, int len2)
{
if (bytes1 == null)
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
(original)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Wed Jan 19 16:35:00 2011
@@ -49,7 +49,6 @@ import org.apache.cassandra.thrift.Index
import org.apache.cassandra.thrift.IndexExpression;
import org.apache.cassandra.thrift.IndexOperator;
import org.apache.cassandra.thrift.IndexType;
-import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.WrappedRunnable;
import static junit.framework.Assert.assertEquals;
@@ -140,27 +139,27 @@ public class ColumnFamilyStoreTest exten
RowMutation rm;
rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(1L), 0);
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(1L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0);
rm.apply();
rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k2"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(2L), 0);
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(2L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(2L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(2L), 0);
rm.apply();
rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k3"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(2L), 0);
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(2L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0);
rm.apply();
rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k4aaaa"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), FBUtilities.toByteBuffer(2L), 0);
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(3L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(2L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(3L), 0);
rm.apply();
// basic single-expression query
- IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
FBUtilities.toByteBuffer(1L));
+ IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(1L));
IndexClause clause = new IndexClause(Arrays.asList(expr),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
IFilter filter = new IdentityQueryFilter();
IPartitioner p = StorageService.getPartitioner();
@@ -176,11 +175,11 @@ public class ColumnFamilyStoreTest exten
key = new
String(rows.get(1).key.key.array(),rows.get(1).key.key.position(),rows.get(1).key.key.remaining());
assert "k3".equals(key);
- assert FBUtilities.toByteBuffer(1L).equals(
rows.get(0).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value());
- assert FBUtilities.toByteBuffer(1L).equals(
rows.get(1).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value());
+ assert ByteBufferUtil.bytes(1L).equals(
rows.get(0).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value());
+ assert ByteBufferUtil.bytes(1L).equals(
rows.get(1).cf.getColumn(ByteBufferUtil.bytes("birthdate")).value());
// add a second expression
- IndexExpression expr2 = new
IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.GTE,
FBUtilities.toByteBuffer(2L));
+ IndexExpression expr2 = new
IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.GTE,
ByteBufferUtil.bytes(2L));
clause = new IndexClause(Arrays.asList(expr, expr2),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
rows =
Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range,
filter);
@@ -209,7 +208,7 @@ public class ColumnFamilyStoreTest exten
// query with index hit but rejected by secondary clause, with a small
enough count that just checking count
// doesn't tell the scan loop that it's done
- IndexExpression expr3 = new
IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.EQ,
FBUtilities.toByteBuffer(-1L));
+ IndexExpression expr3 = new
IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(-1L));
clause = new IndexClause(Arrays.asList(expr, expr3),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 1);
rows =
Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range,
filter);
@@ -223,10 +222,10 @@ public class ColumnFamilyStoreTest exten
RowMutation rm;
rm = new RowMutation("Keyspace3", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0);
rm.apply();
- IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
FBUtilities.toByteBuffer(1L));
+ IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(1L));
IndexClause clause = new IndexClause(Arrays.asList(expr),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
IFilter filter = new IdentityQueryFilter();
IPartitioner p = StorageService.getPartitioner();
@@ -245,7 +244,7 @@ public class ColumnFamilyStoreTest exten
// verify that it's not being indexed under the deletion column value
either
IColumn deletion =
rm.getColumnFamilies().iterator().next().iterator().next();
- ByteBuffer deletionLong = FBUtilities.toByteBuffer((long)
FBUtilities.byteBufferToInt(deletion.value()));
+ ByteBuffer deletionLong = ByteBufferUtil.bytes((long)
ByteBufferUtil.toInt(deletion.value()));
IndexExpression expr0 = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
deletionLong);
IndexClause clause0 = new IndexClause(Arrays.asList(expr0),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
rows = cfs.scan(clause0, range, filter);
@@ -253,7 +252,7 @@ public class ColumnFamilyStoreTest exten
// resurrect w/ a newer timestamp
rm = new RowMutation("Keyspace3", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 2);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 2);
rm.apply();
rows = cfs.scan(clause, range, filter);
assert rows.size() == 1 : StringUtils.join(rows, ",");
@@ -276,13 +275,13 @@ public class ColumnFamilyStoreTest exten
// create a row and update the birthdate value, test that the index
query fetches the new version
RowMutation rm;
rm = new RowMutation("Keyspace2", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 1);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 1);
rm.apply();
rm = new RowMutation("Keyspace2", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(2L), 2);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(2L), 2);
rm.apply();
- IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
FBUtilities.toByteBuffer(1L));
+ IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(1L));
IndexClause clause = new IndexClause(Arrays.asList(expr),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
IFilter filter = new IdentityQueryFilter();
IPartitioner p = StorageService.getPartitioner();
@@ -290,7 +289,7 @@ public class ColumnFamilyStoreTest exten
List<Row> rows = table.getColumnFamilyStore("Indexed1").scan(clause,
range, filter);
assert rows.size() == 0;
- expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"),
IndexOperator.EQ, FBUtilities.toByteBuffer(2L));
+ expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"),
IndexOperator.EQ, ByteBufferUtil.bytes(2L));
clause = new IndexClause(Arrays.asList(expr),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
rows = table.getColumnFamilyStore("Indexed1").scan(clause, range,
filter);
String key = new
String(rows.get(0).key.key.array(),rows.get(0).key.key.position(),rows.get(0).key.key.remaining());
@@ -298,7 +297,7 @@ public class ColumnFamilyStoreTest exten
// update the birthdate value with an OLDER timestamp, and test that
the index ignores this
rm = new RowMutation("Keyspace2", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(3L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(3L), 0);
rm.apply();
rows = table.getColumnFamilyStore("Indexed1").scan(clause, range,
filter);
@@ -315,7 +314,7 @@ public class ColumnFamilyStoreTest exten
// create a row and update the birthdate value, test that the index
query fetches the new version
RowMutation rm;
rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed2", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 1);
+ rm.add(new QueryPath("Indexed2", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 1);
rm.apply();
ColumnFamilyStore cfs = table.getColumnFamilyStore("Indexed2");
@@ -325,7 +324,7 @@ public class ColumnFamilyStoreTest exten
while (!SystemTable.isIndexBuilt("Keyspace1",
cfs.getIndexedColumnFamilyStore(ByteBufferUtil.bytes("birthdate")).columnFamily))
TimeUnit.MILLISECONDS.sleep(100);
- IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
FBUtilities.toByteBuffer(1L));
+ IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(1L));
IndexClause clause = new IndexClause(Arrays.asList(expr),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
IFilter filter = new IdentityQueryFilter();
IPartitioner p = StorageService.getPartitioner();
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TableTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TableTest.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TableTest.java
(original)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/TableTest.java
Wed Jan 19 16:35:00 2011
@@ -238,7 +238,7 @@ public class TableTest extends CleanupHe
{
RowMutation rm = new RowMutation("Keyspace1", ROW.key);
ColumnFamily cf = ColumnFamily.create("Keyspace1",
"StandardLong1");
- cf.addColumn(new Column(FBUtilities.toByteBuffer((long)i),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 0));
+ cf.addColumn(new Column(ByteBufferUtil.bytes((long)i),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 0));
rm.add(cf);
rm.apply();
}
@@ -249,7 +249,7 @@ public class TableTest extends CleanupHe
{
RowMutation rm = new RowMutation("Keyspace1", ROW.key);
ColumnFamily cf = ColumnFamily.create("Keyspace1",
"StandardLong1");
- cf.addColumn(new Column(FBUtilities.toByteBuffer((long)i),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 0));
+ cf.addColumn(new Column(ByteBufferUtil.bytes((long)i),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 0));
rm.add(cf);
rm.apply();
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java
(original)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/hadoop/ColumnFamilyInputFormatTest.java
Wed Jan 19 16:35:00 2011
@@ -26,7 +26,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.cassandra.thrift.SlicePredicate;
-import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.hadoop.conf.Configuration;
import org.junit.Test;
@@ -36,7 +36,7 @@ public class ColumnFamilyInputFormatTest
public void testSlicePredicate()
{
long columnValue = 1271253600000l;
- ByteBuffer columnBytes = FBUtilities.toByteBuffer(columnValue);
+ ByteBuffer columnBytes = ByteBufferUtil.bytes(columnValue);
List<ByteBuffer> columnNames = new ArrayList<ByteBuffer>();
columnNames.add(columnBytes);
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
(original)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
Wed Jan 19 16:35:00 2011
@@ -44,7 +44,6 @@ import org.apache.cassandra.service.Stor
import org.apache.cassandra.thrift.IndexClause;
import org.apache.cassandra.thrift.IndexExpression;
import org.apache.cassandra.thrift.IndexOperator;
-import org.apache.cassandra.utils.FBUtilities;
import org.junit.Test;
import org.apache.cassandra.utils.ByteBufferUtil;
@@ -56,12 +55,12 @@ public class SSTableWriterTest extends C
RowMutation rm;
rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("k1"));
- rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), FBUtilities.toByteBuffer(1L), 0);
+ rm.add(new QueryPath("Indexed1", null,
ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L), 0);
rm.apply();
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Indexed1");
- cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"),
FBUtilities.toByteBuffer(1L), 0));
- cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"),
FBUtilities.toByteBuffer(1L), 0));
+ cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"),
ByteBufferUtil.bytes(1L), 0));
+ cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"),
ByteBufferUtil.bytes(1L), 0));
Map<ByteBuffer, ByteBuffer> entries = new HashMap<ByteBuffer,
ByteBuffer>();
@@ -70,7 +69,7 @@ public class SSTableWriterTest extends C
entries.put(ByteBufferUtil.bytes("k2"),
ByteBuffer.wrap(Arrays.copyOf(buffer.getData(), buffer.getLength())));
cf.clear();
- cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"),
FBUtilities.toByteBuffer(1L), 0));
+ cf.addColumn(new Column(ByteBufferUtil.bytes("anydate"),
ByteBufferUtil.bytes(1L), 0));
buffer = new DataOutputBuffer();
ColumnFamily.serializer().serializeWithIndexes(cf, buffer);
entries.put(ByteBufferUtil.bytes("k3"),
ByteBuffer.wrap(Arrays.copyOf(buffer.getData(), buffer.getLength())));
@@ -86,7 +85,7 @@ public class SSTableWriterTest extends C
cfs.addSSTable(sstr);
cfs.buildSecondaryIndexes(cfs.getSSTables(), cfs.getIndexedColumns());
- IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
FBUtilities.toByteBuffer(1L));
+ IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(1L));
IndexClause clause = new IndexClause(Arrays.asList(expr),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
IFilter filter = new IdentityQueryFilter();
IPartitioner p = StorageService.getPartitioner();
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
(original)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
Wed Jan 19 16:35:00 2011
@@ -70,7 +70,7 @@ public class StreamingTransferTest exten
RowMutation rm = new RowMutation("Keyspace1",
ByteBuffer.wrap(key.getBytes()));
ColumnFamily cf = ColumnFamily.create(table.name,
cfs.columnFamily);
cf.addColumn(column(key, "v", 0));
- cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"),
FBUtilities.toByteBuffer((long) i), 0));
+ cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"),
ByteBufferUtil.bytes((long) i), 0));
rm.add(cf);
rm.apply();
}
@@ -102,7 +102,7 @@ public class StreamingTransferTest exten
assert null !=
cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("key3"), new
QueryPath(cfs.columnFamily)));
// and that the secondary index works
- IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
FBUtilities.toByteBuffer(3L));
+ IndexExpression expr = new
IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(3L));
IndexClause clause = new IndexClause(Arrays.asList(expr),
ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
IFilter filter = new IdentityQueryFilter();
Range range = new Range(p.getMinimumToken(), p.getMinimumToken());
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java?rev=1060853&r1=1060852&r2=1060853&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
(original)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/utils/FBUtilitiesTest.java
Wed Jan 19 16:35:00 2011
@@ -79,8 +79,8 @@ public class FBUtilitiesTest
};
for (int i : ints) {
- ByteBuffer ba = FBUtilities.toByteBuffer(i);
- int actual = FBUtilities.byteBufferToInt(ba);
+ ByteBuffer ba = ByteBufferUtil.bytes(i);
+ int actual = ByteBufferUtil.toInt(ba);
assertEquals(i, actual);
}
}