More work on documentation and examples, removed some things from the API, incorporated some of Keith's feedback.

--HG--
branch : mjc
rename : examples/c/ex_schema.c => examples/c/ex_call_center.c
extra : transplant_source : %AE%E9%C4%0B%3A%C5%0EH%E1%A8%A2L%E6%D2%D6%40G%9Dzq
This commit is contained in:
Michael Cahill
2010-12-16 22:54:09 +11:00
parent 1e1f55ddb8
commit b65420c0bd
18 changed files with 480 additions and 95 deletions

View File

@@ -32,7 +32,7 @@ def unpack(fmt, s):
result = ()
pfmt = tfmt
sizebytes = 0
for f in fmt:
for offset, f in enumerate(fmt):
if f.isdigit():
sizebytes += 1
# With a fixed size, everything is encoded as a string
@@ -54,10 +54,13 @@ def unpack(fmt, s):
result += (s[:l],)
s = s[l+1:]
if f == 'u':
l = struct.unpack_from(tfmt + 'l', s)[0]
s = s[struct.calcsize(tfmt + 'l'):]
result += (s[:l],)
s = s[l:]
if offset == len(fmt) - 1:
result += (s,)
else:
l = struct.unpack_from(tfmt + 'l', s)[0]
s = s[struct.calcsize(tfmt + 'l'):]
result += (s[:l],)
s = s[l:]
pfmt = tfmt
sizebytes = 0
@@ -70,7 +73,7 @@ def pack(fmt, *values):
if not fmt:
return ''
i = sizebytes = 0
for f in fmt:
for offset, f in enumerate(fmt):
if f == 'S':
# Note: this code is being careful about embedded NUL characters
if sizebytes == 0:
@@ -81,7 +84,7 @@ def pack(fmt, *values):
sizebytes = len(str(l))
f = 's'
elif f == 'u':
if sizebytes == 0:
if sizebytes == 0 and offset != len(fmt) - 1:
l = len(values[i])
pfmt += 'l' + str(l)
values = values[:i] + (l,) + values[i:]

View File

@@ -26,6 +26,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print ' WT_HANDLE open(string home, string config)'
print ' WT_HANDLE open_session(WT_HANDLE connection, string config)'
print ' void close_connection(WT_HANDLE connection, string config)'
print ' bool is_new(WT_HANDLE connection)'
print ' void close_session(WT_HANDLE session, string config)'
print ' WT_CURSOR_HANDLE open_cursor(WT_HANDLE session, string uri, string config)'
print ' WT_CURSOR_HANDLE dup_cursor(WT_HANDLE session, WT_HANDLE cursor, string config)'
@@ -127,6 +128,12 @@ elif cmd == 'close_connection':
sys.exit(1)
pp.pprint(client.close_connection(eval(args[0]),args[1],))
elif cmd == 'is_new':
if len(args) != 1:
print 'is_new requires 1 args'
sys.exit(1)
pp.pprint(client.is_new(eval(args[0]),))
elif cmd == 'close_session':
if len(args) != 2:
print 'close_session requires 2 args'

View File

@@ -50,6 +50,13 @@ class Iface:
"""
pass
def is_new(self, connection):
"""
Parameters:
- connection
"""
pass
def close_session(self, session, config):
"""
Parameters:
@@ -384,6 +391,36 @@ class Client(Iface):
raise result.err
return
def is_new(self, connection):
"""
Parameters:
- connection
"""
self.send_is_new(connection)
return self.recv_is_new()
def send_is_new(self, connection):
self._oprot.writeMessageBegin('is_new', TMessageType.CALL, self._seqid)
args = is_new_args()
args.connection = connection
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_is_new(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = is_new_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success != None:
return result.success
raise TApplicationException(TApplicationException.MISSING_RESULT, "is_new failed: unknown result");
def close_session(self, session, config):
"""
Parameters:
@@ -1088,6 +1125,7 @@ class Processor(Iface, TProcessor):
self._processMap["open"] = Processor.process_open
self._processMap["open_session"] = Processor.process_open_session
self._processMap["close_connection"] = Processor.process_close_connection
self._processMap["is_new"] = Processor.process_is_new
self._processMap["close_session"] = Processor.process_close_session
self._processMap["open_cursor"] = Processor.process_open_cursor
self._processMap["dup_cursor"] = Processor.process_dup_cursor
@@ -1189,6 +1227,17 @@ class Processor(Iface, TProcessor):
oprot.writeMessageEnd()
oprot.trans.flush()
def process_is_new(self, seqid, iprot, oprot):
args = is_new_args()
args.read(iprot)
iprot.readMessageEnd()
result = is_new_result()
result.success = self._handler.is_new(args.connection)
oprot.writeMessageBegin("is_new", TMessageType.REPLY, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
def process_close_session(self, seqid, iprot, oprot):
args = close_session_args()
args.read(iprot)
@@ -2118,6 +2167,123 @@ class close_connection_result:
def __ne__(self, other):
return not (self == other)
class is_new_args:
"""
Attributes:
- connection
"""
thrift_spec = (
None, # 0
(1, TType.I32, 'connection', None, None, ), # 1
)
def __init__(self, connection=None,):
self.connection = connection
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
self.connection = iprot.readI32();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('is_new_args')
if self.connection != None:
oprot.writeFieldBegin('connection', TType.I32, 1)
oprot.writeI32(self.connection)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class is_new_result:
"""
Attributes:
- success
"""
thrift_spec = (
(0, TType.BOOL, 'success', None, None, ), # 0
)
def __init__(self, success=None,):
self.success = success
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 0:
if ftype == TType.BOOL:
self.success = iprot.readBool();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('is_new_result')
if self.success != None:
oprot.writeFieldBegin('success', TType.BOOL, 0)
oprot.writeBool(self.success)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class close_session_args:
"""
Attributes: