HBASE-1744 Thrift server to match the new java api (Tim Sell)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1196451 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2011-11-02 04:26:26 +00:00
parent 930eb49759
commit 1b63b76e69
24 changed files with 21589 additions and 1 deletions

View File

@ -31,6 +31,7 @@ Release 0.93.0 - Unreleased
HBASE-4669 Add an option of using round-robin assignment for enabling table
(Jieshan Bean)
HBASE-4696 HRegionThriftServer' might have to indefinitely do redirtects (jgray)
HBASE-1744 Thrift server to match the new java api (Tim Sell)
BUG FIXES
HBASE-4488 Store could miss rows during flush (Lars H via jgray)

View File

@ -80,7 +80,8 @@ if [ $# = 0 ]; then
echo " regionserver run an HBase HRegionServer node"
echo " zookeeper run a Zookeeper server"
echo " rest run an HBase REST server"
echo " thrift run an HBase Thrift server"
echo " thrift run the HBase Thrift server"
echo " thrift2 run the HBase Thrift2 server"
echo " avro run an HBase Avro server"
echo ""
echo "PACKAGE MANAGEMENT"
@ -279,6 +280,11 @@ elif [ "$COMMAND" = "thrift" ] ; then
if [ "$1" != "stop" ] ; then
HBASE_OPTS="$HBASE_OPTS $HBASE_THRIFT_OPTS"
fi
elif [ "$COMMAND" = "thrift2" ] ; then
CLASS='org.apache.hadoop.hbase.thrift2.ThriftServer'
if [ "$1" != "stop" ] ; then
HBASE_OPTS="$HBASE_OPTS $HBASE_THRIFT_OPTS"
fi
elif [ "$COMMAND" = "rest" ] ; then
CLASS='org.apache.hadoop.hbase.rest.Main'
if [ "$1" != "stop" ] ; then

View File

@ -0,0 +1,90 @@
/**
* Copyright 2011 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.thrift2;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hbase.thrift2.generated.TColumnValue;
import org.apache.hadoop.hbase.thrift2.generated.TGet;
import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
import org.apache.hadoop.hbase.thrift2.generated.TIOError;
import org.apache.hadoop.hbase.thrift2.generated.TPut;
import org.apache.hadoop.hbase.thrift2.generated.TResult;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
public class DemoClient {
public static void main(String[] args) throws TIOError, TException {
System.out.println("Thrift2 Demo");
System.out.println("This demo assumes you have a table called \"example\" with a column family called \"family1\"");
String host = "localhost";
int port = 9090;
int timeout = 10000;
boolean framed = false;
TTransport transport = new TSocket(host, port, timeout);
if (framed) {
transport = new TFramedTransport(transport);
}
TProtocol protocol = new TBinaryProtocol(transport);
// This is our thrift client.
THBaseService.Iface client = new THBaseService.Client(protocol);
// open the transport
transport.open();
ByteBuffer table = ByteBuffer.wrap("example".getBytes());
TPut put = new TPut();
put.setRow("row1".getBytes());
TColumnValue columnValue = new TColumnValue();
columnValue.setFamily("family1".getBytes());
columnValue.setQualifier("qualifier1".getBytes());
columnValue.setValue("value1".getBytes());
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(columnValue);
put.setColumnValues(columnValues);
client.put(table, put);
TGet get = new TGet();
get.setRow("row1".getBytes());
TResult result = client.get(table, get);
System.out.print("row = " + new String(result.getRow()));
for (TColumnValue resultColumnValue : result.getColumnValues()) {
System.out.print("family = " + new String(resultColumnValue.getFamily()));
System.out.print("qualifier = " + new String(resultColumnValue.getFamily()));
System.out.print("value = " + new String(resultColumnValue.getValue()));
System.out.print("timestamp = " + resultColumnValue.getTimestamp());
}
transport.close();
}
}

View File

@ -0,0 +1,69 @@
"""
Copyright 2011 The Apache Software Foundation
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
# Instructions:
# 1. Run Thrift to generate the python module hbase
# thrift --gen py ../../../src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
# 2. Create a directory of your choosing that contains:
# a. This file (DemoClient.py).
# b. The directory gen-py/hbase (generated by instruction step 1).
# 3. pip install thrift==0.7.0
# 4. Create a table call "example", with a family called "family1" using the hbase shell.
# 5. Start the hbase thrift2 server
# bin/hbase thrift2 start
# 6. Execute {python DemoClient.py}.
from thrift.transport import TTransport
from thrift.transport import TSocket
from thrift.transport import THttpClient
from thrift.protocol import TBinaryProtocol
from hbase import THBaseService
from hbase.ttypes import *
print "Thrift2 Demo"
print "This demo assumes you have a table called \"example\" with a column family called \"family1\""
host = "localhost"
port = 9090
framed = False
socket = TSocket.TSocket(host, port)
if framed:
transport = TTransport.TFramedTransport(socket)
else:
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = THBaseService.Client(protocol)
transport.open()
table = "example"
put = TPut(row="row1", columnValues=[TColumnValue(family="family1",qualifier="qualifier1",value="value1")])
print "Putting:", put
client.put(table, put)
get = TGet(row="row1")
print "Getting:", get
result = client.get(table, get)
print "Result:", result
transport.close()

View File

@ -0,0 +1,281 @@
/**
* Copyright 2011 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.thrift2;
import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.HTablePool;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.thrift2.generated.TDelete;
import org.apache.hadoop.hbase.thrift2.generated.TGet;
import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
import org.apache.hadoop.hbase.thrift2.generated.TIOError;
import org.apache.hadoop.hbase.thrift2.generated.TIllegalArgument;
import org.apache.hadoop.hbase.thrift2.generated.TIncrement;
import org.apache.hadoop.hbase.thrift2.generated.TPut;
import org.apache.hadoop.hbase.thrift2.generated.TResult;
import org.apache.hadoop.hbase.thrift2.generated.TScan;
import org.apache.thrift.TException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
* This class is a glue object that connects Thrift RPC calls to the HBase client API primarily defined in the
* HTableInterface.
*/
public class ThriftHBaseServiceHandler implements THBaseService.Iface {
// TODO: Size of pool configuraple
private final HTablePool htablePool = new HTablePool();
private static final Log LOG = LogFactory.getLog(ThriftHBaseServiceHandler.class);
// nextScannerId and scannerMap are used to manage scanner state
// TODO: Cleanup thread for Scanners, Scanner id wrap
private final AtomicInteger nextScannerId = new AtomicInteger(0);
private final Map<Integer, ResultScanner> scannerMap = new ConcurrentHashMap<Integer, ResultScanner>();
private HTableInterface getTable(byte[] tableName) {
return htablePool.getTable(tableName);
}
private void closeTable(HTableInterface table) throws TIOError {
try {
table.close();
} catch (IOException e) {
throw getTIOError(e);
}
}
private TIOError getTIOError(IOException e) {
TIOError err = new TIOError();
err.setMessage(e.getMessage());
return err;
}
/**
* Assigns a unique ID to the scanner and adds the mapping to an internal HashMap.
*
* @param scanner to add
* @return Id for this Scanner
*/
private int addScanner(ResultScanner scanner) {
int id = nextScannerId.getAndIncrement();
scannerMap.put(id, scanner);
return id;
}
/**
* Returns the Scanner associated with the specified Id.
*
* @param id of the Scanner to get
* @return a Scanner, or null if the Id is invalid
*/
private ResultScanner getScanner(int id) {
return scannerMap.get(id);
}
/**
* Removes the scanner associated with the specified ID from the internal HashMap.
*
* @param id of the Scanner to remove
* @return the removed Scanner, or <code>null</code> if the Id is invalid
*/
protected ResultScanner removeScanner(int id) {
return scannerMap.remove(id);
}
@Override
public boolean exists(ByteBuffer table, TGet get) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
return htable.exists(getFromThrift(get));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public TResult get(ByteBuffer table, TGet get) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
return resultFromHBase(htable.get(getFromThrift(get)));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public List<TResult> getMultiple(ByteBuffer table, List<TGet> gets) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
return resultsFromHBase(htable.get(getsFromThrift(gets)));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public void put(ByteBuffer table, TPut put) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
htable.put(putFromThrift(put));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TPut put)
throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
return htable.checkAndPut(row.array(), family.array(), qualifier.array(), (value == null) ? null : value.array(), putFromThrift(put));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public void putMultiple(ByteBuffer table, List<TPut> puts) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
htable.put(putsFromThrift(puts));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public void deleteSingle(ByteBuffer table, TDelete deleteSingle) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
htable.delete(deleteFromThrift(deleteSingle));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public List<TDelete> deleteMultiple(ByteBuffer table, List<TDelete> deletes) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
List<Delete> tempDeletes = deletesFromThrift(deletes);
try {
htable.delete(tempDeletes);
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
return deletesFromHBase(tempDeletes);
}
@Override
public boolean checkAndDelete(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value,
TDelete deleteSingle) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
if (value == null) {
return htable.checkAndDelete(row.array(), family.array(), qualifier.array(), null, deleteFromThrift(deleteSingle));
} else {
return htable.checkAndDelete(row.array(), family.array(), qualifier.array(), value.array(), deleteFromThrift(deleteSingle));
}
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public TResult increment(ByteBuffer table, TIncrement increment) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
try {
return resultFromHBase(htable.increment(incrementFromThrift(increment)));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
@Override
public int openScanner(ByteBuffer table, TScan scan) throws TIOError, TException {
HTableInterface htable = getTable(table.array());
ResultScanner resultScanner = null;
try {
resultScanner = htable.getScanner(scanFromThrift(scan));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
return addScanner(resultScanner);
}
@Override
public List<TResult> getScannerRows(int scannerId, int numRows) throws TIOError, TIllegalArgument, TException {
ResultScanner scanner = getScanner(scannerId);
if (scanner == null) {
TIllegalArgument ex = new TIllegalArgument();
ex.setMessage("Invalid scanner Id");
throw ex;
}
try {
return resultsFromHBase(scanner.next(numRows));
} catch (IOException e) {
throw getTIOError(e);
}
}
@Override
public void closeScanner(int scannerId) throws TIOError, TIllegalArgument, TException {
if (removeScanner(scannerId) == null) {
TIllegalArgument ex = new TIllegalArgument();
ex.setMessage("Invalid scanner Id");
throw ex;
}
}
}

View File

@ -0,0 +1,229 @@
/**
* Copyright 2011 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.thrift2;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.server.THsHaServer;
import org.apache.thrift.server.TNonblockingServer;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TNonblockingServerSocket;
import org.apache.thrift.transport.TNonblockingServerTransport;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;
import org.apache.thrift.transport.TTransportFactory;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.List;
/**
* ThriftServer - this class starts up a Thrift server which implements the HBase API specified in the
* HbaseClient.thrift IDL file.
*/
public class ThriftServer {
private static final Log log = LogFactory.getLog("ThriftServer");
private static final String DEFAULT_LISTEN_PORT = "9090";
public ThriftServer() {
}
private static void printUsage() {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("Thrift", null, getOptions(),
"To start the Thrift server run 'bin/hbase-daemon.sh start thrift2'\n" +
"To shutdown the thrift server run 'bin/hbase-daemon.sh stop thrift2' or" +
" send a kill signal to the thrift server pid",
true);
}
private static Options getOptions() {
Options options = new Options();
options.addOption("b", "bind", true,
"Address to bind the Thrift server to. Not supported by the Nonblocking and HsHa server [default: 0.0.0.0]");
options.addOption("p", "port", true, "Port to bind to [default: " + DEFAULT_LISTEN_PORT + "]");
options.addOption("f", "framed", false, "Use framed transport");
options.addOption("c", "compact", false, "Use the compact protocol");
options.addOption("h", "help", false, "Print help information");
OptionGroup servers = new OptionGroup();
servers.addOption(
new Option("nonblocking", false, "Use the TNonblockingServer. This implies the framed transport."));
servers.addOption(new Option("hsha", false, "Use the THsHaServer. This implies the framed transport."));
servers.addOption(new Option("threadpool", false, "Use the TThreadPoolServer. This is the default."));
options.addOptionGroup(servers);
return options;
}
private static CommandLine parseArguments(Options options, String[] args) throws ParseException {
CommandLineParser parser = new PosixParser();
return parser.parse(options, args);
}
private static TProtocolFactory getTProtocolFactory(boolean isCompact) {
if (isCompact) {
log.debug("Using compact protocol");
return new TCompactProtocol.Factory();
} else {
log.debug("Using binary protocol");
return new TBinaryProtocol.Factory();
}
}
private static TTransportFactory getTTransportFactory(boolean framed) {
if (framed) {
log.debug("Using framed transport");
return new TFramedTransport.Factory();
} else {
return new TTransportFactory();
}
}
/*
* If bindValue is null, we don't bind.
*/
private static InetSocketAddress bindToPort(String bindValue, int listenPort)
throws UnknownHostException {
try {
if (bindValue == null) {
return new InetSocketAddress(listenPort);
} else {
return new InetSocketAddress(InetAddress.getByName(bindValue), listenPort);
}
} catch (UnknownHostException e) {
throw new RuntimeException("Could not bind to provided ip address", e);
}
}
private static TServer getTNonBlockingServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
log.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString());
TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
serverArgs.processor(processor);
serverArgs.transportFactory(transportFactory);
serverArgs.protocolFactory(protocolFactory);
return new TNonblockingServer(serverArgs);
}
private static TServer getTHsHaServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
log.info("starting HBase HsHA Thrift server on " + inetSocketAddress.toString());
THsHaServer.Args serverArgs = new THsHaServer.Args(serverTransport);
serverArgs.processor(processor);
serverArgs.transportFactory(transportFactory);
serverArgs.protocolFactory(protocolFactory);
return new THsHaServer(serverArgs);
}
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
TServerTransport serverTransport = new TServerSocket(inetSocketAddress);
log.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
serverArgs.processor(processor);
serverArgs.transportFactory(transportFactory);
serverArgs.protocolFactory(protocolFactory);
return new TThreadPoolServer(serverArgs);
}
/**
* Start up the Thrift2 server.
*
* @param args
*/
public static void main(String[] args) throws Exception {
TServer server = null;
Options options = getOptions();
try {
CommandLine cmd = parseArguments(options, args);
/**
* This is to please both bin/hbase and bin/hbase-daemon. hbase-daemon provides "start" and "stop" arguments hbase
* should print the help if no argument is provided
*/
List<?> argList = cmd.getArgList();
if (cmd.hasOption("help") || !argList.contains("start") || argList.contains("stop")) {
printUsage();
System.exit(1);
}
// Get port to bind to
int listenPort = 0;
try {
listenPort = Integer.parseInt(cmd.getOptionValue("port", DEFAULT_LISTEN_PORT));
} catch (NumberFormatException e) {
throw new RuntimeException("Could not parse the value provided for the port option", e);
}
boolean nonblocking = cmd.hasOption("nonblocking");
boolean hsha = cmd.hasOption("hsha");
// Construct correct ProtocolFactory
TProtocolFactory protocolFactory = getTProtocolFactory(cmd.hasOption("compact"));
THBaseService.Iface handler = new ThriftHBaseServiceHandler();
THBaseService.Processor processor = new THBaseService.Processor(handler);
boolean framed = cmd.hasOption("framed") || nonblocking || hsha;
TTransportFactory transportFactory = getTTransportFactory(framed);
// TODO: Remove once HBASE-2155 is resolved
if (cmd.hasOption("bind") && (nonblocking || hsha)) {
log.error("The Nonblocking and HsHaServer servers don't support IP address binding at the moment." +
" See https://issues.apache.org/jira/browse/HBASE-2155 for details.");
printUsage();
System.exit(1);
}
InetSocketAddress inetSocketAddress = bindToPort(cmd.getOptionValue("bind"), listenPort);
if (nonblocking) {
server = getTNonBlockingServer(protocolFactory, processor, transportFactory, inetSocketAddress);
} else if (hsha) {
server = getTHsHaServer(protocolFactory, processor, transportFactory, inetSocketAddress);
} else {
server = getTThreadPoolServer(protocolFactory, processor, transportFactory, inetSocketAddress);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
printUsage();
System.exit(1);
}
server.serve();
}
}

View File

@ -0,0 +1,336 @@
/**
* Copyright 2011 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.thrift2;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.thrift2.generated.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.*;
public class ThriftUtilities {
private ThriftUtilities() {
throw new UnsupportedOperationException("Can't initialize class");
}
/**
* Creates a {@link Get} (HBase) from a {@link TGet} (Thrift).
*
* This ignores any timestamps set on {@link TColumn} objects.
*
* @param in the <code>TGet</code> to convert
*
* @return <code>Get</code> object
*
* @throws IOException if an invalid time range or max version parameter is given
*/
public static Get getFromThrift(TGet in) throws IOException {
Get out = new Get(in.getRow());
// Timestamp overwrites time range if both are set
if (in.isSetTimestamp()) {
out.setTimeStamp(in.getTimestamp());
} else if (in.isSetTimeRange()) {
out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp());
}
if (in.isSetMaxVersions()) {
out.setMaxVersions(in.getMaxVersions());
}
if (!in.isSetColumns()) {
return out;
}
for (TColumn column : in.getColumns()) {
if (column.isSetQualifier()) {
out.addColumn(column.getFamily(), column.getQualifier());
} else {
out.addFamily(column.getFamily());
}
}
return out;
}
/**
* Converts multiple {@link TGet}s (Thrift) into a list of {@link Get}s (HBase).
*
* @param in list of <code>TGet</code>s to convert
*
* @return list of <code>Get</code> objects
*
* @throws IOException if an invalid time range or max version parameter is given
* @see #getFromThrift(TGet)
*/
public static List<Get> getsFromThrift(List<TGet> in) throws IOException {
List<Get> out = new ArrayList<Get>(in.size());
for (TGet get : in) {
out.add(getFromThrift(get));
}
return out;
}
/**
* Creates a {@link TResult} (Thrift) from a {@link Result} (HBase).
*
* @param in the <code>Result</code> to convert
*
* @return converted result, returns an empty result if the input is <code>null</code>
*/
public static TResult resultFromHBase(Result in) {
KeyValue[] raw = in.raw();
TResult out = new TResult();
byte[] row = in.getRow();
if (row != null) {
out.setRow(in.getRow());
}
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
for (KeyValue kv : raw) {
TColumnValue col = new TColumnValue();
col.setFamily(kv.getFamily());
col.setQualifier(kv.getQualifier());
col.setTimestamp(kv.getTimestamp());
col.setValue(kv.getValue());
columnValues.add(col);
}
out.setColumnValues(columnValues);
return out;
}
/**
* Converts multiple {@link Result}s (HBase) into a list of {@link TResult}s (Thrift).
*
* @param in array of <code>Result</code>s to convert
*
* @return list of converted <code>TResult</code>s
*
* @see #resultFromHBase(Result)
*/
public static List<TResult> resultsFromHBase(Result[] in) {
List<TResult> out = new ArrayList<TResult>(in.length);
for (Result result : in) {
out.add(resultFromHBase(result));
}
return out;
}
/**
* Creates a {@link Put} (HBase) from a {@link TPut} (Thrift)
*
* @param in the <code>TPut</code> to convert
*
* @return converted <code>Put</code>
*/
public static Put putFromThrift(TPut in) {
Put out;
if (in.isSetTimestamp()) {
out = new Put(in.getRow(), in.getTimestamp(), null);
} else {
out = new Put(in.getRow());
}
out.setWriteToWAL(in.isWriteToWal());
for (TColumnValue columnValue : in.getColumnValues()) {
if (columnValue.isSetTimestamp()) {
out.add(columnValue.getFamily(), columnValue.getQualifier(), columnValue.getTimestamp(),
columnValue.getValue());
} else {
out.add(columnValue.getFamily(), columnValue.getQualifier(), columnValue.getValue());
}
}
return out;
}
/**
* Converts multiple {@link TPut}s (Thrift) into a list of {@link Put}s (HBase).
*
* @param in list of <code>TPut</code>s to convert
*
* @return list of converted <code>Put</code>s
*
* @see #putFromThrift(TPut)
*/
public static List<Put> putsFromThrift(List<TPut> in) {
List<Put> out = new ArrayList<Put>(in.size());
for (TPut put : in) {
out.add(putFromThrift(put));
}
return out;
}
/**
* Creates a {@link Delete} (HBase) from a {@link TDelete} (Thrift).
*
* @param in the <code>TDelete</code> to convert
*
* @return converted <code>Delete</code>
*/
public static Delete deleteFromThrift(TDelete in) {
Delete out;
if (in.isSetColumns()) {
out = new Delete(in.getRow());
for (TColumn column : in.getColumns()) {
if (column.isSetQualifier()) {
if (column.isSetTimestamp()) {
if (in.isSetDeleteType() &&
in.getDeleteType().equals(TDeleteType.DELETE_COLUMNS))
out.deleteColumns(column.getFamily(), column.getQualifier(), column.getTimestamp());
else
out.deleteColumn(column.getFamily(), column.getQualifier(), column.getTimestamp());
} else {
if (in.isSetDeleteType() &&
in.getDeleteType().equals(TDeleteType.DELETE_COLUMNS))
out.deleteColumns(column.getFamily(), column.getQualifier());
else
out.deleteColumn(column.getFamily(), column.getQualifier());
}
} else {
if (column.isSetTimestamp()) {
out.deleteFamily(column.getFamily(), column.getTimestamp());
} else {
out.deleteFamily(column.getFamily());
}
}
}
} else {
if (in.isSetTimestamp()) {
out = new Delete(in.getRow(), in.getTimestamp(), null);
} else {
out = new Delete(in.getRow());
}
}
return out;
}
/**
* Converts multiple {@link TDelete}s (Thrift) into a list of {@link Delete}s (HBase).
*
* @param in list of <code>TDelete</code>s to convert
*
* @return list of converted <code>Delete</code>s
*
* @see #deleteFromThrift(TDelete)
*/
public static List<Delete> deletesFromThrift(List<TDelete> in) {
List<Delete> out = new ArrayList<Delete>(in.size());
for (TDelete delete : in) {
out.add(deleteFromThrift(delete));
}
return out;
}
public static TDelete deleteFromHBase(Delete in) {
TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));
List<TColumn> columns = new ArrayList<TColumn>();
long rowTimestamp = in.getTimeStamp();
if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
out.setTimestamp(rowTimestamp);
}
// Map<family, List<KeyValue>>
for (Map.Entry<byte[], List<KeyValue>> familyEntry : in.getFamilyMap().entrySet()) {
TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
for (KeyValue keyValue : familyEntry.getValue()) {
byte[] family = keyValue.getFamily();
byte[] qualifier = keyValue.getQualifier();
long timestamp = keyValue.getTimestamp();
if (family != null) {
column.setFamily(family);
}
if (qualifier != null) {
column.setQualifier(qualifier);
}
if (timestamp != HConstants.LATEST_TIMESTAMP) {
column.setTimestamp(keyValue.getTimestamp());
}
}
columns.add(column);
}
out.setColumns(columns);
return out;
}
public static List<TDelete> deletesFromHBase(List<Delete> in) {
List<TDelete> out = new ArrayList<TDelete>(in.size());
for (Delete delete : in) {
if (delete == null) {
out.add(null);
} else {
out.add(deleteFromHBase(delete));
}
}
return out;
}
public static Scan scanFromThrift(TScan in) throws IOException {
Scan out = new Scan();
if (in.isSetStartRow())
out.setStartRow(in.getStartRow());
if (in.isSetStopRow())
out.setStopRow(in.getStopRow());
if (in.isSetCaching())
out.setCaching(in.getCaching());
if (in.isSetMaxVersions()) {
out.setMaxVersions(in.getMaxVersions());
}
if (in.isSetColumns()) {
for (TColumn column : in.getColumns()) {
if (column.isSetQualifier()) {
out.addColumn(column.getFamily(), column.getQualifier());
} else {
out.addFamily(column.getFamily());
}
}
}
TTimeRange timeRange = in.getTimeRange();
if (timeRange != null &&
timeRange.isSetMinStamp() && timeRange.isSetMaxStamp()) {
out.setTimeRange(timeRange.getMinStamp(), timeRange.getMaxStamp());
}
return out;
}
public static Increment incrementFromThrift(TIncrement in) throws IOException {
Increment out = new Increment(in.getRow());
for (TColumnIncrement column : in.getColumns()) {
out.addColumn(column.getFamily(), column.getQualifier(), column.getAmount());
}
out.setWriteToWAL(in.isWriteToWal());
return out;
}
}

View File

@ -0,0 +1,530 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Addresses a single cell or multiple cells
* in a HBase table by column family and optionally
* a column qualifier and timestamp
*/
public class TColumn implements org.apache.thrift.TBase<TColumn, TColumn._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumn");
private static final org.apache.thrift.protocol.TField FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("family", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("qualifier", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3);
public ByteBuffer family; // required
public ByteBuffer qualifier; // required
public long timestamp; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
FAMILY((short)1, "family"),
QUALIFIER((short)2, "qualifier"),
TIMESTAMP((short)3, "timestamp");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // FAMILY
return FAMILY;
case 2: // QUALIFIER
return QUALIFIER;
case 3: // TIMESTAMP
return TIMESTAMP;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.FAMILY, new org.apache.thrift.meta_data.FieldMetaData("family", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("qualifier", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumn.class, metaDataMap);
}
public TColumn() {
}
public TColumn(
ByteBuffer family)
{
this();
this.family = family;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TColumn(TColumn other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetFamily()) {
this.family = org.apache.thrift.TBaseHelper.copyBinary(other.family);
;
}
if (other.isSetQualifier()) {
this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(other.qualifier);
;
}
this.timestamp = other.timestamp;
}
public TColumn deepCopy() {
return new TColumn(this);
}
@Override
public void clear() {
this.family = null;
this.qualifier = null;
setTimestampIsSet(false);
this.timestamp = 0;
}
public byte[] getFamily() {
setFamily(org.apache.thrift.TBaseHelper.rightSize(family));
return family == null ? null : family.array();
}
public ByteBuffer bufferForFamily() {
return family;
}
public TColumn setFamily(byte[] family) {
setFamily(family == null ? (ByteBuffer)null : ByteBuffer.wrap(family));
return this;
}
public TColumn setFamily(ByteBuffer family) {
this.family = family;
return this;
}
public void unsetFamily() {
this.family = null;
}
/** Returns true if field family is set (has been assigned a value) and false otherwise */
public boolean isSetFamily() {
return this.family != null;
}
public void setFamilyIsSet(boolean value) {
if (!value) {
this.family = null;
}
}
public byte[] getQualifier() {
setQualifier(org.apache.thrift.TBaseHelper.rightSize(qualifier));
return qualifier == null ? null : qualifier.array();
}
public ByteBuffer bufferForQualifier() {
return qualifier;
}
public TColumn setQualifier(byte[] qualifier) {
setQualifier(qualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(qualifier));
return this;
}
public TColumn setQualifier(ByteBuffer qualifier) {
this.qualifier = qualifier;
return this;
}
public void unsetQualifier() {
this.qualifier = null;
}
/** Returns true if field qualifier is set (has been assigned a value) and false otherwise */
public boolean isSetQualifier() {
return this.qualifier != null;
}
public void setQualifierIsSet(boolean value) {
if (!value) {
this.qualifier = null;
}
}
public long getTimestamp() {
return this.timestamp;
}
public TColumn setTimestamp(long timestamp) {
this.timestamp = timestamp;
setTimestampIsSet(true);
return this;
}
public void unsetTimestamp() {
__isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
}
/** Returns true if field timestamp is set (has been assigned a value) and false otherwise */
public boolean isSetTimestamp() {
return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
}
public void setTimestampIsSet(boolean value) {
__isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case FAMILY:
if (value == null) {
unsetFamily();
} else {
setFamily((ByteBuffer)value);
}
break;
case QUALIFIER:
if (value == null) {
unsetQualifier();
} else {
setQualifier((ByteBuffer)value);
}
break;
case TIMESTAMP:
if (value == null) {
unsetTimestamp();
} else {
setTimestamp((Long)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case FAMILY:
return getFamily();
case QUALIFIER:
return getQualifier();
case TIMESTAMP:
return Long.valueOf(getTimestamp());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case FAMILY:
return isSetFamily();
case QUALIFIER:
return isSetQualifier();
case TIMESTAMP:
return isSetTimestamp();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TColumn)
return this.equals((TColumn)that);
return false;
}
public boolean equals(TColumn that) {
if (that == null)
return false;
boolean this_present_family = true && this.isSetFamily();
boolean that_present_family = true && that.isSetFamily();
if (this_present_family || that_present_family) {
if (!(this_present_family && that_present_family))
return false;
if (!this.family.equals(that.family))
return false;
}
boolean this_present_qualifier = true && this.isSetQualifier();
boolean that_present_qualifier = true && that.isSetQualifier();
if (this_present_qualifier || that_present_qualifier) {
if (!(this_present_qualifier && that_present_qualifier))
return false;
if (!this.qualifier.equals(that.qualifier))
return false;
}
boolean this_present_timestamp = true && this.isSetTimestamp();
boolean that_present_timestamp = true && that.isSetTimestamp();
if (this_present_timestamp || that_present_timestamp) {
if (!(this_present_timestamp && that_present_timestamp))
return false;
if (this.timestamp != that.timestamp)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TColumn other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TColumn typedOther = (TColumn)other;
lastComparison = Boolean.valueOf(isSetFamily()).compareTo(typedOther.isSetFamily());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetFamily()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.family, typedOther.family);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetQualifier()).compareTo(typedOther.isSetQualifier());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetQualifier()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.qualifier, typedOther.qualifier);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTimestamp()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // FAMILY
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.family = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // QUALIFIER
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.qualifier = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // TIMESTAMP
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.timestamp = iprot.readI64();
setTimestampIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.family != null) {
oprot.writeFieldBegin(FAMILY_FIELD_DESC);
oprot.writeBinary(this.family);
oprot.writeFieldEnd();
}
if (this.qualifier != null) {
if (isSetQualifier()) {
oprot.writeFieldBegin(QUALIFIER_FIELD_DESC);
oprot.writeBinary(this.qualifier);
oprot.writeFieldEnd();
}
}
if (isSetTimestamp()) {
oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
oprot.writeI64(this.timestamp);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TColumn(");
boolean first = true;
sb.append("family:");
if (this.family == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.family, sb);
}
first = false;
if (isSetQualifier()) {
if (!first) sb.append(", ");
sb.append("qualifier:");
if (this.qualifier == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.qualifier, sb);
}
first = false;
}
if (isSetTimestamp()) {
if (!first) sb.append(", ");
sb.append("timestamp:");
sb.append(this.timestamp);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (family == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'family' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,531 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Represents a single cell and the amount to increment it by
*/
public class TColumnIncrement implements org.apache.thrift.TBase<TColumnIncrement, TColumnIncrement._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnIncrement");
private static final org.apache.thrift.protocol.TField FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("family", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("qualifier", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField AMOUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("amount", org.apache.thrift.protocol.TType.I64, (short)3);
public ByteBuffer family; // required
public ByteBuffer qualifier; // required
public long amount; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
FAMILY((short)1, "family"),
QUALIFIER((short)2, "qualifier"),
AMOUNT((short)3, "amount");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // FAMILY
return FAMILY;
case 2: // QUALIFIER
return QUALIFIER;
case 3: // AMOUNT
return AMOUNT;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __AMOUNT_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.FAMILY, new org.apache.thrift.meta_data.FieldMetaData("family", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("qualifier", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.AMOUNT, new org.apache.thrift.meta_data.FieldMetaData("amount", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumnIncrement.class, metaDataMap);
}
public TColumnIncrement() {
this.amount = 1L;
}
public TColumnIncrement(
ByteBuffer family,
ByteBuffer qualifier)
{
this();
this.family = family;
this.qualifier = qualifier;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TColumnIncrement(TColumnIncrement other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetFamily()) {
this.family = org.apache.thrift.TBaseHelper.copyBinary(other.family);
;
}
if (other.isSetQualifier()) {
this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(other.qualifier);
;
}
this.amount = other.amount;
}
public TColumnIncrement deepCopy() {
return new TColumnIncrement(this);
}
@Override
public void clear() {
this.family = null;
this.qualifier = null;
this.amount = 1L;
}
public byte[] getFamily() {
setFamily(org.apache.thrift.TBaseHelper.rightSize(family));
return family == null ? null : family.array();
}
public ByteBuffer bufferForFamily() {
return family;
}
public TColumnIncrement setFamily(byte[] family) {
setFamily(family == null ? (ByteBuffer)null : ByteBuffer.wrap(family));
return this;
}
public TColumnIncrement setFamily(ByteBuffer family) {
this.family = family;
return this;
}
public void unsetFamily() {
this.family = null;
}
/** Returns true if field family is set (has been assigned a value) and false otherwise */
public boolean isSetFamily() {
return this.family != null;
}
public void setFamilyIsSet(boolean value) {
if (!value) {
this.family = null;
}
}
public byte[] getQualifier() {
setQualifier(org.apache.thrift.TBaseHelper.rightSize(qualifier));
return qualifier == null ? null : qualifier.array();
}
public ByteBuffer bufferForQualifier() {
return qualifier;
}
public TColumnIncrement setQualifier(byte[] qualifier) {
setQualifier(qualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(qualifier));
return this;
}
public TColumnIncrement setQualifier(ByteBuffer qualifier) {
this.qualifier = qualifier;
return this;
}
public void unsetQualifier() {
this.qualifier = null;
}
/** Returns true if field qualifier is set (has been assigned a value) and false otherwise */
public boolean isSetQualifier() {
return this.qualifier != null;
}
public void setQualifierIsSet(boolean value) {
if (!value) {
this.qualifier = null;
}
}
public long getAmount() {
return this.amount;
}
public TColumnIncrement setAmount(long amount) {
this.amount = amount;
setAmountIsSet(true);
return this;
}
public void unsetAmount() {
__isset_bit_vector.clear(__AMOUNT_ISSET_ID);
}
/** Returns true if field amount is set (has been assigned a value) and false otherwise */
public boolean isSetAmount() {
return __isset_bit_vector.get(__AMOUNT_ISSET_ID);
}
public void setAmountIsSet(boolean value) {
__isset_bit_vector.set(__AMOUNT_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case FAMILY:
if (value == null) {
unsetFamily();
} else {
setFamily((ByteBuffer)value);
}
break;
case QUALIFIER:
if (value == null) {
unsetQualifier();
} else {
setQualifier((ByteBuffer)value);
}
break;
case AMOUNT:
if (value == null) {
unsetAmount();
} else {
setAmount((Long)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case FAMILY:
return getFamily();
case QUALIFIER:
return getQualifier();
case AMOUNT:
return Long.valueOf(getAmount());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case FAMILY:
return isSetFamily();
case QUALIFIER:
return isSetQualifier();
case AMOUNT:
return isSetAmount();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TColumnIncrement)
return this.equals((TColumnIncrement)that);
return false;
}
public boolean equals(TColumnIncrement that) {
if (that == null)
return false;
boolean this_present_family = true && this.isSetFamily();
boolean that_present_family = true && that.isSetFamily();
if (this_present_family || that_present_family) {
if (!(this_present_family && that_present_family))
return false;
if (!this.family.equals(that.family))
return false;
}
boolean this_present_qualifier = true && this.isSetQualifier();
boolean that_present_qualifier = true && that.isSetQualifier();
if (this_present_qualifier || that_present_qualifier) {
if (!(this_present_qualifier && that_present_qualifier))
return false;
if (!this.qualifier.equals(that.qualifier))
return false;
}
boolean this_present_amount = true && this.isSetAmount();
boolean that_present_amount = true && that.isSetAmount();
if (this_present_amount || that_present_amount) {
if (!(this_present_amount && that_present_amount))
return false;
if (this.amount != that.amount)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TColumnIncrement other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TColumnIncrement typedOther = (TColumnIncrement)other;
lastComparison = Boolean.valueOf(isSetFamily()).compareTo(typedOther.isSetFamily());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetFamily()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.family, typedOther.family);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetQualifier()).compareTo(typedOther.isSetQualifier());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetQualifier()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.qualifier, typedOther.qualifier);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetAmount()).compareTo(typedOther.isSetAmount());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetAmount()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.amount, typedOther.amount);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // FAMILY
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.family = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // QUALIFIER
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.qualifier = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // AMOUNT
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.amount = iprot.readI64();
setAmountIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.family != null) {
oprot.writeFieldBegin(FAMILY_FIELD_DESC);
oprot.writeBinary(this.family);
oprot.writeFieldEnd();
}
if (this.qualifier != null) {
oprot.writeFieldBegin(QUALIFIER_FIELD_DESC);
oprot.writeBinary(this.qualifier);
oprot.writeFieldEnd();
}
if (isSetAmount()) {
oprot.writeFieldBegin(AMOUNT_FIELD_DESC);
oprot.writeI64(this.amount);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TColumnIncrement(");
boolean first = true;
sb.append("family:");
if (this.family == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.family, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("qualifier:");
if (this.qualifier == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.qualifier, sb);
}
first = false;
if (isSetAmount()) {
if (!first) sb.append(", ");
sb.append("amount:");
sb.append(this.amount);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (family == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'family' was not present! Struct: " + toString());
}
if (qualifier == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'qualifier' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,632 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Represents a single cell and its value.
*/
public class TColumnValue implements org.apache.thrift.TBase<TColumnValue, TColumnValue._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnValue");
private static final org.apache.thrift.protocol.TField FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("family", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("qualifier", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)4);
public ByteBuffer family; // required
public ByteBuffer qualifier; // required
public ByteBuffer value; // required
public long timestamp; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
FAMILY((short)1, "family"),
QUALIFIER((short)2, "qualifier"),
VALUE((short)3, "value"),
TIMESTAMP((short)4, "timestamp");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // FAMILY
return FAMILY;
case 2: // QUALIFIER
return QUALIFIER;
case 3: // VALUE
return VALUE;
case 4: // TIMESTAMP
return TIMESTAMP;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.FAMILY, new org.apache.thrift.meta_data.FieldMetaData("family", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("qualifier", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumnValue.class, metaDataMap);
}
public TColumnValue() {
}
public TColumnValue(
ByteBuffer family,
ByteBuffer qualifier,
ByteBuffer value)
{
this();
this.family = family;
this.qualifier = qualifier;
this.value = value;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TColumnValue(TColumnValue other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetFamily()) {
this.family = org.apache.thrift.TBaseHelper.copyBinary(other.family);
;
}
if (other.isSetQualifier()) {
this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(other.qualifier);
;
}
if (other.isSetValue()) {
this.value = org.apache.thrift.TBaseHelper.copyBinary(other.value);
;
}
this.timestamp = other.timestamp;
}
public TColumnValue deepCopy() {
return new TColumnValue(this);
}
@Override
public void clear() {
this.family = null;
this.qualifier = null;
this.value = null;
setTimestampIsSet(false);
this.timestamp = 0;
}
public byte[] getFamily() {
setFamily(org.apache.thrift.TBaseHelper.rightSize(family));
return family == null ? null : family.array();
}
public ByteBuffer bufferForFamily() {
return family;
}
public TColumnValue setFamily(byte[] family) {
setFamily(family == null ? (ByteBuffer)null : ByteBuffer.wrap(family));
return this;
}
public TColumnValue setFamily(ByteBuffer family) {
this.family = family;
return this;
}
public void unsetFamily() {
this.family = null;
}
/** Returns true if field family is set (has been assigned a value) and false otherwise */
public boolean isSetFamily() {
return this.family != null;
}
public void setFamilyIsSet(boolean value) {
if (!value) {
this.family = null;
}
}
public byte[] getQualifier() {
setQualifier(org.apache.thrift.TBaseHelper.rightSize(qualifier));
return qualifier == null ? null : qualifier.array();
}
public ByteBuffer bufferForQualifier() {
return qualifier;
}
public TColumnValue setQualifier(byte[] qualifier) {
setQualifier(qualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(qualifier));
return this;
}
public TColumnValue setQualifier(ByteBuffer qualifier) {
this.qualifier = qualifier;
return this;
}
public void unsetQualifier() {
this.qualifier = null;
}
/** Returns true if field qualifier is set (has been assigned a value) and false otherwise */
public boolean isSetQualifier() {
return this.qualifier != null;
}
public void setQualifierIsSet(boolean value) {
if (!value) {
this.qualifier = null;
}
}
public byte[] getValue() {
setValue(org.apache.thrift.TBaseHelper.rightSize(value));
return value == null ? null : value.array();
}
public ByteBuffer bufferForValue() {
return value;
}
public TColumnValue setValue(byte[] value) {
setValue(value == null ? (ByteBuffer)null : ByteBuffer.wrap(value));
return this;
}
public TColumnValue setValue(ByteBuffer value) {
this.value = value;
return this;
}
public void unsetValue() {
this.value = null;
}
/** Returns true if field value is set (has been assigned a value) and false otherwise */
public boolean isSetValue() {
return this.value != null;
}
public void setValueIsSet(boolean value) {
if (!value) {
this.value = null;
}
}
public long getTimestamp() {
return this.timestamp;
}
public TColumnValue setTimestamp(long timestamp) {
this.timestamp = timestamp;
setTimestampIsSet(true);
return this;
}
public void unsetTimestamp() {
__isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
}
/** Returns true if field timestamp is set (has been assigned a value) and false otherwise */
public boolean isSetTimestamp() {
return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
}
public void setTimestampIsSet(boolean value) {
__isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case FAMILY:
if (value == null) {
unsetFamily();
} else {
setFamily((ByteBuffer)value);
}
break;
case QUALIFIER:
if (value == null) {
unsetQualifier();
} else {
setQualifier((ByteBuffer)value);
}
break;
case VALUE:
if (value == null) {
unsetValue();
} else {
setValue((ByteBuffer)value);
}
break;
case TIMESTAMP:
if (value == null) {
unsetTimestamp();
} else {
setTimestamp((Long)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case FAMILY:
return getFamily();
case QUALIFIER:
return getQualifier();
case VALUE:
return getValue();
case TIMESTAMP:
return Long.valueOf(getTimestamp());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case FAMILY:
return isSetFamily();
case QUALIFIER:
return isSetQualifier();
case VALUE:
return isSetValue();
case TIMESTAMP:
return isSetTimestamp();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TColumnValue)
return this.equals((TColumnValue)that);
return false;
}
public boolean equals(TColumnValue that) {
if (that == null)
return false;
boolean this_present_family = true && this.isSetFamily();
boolean that_present_family = true && that.isSetFamily();
if (this_present_family || that_present_family) {
if (!(this_present_family && that_present_family))
return false;
if (!this.family.equals(that.family))
return false;
}
boolean this_present_qualifier = true && this.isSetQualifier();
boolean that_present_qualifier = true && that.isSetQualifier();
if (this_present_qualifier || that_present_qualifier) {
if (!(this_present_qualifier && that_present_qualifier))
return false;
if (!this.qualifier.equals(that.qualifier))
return false;
}
boolean this_present_value = true && this.isSetValue();
boolean that_present_value = true && that.isSetValue();
if (this_present_value || that_present_value) {
if (!(this_present_value && that_present_value))
return false;
if (!this.value.equals(that.value))
return false;
}
boolean this_present_timestamp = true && this.isSetTimestamp();
boolean that_present_timestamp = true && that.isSetTimestamp();
if (this_present_timestamp || that_present_timestamp) {
if (!(this_present_timestamp && that_present_timestamp))
return false;
if (this.timestamp != that.timestamp)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TColumnValue other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TColumnValue typedOther = (TColumnValue)other;
lastComparison = Boolean.valueOf(isSetFamily()).compareTo(typedOther.isSetFamily());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetFamily()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.family, typedOther.family);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetQualifier()).compareTo(typedOther.isSetQualifier());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetQualifier()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.qualifier, typedOther.qualifier);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetValue()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTimestamp()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // FAMILY
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.family = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // QUALIFIER
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.qualifier = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // VALUE
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.value = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // TIMESTAMP
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.timestamp = iprot.readI64();
setTimestampIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.family != null) {
oprot.writeFieldBegin(FAMILY_FIELD_DESC);
oprot.writeBinary(this.family);
oprot.writeFieldEnd();
}
if (this.qualifier != null) {
oprot.writeFieldBegin(QUALIFIER_FIELD_DESC);
oprot.writeBinary(this.qualifier);
oprot.writeFieldEnd();
}
if (this.value != null) {
oprot.writeFieldBegin(VALUE_FIELD_DESC);
oprot.writeBinary(this.value);
oprot.writeFieldEnd();
}
if (isSetTimestamp()) {
oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
oprot.writeI64(this.timestamp);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TColumnValue(");
boolean first = true;
sb.append("family:");
if (this.family == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.family, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("qualifier:");
if (this.qualifier == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.qualifier, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("value:");
if (this.value == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.value, sb);
}
first = false;
if (isSetTimestamp()) {
if (!first) sb.append(", ");
sb.append("timestamp:");
sb.append(this.timestamp);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (family == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'family' was not present! Struct: " + toString());
}
if (qualifier == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'qualifier' was not present! Struct: " + toString());
}
if (value == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'value' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,685 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Used to perform Delete operations on a single row.
*
* The scope can be further narrowed down by specifying a list of
* columns or column families as TColumns.
*
* Specifying only a family in a TColumn will delete the whole family.
* If a timestamp is specified all versions with a timestamp less than
* or equal to this will be deleted. If no timestamp is specified the
* current time will be used.
*
* Specifying a family and a column qualifier in a TColumn will delete only
* this qualifier. If a timestamp is specified only versions equal
* to this timestamp will be deleted. If no timestamp is specified the
* most recent version will be deleted. To delete all previous versions,
* specify the DELETE_COLUMNS TDeleteType.
*
* The top level timestamp is only used if a complete row should be deleted
* (i.e. no columns are passed) and if it is specified it works the same way
* as if you had added a TColumn for every column family and this timestamp
* (i.e. all versions older than or equal in all column families will be deleted)
*
*/
public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TDelete");
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3);
private static final org.apache.thrift.protocol.TField DELETE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("deleteType", org.apache.thrift.protocol.TType.I32, (short)4);
public ByteBuffer row; // required
public List<TColumn> columns; // required
public long timestamp; // required
/**
*
* @see TDeleteType
*/
public TDeleteType deleteType; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ROW((short)1, "row"),
COLUMNS((short)2, "columns"),
TIMESTAMP((short)3, "timestamp"),
/**
*
* @see TDeleteType
*/
DELETE_TYPE((short)4, "deleteType");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // ROW
return ROW;
case 2: // COLUMNS
return COLUMNS;
case 3: // TIMESTAMP
return TIMESTAMP;
case 4: // DELETE_TYPE
return DELETE_TYPE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumn.class))));
tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.DELETE_TYPE, new org.apache.thrift.meta_data.FieldMetaData("deleteType", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TDeleteType.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TDelete.class, metaDataMap);
}
public TDelete() {
this.deleteType = org.apache.hadoop.hbase.thrift2.generated.TDeleteType.DELETE_COLUMNS;
}
public TDelete(
ByteBuffer row)
{
this();
this.row = row;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TDelete(TDelete other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetRow()) {
this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
;
}
if (other.isSetColumns()) {
List<TColumn> __this__columns = new ArrayList<TColumn>();
for (TColumn other_element : other.columns) {
__this__columns.add(new TColumn(other_element));
}
this.columns = __this__columns;
}
this.timestamp = other.timestamp;
if (other.isSetDeleteType()) {
this.deleteType = other.deleteType;
}
}
public TDelete deepCopy() {
return new TDelete(this);
}
@Override
public void clear() {
this.row = null;
this.columns = null;
setTimestampIsSet(false);
this.timestamp = 0;
this.deleteType = org.apache.hadoop.hbase.thrift2.generated.TDeleteType.DELETE_COLUMNS;
}
public byte[] getRow() {
setRow(org.apache.thrift.TBaseHelper.rightSize(row));
return row == null ? null : row.array();
}
public ByteBuffer bufferForRow() {
return row;
}
public TDelete setRow(byte[] row) {
setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
return this;
}
public TDelete setRow(ByteBuffer row) {
this.row = row;
return this;
}
public void unsetRow() {
this.row = null;
}
/** Returns true if field row is set (has been assigned a value) and false otherwise */
public boolean isSetRow() {
return this.row != null;
}
public void setRowIsSet(boolean value) {
if (!value) {
this.row = null;
}
}
public int getColumnsSize() {
return (this.columns == null) ? 0 : this.columns.size();
}
public java.util.Iterator<TColumn> getColumnsIterator() {
return (this.columns == null) ? null : this.columns.iterator();
}
public void addToColumns(TColumn elem) {
if (this.columns == null) {
this.columns = new ArrayList<TColumn>();
}
this.columns.add(elem);
}
public List<TColumn> getColumns() {
return this.columns;
}
public TDelete setColumns(List<TColumn> columns) {
this.columns = columns;
return this;
}
public void unsetColumns() {
this.columns = null;
}
/** Returns true if field columns is set (has been assigned a value) and false otherwise */
public boolean isSetColumns() {
return this.columns != null;
}
public void setColumnsIsSet(boolean value) {
if (!value) {
this.columns = null;
}
}
public long getTimestamp() {
return this.timestamp;
}
public TDelete setTimestamp(long timestamp) {
this.timestamp = timestamp;
setTimestampIsSet(true);
return this;
}
public void unsetTimestamp() {
__isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
}
/** Returns true if field timestamp is set (has been assigned a value) and false otherwise */
public boolean isSetTimestamp() {
return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
}
public void setTimestampIsSet(boolean value) {
__isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
}
/**
*
* @see TDeleteType
*/
public TDeleteType getDeleteType() {
return this.deleteType;
}
/**
*
* @see TDeleteType
*/
public TDelete setDeleteType(TDeleteType deleteType) {
this.deleteType = deleteType;
return this;
}
public void unsetDeleteType() {
this.deleteType = null;
}
/** Returns true if field deleteType is set (has been assigned a value) and false otherwise */
public boolean isSetDeleteType() {
return this.deleteType != null;
}
public void setDeleteTypeIsSet(boolean value) {
if (!value) {
this.deleteType = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
if (value == null) {
unsetRow();
} else {
setRow((ByteBuffer)value);
}
break;
case COLUMNS:
if (value == null) {
unsetColumns();
} else {
setColumns((List<TColumn>)value);
}
break;
case TIMESTAMP:
if (value == null) {
unsetTimestamp();
} else {
setTimestamp((Long)value);
}
break;
case DELETE_TYPE:
if (value == null) {
unsetDeleteType();
} else {
setDeleteType((TDeleteType)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case ROW:
return getRow();
case COLUMNS:
return getColumns();
case TIMESTAMP:
return Long.valueOf(getTimestamp());
case DELETE_TYPE:
return getDeleteType();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case ROW:
return isSetRow();
case COLUMNS:
return isSetColumns();
case TIMESTAMP:
return isSetTimestamp();
case DELETE_TYPE:
return isSetDeleteType();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TDelete)
return this.equals((TDelete)that);
return false;
}
public boolean equals(TDelete that) {
if (that == null)
return false;
boolean this_present_row = true && this.isSetRow();
boolean that_present_row = true && that.isSetRow();
if (this_present_row || that_present_row) {
if (!(this_present_row && that_present_row))
return false;
if (!this.row.equals(that.row))
return false;
}
boolean this_present_columns = true && this.isSetColumns();
boolean that_present_columns = true && that.isSetColumns();
if (this_present_columns || that_present_columns) {
if (!(this_present_columns && that_present_columns))
return false;
if (!this.columns.equals(that.columns))
return false;
}
boolean this_present_timestamp = true && this.isSetTimestamp();
boolean that_present_timestamp = true && that.isSetTimestamp();
if (this_present_timestamp || that_present_timestamp) {
if (!(this_present_timestamp && that_present_timestamp))
return false;
if (this.timestamp != that.timestamp)
return false;
}
boolean this_present_deleteType = true && this.isSetDeleteType();
boolean that_present_deleteType = true && that.isSetDeleteType();
if (this_present_deleteType || that_present_deleteType) {
if (!(this_present_deleteType && that_present_deleteType))
return false;
if (!this.deleteType.equals(that.deleteType))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TDelete other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TDelete typedOther = (TDelete)other;
lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRow()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetColumns()).compareTo(typedOther.isSetColumns());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetColumns()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columns, typedOther.columns);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTimestamp()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDeleteType()).compareTo(typedOther.isSetDeleteType());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDeleteType()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.deleteType, typedOther.deleteType);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // ROW
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.row = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // COLUMNS
if (field.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list12 = iprot.readListBegin();
this.columns = new ArrayList<TColumn>(_list12.size);
for (int _i13 = 0; _i13 < _list12.size; ++_i13)
{
TColumn _elem14; // required
_elem14 = new TColumn();
_elem14.read(iprot);
this.columns.add(_elem14);
}
iprot.readListEnd();
}
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // TIMESTAMP
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.timestamp = iprot.readI64();
setTimestampIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // DELETE_TYPE
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.deleteType = TDeleteType.findByValue(iprot.readI32());
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.row != null) {
oprot.writeFieldBegin(ROW_FIELD_DESC);
oprot.writeBinary(this.row);
oprot.writeFieldEnd();
}
if (this.columns != null) {
if (isSetColumns()) {
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.columns.size()));
for (TColumn _iter15 : this.columns)
{
_iter15.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
}
if (isSetTimestamp()) {
oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
oprot.writeI64(this.timestamp);
oprot.writeFieldEnd();
}
if (this.deleteType != null) {
if (isSetDeleteType()) {
oprot.writeFieldBegin(DELETE_TYPE_FIELD_DESC);
oprot.writeI32(this.deleteType.getValue());
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TDelete(");
boolean first = true;
sb.append("row:");
if (this.row == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.row, sb);
}
first = false;
if (isSetColumns()) {
if (!first) sb.append(", ");
sb.append("columns:");
if (this.columns == null) {
sb.append("null");
} else {
sb.append(this.columns);
}
first = false;
}
if (isSetTimestamp()) {
if (!first) sb.append(", ");
sb.append("timestamp:");
sb.append(this.timestamp);
first = false;
}
if (isSetDeleteType()) {
if (!first) sb.append(", ");
sb.append("deleteType:");
if (this.deleteType == null) {
sb.append("null");
} else {
sb.append(this.deleteType);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (row == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'row' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,49 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.Map;
import java.util.HashMap;
import org.apache.thrift.TEnum;
/**
* Specify type of delete:
* - DELETE_COLUMN means exactly one version will be removed,
* - DELETE_COLUMNS means previous versions will also be removed.
*/
public enum TDeleteType implements org.apache.thrift.TEnum {
DELETE_COLUMN(0),
DELETE_COLUMNS(1);
private final int value;
private TDeleteType(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
public static TDeleteType findByValue(int value) {
switch (value) {
case 0:
return DELETE_COLUMN;
case 1:
return DELETE_COLUMNS;
default:
return null;
}
}
}

View File

@ -0,0 +1,744 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Used to perform Get operations on a single row.
*
* The scope can be further narrowed down by specifying a list of
* columns or column families.
*
* To get everything for a row, instantiate a Get object with just the row to get.
* To further define the scope of what to get you can add a timestamp or time range
* with an optional maximum number of versions to return.
*
* If you specify a time range and a timestamp the range is ignored.
* Timestamps on TColumns are ignored.
*
* TODO: Filter, Locks
*/
public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TGet");
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3);
private static final org.apache.thrift.protocol.TField TIME_RANGE_FIELD_DESC = new org.apache.thrift.protocol.TField("timeRange", org.apache.thrift.protocol.TType.STRUCT, (short)4);
private static final org.apache.thrift.protocol.TField MAX_VERSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("maxVersions", org.apache.thrift.protocol.TType.I32, (short)5);
public ByteBuffer row; // required
public List<TColumn> columns; // required
public long timestamp; // required
public TTimeRange timeRange; // required
public int maxVersions; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ROW((short)1, "row"),
COLUMNS((short)2, "columns"),
TIMESTAMP((short)3, "timestamp"),
TIME_RANGE((short)4, "timeRange"),
MAX_VERSIONS((short)5, "maxVersions");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // ROW
return ROW;
case 2: // COLUMNS
return COLUMNS;
case 3: // TIMESTAMP
return TIMESTAMP;
case 4: // TIME_RANGE
return TIME_RANGE;
case 5: // MAX_VERSIONS
return MAX_VERSIONS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private static final int __MAXVERSIONS_ISSET_ID = 1;
private BitSet __isset_bit_vector = new BitSet(2);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumn.class))));
tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.TIME_RANGE, new org.apache.thrift.meta_data.FieldMetaData("timeRange", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTimeRange.class)));
tmpMap.put(_Fields.MAX_VERSIONS, new org.apache.thrift.meta_data.FieldMetaData("maxVersions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TGet.class, metaDataMap);
}
public TGet() {
}
public TGet(
ByteBuffer row)
{
this();
this.row = row;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TGet(TGet other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetRow()) {
this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
;
}
if (other.isSetColumns()) {
List<TColumn> __this__columns = new ArrayList<TColumn>();
for (TColumn other_element : other.columns) {
__this__columns.add(new TColumn(other_element));
}
this.columns = __this__columns;
}
this.timestamp = other.timestamp;
if (other.isSetTimeRange()) {
this.timeRange = new TTimeRange(other.timeRange);
}
this.maxVersions = other.maxVersions;
}
public TGet deepCopy() {
return new TGet(this);
}
@Override
public void clear() {
this.row = null;
this.columns = null;
setTimestampIsSet(false);
this.timestamp = 0;
this.timeRange = null;
setMaxVersionsIsSet(false);
this.maxVersions = 0;
}
public byte[] getRow() {
setRow(org.apache.thrift.TBaseHelper.rightSize(row));
return row == null ? null : row.array();
}
public ByteBuffer bufferForRow() {
return row;
}
public TGet setRow(byte[] row) {
setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
return this;
}
public TGet setRow(ByteBuffer row) {
this.row = row;
return this;
}
public void unsetRow() {
this.row = null;
}
/** Returns true if field row is set (has been assigned a value) and false otherwise */
public boolean isSetRow() {
return this.row != null;
}
public void setRowIsSet(boolean value) {
if (!value) {
this.row = null;
}
}
public int getColumnsSize() {
return (this.columns == null) ? 0 : this.columns.size();
}
public java.util.Iterator<TColumn> getColumnsIterator() {
return (this.columns == null) ? null : this.columns.iterator();
}
public void addToColumns(TColumn elem) {
if (this.columns == null) {
this.columns = new ArrayList<TColumn>();
}
this.columns.add(elem);
}
public List<TColumn> getColumns() {
return this.columns;
}
public TGet setColumns(List<TColumn> columns) {
this.columns = columns;
return this;
}
public void unsetColumns() {
this.columns = null;
}
/** Returns true if field columns is set (has been assigned a value) and false otherwise */
public boolean isSetColumns() {
return this.columns != null;
}
public void setColumnsIsSet(boolean value) {
if (!value) {
this.columns = null;
}
}
public long getTimestamp() {
return this.timestamp;
}
public TGet setTimestamp(long timestamp) {
this.timestamp = timestamp;
setTimestampIsSet(true);
return this;
}
public void unsetTimestamp() {
__isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
}
/** Returns true if field timestamp is set (has been assigned a value) and false otherwise */
public boolean isSetTimestamp() {
return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
}
public void setTimestampIsSet(boolean value) {
__isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
}
public TTimeRange getTimeRange() {
return this.timeRange;
}
public TGet setTimeRange(TTimeRange timeRange) {
this.timeRange = timeRange;
return this;
}
public void unsetTimeRange() {
this.timeRange = null;
}
/** Returns true if field timeRange is set (has been assigned a value) and false otherwise */
public boolean isSetTimeRange() {
return this.timeRange != null;
}
public void setTimeRangeIsSet(boolean value) {
if (!value) {
this.timeRange = null;
}
}
public int getMaxVersions() {
return this.maxVersions;
}
public TGet setMaxVersions(int maxVersions) {
this.maxVersions = maxVersions;
setMaxVersionsIsSet(true);
return this;
}
public void unsetMaxVersions() {
__isset_bit_vector.clear(__MAXVERSIONS_ISSET_ID);
}
/** Returns true if field maxVersions is set (has been assigned a value) and false otherwise */
public boolean isSetMaxVersions() {
return __isset_bit_vector.get(__MAXVERSIONS_ISSET_ID);
}
public void setMaxVersionsIsSet(boolean value) {
__isset_bit_vector.set(__MAXVERSIONS_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
if (value == null) {
unsetRow();
} else {
setRow((ByteBuffer)value);
}
break;
case COLUMNS:
if (value == null) {
unsetColumns();
} else {
setColumns((List<TColumn>)value);
}
break;
case TIMESTAMP:
if (value == null) {
unsetTimestamp();
} else {
setTimestamp((Long)value);
}
break;
case TIME_RANGE:
if (value == null) {
unsetTimeRange();
} else {
setTimeRange((TTimeRange)value);
}
break;
case MAX_VERSIONS:
if (value == null) {
unsetMaxVersions();
} else {
setMaxVersions((Integer)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case ROW:
return getRow();
case COLUMNS:
return getColumns();
case TIMESTAMP:
return Long.valueOf(getTimestamp());
case TIME_RANGE:
return getTimeRange();
case MAX_VERSIONS:
return Integer.valueOf(getMaxVersions());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case ROW:
return isSetRow();
case COLUMNS:
return isSetColumns();
case TIMESTAMP:
return isSetTimestamp();
case TIME_RANGE:
return isSetTimeRange();
case MAX_VERSIONS:
return isSetMaxVersions();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TGet)
return this.equals((TGet)that);
return false;
}
public boolean equals(TGet that) {
if (that == null)
return false;
boolean this_present_row = true && this.isSetRow();
boolean that_present_row = true && that.isSetRow();
if (this_present_row || that_present_row) {
if (!(this_present_row && that_present_row))
return false;
if (!this.row.equals(that.row))
return false;
}
boolean this_present_columns = true && this.isSetColumns();
boolean that_present_columns = true && that.isSetColumns();
if (this_present_columns || that_present_columns) {
if (!(this_present_columns && that_present_columns))
return false;
if (!this.columns.equals(that.columns))
return false;
}
boolean this_present_timestamp = true && this.isSetTimestamp();
boolean that_present_timestamp = true && that.isSetTimestamp();
if (this_present_timestamp || that_present_timestamp) {
if (!(this_present_timestamp && that_present_timestamp))
return false;
if (this.timestamp != that.timestamp)
return false;
}
boolean this_present_timeRange = true && this.isSetTimeRange();
boolean that_present_timeRange = true && that.isSetTimeRange();
if (this_present_timeRange || that_present_timeRange) {
if (!(this_present_timeRange && that_present_timeRange))
return false;
if (!this.timeRange.equals(that.timeRange))
return false;
}
boolean this_present_maxVersions = true && this.isSetMaxVersions();
boolean that_present_maxVersions = true && that.isSetMaxVersions();
if (this_present_maxVersions || that_present_maxVersions) {
if (!(this_present_maxVersions && that_present_maxVersions))
return false;
if (this.maxVersions != that.maxVersions)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TGet other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TGet typedOther = (TGet)other;
lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRow()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetColumns()).compareTo(typedOther.isSetColumns());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetColumns()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columns, typedOther.columns);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTimestamp()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTimeRange()).compareTo(typedOther.isSetTimeRange());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTimeRange()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timeRange, typedOther.timeRange);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetMaxVersions()).compareTo(typedOther.isSetMaxVersions());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMaxVersions()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.maxVersions, typedOther.maxVersions);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // ROW
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.row = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // COLUMNS
if (field.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list4 = iprot.readListBegin();
this.columns = new ArrayList<TColumn>(_list4.size);
for (int _i5 = 0; _i5 < _list4.size; ++_i5)
{
TColumn _elem6; // required
_elem6 = new TColumn();
_elem6.read(iprot);
this.columns.add(_elem6);
}
iprot.readListEnd();
}
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // TIMESTAMP
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.timestamp = iprot.readI64();
setTimestampIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // TIME_RANGE
if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
this.timeRange = new TTimeRange();
this.timeRange.read(iprot);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 5: // MAX_VERSIONS
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.maxVersions = iprot.readI32();
setMaxVersionsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.row != null) {
oprot.writeFieldBegin(ROW_FIELD_DESC);
oprot.writeBinary(this.row);
oprot.writeFieldEnd();
}
if (this.columns != null) {
if (isSetColumns()) {
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.columns.size()));
for (TColumn _iter7 : this.columns)
{
_iter7.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
}
if (isSetTimestamp()) {
oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
oprot.writeI64(this.timestamp);
oprot.writeFieldEnd();
}
if (this.timeRange != null) {
if (isSetTimeRange()) {
oprot.writeFieldBegin(TIME_RANGE_FIELD_DESC);
this.timeRange.write(oprot);
oprot.writeFieldEnd();
}
}
if (isSetMaxVersions()) {
oprot.writeFieldBegin(MAX_VERSIONS_FIELD_DESC);
oprot.writeI32(this.maxVersions);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TGet(");
boolean first = true;
sb.append("row:");
if (this.row == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.row, sb);
}
first = false;
if (isSetColumns()) {
if (!first) sb.append(", ");
sb.append("columns:");
if (this.columns == null) {
sb.append("null");
} else {
sb.append(this.columns);
}
first = false;
}
if (isSetTimestamp()) {
if (!first) sb.append(", ");
sb.append("timestamp:");
sb.append(this.timestamp);
first = false;
}
if (isSetTimeRange()) {
if (!first) sb.append(", ");
sb.append("timeRange:");
if (this.timeRange == null) {
sb.append("null");
} else {
sb.append(this.timeRange);
}
first = false;
}
if (isSetMaxVersions()) {
if (!first) sb.append(", ");
sb.append("maxVersions:");
sb.append(this.maxVersions);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (row == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'row' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,321 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A TIOError exception signals that an error occurred communicating
* to the HBase master or a HBase region server. Also used to return
* more general HBase error conditions.
*/
public class TIOError extends Exception implements org.apache.thrift.TBase<TIOError, TIOError._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIOError");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
public String message; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MESSAGE((short)1, "message");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // MESSAGE
return MESSAGE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIOError.class, metaDataMap);
}
public TIOError() {
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TIOError(TIOError other) {
if (other.isSetMessage()) {
this.message = other.message;
}
}
public TIOError deepCopy() {
return new TIOError(this);
}
@Override
public void clear() {
this.message = null;
}
public String getMessage() {
return this.message;
}
public TIOError setMessage(String message) {
this.message = message;
return this;
}
public void unsetMessage() {
this.message = null;
}
/** Returns true if field message is set (has been assigned a value) and false otherwise */
public boolean isSetMessage() {
return this.message != null;
}
public void setMessageIsSet(boolean value) {
if (!value) {
this.message = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case MESSAGE:
return isSetMessage();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TIOError)
return this.equals((TIOError)that);
return false;
}
public boolean equals(TIOError that) {
if (that == null)
return false;
boolean this_present_message = true && this.isSetMessage();
boolean that_present_message = true && that.isSetMessage();
if (this_present_message || that_present_message) {
if (!(this_present_message && that_present_message))
return false;
if (!this.message.equals(that.message))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TIOError other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TIOError typedOther = (TIOError)other;
lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMessage()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // MESSAGE
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.message = iprot.readString();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.message != null) {
if (isSetMessage()) {
oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
oprot.writeString(this.message);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TIOError(");
boolean first = true;
if (isSetMessage()) {
sb.append("message:");
if (this.message == null) {
sb.append("null");
} else {
sb.append(this.message);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,320 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A TIllegalArgument exception indicates an illegal or invalid
* argument was passed into a procedure.
*/
public class TIllegalArgument extends Exception implements org.apache.thrift.TBase<TIllegalArgument, TIllegalArgument._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIllegalArgument");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
public String message; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MESSAGE((short)1, "message");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // MESSAGE
return MESSAGE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIllegalArgument.class, metaDataMap);
}
public TIllegalArgument() {
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TIllegalArgument(TIllegalArgument other) {
if (other.isSetMessage()) {
this.message = other.message;
}
}
public TIllegalArgument deepCopy() {
return new TIllegalArgument(this);
}
@Override
public void clear() {
this.message = null;
}
public String getMessage() {
return this.message;
}
public TIllegalArgument setMessage(String message) {
this.message = message;
return this;
}
public void unsetMessage() {
this.message = null;
}
/** Returns true if field message is set (has been assigned a value) and false otherwise */
public boolean isSetMessage() {
return this.message != null;
}
public void setMessageIsSet(boolean value) {
if (!value) {
this.message = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case MESSAGE:
return isSetMessage();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TIllegalArgument)
return this.equals((TIllegalArgument)that);
return false;
}
public boolean equals(TIllegalArgument that) {
if (that == null)
return false;
boolean this_present_message = true && this.isSetMessage();
boolean that_present_message = true && that.isSetMessage();
if (this_present_message || that_present_message) {
if (!(this_present_message && that_present_message))
return false;
if (!this.message.equals(that.message))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TIllegalArgument other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TIllegalArgument typedOther = (TIllegalArgument)other;
lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMessage()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // MESSAGE
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.message = iprot.readString();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.message != null) {
if (isSetMessage()) {
oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
oprot.writeString(this.message);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TIllegalArgument(");
boolean first = true;
if (isSetMessage()) {
sb.append("message:");
if (this.message == null) {
sb.append("null");
} else {
sb.append(this.message);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,561 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Used to perform Increment operations for a single row.
*
* You can specify if this Increment should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncrement._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIncrement");
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField WRITE_TO_WAL_FIELD_DESC = new org.apache.thrift.protocol.TField("writeToWal", org.apache.thrift.protocol.TType.BOOL, (short)3);
public ByteBuffer row; // required
public List<TColumnIncrement> columns; // required
public boolean writeToWal; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ROW((short)1, "row"),
COLUMNS((short)2, "columns"),
WRITE_TO_WAL((short)3, "writeToWal");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // ROW
return ROW;
case 2: // COLUMNS
return COLUMNS;
case 3: // WRITE_TO_WAL
return WRITE_TO_WAL;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __WRITETOWAL_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumnIncrement.class))));
tmpMap.put(_Fields.WRITE_TO_WAL, new org.apache.thrift.meta_data.FieldMetaData("writeToWal", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIncrement.class, metaDataMap);
}
public TIncrement() {
this.writeToWal = true;
}
public TIncrement(
ByteBuffer row,
List<TColumnIncrement> columns)
{
this();
this.row = row;
this.columns = columns;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TIncrement(TIncrement other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetRow()) {
this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
;
}
if (other.isSetColumns()) {
List<TColumnIncrement> __this__columns = new ArrayList<TColumnIncrement>();
for (TColumnIncrement other_element : other.columns) {
__this__columns.add(new TColumnIncrement(other_element));
}
this.columns = __this__columns;
}
this.writeToWal = other.writeToWal;
}
public TIncrement deepCopy() {
return new TIncrement(this);
}
@Override
public void clear() {
this.row = null;
this.columns = null;
this.writeToWal = true;
}
public byte[] getRow() {
setRow(org.apache.thrift.TBaseHelper.rightSize(row));
return row == null ? null : row.array();
}
public ByteBuffer bufferForRow() {
return row;
}
public TIncrement setRow(byte[] row) {
setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
return this;
}
public TIncrement setRow(ByteBuffer row) {
this.row = row;
return this;
}
public void unsetRow() {
this.row = null;
}
/** Returns true if field row is set (has been assigned a value) and false otherwise */
public boolean isSetRow() {
return this.row != null;
}
public void setRowIsSet(boolean value) {
if (!value) {
this.row = null;
}
}
public int getColumnsSize() {
return (this.columns == null) ? 0 : this.columns.size();
}
public java.util.Iterator<TColumnIncrement> getColumnsIterator() {
return (this.columns == null) ? null : this.columns.iterator();
}
public void addToColumns(TColumnIncrement elem) {
if (this.columns == null) {
this.columns = new ArrayList<TColumnIncrement>();
}
this.columns.add(elem);
}
public List<TColumnIncrement> getColumns() {
return this.columns;
}
public TIncrement setColumns(List<TColumnIncrement> columns) {
this.columns = columns;
return this;
}
public void unsetColumns() {
this.columns = null;
}
/** Returns true if field columns is set (has been assigned a value) and false otherwise */
public boolean isSetColumns() {
return this.columns != null;
}
public void setColumnsIsSet(boolean value) {
if (!value) {
this.columns = null;
}
}
public boolean isWriteToWal() {
return this.writeToWal;
}
public TIncrement setWriteToWal(boolean writeToWal) {
this.writeToWal = writeToWal;
setWriteToWalIsSet(true);
return this;
}
public void unsetWriteToWal() {
__isset_bit_vector.clear(__WRITETOWAL_ISSET_ID);
}
/** Returns true if field writeToWal is set (has been assigned a value) and false otherwise */
public boolean isSetWriteToWal() {
return __isset_bit_vector.get(__WRITETOWAL_ISSET_ID);
}
public void setWriteToWalIsSet(boolean value) {
__isset_bit_vector.set(__WRITETOWAL_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
if (value == null) {
unsetRow();
} else {
setRow((ByteBuffer)value);
}
break;
case COLUMNS:
if (value == null) {
unsetColumns();
} else {
setColumns((List<TColumnIncrement>)value);
}
break;
case WRITE_TO_WAL:
if (value == null) {
unsetWriteToWal();
} else {
setWriteToWal((Boolean)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case ROW:
return getRow();
case COLUMNS:
return getColumns();
case WRITE_TO_WAL:
return Boolean.valueOf(isWriteToWal());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case ROW:
return isSetRow();
case COLUMNS:
return isSetColumns();
case WRITE_TO_WAL:
return isSetWriteToWal();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TIncrement)
return this.equals((TIncrement)that);
return false;
}
public boolean equals(TIncrement that) {
if (that == null)
return false;
boolean this_present_row = true && this.isSetRow();
boolean that_present_row = true && that.isSetRow();
if (this_present_row || that_present_row) {
if (!(this_present_row && that_present_row))
return false;
if (!this.row.equals(that.row))
return false;
}
boolean this_present_columns = true && this.isSetColumns();
boolean that_present_columns = true && that.isSetColumns();
if (this_present_columns || that_present_columns) {
if (!(this_present_columns && that_present_columns))
return false;
if (!this.columns.equals(that.columns))
return false;
}
boolean this_present_writeToWal = true && this.isSetWriteToWal();
boolean that_present_writeToWal = true && that.isSetWriteToWal();
if (this_present_writeToWal || that_present_writeToWal) {
if (!(this_present_writeToWal && that_present_writeToWal))
return false;
if (this.writeToWal != that.writeToWal)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TIncrement other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TIncrement typedOther = (TIncrement)other;
lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRow()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetColumns()).compareTo(typedOther.isSetColumns());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetColumns()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columns, typedOther.columns);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetWriteToWal()).compareTo(typedOther.isSetWriteToWal());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetWriteToWal()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.writeToWal, typedOther.writeToWal);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // ROW
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.row = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // COLUMNS
if (field.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list16 = iprot.readListBegin();
this.columns = new ArrayList<TColumnIncrement>(_list16.size);
for (int _i17 = 0; _i17 < _list16.size; ++_i17)
{
TColumnIncrement _elem18; // required
_elem18 = new TColumnIncrement();
_elem18.read(iprot);
this.columns.add(_elem18);
}
iprot.readListEnd();
}
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // WRITE_TO_WAL
if (field.type == org.apache.thrift.protocol.TType.BOOL) {
this.writeToWal = iprot.readBool();
setWriteToWalIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.row != null) {
oprot.writeFieldBegin(ROW_FIELD_DESC);
oprot.writeBinary(this.row);
oprot.writeFieldEnd();
}
if (this.columns != null) {
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.columns.size()));
for (TColumnIncrement _iter19 : this.columns)
{
_iter19.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
if (isSetWriteToWal()) {
oprot.writeFieldBegin(WRITE_TO_WAL_FIELD_DESC);
oprot.writeBool(this.writeToWal);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TIncrement(");
boolean first = true;
sb.append("row:");
if (this.row == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.row, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("columns:");
if (this.columns == null) {
sb.append("null");
} else {
sb.append(this.columns);
}
first = false;
if (isSetWriteToWal()) {
if (!first) sb.append(", ");
sb.append("writeToWal:");
sb.append(this.writeToWal);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (row == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'row' was not present! Struct: " + toString());
}
if (columns == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'columns' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,651 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Used to perform Put operations for a single row.
*
* Add column values to this object and they'll be added.
* You can provide a default timestamp if the column values
* don't have one. If you don't provide a default timestamp
* the current time is inserted.
*
* You can also specify if this Put should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TPut");
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMN_VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("columnValues", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3);
private static final org.apache.thrift.protocol.TField WRITE_TO_WAL_FIELD_DESC = new org.apache.thrift.protocol.TField("writeToWal", org.apache.thrift.protocol.TType.BOOL, (short)4);
public ByteBuffer row; // required
public List<TColumnValue> columnValues; // required
public long timestamp; // required
public boolean writeToWal; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ROW((short)1, "row"),
COLUMN_VALUES((short)2, "columnValues"),
TIMESTAMP((short)3, "timestamp"),
WRITE_TO_WAL((short)4, "writeToWal");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // ROW
return ROW;
case 2: // COLUMN_VALUES
return COLUMN_VALUES;
case 3: // TIMESTAMP
return TIMESTAMP;
case 4: // WRITE_TO_WAL
return WRITE_TO_WAL;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private static final int __WRITETOWAL_ISSET_ID = 1;
private BitSet __isset_bit_vector = new BitSet(2);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.COLUMN_VALUES, new org.apache.thrift.meta_data.FieldMetaData("columnValues", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumnValue.class))));
tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.WRITE_TO_WAL, new org.apache.thrift.meta_data.FieldMetaData("writeToWal", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TPut.class, metaDataMap);
}
public TPut() {
this.writeToWal = true;
}
public TPut(
ByteBuffer row,
List<TColumnValue> columnValues)
{
this();
this.row = row;
this.columnValues = columnValues;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TPut(TPut other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetRow()) {
this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
;
}
if (other.isSetColumnValues()) {
List<TColumnValue> __this__columnValues = new ArrayList<TColumnValue>();
for (TColumnValue other_element : other.columnValues) {
__this__columnValues.add(new TColumnValue(other_element));
}
this.columnValues = __this__columnValues;
}
this.timestamp = other.timestamp;
this.writeToWal = other.writeToWal;
}
public TPut deepCopy() {
return new TPut(this);
}
@Override
public void clear() {
this.row = null;
this.columnValues = null;
setTimestampIsSet(false);
this.timestamp = 0;
this.writeToWal = true;
}
public byte[] getRow() {
setRow(org.apache.thrift.TBaseHelper.rightSize(row));
return row == null ? null : row.array();
}
public ByteBuffer bufferForRow() {
return row;
}
public TPut setRow(byte[] row) {
setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
return this;
}
public TPut setRow(ByteBuffer row) {
this.row = row;
return this;
}
public void unsetRow() {
this.row = null;
}
/** Returns true if field row is set (has been assigned a value) and false otherwise */
public boolean isSetRow() {
return this.row != null;
}
public void setRowIsSet(boolean value) {
if (!value) {
this.row = null;
}
}
public int getColumnValuesSize() {
return (this.columnValues == null) ? 0 : this.columnValues.size();
}
public java.util.Iterator<TColumnValue> getColumnValuesIterator() {
return (this.columnValues == null) ? null : this.columnValues.iterator();
}
public void addToColumnValues(TColumnValue elem) {
if (this.columnValues == null) {
this.columnValues = new ArrayList<TColumnValue>();
}
this.columnValues.add(elem);
}
public List<TColumnValue> getColumnValues() {
return this.columnValues;
}
public TPut setColumnValues(List<TColumnValue> columnValues) {
this.columnValues = columnValues;
return this;
}
public void unsetColumnValues() {
this.columnValues = null;
}
/** Returns true if field columnValues is set (has been assigned a value) and false otherwise */
public boolean isSetColumnValues() {
return this.columnValues != null;
}
public void setColumnValuesIsSet(boolean value) {
if (!value) {
this.columnValues = null;
}
}
public long getTimestamp() {
return this.timestamp;
}
public TPut setTimestamp(long timestamp) {
this.timestamp = timestamp;
setTimestampIsSet(true);
return this;
}
public void unsetTimestamp() {
__isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
}
/** Returns true if field timestamp is set (has been assigned a value) and false otherwise */
public boolean isSetTimestamp() {
return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
}
public void setTimestampIsSet(boolean value) {
__isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
}
public boolean isWriteToWal() {
return this.writeToWal;
}
public TPut setWriteToWal(boolean writeToWal) {
this.writeToWal = writeToWal;
setWriteToWalIsSet(true);
return this;
}
public void unsetWriteToWal() {
__isset_bit_vector.clear(__WRITETOWAL_ISSET_ID);
}
/** Returns true if field writeToWal is set (has been assigned a value) and false otherwise */
public boolean isSetWriteToWal() {
return __isset_bit_vector.get(__WRITETOWAL_ISSET_ID);
}
public void setWriteToWalIsSet(boolean value) {
__isset_bit_vector.set(__WRITETOWAL_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
if (value == null) {
unsetRow();
} else {
setRow((ByteBuffer)value);
}
break;
case COLUMN_VALUES:
if (value == null) {
unsetColumnValues();
} else {
setColumnValues((List<TColumnValue>)value);
}
break;
case TIMESTAMP:
if (value == null) {
unsetTimestamp();
} else {
setTimestamp((Long)value);
}
break;
case WRITE_TO_WAL:
if (value == null) {
unsetWriteToWal();
} else {
setWriteToWal((Boolean)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case ROW:
return getRow();
case COLUMN_VALUES:
return getColumnValues();
case TIMESTAMP:
return Long.valueOf(getTimestamp());
case WRITE_TO_WAL:
return Boolean.valueOf(isWriteToWal());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case ROW:
return isSetRow();
case COLUMN_VALUES:
return isSetColumnValues();
case TIMESTAMP:
return isSetTimestamp();
case WRITE_TO_WAL:
return isSetWriteToWal();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TPut)
return this.equals((TPut)that);
return false;
}
public boolean equals(TPut that) {
if (that == null)
return false;
boolean this_present_row = true && this.isSetRow();
boolean that_present_row = true && that.isSetRow();
if (this_present_row || that_present_row) {
if (!(this_present_row && that_present_row))
return false;
if (!this.row.equals(that.row))
return false;
}
boolean this_present_columnValues = true && this.isSetColumnValues();
boolean that_present_columnValues = true && that.isSetColumnValues();
if (this_present_columnValues || that_present_columnValues) {
if (!(this_present_columnValues && that_present_columnValues))
return false;
if (!this.columnValues.equals(that.columnValues))
return false;
}
boolean this_present_timestamp = true && this.isSetTimestamp();
boolean that_present_timestamp = true && that.isSetTimestamp();
if (this_present_timestamp || that_present_timestamp) {
if (!(this_present_timestamp && that_present_timestamp))
return false;
if (this.timestamp != that.timestamp)
return false;
}
boolean this_present_writeToWal = true && this.isSetWriteToWal();
boolean that_present_writeToWal = true && that.isSetWriteToWal();
if (this_present_writeToWal || that_present_writeToWal) {
if (!(this_present_writeToWal && that_present_writeToWal))
return false;
if (this.writeToWal != that.writeToWal)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TPut other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TPut typedOther = (TPut)other;
lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRow()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetColumnValues()).compareTo(typedOther.isSetColumnValues());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetColumnValues()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columnValues, typedOther.columnValues);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTimestamp()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetWriteToWal()).compareTo(typedOther.isSetWriteToWal());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetWriteToWal()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.writeToWal, typedOther.writeToWal);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // ROW
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.row = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // COLUMN_VALUES
if (field.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list8 = iprot.readListBegin();
this.columnValues = new ArrayList<TColumnValue>(_list8.size);
for (int _i9 = 0; _i9 < _list8.size; ++_i9)
{
TColumnValue _elem10; // required
_elem10 = new TColumnValue();
_elem10.read(iprot);
this.columnValues.add(_elem10);
}
iprot.readListEnd();
}
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // TIMESTAMP
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.timestamp = iprot.readI64();
setTimestampIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // WRITE_TO_WAL
if (field.type == org.apache.thrift.protocol.TType.BOOL) {
this.writeToWal = iprot.readBool();
setWriteToWalIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.row != null) {
oprot.writeFieldBegin(ROW_FIELD_DESC);
oprot.writeBinary(this.row);
oprot.writeFieldEnd();
}
if (this.columnValues != null) {
oprot.writeFieldBegin(COLUMN_VALUES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.columnValues.size()));
for (TColumnValue _iter11 : this.columnValues)
{
_iter11.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
if (isSetTimestamp()) {
oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
oprot.writeI64(this.timestamp);
oprot.writeFieldEnd();
}
if (isSetWriteToWal()) {
oprot.writeFieldBegin(WRITE_TO_WAL_FIELD_DESC);
oprot.writeBool(this.writeToWal);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TPut(");
boolean first = true;
sb.append("row:");
if (this.row == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.row, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("columnValues:");
if (this.columnValues == null) {
sb.append("null");
} else {
sb.append(this.columnValues);
}
first = false;
if (isSetTimestamp()) {
if (!first) sb.append(", ");
sb.append("timestamp:");
sb.append(this.timestamp);
first = false;
}
if (isSetWriteToWal()) {
if (!first) sb.append(", ");
sb.append("writeToWal:");
sb.append(this.writeToWal);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (row == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'row' was not present! Struct: " + toString());
}
if (columnValues == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'columnValues' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,465 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* if no Result is found, row and columnValues will not be set.
*/
public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TResult");
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMN_VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("columnValues", org.apache.thrift.protocol.TType.LIST, (short)2);
public ByteBuffer row; // required
public List<TColumnValue> columnValues; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ROW((short)1, "row"),
COLUMN_VALUES((short)2, "columnValues");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // ROW
return ROW;
case 2: // COLUMN_VALUES
return COLUMN_VALUES;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.COLUMN_VALUES, new org.apache.thrift.meta_data.FieldMetaData("columnValues", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumnValue.class))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TResult.class, metaDataMap);
}
public TResult() {
}
public TResult(
List<TColumnValue> columnValues)
{
this();
this.columnValues = columnValues;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TResult(TResult other) {
if (other.isSetRow()) {
this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
;
}
if (other.isSetColumnValues()) {
List<TColumnValue> __this__columnValues = new ArrayList<TColumnValue>();
for (TColumnValue other_element : other.columnValues) {
__this__columnValues.add(new TColumnValue(other_element));
}
this.columnValues = __this__columnValues;
}
}
public TResult deepCopy() {
return new TResult(this);
}
@Override
public void clear() {
this.row = null;
this.columnValues = null;
}
public byte[] getRow() {
setRow(org.apache.thrift.TBaseHelper.rightSize(row));
return row == null ? null : row.array();
}
public ByteBuffer bufferForRow() {
return row;
}
public TResult setRow(byte[] row) {
setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
return this;
}
public TResult setRow(ByteBuffer row) {
this.row = row;
return this;
}
public void unsetRow() {
this.row = null;
}
/** Returns true if field row is set (has been assigned a value) and false otherwise */
public boolean isSetRow() {
return this.row != null;
}
public void setRowIsSet(boolean value) {
if (!value) {
this.row = null;
}
}
public int getColumnValuesSize() {
return (this.columnValues == null) ? 0 : this.columnValues.size();
}
public java.util.Iterator<TColumnValue> getColumnValuesIterator() {
return (this.columnValues == null) ? null : this.columnValues.iterator();
}
public void addToColumnValues(TColumnValue elem) {
if (this.columnValues == null) {
this.columnValues = new ArrayList<TColumnValue>();
}
this.columnValues.add(elem);
}
public List<TColumnValue> getColumnValues() {
return this.columnValues;
}
public TResult setColumnValues(List<TColumnValue> columnValues) {
this.columnValues = columnValues;
return this;
}
public void unsetColumnValues() {
this.columnValues = null;
}
/** Returns true if field columnValues is set (has been assigned a value) and false otherwise */
public boolean isSetColumnValues() {
return this.columnValues != null;
}
public void setColumnValuesIsSet(boolean value) {
if (!value) {
this.columnValues = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
if (value == null) {
unsetRow();
} else {
setRow((ByteBuffer)value);
}
break;
case COLUMN_VALUES:
if (value == null) {
unsetColumnValues();
} else {
setColumnValues((List<TColumnValue>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case ROW:
return getRow();
case COLUMN_VALUES:
return getColumnValues();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case ROW:
return isSetRow();
case COLUMN_VALUES:
return isSetColumnValues();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TResult)
return this.equals((TResult)that);
return false;
}
public boolean equals(TResult that) {
if (that == null)
return false;
boolean this_present_row = true && this.isSetRow();
boolean that_present_row = true && that.isSetRow();
if (this_present_row || that_present_row) {
if (!(this_present_row && that_present_row))
return false;
if (!this.row.equals(that.row))
return false;
}
boolean this_present_columnValues = true && this.isSetColumnValues();
boolean that_present_columnValues = true && that.isSetColumnValues();
if (this_present_columnValues || that_present_columnValues) {
if (!(this_present_columnValues && that_present_columnValues))
return false;
if (!this.columnValues.equals(that.columnValues))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TResult other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TResult typedOther = (TResult)other;
lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRow()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetColumnValues()).compareTo(typedOther.isSetColumnValues());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetColumnValues()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columnValues, typedOther.columnValues);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // ROW
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.row = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // COLUMN_VALUES
if (field.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
this.columnValues = new ArrayList<TColumnValue>(_list0.size);
for (int _i1 = 0; _i1 < _list0.size; ++_i1)
{
TColumnValue _elem2; // required
_elem2 = new TColumnValue();
_elem2.read(iprot);
this.columnValues.add(_elem2);
}
iprot.readListEnd();
}
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.row != null) {
if (isSetRow()) {
oprot.writeFieldBegin(ROW_FIELD_DESC);
oprot.writeBinary(this.row);
oprot.writeFieldEnd();
}
}
if (this.columnValues != null) {
oprot.writeFieldBegin(COLUMN_VALUES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.columnValues.size()));
for (TColumnValue _iter3 : this.columnValues)
{
_iter3.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TResult(");
boolean first = true;
if (isSetRow()) {
sb.append("row:");
if (this.row == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.row, sb);
}
first = false;
}
if (!first) sb.append(", ");
sb.append("columnValues:");
if (this.columnValues == null) {
sb.append("null");
} else {
sb.append(this.columnValues);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (columnValues == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'columnValues' was not present! Struct: " + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,831 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Any timestamps in the columns are ignored, use timeRange to select by timestamp.
* Max versions defaults to 1.
*/
public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TScan");
private static final org.apache.thrift.protocol.TField START_ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("startRow", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField STOP_ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("stopRow", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)3);
private static final org.apache.thrift.protocol.TField CACHING_FIELD_DESC = new org.apache.thrift.protocol.TField("caching", org.apache.thrift.protocol.TType.I32, (short)4);
private static final org.apache.thrift.protocol.TField MAX_VERSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("maxVersions", org.apache.thrift.protocol.TType.I32, (short)5);
private static final org.apache.thrift.protocol.TField TIME_RANGE_FIELD_DESC = new org.apache.thrift.protocol.TField("timeRange", org.apache.thrift.protocol.TType.STRUCT, (short)6);
public ByteBuffer startRow; // required
public ByteBuffer stopRow; // required
public List<TColumn> columns; // required
public int caching; // required
public int maxVersions; // required
public TTimeRange timeRange; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
START_ROW((short)1, "startRow"),
STOP_ROW((short)2, "stopRow"),
COLUMNS((short)3, "columns"),
CACHING((short)4, "caching"),
MAX_VERSIONS((short)5, "maxVersions"),
TIME_RANGE((short)6, "timeRange");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // START_ROW
return START_ROW;
case 2: // STOP_ROW
return STOP_ROW;
case 3: // COLUMNS
return COLUMNS;
case 4: // CACHING
return CACHING;
case 5: // MAX_VERSIONS
return MAX_VERSIONS;
case 6: // TIME_RANGE
return TIME_RANGE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __CACHING_ISSET_ID = 0;
private static final int __MAXVERSIONS_ISSET_ID = 1;
private BitSet __isset_bit_vector = new BitSet(2);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.START_ROW, new org.apache.thrift.meta_data.FieldMetaData("startRow", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.STOP_ROW, new org.apache.thrift.meta_data.FieldMetaData("stopRow", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumn.class))));
tmpMap.put(_Fields.CACHING, new org.apache.thrift.meta_data.FieldMetaData("caching", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.MAX_VERSIONS, new org.apache.thrift.meta_data.FieldMetaData("maxVersions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.TIME_RANGE, new org.apache.thrift.meta_data.FieldMetaData("timeRange", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTimeRange.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap);
}
public TScan() {
this.maxVersions = 1;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TScan(TScan other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetStartRow()) {
this.startRow = org.apache.thrift.TBaseHelper.copyBinary(other.startRow);
;
}
if (other.isSetStopRow()) {
this.stopRow = org.apache.thrift.TBaseHelper.copyBinary(other.stopRow);
;
}
if (other.isSetColumns()) {
List<TColumn> __this__columns = new ArrayList<TColumn>();
for (TColumn other_element : other.columns) {
__this__columns.add(new TColumn(other_element));
}
this.columns = __this__columns;
}
this.caching = other.caching;
this.maxVersions = other.maxVersions;
if (other.isSetTimeRange()) {
this.timeRange = new TTimeRange(other.timeRange);
}
}
public TScan deepCopy() {
return new TScan(this);
}
@Override
public void clear() {
this.startRow = null;
this.stopRow = null;
this.columns = null;
setCachingIsSet(false);
this.caching = 0;
this.maxVersions = 1;
this.timeRange = null;
}
public byte[] getStartRow() {
setStartRow(org.apache.thrift.TBaseHelper.rightSize(startRow));
return startRow == null ? null : startRow.array();
}
public ByteBuffer bufferForStartRow() {
return startRow;
}
public TScan setStartRow(byte[] startRow) {
setStartRow(startRow == null ? (ByteBuffer)null : ByteBuffer.wrap(startRow));
return this;
}
public TScan setStartRow(ByteBuffer startRow) {
this.startRow = startRow;
return this;
}
public void unsetStartRow() {
this.startRow = null;
}
/** Returns true if field startRow is set (has been assigned a value) and false otherwise */
public boolean isSetStartRow() {
return this.startRow != null;
}
public void setStartRowIsSet(boolean value) {
if (!value) {
this.startRow = null;
}
}
public byte[] getStopRow() {
setStopRow(org.apache.thrift.TBaseHelper.rightSize(stopRow));
return stopRow == null ? null : stopRow.array();
}
public ByteBuffer bufferForStopRow() {
return stopRow;
}
public TScan setStopRow(byte[] stopRow) {
setStopRow(stopRow == null ? (ByteBuffer)null : ByteBuffer.wrap(stopRow));
return this;
}
public TScan setStopRow(ByteBuffer stopRow) {
this.stopRow = stopRow;
return this;
}
public void unsetStopRow() {
this.stopRow = null;
}
/** Returns true if field stopRow is set (has been assigned a value) and false otherwise */
public boolean isSetStopRow() {
return this.stopRow != null;
}
public void setStopRowIsSet(boolean value) {
if (!value) {
this.stopRow = null;
}
}
public int getColumnsSize() {
return (this.columns == null) ? 0 : this.columns.size();
}
public java.util.Iterator<TColumn> getColumnsIterator() {
return (this.columns == null) ? null : this.columns.iterator();
}
public void addToColumns(TColumn elem) {
if (this.columns == null) {
this.columns = new ArrayList<TColumn>();
}
this.columns.add(elem);
}
public List<TColumn> getColumns() {
return this.columns;
}
public TScan setColumns(List<TColumn> columns) {
this.columns = columns;
return this;
}
public void unsetColumns() {
this.columns = null;
}
/** Returns true if field columns is set (has been assigned a value) and false otherwise */
public boolean isSetColumns() {
return this.columns != null;
}
public void setColumnsIsSet(boolean value) {
if (!value) {
this.columns = null;
}
}
public int getCaching() {
return this.caching;
}
public TScan setCaching(int caching) {
this.caching = caching;
setCachingIsSet(true);
return this;
}
public void unsetCaching() {
__isset_bit_vector.clear(__CACHING_ISSET_ID);
}
/** Returns true if field caching is set (has been assigned a value) and false otherwise */
public boolean isSetCaching() {
return __isset_bit_vector.get(__CACHING_ISSET_ID);
}
public void setCachingIsSet(boolean value) {
__isset_bit_vector.set(__CACHING_ISSET_ID, value);
}
public int getMaxVersions() {
return this.maxVersions;
}
public TScan setMaxVersions(int maxVersions) {
this.maxVersions = maxVersions;
setMaxVersionsIsSet(true);
return this;
}
public void unsetMaxVersions() {
__isset_bit_vector.clear(__MAXVERSIONS_ISSET_ID);
}
/** Returns true if field maxVersions is set (has been assigned a value) and false otherwise */
public boolean isSetMaxVersions() {
return __isset_bit_vector.get(__MAXVERSIONS_ISSET_ID);
}
public void setMaxVersionsIsSet(boolean value) {
__isset_bit_vector.set(__MAXVERSIONS_ISSET_ID, value);
}
public TTimeRange getTimeRange() {
return this.timeRange;
}
public TScan setTimeRange(TTimeRange timeRange) {
this.timeRange = timeRange;
return this;
}
public void unsetTimeRange() {
this.timeRange = null;
}
/** Returns true if field timeRange is set (has been assigned a value) and false otherwise */
public boolean isSetTimeRange() {
return this.timeRange != null;
}
public void setTimeRangeIsSet(boolean value) {
if (!value) {
this.timeRange = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case START_ROW:
if (value == null) {
unsetStartRow();
} else {
setStartRow((ByteBuffer)value);
}
break;
case STOP_ROW:
if (value == null) {
unsetStopRow();
} else {
setStopRow((ByteBuffer)value);
}
break;
case COLUMNS:
if (value == null) {
unsetColumns();
} else {
setColumns((List<TColumn>)value);
}
break;
case CACHING:
if (value == null) {
unsetCaching();
} else {
setCaching((Integer)value);
}
break;
case MAX_VERSIONS:
if (value == null) {
unsetMaxVersions();
} else {
setMaxVersions((Integer)value);
}
break;
case TIME_RANGE:
if (value == null) {
unsetTimeRange();
} else {
setTimeRange((TTimeRange)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case START_ROW:
return getStartRow();
case STOP_ROW:
return getStopRow();
case COLUMNS:
return getColumns();
case CACHING:
return Integer.valueOf(getCaching());
case MAX_VERSIONS:
return Integer.valueOf(getMaxVersions());
case TIME_RANGE:
return getTimeRange();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case START_ROW:
return isSetStartRow();
case STOP_ROW:
return isSetStopRow();
case COLUMNS:
return isSetColumns();
case CACHING:
return isSetCaching();
case MAX_VERSIONS:
return isSetMaxVersions();
case TIME_RANGE:
return isSetTimeRange();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TScan)
return this.equals((TScan)that);
return false;
}
public boolean equals(TScan that) {
if (that == null)
return false;
boolean this_present_startRow = true && this.isSetStartRow();
boolean that_present_startRow = true && that.isSetStartRow();
if (this_present_startRow || that_present_startRow) {
if (!(this_present_startRow && that_present_startRow))
return false;
if (!this.startRow.equals(that.startRow))
return false;
}
boolean this_present_stopRow = true && this.isSetStopRow();
boolean that_present_stopRow = true && that.isSetStopRow();
if (this_present_stopRow || that_present_stopRow) {
if (!(this_present_stopRow && that_present_stopRow))
return false;
if (!this.stopRow.equals(that.stopRow))
return false;
}
boolean this_present_columns = true && this.isSetColumns();
boolean that_present_columns = true && that.isSetColumns();
if (this_present_columns || that_present_columns) {
if (!(this_present_columns && that_present_columns))
return false;
if (!this.columns.equals(that.columns))
return false;
}
boolean this_present_caching = true && this.isSetCaching();
boolean that_present_caching = true && that.isSetCaching();
if (this_present_caching || that_present_caching) {
if (!(this_present_caching && that_present_caching))
return false;
if (this.caching != that.caching)
return false;
}
boolean this_present_maxVersions = true && this.isSetMaxVersions();
boolean that_present_maxVersions = true && that.isSetMaxVersions();
if (this_present_maxVersions || that_present_maxVersions) {
if (!(this_present_maxVersions && that_present_maxVersions))
return false;
if (this.maxVersions != that.maxVersions)
return false;
}
boolean this_present_timeRange = true && this.isSetTimeRange();
boolean that_present_timeRange = true && that.isSetTimeRange();
if (this_present_timeRange || that_present_timeRange) {
if (!(this_present_timeRange && that_present_timeRange))
return false;
if (!this.timeRange.equals(that.timeRange))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TScan other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TScan typedOther = (TScan)other;
lastComparison = Boolean.valueOf(isSetStartRow()).compareTo(typedOther.isSetStartRow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStartRow()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.startRow, typedOther.startRow);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetStopRow()).compareTo(typedOther.isSetStopRow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStopRow()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.stopRow, typedOther.stopRow);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetColumns()).compareTo(typedOther.isSetColumns());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetColumns()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columns, typedOther.columns);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetCaching()).compareTo(typedOther.isSetCaching());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetCaching()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.caching, typedOther.caching);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetMaxVersions()).compareTo(typedOther.isSetMaxVersions());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMaxVersions()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.maxVersions, typedOther.maxVersions);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTimeRange()).compareTo(typedOther.isSetTimeRange());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTimeRange()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timeRange, typedOther.timeRange);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // START_ROW
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.startRow = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // STOP_ROW
if (field.type == org.apache.thrift.protocol.TType.STRING) {
this.stopRow = iprot.readBinary();
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // COLUMNS
if (field.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list20 = iprot.readListBegin();
this.columns = new ArrayList<TColumn>(_list20.size);
for (int _i21 = 0; _i21 < _list20.size; ++_i21)
{
TColumn _elem22; // required
_elem22 = new TColumn();
_elem22.read(iprot);
this.columns.add(_elem22);
}
iprot.readListEnd();
}
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // CACHING
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.caching = iprot.readI32();
setCachingIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 5: // MAX_VERSIONS
if (field.type == org.apache.thrift.protocol.TType.I32) {
this.maxVersions = iprot.readI32();
setMaxVersionsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 6: // TIME_RANGE
if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
this.timeRange = new TTimeRange();
this.timeRange.read(iprot);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.startRow != null) {
if (isSetStartRow()) {
oprot.writeFieldBegin(START_ROW_FIELD_DESC);
oprot.writeBinary(this.startRow);
oprot.writeFieldEnd();
}
}
if (this.stopRow != null) {
if (isSetStopRow()) {
oprot.writeFieldBegin(STOP_ROW_FIELD_DESC);
oprot.writeBinary(this.stopRow);
oprot.writeFieldEnd();
}
}
if (this.columns != null) {
if (isSetColumns()) {
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.columns.size()));
for (TColumn _iter23 : this.columns)
{
_iter23.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
}
if (isSetCaching()) {
oprot.writeFieldBegin(CACHING_FIELD_DESC);
oprot.writeI32(this.caching);
oprot.writeFieldEnd();
}
if (isSetMaxVersions()) {
oprot.writeFieldBegin(MAX_VERSIONS_FIELD_DESC);
oprot.writeI32(this.maxVersions);
oprot.writeFieldEnd();
}
if (this.timeRange != null) {
if (isSetTimeRange()) {
oprot.writeFieldBegin(TIME_RANGE_FIELD_DESC);
this.timeRange.write(oprot);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TScan(");
boolean first = true;
if (isSetStartRow()) {
sb.append("startRow:");
if (this.startRow == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.startRow, sb);
}
first = false;
}
if (isSetStopRow()) {
if (!first) sb.append(", ");
sb.append("stopRow:");
if (this.stopRow == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.stopRow, sb);
}
first = false;
}
if (isSetColumns()) {
if (!first) sb.append(", ");
sb.append("columns:");
if (this.columns == null) {
sb.append("null");
} else {
sb.append(this.columns);
}
first = false;
}
if (isSetCaching()) {
if (!first) sb.append(", ");
sb.append("caching:");
sb.append(this.caching);
first = false;
}
if (isSetMaxVersions()) {
if (!first) sb.append(", ");
sb.append("maxVersions:");
sb.append(this.maxVersions);
first = false;
}
if (isSetTimeRange()) {
if (!first) sb.append(", ");
sb.append("timeRange:");
if (this.timeRange == null) {
sb.append("null");
} else {
sb.append(this.timeRange);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,411 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TTimeRange implements org.apache.thrift.TBase<TTimeRange, TTimeRange._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TTimeRange");
private static final org.apache.thrift.protocol.TField MIN_STAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("minStamp", org.apache.thrift.protocol.TType.I64, (short)1);
private static final org.apache.thrift.protocol.TField MAX_STAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("maxStamp", org.apache.thrift.protocol.TType.I64, (short)2);
public long minStamp; // required
public long maxStamp; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MIN_STAMP((short)1, "minStamp"),
MAX_STAMP((short)2, "maxStamp");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // MIN_STAMP
return MIN_STAMP;
case 2: // MAX_STAMP
return MAX_STAMP;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __MINSTAMP_ISSET_ID = 0;
private static final int __MAXSTAMP_ISSET_ID = 1;
private BitSet __isset_bit_vector = new BitSet(2);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MIN_STAMP, new org.apache.thrift.meta_data.FieldMetaData("minStamp", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.MAX_STAMP, new org.apache.thrift.meta_data.FieldMetaData("maxStamp", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TTimeRange.class, metaDataMap);
}
public TTimeRange() {
}
public TTimeRange(
long minStamp,
long maxStamp)
{
this();
this.minStamp = minStamp;
setMinStampIsSet(true);
this.maxStamp = maxStamp;
setMaxStampIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TTimeRange(TTimeRange other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
this.minStamp = other.minStamp;
this.maxStamp = other.maxStamp;
}
public TTimeRange deepCopy() {
return new TTimeRange(this);
}
@Override
public void clear() {
setMinStampIsSet(false);
this.minStamp = 0;
setMaxStampIsSet(false);
this.maxStamp = 0;
}
public long getMinStamp() {
return this.minStamp;
}
public TTimeRange setMinStamp(long minStamp) {
this.minStamp = minStamp;
setMinStampIsSet(true);
return this;
}
public void unsetMinStamp() {
__isset_bit_vector.clear(__MINSTAMP_ISSET_ID);
}
/** Returns true if field minStamp is set (has been assigned a value) and false otherwise */
public boolean isSetMinStamp() {
return __isset_bit_vector.get(__MINSTAMP_ISSET_ID);
}
public void setMinStampIsSet(boolean value) {
__isset_bit_vector.set(__MINSTAMP_ISSET_ID, value);
}
public long getMaxStamp() {
return this.maxStamp;
}
public TTimeRange setMaxStamp(long maxStamp) {
this.maxStamp = maxStamp;
setMaxStampIsSet(true);
return this;
}
public void unsetMaxStamp() {
__isset_bit_vector.clear(__MAXSTAMP_ISSET_ID);
}
/** Returns true if field maxStamp is set (has been assigned a value) and false otherwise */
public boolean isSetMaxStamp() {
return __isset_bit_vector.get(__MAXSTAMP_ISSET_ID);
}
public void setMaxStampIsSet(boolean value) {
__isset_bit_vector.set(__MAXSTAMP_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case MIN_STAMP:
if (value == null) {
unsetMinStamp();
} else {
setMinStamp((Long)value);
}
break;
case MAX_STAMP:
if (value == null) {
unsetMaxStamp();
} else {
setMaxStamp((Long)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case MIN_STAMP:
return Long.valueOf(getMinStamp());
case MAX_STAMP:
return Long.valueOf(getMaxStamp());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case MIN_STAMP:
return isSetMinStamp();
case MAX_STAMP:
return isSetMaxStamp();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TTimeRange)
return this.equals((TTimeRange)that);
return false;
}
public boolean equals(TTimeRange that) {
if (that == null)
return false;
boolean this_present_minStamp = true;
boolean that_present_minStamp = true;
if (this_present_minStamp || that_present_minStamp) {
if (!(this_present_minStamp && that_present_minStamp))
return false;
if (this.minStamp != that.minStamp)
return false;
}
boolean this_present_maxStamp = true;
boolean that_present_maxStamp = true;
if (this_present_maxStamp || that_present_maxStamp) {
if (!(this_present_maxStamp && that_present_maxStamp))
return false;
if (this.maxStamp != that.maxStamp)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(TTimeRange other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TTimeRange typedOther = (TTimeRange)other;
lastComparison = Boolean.valueOf(isSetMinStamp()).compareTo(typedOther.isSetMinStamp());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMinStamp()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.minStamp, typedOther.minStamp);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetMaxStamp()).compareTo(typedOther.isSetMaxStamp());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMaxStamp()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.maxStamp, typedOther.maxStamp);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (field.id) {
case 1: // MIN_STAMP
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.minStamp = iprot.readI64();
setMinStampIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // MAX_STAMP
if (field.type == org.apache.thrift.protocol.TType.I64) {
this.maxStamp = iprot.readI64();
setMaxStampIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
if (!isSetMinStamp()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'minStamp' was not found in serialized data! Struct: " + toString());
}
if (!isSetMaxStamp()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'maxStamp' was not found in serialized data! Struct: " + toString());
}
validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(MIN_STAMP_FIELD_DESC);
oprot.writeI64(this.minStamp);
oprot.writeFieldEnd();
oprot.writeFieldBegin(MAX_STAMP_FIELD_DESC);
oprot.writeI64(this.maxStamp);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TTimeRange(");
boolean first = true;
sb.append("minStamp:");
sb.append(this.minStamp);
first = false;
if (!first) sb.append(", ");
sb.append("maxStamp:");
sb.append(this.maxStamp);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// alas, we cannot check 'minStamp' because it's a primitive and you chose the non-beans generator.
// alas, we cannot check 'maxStamp' because it's a primitive and you chose the non-beans generator.
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}

View File

@ -0,0 +1,84 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head />
<body bgcolor="white">
Provides an HBase <a href="http://thrift.apache.org/">Thrift</a>
service.
This package contains a Thrift interface definition file for an HBase RPC
service and a Java server implementation.
There is currently 2 thrift server implementations in HBase, the packages:
<ul>
<li>org.apache.hadoop.hbase.thrift - This may one day be marked as depreceated.</li>
<li>org.apache.hadoop.hbase.thrift2 - This is intended to closely match to the HTable interface.</li>
</ul>
<h2><a name="whatisthrift">What is Thrift?</a></h2>
<p>From http://thrift.apache.org/</p>
<p>"Thrift is a software framework for scalable cross-language services
development. It combines a software stack with a code generation engine to
build services that work efficiently and seamlessly between C++, Java, Python,
PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk,
and OCaml. Originally developed at Facebook, Thrift was open sourced in April
2007 and entered the Apache Incubator in May, 2008"</p>
<h2><a name="description">Description</a></h2>
<p>The <a href="generated/THBaseService.Iface.html">HBase API</a> is defined in the
file hbase.thrift. A server-side implementation of the API is in
<code>org.apache.hadoop.hbase.thrift2.ThriftHBaseServiceHandler</code> with the
server boiler plate in <code>org.apache.hadoop.hbase.thrift2.ThriftServer</code>.
The generated interfaces, types, and RPC utility files are checked into SVN under the
<code>org.apache.hadoop.hbase.thrift2.generated</code> directory.
</p>
<p>The files were generated by running the commands:
<pre>
thrift -strict --gen java src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
mv gen-java/org/apache/hadoop/hbase/thrift2/generated src/main/java/org/apache/hadoop/hbase/thrift2/generated
rm -rf gen-java
</pre>
</p>
<p>The 'thrift' binary is the Thrift compiler, and it is distributed separately from HBase
in a Thrift release. Additionally, specific language runtime libraries are a
part of a Thrift release. A version of the Java runtime is included in HBase via maven.
</p>
<p>To start ThriftServer, use:
<pre>
./bin/hbase-daemon.sh start thrift2 [--port=PORT]
</pre>
The default port is 9090.
</p>
<p>To stop, use:
<pre>
./bin/hbase-daemon.sh stop thrift
</pre>
</p>
</body>
</html>

View File

@ -0,0 +1,411 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// NOTE: The "required" and "optional" keywords for the service methods are purely for documentation
namespace java org.apache.hadoop.hbase.thrift2.generated
namespace cpp apache.hadoop.hbase.thrift2
namespace rb Apache.Hadoop.Hbase.Thrift2
namespace py hbase
namespace perl Hbase
struct TTimeRange {
1: required i64 minStamp,
2: required i64 maxStamp
}
/**
* Addresses a single cell or multiple cells
* in a HBase table by column family and optionally
* a column qualifier and timestamp
*/
struct TColumn {
1: required binary family,
2: optional binary qualifier,
3: optional i64 timestamp
}
/**
* Represents a single cell and its value.
*/
struct TColumnValue {
1: required binary family,
2: required binary qualifier,
3: required binary value,
4: optional i64 timestamp
}
/**
* Represents a single cell and the amount to increment it by
*/
struct TColumnIncrement {
1: required binary family,
2: required binary qualifier,
3: optional i64 amount = 1
}
/**
* if no Result is found, row and columnValues will not be set.
*/
struct TResult {
1: optional binary row,
2: required list<TColumnValue> columnValues
}
/**
* Specify type of delete:
* - DELETE_COLUMN means exactly one version will be removed,
* - DELETE_COLUMNS means previous versions will also be removed.
*/
enum TDeleteType {
DELETE_COLUMN = 0,
DELETE_COLUMNS = 1
}
/**
* Used to perform Get operations on a single row.
*
* The scope can be further narrowed down by specifying a list of
* columns or column families.
*
* To get everything for a row, instantiate a Get object with just the row to get.
* To further define the scope of what to get you can add a timestamp or time range
* with an optional maximum number of versions to return.
*
* If you specify a time range and a timestamp the range is ignored.
* Timestamps on TColumns are ignored.
*
* TODO: Filter, Locks
*/
struct TGet {
1: required binary row,
2: optional list<TColumn> columns,
3: optional i64 timestamp,
4: optional TTimeRange timeRange,
5: optional i32 maxVersions,
}
/**
* Used to perform Put operations for a single row.
*
* Add column values to this object and they'll be added.
* You can provide a default timestamp if the column values
* don't have one. If you don't provide a default timestamp
* the current time is inserted.
*
* You can also specify if this Put should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
struct TPut {
1: required binary row,
2: required list<TColumnValue> columnValues
3: optional i64 timestamp,
4: optional bool writeToWal = 1
}
/**
* Used to perform Delete operations on a single row.
*
* The scope can be further narrowed down by specifying a list of
* columns or column families as TColumns.
*
* Specifying only a family in a TColumn will delete the whole family.
* If a timestamp is specified all versions with a timestamp less than
* or equal to this will be deleted. If no timestamp is specified the
* current time will be used.
*
* Specifying a family and a column qualifier in a TColumn will delete only
* this qualifier. If a timestamp is specified only versions equal
* to this timestamp will be deleted. If no timestamp is specified the
* most recent version will be deleted. To delete all previous versions,
* specify the DELETE_COLUMNS TDeleteType.
*
* The top level timestamp is only used if a complete row should be deleted
* (i.e. no columns are passed) and if it is specified it works the same way
* as if you had added a TColumn for every column family and this timestamp
* (i.e. all versions older than or equal in all column families will be deleted)
*
*/
struct TDelete {
1: required binary row,
2: optional list<TColumn> columns,
3: optional i64 timestamp,
4: optional TDeleteType deleteType = 1
}
/**
* Used to perform Increment operations for a single row.
*
* You can specify if this Increment should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
struct TIncrement {
1: required binary row,
2: required list<TColumnIncrement> columns,
3: optional bool writeToWal = 1
}
/**
* Any timestamps in the columns are ignored, use timeRange to select by timestamp.
* Max versions defaults to 1.
*/
struct TScan {
1: optional binary startRow,
2: optional binary stopRow,
3: optional list<TColumn> columns
4: optional i32 caching,
5: optional i32 maxVersions=1,
6: optional TTimeRange timeRange,
}
//
// Exceptions
//
/**
* A TIOError exception signals that an error occurred communicating
* to the HBase master or a HBase region server. Also used to return
* more general HBase error conditions.
*/
exception TIOError {
1: optional string message
}
/**
* A TIllegalArgument exception indicates an illegal or invalid
* argument was passed into a procedure.
*/
exception TIllegalArgument {
1: optional string message
}
service THBaseService {
/**
* Test for the existence of columns in the table, as specified in the TGet.
*
* @return true if the specified TGet matches one or more keys, false if not
*/
bool exists(
/** the table to check on */
1: required binary table,
/** the TGet to check for */
2: required TGet get
) throws (1:TIOError io)
/**
* Method for getting data from a row.
*
* If the row cannot be found an empty Result is returned.
* This can be checked by the empty field of the TResult
*
* @return the result
*/
TResult get(
/** the table to get from */
1: required binary table,
/** the TGet to fetch */
2: required TGet get
) throws (1: TIOError io)
/**
* Method for getting multiple rows.
*
* If a row cannot be found there will be a null
* value in the result list for that TGet at the
* same position.
*
* So the Results are in the same order as the TGets.
*/
list<TResult> getMultiple(
/** the table to get from */
1: required binary table,
/** a list of TGets to fetch, the Result list
will have the Results at corresponding positions
or null if there was an error */
2: required list<TGet> gets
) throws (1: TIOError io)
/**
* Commit a TPut to a table.
*/
void put(
/** the table to put data in */
1: required binary table,
/** the TPut to put */
2: required TPut put
) throws (1: TIOError io)
/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the TPut.
*
* @return true if the new put was executed, false otherwise
*/
bool checkAndPut(
/** to check in and put to */
1: required binary table,
/** row to check */
2: required binary row,
/** column family to check */
3: required binary family,
/** column qualifier to check */
4: required binary qualifier,
/** the expected value, if not provided the
check is for the non-existence of the
column in question */
5: binary value,
/** the TPut to put if the check succeeds */
6: required TPut put
) throws (1: TIOError io)
/**
* Commit a List of Puts to the table.
*/
void putMultiple(
/** the table to put data in */
1: required binary table,
/** a list of TPuts to commit */
2: required list<TPut> puts
) throws (1: TIOError io)
/**
* Deletes as specified by the TDelete.
*
* Note: "delete" is a reserved keyword and cannot be used in Thrift
* thus the inconsistent naming scheme from the other functions.
*/
void deleteSingle(
/** the table to delete from */
1: required binary table,
/** the TDelete to delete */
2: required TDelete deleteSingle
) throws (1: TIOError io)
/**
* Bulk commit a List of TDeletes to the table.
*
* This returns a list of TDeletes that were not
* executed. So if everything succeeds you'll
* receive an empty list.
*/
list<TDelete> deleteMultiple(
/** the table to delete from */
1: required binary table,
/** list of TDeletes to delete */
2: required list<TDelete> deletes
) throws (1: TIOError io)
/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the delete.
*
* @return true if the new delete was executed, false otherwise
*/
bool checkAndDelete(
/** to check in and delete from */
1: required binary table,
/** row to check */
2: required binary row,
/** column family to check */
3: required binary family,
/** column qualifier to check */
4: required binary qualifier,
/** the expected value, if not provided the
check is for the non-existence of the
column in question */
5: binary value,
/** the TDelete to execute if the check succeeds */
6: required TDelete deleteSingle
) throws (1: TIOError io)
TResult increment(
/** the table to increment the value on */
1: required binary table,
/** the TIncrement to increment */
2: required TIncrement increment
) throws (1: TIOError io)
/**
* Get a Scanner for the provided TScan object.
*
* @return Scanner Id to be used with other scanner procedures
*/
i32 openScanner(
/** the table to get the Scanner for */
1: required binary table,
/** the scan object to get a Scanner for */
2: required TScan scan,
) throws (1: TIOError io)
/**
* Grabs multiple rows from a Scanner.
*
* @return Between zero and numRows TResults
*/
list<TResult> getScannerRows(
/** the Id of the Scanner to return rows from. This is an Id returned from the openScanner function. */
1: required i32 scannerId,
/** number of rows to return */
2: i32 numRows = 1
) throws (
1: TIOError io,
/** if the scannerId is invalid */
2: TIllegalArgument ia
)
/**
* Closes the scanner. Should be called if you need to close
* the Scanner before all results are read.
*
* Exhausted scanners are closed automatically.
*/
void closeScanner(
/** the Id of the Scanner to close **/
1: required i32 scannerId
) throws (
1: TIOError io,
/** if the scannerId is invalid */
2: TIllegalArgument ia
)
}

View File

@ -0,0 +1,511 @@
/*
* Copyright 2009 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.thrift2;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.thrift2.generated.TColumn;
import org.apache.hadoop.hbase.thrift2.generated.TColumnIncrement;
import org.apache.hadoop.hbase.thrift2.generated.TColumnValue;
import org.apache.hadoop.hbase.thrift2.generated.TDelete;
import org.apache.hadoop.hbase.thrift2.generated.TDeleteType;
import org.apache.hadoop.hbase.thrift2.generated.TGet;
import org.apache.hadoop.hbase.thrift2.generated.TIOError;
import org.apache.hadoop.hbase.thrift2.generated.TIllegalArgument;
import org.apache.hadoop.hbase.thrift2.generated.TIncrement;
import org.apache.hadoop.hbase.thrift2.generated.TPut;
import org.apache.hadoop.hbase.thrift2.generated.TResult;
import org.apache.hadoop.hbase.thrift2.generated.TScan;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.thrift.TException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Unit testing for ThriftServer.HBaseHandler, a part of the org.apache.hadoop.hbase.thrift2 package.
*/
public class TestThriftHBaseServiceHandler {
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
// Static names for tables, columns, rows, and values
private static byte[] tableAname = Bytes.toBytes("tableA");
private static byte[] familyAname = Bytes.toBytes("familyA");
private static byte[] familyBname = Bytes.toBytes("familyB");
private static byte[] qualifierAname = Bytes.toBytes("qualifierA");
private static byte[] qualifierBname = Bytes.toBytes("qualifierB");
private static byte[] valueAname = Bytes.toBytes("valueA");
private static byte[] valueBname = Bytes.toBytes("valueB");
private static HColumnDescriptor[] families = new HColumnDescriptor[] {
new HColumnDescriptor(familyAname),
new HColumnDescriptor(familyBname, 2, HColumnDescriptor.DEFAULT_COMPRESSION, HColumnDescriptor.DEFAULT_IN_MEMORY,
HColumnDescriptor.DEFAULT_BLOCKCACHE, HColumnDescriptor.DEFAULT_TTL, HColumnDescriptor.DEFAULT_BLOOMFILTER) };
public void assertTColumnValuesEqual(List<TColumnValue> columnValuesA, List<TColumnValue> columnValuesB) {
assertEquals(columnValuesA.size(), columnValuesB.size());
Comparator<TColumnValue> comparator = new Comparator<TColumnValue>() {
@Override
public int compare(TColumnValue o1, TColumnValue o2) {
return Bytes.compareTo(Bytes.add(o1.getFamily(), o1.getQualifier()),
Bytes.add(o2.getFamily(), o2.getQualifier()));
}
};
Collections.sort(columnValuesA, comparator);
Collections.sort(columnValuesB, comparator);
for (int i = 0; i < columnValuesA.size(); i++) {
TColumnValue a = columnValuesA.get(i);
TColumnValue b = columnValuesB.get(i);
assertArrayEquals(a.getFamily(), b.getFamily());
assertArrayEquals(a.getQualifier(), b.getQualifier());
assertArrayEquals(a.getValue(), b.getValue());
}
}
@BeforeClass
public static void beforeClass() throws Exception {
UTIL.startMiniCluster();
HBaseAdmin admin = new HBaseAdmin(new Configuration());
HTableDescriptor tableDescriptor = new HTableDescriptor(tableAname);
for (HColumnDescriptor family : families) {
tableDescriptor.addFamily(family);
}
admin.createTable(tableDescriptor);
}
@AfterClass
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
@Before
public void setup() throws Exception {
}
@Test
public void testExists() throws TIOError, TException {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testExists".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
TGet get = new TGet(ByteBuffer.wrap(rowName));
assertFalse(handler.exists(table, get));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
.wrap(valueAname)));
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname), ByteBuffer
.wrap(valueBname)));
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
}
@Test
public void testPutGet() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testPutGet".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
.wrap(valueAname)));
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname), ByteBuffer
.wrap(valueBname)));
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
TGet get = new TGet(ByteBuffer.wrap(rowName));
TResult result = handler.get(table, get);
assertArrayEquals(rowName, result.getRow());
List<TColumnValue> returnedColumnValues = result.getColumnValues();
assertTColumnValuesEqual(columnValues, returnedColumnValues);
}
@Test
public void testPutGetMultiple() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
ByteBuffer table = ByteBuffer.wrap(tableAname);
byte[] rowName1 = "testPutGetMultiple1".getBytes();
byte[] rowName2 = "testPutGetMultiple2".getBytes();
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
.wrap(valueAname)));
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname), ByteBuffer
.wrap(valueBname)));
List<TPut> puts = new ArrayList<TPut>();
puts.add(new TPut(ByteBuffer.wrap(rowName1), columnValues));
puts.add(new TPut(ByteBuffer.wrap(rowName2), columnValues));
handler.putMultiple(table, puts);
List<TGet> gets = new ArrayList<TGet>();
gets.add(new TGet(ByteBuffer.wrap(rowName1)));
gets.add(new TGet(ByteBuffer.wrap(rowName2)));
List<TResult> results = handler.getMultiple(table, gets);
assertEquals(2, results.size());
assertArrayEquals(rowName1, results.get(0).getRow());
assertTColumnValuesEqual(columnValues, results.get(0).getColumnValues());
assertArrayEquals(rowName2, results.get(1).getRow());
assertTColumnValuesEqual(columnValues, results.get(1).getColumnValues());
}
@Test
public void testDeleteMultiple() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
ByteBuffer table = ByteBuffer.wrap(tableAname);
byte[] rowName1 = "testDeleteMultiple1".getBytes();
byte[] rowName2 = "testDeleteMultiple2".getBytes();
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
.wrap(valueAname)));
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname), ByteBuffer
.wrap(valueBname)));
List<TPut> puts = new ArrayList<TPut>();
puts.add(new TPut(ByteBuffer.wrap(rowName1), columnValues));
puts.add(new TPut(ByteBuffer.wrap(rowName2), columnValues));
handler.putMultiple(table, puts);
List<TDelete> deletes = new ArrayList<TDelete>();
deletes.add(new TDelete(ByteBuffer.wrap(rowName1)));
deletes.add(new TDelete(ByteBuffer.wrap(rowName2)));
List<TDelete> deleteResults = handler.deleteMultiple(table, deletes);
// 0 means they were all successfully applies
assertEquals(0, deleteResults.size());
assertFalse(handler.exists(table, new TGet(ByteBuffer.wrap(rowName1))));
assertFalse(handler.exists(table, new TGet(ByteBuffer.wrap(rowName2))));
}
@Test
public void testDelete() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testDelete".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
TColumnValue columnValueB = new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname),
ByteBuffer.wrap(valueBname));
columnValues.add(columnValueA);
columnValues.add(columnValueB);
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
TDelete delete = new TDelete(ByteBuffer.wrap(rowName));
List<TColumn> deleteColumns = new ArrayList<TColumn>();
TColumn deleteColumn = new TColumn(ByteBuffer.wrap(familyAname));
deleteColumn.setQualifier(qualifierAname);
deleteColumns.add(deleteColumn);
delete.setColumns(deleteColumns);
handler.deleteSingle(table, delete);
TGet get = new TGet(ByteBuffer.wrap(rowName));
TResult result = handler.get(table, get);
assertArrayEquals(rowName, result.getRow());
List<TColumnValue> returnedColumnValues = result.getColumnValues();
List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
expectedColumnValues.add(columnValueB);
assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
@Test
public void testDeleteAllTimestamps() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testDeleteAllTimestamps".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
columnValueA.setTimestamp(System.currentTimeMillis() - 10);
columnValues.add(columnValueA);
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
columnValueA.setTimestamp(System.currentTimeMillis());
handler.put(table, put);
TGet get = new TGet(ByteBuffer.wrap(rowName));
get.setMaxVersions(2);
TResult result = handler.get(table, get);
assertEquals(2, result.getColumnValuesSize());
TDelete delete = new TDelete(ByteBuffer.wrap(rowName));
List<TColumn> deleteColumns = new ArrayList<TColumn>();
TColumn deleteColumn = new TColumn(ByteBuffer.wrap(familyAname));
deleteColumn.setQualifier(qualifierAname);
deleteColumns.add(deleteColumn);
delete.setColumns(deleteColumns);
delete.setDeleteType(TDeleteType.DELETE_COLUMNS); // This is the default anyway.
handler.deleteSingle(table, delete);
get = new TGet(ByteBuffer.wrap(rowName));
result = handler.get(table, get);
assertNull(result.getRow());
assertEquals(0, result.getColumnValuesSize());
}
@Test
public void testDeleteSingleTimestamp() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testDeleteSingleTimestamp".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
long timestamp1 = System.currentTimeMillis() - 10;
long timestamp2 = System.currentTimeMillis();
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
columnValueA.setTimestamp(timestamp1);
columnValues.add(columnValueA);
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
columnValueA.setTimestamp(timestamp2);
handler.put(table, put);
TGet get = new TGet(ByteBuffer.wrap(rowName));
get.setMaxVersions(2);
TResult result = handler.get(table, get);
assertEquals(2, result.getColumnValuesSize());
TDelete delete = new TDelete(ByteBuffer.wrap(rowName));
List<TColumn> deleteColumns = new ArrayList<TColumn>();
TColumn deleteColumn = new TColumn(ByteBuffer.wrap(familyAname));
deleteColumn.setQualifier(qualifierAname);
deleteColumns.add(deleteColumn);
delete.setColumns(deleteColumns);
delete.setDeleteType(TDeleteType.DELETE_COLUMN);
handler.deleteSingle(table, delete);
get = new TGet(ByteBuffer.wrap(rowName));
result = handler.get(table, get);
assertArrayEquals(rowName, result.getRow());
assertEquals(1, result.getColumnValuesSize());
// the older timestamp should remain.
assertEquals(timestamp1, result.getColumnValues().get(0).getTimestamp());
}
@Test
public void testIncrement() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testIncrement".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
.wrap(Bytes.toBytes(1L))));
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
incrementColumns.add(new TColumnIncrement(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname)));
TIncrement increment = new TIncrement(ByteBuffer.wrap(rowName), incrementColumns);
handler.increment(table, increment);
TGet get = new TGet(ByteBuffer.wrap(rowName));
TResult result = handler.get(table, get);
assertArrayEquals(rowName, result.getRow());
assertEquals(1, result.getColumnValuesSize());
TColumnValue columnValue = result.getColumnValues().get(0);
assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
/**
* check that checkAndPut fails if the cell does not exist, then put in the cell, then check that the checkAndPut
* succeeds.
*
* @throws Exception
*/
@Test
public void testCheckAndPut() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testCheckAndPut".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
List<TColumnValue> columnValuesA = new ArrayList<TColumnValue>();
TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
columnValuesA.add(columnValueA);
TPut putA = new TPut(ByteBuffer.wrap(rowName), columnValuesA);
putA.setColumnValues(columnValuesA);
List<TColumnValue> columnValuesB = new ArrayList<TColumnValue>();
TColumnValue columnValueB = new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname),
ByteBuffer.wrap(valueBname));
columnValuesB.add(columnValueB);
TPut putB = new TPut(ByteBuffer.wrap(rowName), columnValuesB);
putB.setColumnValues(columnValuesB);
assertFalse(handler.checkAndPut(table, ByteBuffer.wrap(rowName), ByteBuffer.wrap(familyAname),
ByteBuffer.wrap(qualifierAname), ByteBuffer.wrap(valueAname), putB));
TGet get = new TGet(ByteBuffer.wrap(rowName));
TResult result = handler.get(table, get);
assertEquals(0, result.getColumnValuesSize());
handler.put(table, putA);
assertTrue(handler.checkAndPut(table, ByteBuffer.wrap(rowName), ByteBuffer.wrap(familyAname),
ByteBuffer.wrap(qualifierAname), ByteBuffer.wrap(valueAname), putB));
result = handler.get(table, get);
assertArrayEquals(rowName, result.getRow());
List<TColumnValue> returnedColumnValues = result.getColumnValues();
List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
expectedColumnValues.add(columnValueA);
expectedColumnValues.add(columnValueB);
assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
/**
* check that checkAndDelete fails if the cell does not exist, then put in the cell, then check that the
* checkAndDelete succeeds.
*
* @throws Exception
*/
@Test
public void testCheckAndDelete() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
byte[] rowName = "testCheckAndDelete".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
List<TColumnValue> columnValuesA = new ArrayList<TColumnValue>();
TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
columnValuesA.add(columnValueA);
TPut putA = new TPut(ByteBuffer.wrap(rowName), columnValuesA);
putA.setColumnValues(columnValuesA);
List<TColumnValue> columnValuesB = new ArrayList<TColumnValue>();
TColumnValue columnValueB = new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname),
ByteBuffer.wrap(valueBname));
columnValuesB.add(columnValueB);
TPut putB = new TPut(ByteBuffer.wrap(rowName), columnValuesB);
putB.setColumnValues(columnValuesB);
// put putB so that we know whether the row has been deleted or not
handler.put(table, putB);
TDelete delete = new TDelete(ByteBuffer.wrap(rowName));
assertFalse(handler.checkAndDelete(table, ByteBuffer.wrap(rowName), ByteBuffer.wrap(familyAname),
ByteBuffer.wrap(qualifierAname), ByteBuffer.wrap(valueAname), delete));
TGet get = new TGet(ByteBuffer.wrap(rowName));
TResult result = handler.get(table, get);
assertArrayEquals(rowName, result.getRow());
assertTColumnValuesEqual(columnValuesB, result.getColumnValues());
handler.put(table, putA);
assertTrue(handler.checkAndDelete(table, ByteBuffer.wrap(rowName), ByteBuffer.wrap(familyAname),
ByteBuffer.wrap(qualifierAname), ByteBuffer.wrap(valueAname), delete));
result = handler.get(table, get);
assertFalse(result.isSetRow());
assertEquals(0, result.getColumnValuesSize());
}
@Test
public void testScan() throws Exception {
ThriftHBaseServiceHandler handler = new ThriftHBaseServiceHandler();
ByteBuffer table = ByteBuffer.wrap(tableAname);
TScan scan = new TScan();
List<TColumn> columns = new ArrayList<TColumn>();
TColumn column = new TColumn();
column.setFamily(familyAname);
column.setQualifier(qualifierAname);
columns.add(column);
scan.setColumns(columns);
scan.setStartRow("testScan".getBytes());
TColumnValue columnValue = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(columnValue);
for (int i = 0; i < 10; i++) {
TPut put = new TPut(ByteBuffer.wrap(("testScan" + i).getBytes()), columnValues);
handler.put(table, put);
}
int scanId = handler.openScanner(table, scan);
List<TResult> results = handler.getScannerRows(scanId, 10);
assertEquals(10, results.size());
for (int i = 0; i < 10; i++) {
assertArrayEquals(("testScan" + i).getBytes(), results.get(i).getRow());
}
results = handler.getScannerRows(scanId, 10);
assertEquals(0, results.size());
handler.closeScanner(scanId);
try {
handler.getScannerRows(scanId, 10);
fail("Scanner id should be invalid");
} catch (TIllegalArgument e) {
}
}
}