text stringlengths 0 1.05M | meta dict |
|---|---|
from pydoop.hdfs.core.bridged import get_wrapper_factory
FACTORY = get_wrapper_factory()
def wrap_class(fully_qualified_class_name):
return FACTORY.get_wrapper(fully_qualified_class_name)
def wrap_class_instance(fully_qualified_class_name, *args):
return FACTORY.get_wrapper(fully_qualified_class_name)(*a... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/hdfs/core/bridged/common.py",
"copies": "3",
"size": "1407",
"license": "apache-2.0",
"hash": 6526809660776330000,
"line_mean": 30.2666666667,
"line_max": 77,
"alpha_frac": 0.7341862118,
"autogenerated": false,
"ratio": 3.6076923076923078,
"con... |
from pydoop.mapreduce.binary_streams import (
BinaryWriter, BinaryDownStreamFilter
)
import sys
sys.path.append('./build/lib.linux-x86_64-2.7')
import dummy
from timer import Timer
def write_data(N, fname):
with open(fname, 'w') as f:
writer = BinaryWriter(f)
for i in range(N):
... | {
"repo_name": "kikkomep/pydoop",
"path": "test/timings/binary_build.py",
"copies": "3",
"size": "2082",
"license": "apache-2.0",
"hash": 4617554583953422000,
"line_mean": 25.025,
"line_max": 79,
"alpha_frac": 0.6484149856,
"autogenerated": false,
"ratio": 3.3312,
"config_test": false,
"has_no... |
from .streams import DownStreamFilter, UpStreamFilter
from pydoop.utils.serialize import codec, codec_core
import logging
logging.basicConfig()
LOGGER = logging.getLogger('binary_streams')
LOGGER.setLevel(logging.CRITICAL)
# these constants should be exactly what has been defined in PipesMapper.java
# BinaryProtocol... | {
"repo_name": "kikkomep/pydoop",
"path": "pydoop/mapreduce/binary_streams.py",
"copies": "3",
"size": "3737",
"license": "apache-2.0",
"hash": -5924981362475126000,
"line_mean": 29.8842975207,
"line_max": 77,
"alpha_frac": 0.6941396842,
"autogenerated": false,
"ratio": 3.512218045112782,
"confi... |
from .streams import (
DownStreamFilter, UpStreamFilter, ProtocolAbort, ProtocolError
)
from .string_utils import quote_string
def toBool(s):
return s.lower().find('true') > -1
class TextDownStreamFilter(DownStreamFilter):
"""
Naive textual stream filter implementation.
It recognizes commands ... | {
"repo_name": "kikkomep/pydoop",
"path": "pydoop/mapreduce/text_streams.py",
"copies": "3",
"size": "2833",
"license": "apache-2.0",
"hash": 2181626519263625700,
"line_mean": 31.1931818182,
"line_max": 77,
"alpha_frac": 0.6201906107,
"autogenerated": false,
"ratio": 3.737467018469657,
"config_t... |
import hmac
import hashlib
import base64
import string
DIGITS = frozenset(string.digits)
QUOTE_MAP = {
'\\': '\\\\',
'\t': '\\t',
'\n': '\\n',
' ': '\\s',
}
UNQUOTE_MAP = {
't': '\t',
'n': '\n',
's': ' ',
'X': '\\',
}
def quote_string(in_string, deliminators='\\'):
retur... | {
"repo_name": "kikkomep/pydoop",
"path": "pydoop/mapreduce/string_utils.py",
"copies": "3",
"size": "1523",
"license": "apache-2.0",
"hash": -5707506383221289000,
"line_mean": 24.3833333333,
"line_max": 77,
"alpha_frac": 0.6086671044,
"autogenerated": false,
"ratio": 3.1861924686192467,
"config... |
import jpype
from .factory import ClassLoader
class JPypeClassLoader(ClassLoader):
wrapper_for_java_builtin_type = {
"byte": jpype.JByte,
#"short": jpype.JShort,
"int": jpype.JInt,
"long": jpype.JLong,
"float": jpype.JFloat,
"double": jpype.JBoolean,
"char... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/utils/bridge/jpype_loader.py",
"copies": "3",
"size": "1879",
"license": "apache-2.0",
"hash": -5447974062265912000,
"line_mean": 30.3166666667,
"line_max": 77,
"alpha_frac": 0.6593932943,
"autogenerated": false,
"ratio": 3.684313725490196,
"config_... |
import logging
import os
from pydoop.mapreduce.simulator import HadoopSimulatorNetwork
DATA = """1 Chapter One Down the Rabbit Hole: Alice is feeling bored while
1 sitting on the riverbank with her elder sister, when she notices a
1 talking, clothed White Rabbit with a pocket watch run past. She
1 follows it down a... | {
"repo_name": "kikkomep/pydoop",
"path": "test/mapreduce/try_network_simulator.py",
"copies": "3",
"size": "3474",
"license": "apache-2.0",
"hash": -5278668241790096000,
"line_mean": 33.396039604,
"line_max": 77,
"alpha_frac": 0.6801957398,
"autogenerated": false,
"ratio": 3.376093294460641,
"c... |
import os
import importlib
from abc import abstractmethod, ABCMeta
class JavaWrapperFactory(object):
_instance = None
def __init__(self, java_bridge_name="JPype",
java_bridge_package="pydoop.utils.bridge",
classpath=None, opts=""):
self._classpath = None
if... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/utils/bridge/factory.py",
"copies": "3",
"size": "3504",
"license": "apache-2.0",
"hash": -7862147203006639000,
"line_mean": 29.4695652174,
"line_max": 77,
"alpha_frac": 0.6418378995,
"autogenerated": false,
"ratio": 3.9727891156462585,
"config_test... |
import os
import sys
import fnmatch
def get_java_home():
try:
return os.environ["JAVA_HOME"]
except KeyError:
raise RuntimeError("java home not found, try setting JAVA_HOME")
def load_jvm_lib(java_home=None):
if not java_home:
java_home = get_java_home()
jvm_path, jvm_lib = ... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/utils/jvm.py",
"copies": "3",
"size": "3538",
"license": "apache-2.0",
"hash": -5604271268377117000,
"line_mean": 29.2393162393,
"line_max": 77,
"alpha_frac": 0.6139061617,
"autogenerated": false,
"ratio": 3.438289601554908,
"config_test": false,
... |
import os
from pydoop.mapreduce.simulator import HadoopSimulatorNetwork
from pydoop.mapreduce.pipes import InputSplit
# needs "stats.avsc" in the cwd
def main():
program_name = './avro_pyrw.py'
data_in = './users.avro'
path = os.path.realpath(data_in)
length = os.stat(path).st_size
input_split =... | {
"repo_name": "kikkomep/pydoop",
"path": "examples/avro/py/simulate_cc.py",
"copies": "3",
"size": "1285",
"license": "apache-2.0",
"hash": 2211176821269357800,
"line_mean": 29.5952380952,
"line_max": 77,
"alpha_frac": 0.6988326848,
"autogenerated": false,
"ratio": 3.463611859838275,
"config_te... |
import random
import sys
offices = ['office-%s' % i for i in xrange(3)]
colors = ['red', 'blue', 'yellow', 'orange', 'maroon', 'green']
names = ['Alyssa', 'John', 'Kathy', 'Ben', 'Karla', 'Ross', 'Violetta']
def create_input(n, stream):
for i in range(n):
stream.write(';'.join([
random.choic... | {
"repo_name": "kikkomep/pydoop",
"path": "examples/avro/py/create_input.py",
"copies": "3",
"size": "1183",
"license": "apache-2.0",
"hash": -3096787670465134000,
"line_mean": 27.8536585366,
"line_max": 77,
"alpha_frac": 0.6534234996,
"autogenerated": false,
"ratio": 3.3512747875354107,
"config... |
import re
import pydoop.mapreduce.api as api
import pydoop.mapreduce.pipes as pp
class Mapper(api.Mapper):
def map(self, context):
words = re.sub('[^0-9a-zA-Z]+', ' ', context.getInputValue()).split()
for w in words:
context.emit(w, 1)
class Reducer(api.Reducer):
def reduce(s... | {
"repo_name": "ilveroluca/pydoop",
"path": "examples/input_format/wordcount_rr.py",
"copies": "3",
"size": "1123",
"license": "apache-2.0",
"hash": -2367379758760120000,
"line_mean": 25.1162790698,
"line_max": 77,
"alpha_frac": 0.7016918967,
"autogenerated": false,
"ratio": 3.4660493827160495,
... |
import sys
from collections import Counter
def main(efname, rfname):
expected = {}
with open(efname) as f:
for l in f:
p = l.strip().split(';')
expected.setdefault(p[1], Counter())[p[2]] += 1
computed = {}
with open(rfname) as f:
for l in f:
p = l... | {
"repo_name": "ilveroluca/pydoop",
"path": "examples/avro/py/check_results.py",
"copies": "3",
"size": "1375",
"license": "apache-2.0",
"hash": -4016913356522041300,
"line_mean": 28.2553191489,
"line_max": 77,
"alpha_frac": 0.6196363636,
"autogenerated": false,
"ratio": 3.55297157622739,
"confi... |
import sys
import os
import logging
import time
import numbers
from cStringIO import StringIO
from copy import deepcopy
from pydoop import hadoop_version_info
from pydoop.utils.serialize import (
deserialize_text,
deserialize_long,
serialize_old_style_filename,
deserialize_old_style_filename,
seri... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/mapreduce/pipes.py",
"copies": "3",
"size": "17949",
"license": "apache-2.0",
"hash": 7857156569605061000,
"line_mean": 32.802259887,
"line_max": 79,
"alpha_frac": 0.601927684,
"autogenerated": false,
"ratio": 3.9318729463307776,
"config_test": fals... |
import sys
import os
import logging
logging.basicConfig(level=logging.INFO)
from pydoop.hdfs import hdfs
import pydoop.test_support as pts
def get_res(output_dir):
fs = hdfs()
data = []
for x in fs.list_directory(output_dir):
if os.path.split(x['path'])[-1].startswith('part-'):
with... | {
"repo_name": "kikkomep/pydoop",
"path": "examples/input_format/check_results.py",
"copies": "3",
"size": "1646",
"license": "apache-2.0",
"hash": 4185572903502480000,
"line_mean": 26.4333333333,
"line_max": 77,
"alpha_frac": 0.6780072904,
"autogenerated": false,
"ratio": 3.4008264462809916,
"c... |
import sys
import os
import re
import logging
logging.basicConfig(level=logging.INFO)
from pydoop.hdfs import hdfs
import pydoop.test_support as pts
try:
from collections import Counter # new in Python 2.7
except ImportError:
class Counter(dict):
def __init__(self, seq):
super(Counter, ... | {
"repo_name": "ilveroluca/pydoop",
"path": "examples/self_contained/check_results.py",
"copies": "3",
"size": "2163",
"license": "apache-2.0",
"hash": 5024443491933460000,
"line_mean": 26.0375,
"line_max": 77,
"alpha_frac": 0.6444752658,
"autogenerated": false,
"ratio": 3.390282131661442,
"conf... |
import sys
import os
import socket
from threading import Thread, Event
import logging
from pydoop.sercore import fdopen as ph_fdopen
from .text_streams import TextDownStreamFilter, TextUpStreamFilter
from .binary_streams import BinaryDownStreamFilter, BinaryUpStreamFilter
logging.basicConfig(level=logging.CRITICAL)... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/mapreduce/connections.py",
"copies": "3",
"size": "3396",
"license": "apache-2.0",
"hash": -887743863597859000,
"line_mean": 29.8727272727,
"line_max": 77,
"alpha_frac": 0.6383981154,
"autogenerated": false,
"ratio": 3.841628959276018,
"config_test"... |
import sys
import os
import unittest
import tempfile
from numbers import Number
import pydoop.hdfs as hdfs
from pydoop.hdfs.common import DEFAULT_PORT, DEFAULT_USER
from pydoop.utils.misc import make_random_str
from pydoop.test_utils import UNI_CHR
def uni_last(tup):
return tup[:-1] + (tup[-1]+UNI_CHR,)
class... | {
"repo_name": "kikkomep/pydoop",
"path": "test/hdfs/test_path.py",
"copies": "3",
"size": "20264",
"license": "apache-2.0",
"hash": 735280923060532100,
"line_mean": 33.4040747029,
"line_max": 78,
"alpha_frac": 0.5151993683,
"autogenerated": false,
"ratio": 3.41029956243689,
"config_test": true,... |
import sys
sys.path.insert(0, '../../build/lib.linux-x86_64-2.7')
from pydoop.mapreduce.binary_streams import (
BinaryDownStreamFilter, BinaryWriter
)
from timer import Timer
def test_write(N, fname):
with open(fname, 'w') as f:
writer = BinaryWriter(f)
def foo():
writer_send =... | {
"repo_name": "mdrio/pydoop",
"path": "test/timings/try_binary.py",
"copies": "3",
"size": "2391",
"license": "apache-2.0",
"hash": 6958681809202273000,
"line_mean": 25.5666666667,
"line_max": 77,
"alpha_frac": 0.5872020075,
"autogenerated": false,
"ratio": 3.4752906976744184,
"config_test": fa... |
import time
class Timer(object):
def __init__(self, verbose=False):
self.verbose = verbose
def __enter__(self):
self.start = time.time()
return self
def __exit__(self, *args):
self.end = time.time()
self.secs = self.end - self.start
self.msecs = self.sec... | {
"repo_name": "ilveroluca/pydoop",
"path": "test/timings/timer.py",
"copies": "3",
"size": "1028",
"license": "apache-2.0",
"hash": 688489828460174600,
"line_mean": 27.5555555556,
"line_max": 77,
"alpha_frac": 0.6750972763,
"autogenerated": false,
"ratio": 3.8074074074074074,
"config_test": fal... |
import unittest
from pydoop.mapreduce.api import JobConf
class jobconf_tc(unittest.TestCase):
def test_missing_key(self):
jc = JobConf(((1, 2), (3, 4)))
self.assertRaises(RuntimeError, jc.get, 'no_key')
def suite():
suite = unittest.TestSuite()
suite.addTest(jobconf_tc('test_missing_key... | {
"repo_name": "ilveroluca/pydoop",
"path": "test/backward_compatibility/test_jobconf.py",
"copies": "3",
"size": "1054",
"license": "apache-2.0",
"hash": 5832291167517452000,
"line_mean": 27.4864864865,
"line_max": 77,
"alpha_frac": 0.7134724858,
"autogenerated": false,
"ratio": 3.685314685314685... |
import unittest
from pydoop.test_utils import get_module
TEST_MODULE_NAMES = [
'test_serialize',
]
def suite(path=None):
suites = []
for module in TEST_MODULE_NAMES:
suites.append(get_module(module, path).suite())
return unittest.TestSuite(suites)
if __name__ == '__main__':
import sys... | {
"repo_name": "mdrio/pydoop",
"path": "test/serialize/all_tests.py",
"copies": "3",
"size": "1037",
"license": "apache-2.0",
"hash": 7758051547070031000,
"line_mean": 26.2894736842,
"line_max": 77,
"alpha_frac": 0.7193828351,
"autogenerated": false,
"ratio": 3.7302158273381294,
"config_test": t... |
import unittest
from pydoop.test_utils import get_module
TEST_MODULE_NAMES = [
'test_submit',
]
def suite(path=None):
suites = []
for module in TEST_MODULE_NAMES:
suites.append(get_module(module, path).suite())
return unittest.TestSuite(suites)
if __name__ == '__main__':
import sys
... | {
"repo_name": "kikkomep/pydoop",
"path": "test/app/all_tests.py",
"copies": "3",
"size": "1034",
"license": "apache-2.0",
"hash": -2618415973447225300,
"line_mean": 26.2105263158,
"line_max": 77,
"alpha_frac": 0.7185686654,
"autogenerated": false,
"ratio": 3.7194244604316546,
"config_test": tru... |
import unittest
import getpass
import tempfile
import os
import pydoop.hdfs as hdfs
from common_hdfs_tests import TestCommon, common_tests
class TestConnection(unittest.TestCase):
def runTest(self):
current_user = getpass.getuser()
cwd = os.getcwd()
os.chdir(tempfile.gettempdir())
... | {
"repo_name": "ilveroluca/pydoop",
"path": "test/hdfs/test_local_fs.py",
"copies": "3",
"size": "1580",
"license": "apache-2.0",
"hash": -4434233968028293000,
"line_mean": 25.7796610169,
"line_max": 77,
"alpha_frac": 0.6753164557,
"autogenerated": false,
"ratio": 3.8256658595641646,
"config_tes... |
import unittest
import itertools as it
import os
from collections import Counter
from pydoop.mapreduce.api import Mapper, Reducer, Factory, JobConf
from pydoop.mapreduce.simulator import HadoopSimulatorLocal
from pydoop.mapreduce.simulator import TrivialRecordReader
from pydoop.test_utils import WDTestCase
from pydoo... | {
"repo_name": "kikkomep/pydoop",
"path": "test/mapreduce/test_support.py",
"copies": "3",
"size": "7990",
"license": "apache-2.0",
"hash": -610112717174666600,
"line_mean": 34.8295964126,
"line_max": 79,
"alpha_frac": 0.6046307885,
"autogenerated": false,
"ratio": 3.4499136442141625,
"config_te... |
import unittest
import itertools as it
from pydoop.mapreduce.streams import ProtocolError
from pydoop.mapreduce.text_streams import TextDownStreamFilter
from pydoop.test_utils import WDTestCase
STREAM_1 = [
('start', 0),
('setJobConf', 'key1', 'value1', 'key2', 'value2'),
('setInputTypes', 'key_type', '... | {
"repo_name": "ilveroluca/pydoop",
"path": "test/mapreduce/test_text_stream.py",
"copies": "3",
"size": "2212",
"license": "apache-2.0",
"hash": -1773209451168504600,
"line_mean": 28.4933333333,
"line_max": 77,
"alpha_frac": 0.6112115732,
"autogenerated": false,
"ratio": 3.550561797752809,
"con... |
import unittest
import pydoop
pp = pydoop.import_version_specific_module('_pipes')
import gc
class str_lifetime_tc(unittest.TestCase):
def memory_stress(self):
N = 10000
S = 10000000
for x in xrange(N):
pp.create_a_string(S)
def push_leak_map_context(self):
N = ... | {
"repo_name": "mdrio/pydoop",
"path": "test/backward_compatibility/test_string_lifetime.py",
"copies": "3",
"size": "1776",
"license": "apache-2.0",
"hash": -5441221831721168000,
"line_mean": 26.3230769231,
"line_max": 77,
"alpha_frac": 0.6204954955,
"autogenerated": false,
"ratio": 3.66942148760... |
import unittest
import shutil
import tempfile
import os
import pydoop.app.main as app
from pydoop.app.submit import PydoopSubmitter
import re
def nop(x=None):
pass
class Args(object):
def __init__(self, **kwargs):
for k, v in kwargs.iteritems():
setattr(self, k, v)
def __getattr__(... | {
"repo_name": "mdrio/pydoop",
"path": "test/app/test_submit.py",
"copies": "2",
"size": "8619",
"license": "apache-2.0",
"hash": 8706878524347405000,
"line_mean": 34.4691358025,
"line_max": 86,
"alpha_frac": 0.5768650656,
"autogenerated": false,
"ratio": 3.785243741765481,
"config_test": true,
... |
import unittest
import tempfile
import os
import stat
import shutil
import subprocess as sp
from xml.dom.minidom import getDOMImplementation
DOM_IMPL = getDOMImplementation()
import pydoop.hadoop_utils as hu
class TestHadoopUtils(unittest.TestCase):
def setUp(self):
self.hadoop_version = "0.20.2"
... | {
"repo_name": "kikkomep/pydoop",
"path": "test/backward_compatibility/test_utils.py",
"copies": "3",
"size": "6007",
"license": "apache-2.0",
"hash": -2661754296162474000,
"line_mean": 38.2614379085,
"line_max": 78,
"alpha_frac": 0.5936407525,
"autogenerated": false,
"ratio": 3.418895845190666,
... |
"""
Abstract low-level HDFS interface.
"""
from abc import ABCMeta, abstractmethod
from pydoop.hdfs.common import BUFSIZE
class CoreHdfsFs(object):
"""
Abstract filesystem interface.
"""
__metaclass__ = ABCMeta
@abstractmethod
def close(self):
pass
@abstractmethod
def ope... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/hdfs/core/api.py",
"copies": "3",
"size": "3717",
"license": "apache-2.0",
"hash": -7345112057015538000,
"line_mean": 18.1597938144,
"line_max": 79,
"alpha_frac": 0.6236211999,
"autogenerated": false,
"ratio": 4.181102362204724,
"config_test": ... |
"""
An interface to simplify pydoop jobs submission.
"""
import os
import sys
import glob
import argparse
import logging
import uuid
logging.basicConfig(level=logging.INFO)
import pydoop
import pydoop.hdfs as hdfs
import pydoop.hadut as hadut
import pydoop.utils as utils
import pydoop.utils.conversion_tables as conv... | {
"repo_name": "kikkomep/pydoop",
"path": "pydoop/app/submit.py",
"copies": "1",
"size": "23246",
"license": "apache-2.0",
"hash": -259325651786797400,
"line_mean": 39.5689354276,
"line_max": 112,
"alpha_frac": 0.5873698701,
"autogenerated": false,
"ratio": 3.725917615002404,
"config_test": fals... |
"""
Avro tools.
"""
# DEV NOTE: since Avro is not a requirement, do *not* import this
# module anywhere in the main code (importing it in the Avro examples
# is OK, ofc).
from cStringIO import StringIO
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumW... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/avrolib.py",
"copies": "3",
"size": "8590",
"license": "apache-2.0",
"hash": -4632699503361526000,
"line_mean": 32.95256917,
"line_max": 77,
"alpha_frac": 0.6039580908,
"autogenerated": false,
"ratio": 3.725065047701648,
"config_test": false,
"has... |
"""
Check that resetting the hdfs module after changing
os.environ['HADOOP_CONF_DIR'] works (i.e., Pydoop references the
correct HDFS service).
Note that it does **NOT** work if you've already instantiated an hdfs
handle, and this is NOT due to the caching system.
"""
import sys
import os
import argparse
import pyd... | {
"repo_name": "ilveroluca/pydoop",
"path": "test/backward_compatibility/try_hdfs.py",
"copies": "3",
"size": "1653",
"license": "apache-2.0",
"hash": 6023153216481835000,
"line_mean": 26.55,
"line_max": 77,
"alpha_frac": 0.6751361162,
"autogenerated": false,
"ratio": 3.3665987780040734,
"config... |
"""
Common hdfs utilities.
"""
import getpass
import pwd
import grp
BUFSIZE = 16384
DEFAULT_PORT = 8020 # org/apache/hadoop/hdfs/server/namenode/NameNode.java
DEFAULT_USER = getpass.getuser()
DEFAULT_LIBHDFS_OPTS = "-Xmx48m" # enough for most applications
# Unicode objects are encoded using this encoding:
TEXT_E... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/hdfs/common.py",
"copies": "3",
"size": "1771",
"license": "apache-2.0",
"hash": 6525480399187784000,
"line_mean": 25.0441176471,
"line_max": 77,
"alpha_frac": 0.7086391869,
"autogenerated": false,
"ratio": 3.479371316306483,
"config_test": fal... |
"""
Convert text to upper or lower case. By default, the program will
switch text to upper case. Set the config property
'caseswitch.case=lower' if you prefer to switch to lower case.
Set --kv-separator to the empty string when running this example.
"""
def mapper(_, record, writer, conf):
if conf['caseswitch... | {
"repo_name": "kikkomep/pydoop",
"path": "examples/pydoop_script/caseswitch.py",
"copies": "3",
"size": "1200",
"license": "apache-2.0",
"hash": 1752066336792908800,
"line_mean": 31.4324324324,
"line_max": 77,
"alpha_frac": 0.7025,
"autogenerated": false,
"ratio": 3.883495145631068,
"config_tes... |
"""
Generate an HDFS tree containing files of different block size.
"""
import sys
import random
import pydoop
import pydoop.hdfs as hdfs
from common import isdir, MB, TEST_ROOT
BS_RANGE = [_*MB for _ in range(50, 101, 10)]
def treegen(fs, root, depth, span):
if isdir(fs, root) and depth > 0:
for i ... | {
"repo_name": "ilveroluca/pydoop",
"path": "examples/hdfs/treegen.py",
"copies": "3",
"size": "2260",
"license": "apache-2.0",
"hash": -909842591202150900,
"line_mean": 26.9012345679,
"line_max": 77,
"alpha_frac": 0.5588495575,
"autogenerated": false,
"ratio": 3.616,
"config_test": false,
"ha... |
"""
HDFS core implementation.
"""
from . import impl
def init(backend=impl.DEFAULT):
if backend == impl.NATIVE:
import pydoop.utils.jvm as jvm
jvm.load_jvm_lib()
try:
# NOTE: JVM must be already instantiated
import pydoop.native_core_hdfs
except ImportErro... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/hdfs/core/__init__.py",
"copies": "3",
"size": "1709",
"license": "apache-2.0",
"hash": -1984589264308067800,
"line_mean": 28.9824561404,
"line_max": 78,
"alpha_frac": 0.6869514336,
"autogenerated": false,
"ratio": 3.8232662192393736,
"config_test":... |
"""
Important environment variables
-------------------------------
The Pydoop setup looks in a number of default paths for what it
needs. If necessary, you can override its behaviour or provide an
alternative path by exporting the environment variables below::
JAVA_HOME, e.g., /opt/sun-jdk
HADOOP_HOME, e.g., /... | {
"repo_name": "mdrio/pydoop",
"path": "setup.py",
"copies": "1",
"size": "14695",
"license": "apache-2.0",
"hash": 6734175505580446000,
"line_mean": 31.8013392857,
"line_max": 79,
"alpha_frac": 0.5973460361,
"autogenerated": false,
"ratio": 3.4519614752172894,
"config_test": true,
"has_no_key... |
"""
JPype-bridged HDFS core implementation.
"""
import os
import pydoop
from pydoop.utils.bridge.factory import JavaWrapperFactory
def get_implementation_module():
from . import hadoop
return hadoop
def init(bridge_type):
hadoop_classpath = pydoop.hadoop_classpath()
if hadoop_classpath is None:
... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/hdfs/core/bridged/__init__.py",
"copies": "3",
"size": "1316",
"license": "apache-2.0",
"hash": 2643279512804576000,
"line_mean": 24.8039215686,
"line_max": 77,
"alpha_frac": 0.7317629179,
"autogenerated": false,
"ratio": 3.7070422535211267,
"c... |
"""
Miscellaneous utilities for testing.
"""
import re
import sys
import os
import tempfile
from pydoop.hdfs import default_is_local
def inject_code(new_code, target_code):
"""
Inject new_code into target_code, before the first import.
NOTE: this is just a hack to make examples work out-of-the-box, in... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/test_support.py",
"copies": "3",
"size": "3704",
"license": "apache-2.0",
"hash": -2868349906231624000,
"line_mean": 27.0606060606,
"line_max": 79,
"alpha_frac": 0.5791036717,
"autogenerated": false,
"ratio": 3.541108986615679,
"config_test": f... |
"""
Pydoop command line tool.
"""
import os
import argparse
import importlib
import sys
from pydoop.version import version
SUBMOD_NAMES = [
"script",
"submit",
]
PYDOOP_CONF_FILE = "~/.pydoop/pydoop.conf"
class PatchedArgumentParser(argparse.ArgumentParser):
"""
This is a work-around for a bug i... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/app/main.py",
"copies": "1",
"size": "2665",
"license": "apache-2.0",
"hash": -3771648261050788400,
"line_mean": 30.3529411765,
"line_max": 77,
"alpha_frac": 0.6615384615,
"autogenerated": false,
"ratio": 3.711699164345404,
"config_test": false,
"... |
"""
Pydoop command line tool.
"""
import os
import argparse
import importlib
from pydoop.version import version
SUBMOD_NAMES = [
"script",
"submit",
]
PYDOOP_CONF_FILE = "~/.pydoop/pydoop.conf"
class PatchedArgumentParser(argparse.ArgumentParser):
"""
This is a work-around for a bug in ArgumentP... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/app/main.py",
"copies": "2",
"size": "2547",
"license": "apache-2.0",
"hash": -7919569533096347000,
"line_mean": 30.4444444444,
"line_max": 77,
"alpha_frac": 0.6682371417,
"autogenerated": false,
"ratio": 3.7128279883381925,
"config_test": fals... |
"""
pydoop.hdfs.file -- HDFS File Objects
-------------------------------------
"""
import os
from pydoop.hdfs import common
def _complain_ifclosed(closed):
if closed:
raise ValueError("I/O operation on closed HDFS file object")
def _seek_with_boundary_checks(f, position, whence):
if whence == os... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/hdfs/file.py",
"copies": "3",
"size": "12020",
"license": "apache-2.0",
"hash": -7354317316912920000,
"line_mean": 28.6790123457,
"line_max": 77,
"alpha_frac": 0.5645590682,
"autogenerated": false,
"ratio": 4.034911043974488,
"config_test": false,
... |
"""
pydoop.hdfs.fs -- File System Handles
-------------------------------------
"""
import os
import socket
import urlparse
import getpass
import re
import operator as ops
import pydoop
from . import common
from .file import hdfs_file, local_file
from .core import core_hdfs_fs
class _FSStatus(object):
def __i... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/hdfs/fs.py",
"copies": "3",
"size": "20716",
"license": "apache-2.0",
"hash": 8524528727528280000,
"line_mean": 31.9872611465,
"line_max": 78,
"alpha_frac": 0.5547402974,
"autogenerated": false,
"ratio": 3.973149213655543,
"config_test": false,
"h... |
"""
pydoop.hdfs.path -- Path Name Manipulations
-------------------------------------------
"""
import os
import re
import time
from . import common, fs as hdfs_fs
curdir, pardir, sep = '.', '..', '/' # pylint: disable=C0103
class StatResult(object):
"""
Mimics the object type returned by :func:`os.stat... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/hdfs/path.py",
"copies": "3",
"size": "15469",
"license": "apache-2.0",
"hash": -8790600136500147000,
"line_mean": 27.3315018315,
"line_max": 78,
"alpha_frac": 0.5790936712,
"autogenerated": false,
"ratio": 3.644051825677267,
"config_test": false,
... |
"""
Pydoop Script
=============
A quick and easy to use interface for running simple MapReduce jobs.
Pydoop script is a front-end to pydoop submit that automatically builds
a map-reduce program using functions contained in a user provided
python module.
"""
import os
import warnings
import pydoop
import pydoop.had... | {
"repo_name": "kikkomep/pydoop",
"path": "pydoop/app/script.py",
"copies": "2",
"size": "6809",
"license": "apache-2.0",
"hash": 5311981317734880000,
"line_mean": 37.9085714286,
"line_max": 101,
"alpha_frac": 0.6310765164,
"autogenerated": false,
"ratio": 3.974897840046702,
"config_test": false... |
"""
The MapReduce API allows to write the components of a MapReduce application.
The basic MapReduce components (:class:`Mapper`, :class:`Reducer`,
:class:`RecordReader`, etc.) are provided as abstract classes that
must be subclassed by the developer, providing implementations for all
methods called by the framework... | {
"repo_name": "kikkomep/pydoop",
"path": "pydoop/mapreduce/api.py",
"copies": "3",
"size": "14538",
"license": "apache-2.0",
"hash": 5941688919930390000,
"line_mean": 25.3847549909,
"line_max": 79,
"alpha_frac": 0.6020085294,
"autogenerated": false,
"ratio": 4.24715162138475,
"config_test": fal... |
"""
This module provides basic, stand-alone Hadoop simulators for
debugging support.
"""
import SocketServer
import threading
import os
import tempfile
import uuid
import cStringIO
import logging
logging.basicConfig()
LOGGER = logging.getLogger('simulator')
LOGGER.setLevel(logging.CRITICAL)
# threading._VERBOSE = Tr... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/mapreduce/simulator.py",
"copies": "3",
"size": "31101",
"license": "apache-2.0",
"hash": -4499401372561116700,
"line_mean": 36.8357664234,
"line_max": 123,
"alpha_frac": 0.5782772258,
"autogenerated": false,
"ratio": 3.909125188536953,
"config... |
"""
Traverse an HDFS tree and output disk space usage by block size.
"""
import sys
import pydoop.hdfs as hdfs
from common import isdir, MB, TEST_ROOT
def usage_by_bs(fs, root):
stats = {}
for info in fs.walk(root):
if info['kind'] == 'directory':
continue
bs = int(info['block_si... | {
"repo_name": "ilveroluca/pydoop",
"path": "examples/hdfs/treewalk.py",
"copies": "3",
"size": "1421",
"license": "apache-2.0",
"hash": 3094117532303937000,
"line_mean": 25.8113207547,
"line_max": 77,
"alpha_frac": 0.6305418719,
"autogenerated": false,
"ratio": 3.482843137254902,
"config_test":... |
"""
Utilities for unit tests.
"""
import sys
import os
import random
import uuid
import tempfile
import pydoop
_HADOOP_HOME = pydoop.hadoop_home()
_HADOOP_CONF_DIR = pydoop.hadoop_conf()
_RANDOM_DATA_SIZE = 32
_DEFAULT_HDFS_HOST = "localhost"
_DEFAULT_HDFS_PORT = 8020 # if pydoop.is_cloudera() else 9000
_DEFAULT_... | {
"repo_name": "ilveroluca/pydoop",
"path": "test/mapreduce/utils.py",
"copies": "3",
"size": "3084",
"license": "apache-2.0",
"hash": -7834222809687425000,
"line_mean": 25.1355932203,
"line_max": 77,
"alpha_frac": 0.593385214,
"autogenerated": false,
"ratio": 3.199170124481328,
"config_test": f... |
r"""
This module allows you to connect to an HDFS installation, read and
write files and get information on files, directories and global
filesystem properties.
Configuration
-------------
The hdfs module is built on top of ``libhdfs``, in turn a JNI wrapper
around the Java fs code: therefore, for the module to wor... | {
"repo_name": "mdrio/pydoop",
"path": "pydoop/hdfs/__init__.py",
"copies": "3",
"size": "11600",
"license": "apache-2.0",
"hash": 8620677155202648000,
"line_mean": 28.9741602067,
"line_max": 79,
"alpha_frac": 0.5931896552,
"autogenerated": false,
"ratio": 3.5409035409035408,
"config_test": fals... |
"""Serialization routines based on Hadoop's SerialUtils.cc.
Client modules will typically use the ProtocolCodec interface to write binary
protocol interfaces as follows.
.. code-block:: python
from pydoop.utils.serialize import codec
MAP_ITEM = 4
codec.add_rule(MAP_ITEM, 'mapItem', 'ss')
# ... more cmd ... | {
"repo_name": "ilveroluca/pydoop",
"path": "pydoop/utils/serialize.py",
"copies": "3",
"size": "10541",
"license": "apache-2.0",
"hash": 2802355653415809000,
"line_mean": 28.8611898017,
"line_max": 79,
"alpha_frac": 0.6512664833,
"autogenerated": false,
"ratio": 3.658799028115238,
"config_test"... |
# DEV NOTE: this module is used by the setup script, so it MUST be
# importable even if Pydoop has not been installed (yet).
"""
Tools for retrieving information on the available Hadoop
installation(s): version, classpath, etc.
Known issues: from-tarball CDH installation is not supported.
"""
import os
import glob
... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/hadoop_utils.py",
"copies": "1",
"size": "19466",
"license": "apache-2.0",
"hash": -8995807190169622000,
"line_mean": 32.8539130435,
"line_max": 79,
"alpha_frac": 0.5322613788,
"autogenerated": false,
"ratio": 3.7812742812742814,
"config_test": fa... |
from abc import abstractmethod
from itertools import groupby
from operator import itemgetter
from pydoop.utils.py3compat import ABC
from pydoop.utils.serialize import private_decode
# these constants should be exactly what has been defined in
# PipesMapper.java and BinaryProtocol.java
START_MESSAGE = 0
SET_JOB_CONF... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/streams.py",
"copies": "1",
"size": "4999",
"license": "apache-2.0",
"hash": -1883578882791362000,
"line_mean": 23.8706467662,
"line_max": 77,
"alpha_frac": 0.6703340668,
"autogenerated": false,
"ratio": 3.638282387190684,
"config_test":... |
from __future__ import print_function
from pydoop.mapreduce.binary_streams import (
BinaryWriter, BinaryDownStreamFilter
)
import sys
sys.path.append('./build/lib.linux-x86_64-2.7')
import dummy
from timer import Timer
def write_data(N, fname):
with open(fname, 'w') as f:
writer = BinaryWriter(f)... | {
"repo_name": "elzaggo/pydoop",
"path": "test/timings/binary_build.py",
"copies": "1",
"size": "2133",
"license": "apache-2.0",
"hash": -8091075598876089000,
"line_mean": 25.012195122,
"line_max": 79,
"alpha_frac": 0.6465072668,
"autogenerated": false,
"ratio": 3.3380281690140845,
"config_test"... |
from __future__ import print_function
from timer import Timer
import jpyutil
jvm = jpyutil.init_jvm(jvm_maxmem='48M')
import jpy
N = 256
z = '\xff' * N * 1024
with Timer() as t:
bz = bytearray(z) # view string as bytearray
a = jpy.array('byte', bz) # project this to a java array
ba = bytearray(a) # b... | {
"repo_name": "elzaggo/pydoop",
"path": "test/timings/try_jpy.py",
"copies": "1",
"size": "1043",
"license": "apache-2.0",
"hash": 1329887047148212500,
"line_mean": 30.6060606061,
"line_max": 79,
"alpha_frac": 0.7133269415,
"autogenerated": false,
"ratio": 3.3973941368078178,
"config_test": fal... |
from __future__ import print_function
import sys
sys.path.insert(0, '../../build/lib.linux-x86_64-2.7')
from pydoop.mapreduce.binary_streams import (
BinaryDownStreamFilter, BinaryWriter
)
from timer import Timer
def test_write(N, fname):
with open(fname, 'w') as f:
writer = BinaryWriter(f)
... | {
"repo_name": "elzaggo/pydoop",
"path": "test/timings/try_binary.py",
"copies": "1",
"size": "2437",
"license": "apache-2.0",
"hash": -155759118024358270,
"line_mean": 25.4891304348,
"line_max": 77,
"alpha_frac": 0.588018055,
"autogenerated": false,
"ratio": 3.461647727272727,
"config_test": fa... |
from __future__ import print_function
import time
class Timer(object):
def __init__(self, verbose=False):
self.verbose = verbose
def __enter__(self):
self.start = time.time()
return self
def __exit__(self, *args):
self.end = time.time()
self.secs = self.end - se... | {
"repo_name": "elzaggo/pydoop",
"path": "test/timings/timer.py",
"copies": "1",
"size": "1067",
"license": "apache-2.0",
"hash": 7228436923076952000,
"line_mean": 27.8378378378,
"line_max": 77,
"alpha_frac": 0.6776007498,
"autogenerated": false,
"ratio": 3.8107142857142855,
"config_test": false... |
from __future__ import print_function
import argparse
import io
import os
import sys
RECORD_LEN = 100
BUFSIZE = 32 * 1024
def iterrecords(f):
while True:
record = f.read(RECORD_LEN)
if not record:
raise StopIteration
yield record
def check_record(i, record):
assert le... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/check_input.py",
"copies": "1",
"size": "1794",
"license": "apache-2.0",
"hash": 2040963226508937200,
"line_mean": 25.776119403,
"line_max": 77,
"alpha_frac": 0.6426978818,
"autogenerated": false,
"ratio": 3.5176470588235293,
"co... |
from pydoop.app.submit import (
add_parser_common_arguments,
add_parser_arguments)
from pydoop.app.submit import PydoopSubmitter
import sys
import argparse
DEFAULT_NUM_RECORDS = 100000
DEFAULT_NUM_MAPS = 2
NUM_ROWS_KEY = 'mapreduce.pterasort.num-rows'
NUM_MAPS_KEY = 'mapreduce.job.maps'
def make_parser():
... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/genrecords.py",
"copies": "1",
"size": "2271",
"license": "apache-2.0",
"hash": -5646531770210707000,
"line_mean": 28.4935064935,
"line_max": 77,
"alpha_frac": 0.6715103479,
"autogenerated": false,
"ratio": 3.207627118644068,
"co... |
from .streams import (
StreamWriter, StreamReader, DownStreamAdapter, UpStreamAdapter,
)
from pydoop.utils.serialize import CommandReader, CommandWriter, RULES
from pydoop.utils.py3compat import unicode
import logging
logging.basicConfig()
LOGGER = logging.getLogger('binary_streams')
LOGGER.setLevel(logging.CRITI... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/binary_streams.py",
"copies": "1",
"size": "3428",
"license": "apache-2.0",
"hash": 8109470316151028000,
"line_mean": 32.9405940594,
"line_max": 79,
"alpha_frac": 0.6627771295,
"autogenerated": false,
"ratio": 3.9814169570267133,
"config... |
from .streams import (
StreamWriter, StreamReader,
DownStreamAdapter, UpStreamAdapter,
ProtocolAbort, ProtocolError
)
from .string_utils import quote_string, unquote_string
class TextWriter(StreamWriter):
SEP = '\t'
EOL = '\n'
CMD_TABLE = {
StreamWriter.START_MESSAGE: 'start',
... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/text_streams.py",
"copies": "1",
"size": "5193",
"license": "apache-2.0",
"hash": -8846336986489783000,
"line_mean": 35.829787234,
"line_max": 78,
"alpha_frac": 0.6133256307,
"autogenerated": false,
"ratio": 3.988479262672811,
"config_te... |
import hmac
import hashlib
import base64
import string
DIGITS = frozenset(string.digits)
QUOTE_MAP = {
'\\': '\\\\',
'\t': '\\t',
'\n': '\\n',
' ': '\\s',
}
UNQUOTE_MAP = {
't': '\t',
'n': '\n',
's': ' ',
'X': '\\',
}
def quote_string(in_string, deliminators='\\'):
return ''.joi... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/string_utils.py",
"copies": "1",
"size": "1516",
"license": "apache-2.0",
"hash": -6840124351428767000,
"line_mean": 24.2666666667,
"line_max": 77,
"alpha_frac": 0.6114775726,
"autogenerated": false,
"ratio": 3.1715481171548117,
"config_... |
import logging
import os
from pydoop.mapreduce.simulator import HadoopSimulatorNetwork
DATA = """1 Chapter One Down the Rabbit Hole: Alice is feeling bored while
1 sitting on the riverbank with her elder sister, when she notices a
1 talking, clothed White Rabbit with a pocket watch run past. She
1 follows it down a... | {
"repo_name": "elzaggo/pydoop",
"path": "test/mapreduce/try_network_simulator.py",
"copies": "1",
"size": "3605",
"license": "apache-2.0",
"hash": -8008870909040505000,
"line_mean": 33.3333333333,
"line_max": 78,
"alpha_frac": 0.6785020804,
"autogenerated": false,
"ratio": 3.369158878504673,
"c... |
import os
import io
import itertools as it
from concurrent.futures import ThreadPoolExecutor
from bintrees.avltree import AVLTree
import pydoop.mapreduce.api as api
import pydoop.mapreduce.pipes as pp
import pydoop.hdfs as hdfs
import pydoop.utils.serialize as srl
from ioformats import Reader, Writer, KEY_LENGTH, REC... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/pterasort.py",
"copies": "1",
"size": "4838",
"license": "apache-2.0",
"hash": 6069883307433751000,
"line_mean": 33.3120567376,
"line_max": 77,
"alpha_frac": 0.6062422489,
"autogenerated": false,
"ratio": 3.6568405139833713,
"con... |
import os
import sys
import fnmatch
def get_java_home():
try:
return os.environ["JAVA_HOME"]
except KeyError:
raise RuntimeError("java home not found, try setting JAVA_HOME")
def load_jvm_lib(java_home=None):
if not java_home:
java_home = get_java_home()
jvm_path, jvm_lib = ... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/utils/jvm.py",
"copies": "1",
"size": "3538",
"license": "apache-2.0",
"hash": 5276341812160425000,
"line_mean": 29.2393162393,
"line_max": 77,
"alpha_frac": 0.6139061617,
"autogenerated": false,
"ratio": 3.438289601554908,
"config_test": false,
... |
import pickle
import io
from collections import Counter
import pydoop.hdfs as hdfs
from pterasort import Partitioner
RECORD_LENGTH = 91
KEY_LENGTH = 10
fname = Partitioner.initialize_break_points(
5, 1000, '/user/root/genrecords_output'
)
with io.open('__break_point_cache_file', 'rb') as f:
data = f.read()
... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/test_partitioner.py",
"copies": "1",
"size": "1244",
"license": "apache-2.0",
"hash": -5323606031987155000,
"line_mean": 28.619047619,
"line_max": 77,
"alpha_frac": 0.7395498392,
"autogenerated": false,
"ratio": 3.353099730458221,
... |
import pydoop.mapreduce.api as api
import pydoop.hdfs as hdfs
import logging
logging.basicConfig()
LOGGER = logging.getLogger("ioformats")
LOGGER.setLevel(logging.WARNING)
KEY_LENGTH = 10
RECORD_LENGTH = 100 # key + value
class Writer(api.RecordWriter):
def __init__(self, context):
super(Writer, self... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/ioformats.py",
"copies": "1",
"size": "3578",
"license": "apache-2.0",
"hash": -1405037462609087700,
"line_mean": 31.8256880734,
"line_max": 77,
"alpha_frac": 0.6173840134,
"autogenerated": false,
"ratio": 3.7270833333333333,
"co... |
import pydoop.mapreduce.api as api
import pydoop.mapreduce.pipes as pp
from ioformats import CheckReader as Reader
import logging
logging.basicConfig()
LOGGER = logging.getLogger("pteracheck")
LOGGER.setLevel(logging.CRITICAL)
class StupidMapper(api.Mapper):
def __init__(self, context):
super(StupidMa... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/pteracheck.py",
"copies": "1",
"size": "2032",
"license": "apache-2.0",
"hash": 7705318266548718000,
"line_mean": 28.0285714286,
"line_max": 77,
"alpha_frac": 0.6692913386,
"autogenerated": false,
"ratio": 3.5400696864111496,
"co... |
import pydoop.mapreduce.streams as streams
JOB_CONF = (
'k', 'v',
'mapreduce.job.inputformat.class', 'foo',
'mapreduce.pipes.isjavarecordreader', 'true',
'mapreduce.pipes.isjavarecordwriter', 'true',
)
STREAM_1_DATA = [
(streams.MAP_ITEM, 'key1', 'val1'),
(streams.MAP_ITEM, 'key2', 'val2'),
... | {
"repo_name": "elzaggo/pydoop",
"path": "test/mapreduce/data/stream_data.py",
"copies": "1",
"size": "3198",
"license": "apache-2.0",
"hash": -4840481813749175000,
"line_mean": 31.9690721649,
"line_max": 77,
"alpha_frac": 0.6413383365,
"autogenerated": false,
"ratio": 2.9339449541284406,
"confi... |
import random
import sys
offices = ['office-%s' % i for i in range(3)]
colors = ['red', 'blue', 'yellow', 'orange', 'maroon', 'green']
names = ['Alyssa', 'John', 'Kathy', 'Ben', 'Karla', 'Ross', 'Violetta']
def create_input(n, stream):
for i in range(n):
stream.write(';'.join([
random.choice... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/create_input.py",
"copies": "1",
"size": "1183",
"license": "apache-2.0",
"hash": -1459722362899081200,
"line_mean": 27.1666666667,
"line_max": 77,
"alpha_frac": 0.652578191,
"autogenerated": false,
"ratio": 3.3512747875354107,
"config_t... |
import sys
import argparse
from pydoop.app.submit import (
add_parser_common_arguments,
add_parser_arguments)
from pydoop.app.submit import PydoopSubmitter
from pterasort import Partitioner
DEFAULT_SAMPLED_RECORDS = 100
DEFAULT_NUM_THREADS = 4
def make_parser():
parser = argparse.ArgumentParser()
p... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/sortrecords.py",
"copies": "1",
"size": "2091",
"license": "apache-2.0",
"hash": 2591848123658345500,
"line_mean": 30.2089552239,
"line_max": 77,
"alpha_frac": 0.649928264,
"autogenerated": false,
"ratio": 3.714031971580817,
"con... |
import sys
import csv
from operator import itemgetter
LIMIT = 10
def main(argv):
with open(argv[1]) as f:
reader = csv.reader(f, delimiter='\t')
data = [(k, int(v)) for (k, v) in reader]
data.sort(key=itemgetter(1), reverse=True)
for i, t in enumerate(data):
sys.stdou... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/show_kmer_count.py",
"copies": "1",
"size": "1053",
"license": "apache-2.0",
"hash": -8755524352792435000,
"line_mean": 26.7105263158,
"line_max": 77,
"alpha_frac": 0.6628679962,
"autogenerated": false,
"ratio": 3.5816326530612246,
"conf... |
import sys
import csv
import avro.schema
from avro.datafile import DataFileWriter
from avro.io import DatumWriter
parse = avro.schema.Parse if sys.version_info[0] == 3 else avro.schema.parse
FIELDS = ['name', 'office', 'favorite_color']
def main(schema_fn, csv_fn, avro_fn):
with open(schema_fn) as f_in:
... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/write_avro.py",
"copies": "1",
"size": "1525",
"license": "apache-2.0",
"hash": 5149389795546262000,
"line_mean": 28.9019607843,
"line_max": 77,
"alpha_frac": 0.6642622951,
"autogenerated": false,
"ratio": 3.3664459161147904,
"config_tes... |
import sys
import os
import argparse
from collections import Counter
import pydoop.hadut as hadut
import pydoop.hdfs as hdfs
import pydoop.test_support as pts
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DEFAULT_INPUT_DIR = os.path.join(THIS_DIR, os.pardir, "input")
CHECKS = [
"base_histogram",
"cas... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pydoop_script/check.py",
"copies": "1",
"size": "4317",
"license": "apache-2.0",
"hash": 2828317787085260000,
"line_mean": 29.8357142857,
"line_max": 79,
"alpha_frac": 0.6275191105,
"autogenerated": false,
"ratio": 3.359533073929961,
"config_tes... |
import sys
import os
import argparse
from pydoop.app.submit import (
add_parser_common_arguments,
add_parser_arguments)
from pydoop.app.submit import PydoopSubmitter
import pydoop.hdfs as hdfs
def make_parser():
parser = argparse.ArgumentParser()
add_parser_common_arguments(parser)
add_parser_ar... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pseudo_terasort/checkrecords.py",
"copies": "1",
"size": "1955",
"license": "apache-2.0",
"hash": 6391386018949097000,
"line_mean": 27.75,
"line_max": 77,
"alpha_frac": 0.6751918159,
"autogenerated": false,
"ratio": 3.274706867671692,
"config_te... |
import sys
import os
import errno
from collections import Counter
from avro.io import DatumReader
from avro.datafile import DataFileReader
from pydoop.utils.py3compat import iteritems
def iter_fnames(path):
try:
contents = os.listdir(path)
except OSError as e:
if e.errno == errno.ENOTDIR:
... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/check_cc.py",
"copies": "1",
"size": "1937",
"license": "apache-2.0",
"hash": -305784376850504060,
"line_mean": 27.4852941176,
"line_max": 77,
"alpha_frac": 0.6097057305,
"autogenerated": false,
"ratio": 3.668560606060606,
"config_test":... |
import sys
import os
import errno
from collections import Counter
from pydoop.utils.py3compat import iteritems
def iter_lines(path):
try:
contents = os.listdir(path)
except OSError as e:
if e.errno == errno.ENOTDIR:
contents = [path]
for name in contents:
with open(os... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/check_results.py",
"copies": "1",
"size": "1677",
"license": "apache-2.0",
"hash": -3010747108164321300,
"line_mean": 26.4918032787,
"line_max": 77,
"alpha_frac": 0.6231365534,
"autogenerated": false,
"ratio": 3.5756929637526653,
"config... |
import sys
import os
import logging
import time
import numbers
import struct
import types
from copy import deepcopy
from pydoop import hadoop_version_info
from pydoop.utils.serialize import (
deserialize_text,
deserialize_long,
serialize_old_style_filename,
deserialize_old_style_filename,
seriali... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/pipes.py",
"copies": "1",
"size": "21990",
"license": "apache-2.0",
"hash": -6981614046066680000,
"line_mean": 34.0159235669,
"line_max": 79,
"alpha_frac": 0.6068212824,
"autogenerated": false,
"ratio": 3.8694351574872425,
"config_test":... |
import sys
import os
import logging
logging.basicConfig(level=logging.INFO)
from pydoop.hdfs import hdfs
import pydoop.test_support as pts
def get_res(output_dir):
fs = hdfs()
data = []
for x in fs.list_directory(output_dir):
if os.path.split(x['path'])[-1].startswith('part-'):
with... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/input_format/check_results.py",
"copies": "1",
"size": "1653",
"license": "apache-2.0",
"hash": -668354664021569900,
"line_mean": 26.0983606557,
"line_max": 77,
"alpha_frac": 0.6763460375,
"autogenerated": false,
"ratio": 3.3942505133470227,
"co... |
import sys
import os
import shutil
import tempfile
from pydoop.mapreduce.simulator import HadoopSimulatorNetwork
from pydoop.mapreduce.pipes import InputSplit
import pydoop.test_support as pts
WD = tempfile.mkdtemp(prefix="pydoop_")
def cp_script(script):
dest = os.path.join(WD, os.path.basename(script))
w... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/simulate_cc.py",
"copies": "1",
"size": "1754",
"license": "apache-2.0",
"hash": 1945117965059372300,
"line_mean": 28.7288135593,
"line_max": 77,
"alpha_frac": 0.6870011403,
"autogenerated": false,
"ratio": 3.3473282442748094,
"config_te... |
import sys
import os
import socket
import logging
from .text_streams import TextDownStreamAdapter, TextUpStreamAdapter
from .binary_streams import BinaryDownStreamAdapter, BinaryUpStreamAdapter
logging.basicConfig(level=logging.CRITICAL)
LOGGER = logging.getLogger('connections')
BUF_SIZE = 128 * 1024
class Conn... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/connections.py",
"copies": "1",
"size": "2506",
"license": "apache-2.0",
"hash": 2928358723845819000,
"line_mean": 30.325,
"line_max": 78,
"alpha_frac": 0.7110933759,
"autogenerated": false,
"ratio": 3.6318840579710145,
"config_test": fa... |
import sys
import random
import avro.schema
from avro.datafile import DataFileWriter
from avro.io import DatumWriter
if sys.version_info[0] == 3:
xrange = range
parse = avro.schema.Parse
else:
parse = avro.schema.parse
NAME_POOL = ['george', 'john', 'paul', 'ringo']
OFFICE_POOL = ['office-%d' % _ for _ ... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/generate_avro_users.py",
"copies": "1",
"size": "1721",
"license": "apache-2.0",
"hash": -5739901895168507000,
"line_mean": 28.1694915254,
"line_max": 77,
"alpha_frac": 0.6380011621,
"autogenerated": false,
"ratio": 3.435129740518962,
"c... |
import sys
import re
import logging
from collections import Counter
logging.basicConfig(level=logging.INFO)
from pydoop.hdfs import hdfs
import pydoop.test_support as pts
import pydoop.hadut as hadut
def compute_vc(input_dir):
fs = hdfs()
data = []
for x in fs.list_directory(input_dir):
with fs... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/self_contained/check_results.py",
"copies": "1",
"size": "1740",
"license": "apache-2.0",
"hash": -1005749735056011100,
"line_mean": 25.3636363636,
"line_max": 77,
"alpha_frac": 0.6896551724,
"autogenerated": false,
"ratio": 3.359073359073359,
"... |
import sys
import unittest
from pydoop.test_utils import get_module
TEST_MODULE_NAMES = [
'test_hadoop_utils',
'test_hadut',
'test_pydoop',
]
def suite(path=None):
suites = []
for module in TEST_MODULE_NAMES:
suites.append(get_module(module, path).suite())
return unittest.TestSuite... | {
"repo_name": "elzaggo/pydoop",
"path": "test/common/all_tests.py",
"copies": "1",
"size": "1095",
"license": "apache-2.0",
"hash": 4840029606489817000,
"line_mean": 23.3333333333,
"line_max": 77,
"alpha_frac": 0.7105022831,
"autogenerated": false,
"ratio": 3.6258278145695364,
"config_test": tr... |
import sys
from avro.io import DatumReader
from avro.datafile import DataFileReader
def main(fn, out_fn, avro_mode=''):
with open(out_fn, 'w') as fo:
with open(fn, 'rb') as f:
reader = DataFileReader(f, DatumReader())
for r in reader:
if avro_mode.upper() == 'KV':... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/avro/py/avro_container_dump_results.py",
"copies": "1",
"size": "1109",
"license": "apache-2.0",
"hash": 6665231172398495000,
"line_mean": 28.1842105263,
"line_max": 77,
"alpha_frac": 0.6474301172,
"autogenerated": false,
"ratio": 3.52063492063492... |
import unittest
from pydoop.mapreduce.api import JobConf
class jobconf_tc(unittest.TestCase):
def test_missing_key(self):
jc = JobConf(('a', 'b', 'c', 'd'))
self.assertRaises(RuntimeError, jc.get, 'no_key')
def suite():
suite = unittest.TestSuite()
suite.addTest(jobconf_tc('test_missing... | {
"repo_name": "elzaggo/pydoop",
"path": "test/mapreduce/test_jobconf.py",
"copies": "1",
"size": "1058",
"license": "apache-2.0",
"hash": -5259677141545608000,
"line_mean": 27.5945945946,
"line_max": 77,
"alpha_frac": 0.7107750473,
"autogenerated": false,
"ratio": 3.673611111111111,
"config_tes... |
import unittest
from pydoop.utils.serialize import FlowWriter, FlowReader
from pydoop.test_utils import WDTestCase
class TestFlow(WDTestCase):
def write_read_helper(self, N, rule, data):
fname = 'foo.dat' # self._mkfn('foo.dat')
with FlowWriter(open(fname, 'wb')) as stream:
for _ in ... | {
"repo_name": "elzaggo/pydoop",
"path": "test/serialize/test_flow.py",
"copies": "1",
"size": "2171",
"license": "apache-2.0",
"hash": -7813119362044831000,
"line_mean": 31.8939393939,
"line_max": 77,
"alpha_frac": 0.6034085675,
"autogenerated": false,
"ratio": 3.5415986949429037,
"config_test"... |
import unittest
import getpass
import socket
from itertools import product
import pydoop.hdfs as hdfs
import pydoop
from common_hdfs_tests import TestCommon, common_tests
import pydoop.test_utils as u
from pydoop.utils.py3compat import clong
CURRENT_USER = getpass.getuser()
class TestConnection(unittest.TestCase):... | {
"repo_name": "elzaggo/pydoop",
"path": "test/hdfs/test_hdfs_fs.py",
"copies": "1",
"size": "8056",
"license": "apache-2.0",
"hash": -7203747212715099000,
"line_mean": 34.1790393013,
"line_max": 79,
"alpha_frac": 0.5652929494,
"autogenerated": false,
"ratio": 3.5725055432372503,
"config_test": ... |
import unittest
import getpass
import tempfile
import os
import pydoop.hdfs as hdfs
from common_hdfs_tests import TestCommon, common_tests
class TestConnection(unittest.TestCase):
def runTest(self):
current_user = getpass.getuser()
cwd = os.getcwd()
os.chdir(tempfile.gettempdir())
... | {
"repo_name": "elzaggo/pydoop",
"path": "test/hdfs/test_local_fs.py",
"copies": "1",
"size": "1580",
"license": "apache-2.0",
"hash": -5310202553592374000,
"line_mean": 25.7796610169,
"line_max": 77,
"alpha_frac": 0.6753164557,
"autogenerated": false,
"ratio": 3.8256658595641646,
"config_test":... |
import unittest
import tempfile
import os
import stat
import shutil
import subprocess as sp
from xml.dom.minidom import getDOMImplementation
DOM_IMPL = getDOMImplementation()
import pydoop.hadoop_utils as hu
class TestHadoopUtils(unittest.TestCase):
def setUp(self):
self.hadoop_version = "0.20.2"
... | {
"repo_name": "elzaggo/pydoop",
"path": "test/common/test_hadoop_utils.py",
"copies": "1",
"size": "6008",
"license": "apache-2.0",
"hash": -4702220403739622000,
"line_mean": 38.2679738562,
"line_max": 78,
"alpha_frac": 0.5937083888,
"autogenerated": false,
"ratio": 3.4155770324047756,
"config_... |
"""
An interface to simplify pydoop jobs submission.
"""
import os
import sys
import glob
import argparse
import logging
import uuid
logging.basicConfig(level=logging.INFO)
import pydoop
import pydoop.hdfs as hdfs
import pydoop.hadut as hadut
import pydoop.utils as utils
import pydoop.utils.conversion_tables as conv... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/app/submit.py",
"copies": "1",
"size": "22500",
"license": "apache-2.0",
"hash": -2356729556907136000,
"line_mean": 38.6825396825,
"line_max": 79,
"alpha_frac": 0.5836,
"autogenerated": false,
"ratio": 3.7369207772795217,
"config_test": false,
"... |
"""
Avro tools.
"""
# DEV NOTE: since Avro is not a requirement, do *not* import this
# module anywhere in the main code (importing it in the Avro examples
# is OK, ofc).
import sys
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter, BinaryDecoder,... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/avrolib.py",
"copies": "1",
"size": "7937",
"license": "apache-2.0",
"hash": 7786764728036024000,
"line_mean": 32.2092050209,
"line_max": 77,
"alpha_frac": 0.6028726219,
"autogenerated": false,
"ratio": 3.7054154995331468,
"config_test": false,
... |
"""
Check that resetting the hdfs module after changing
os.environ['HADOOP_CONF_DIR'] works (i.e., Pydoop references the
correct HDFS service).
Note that it does **NOT** work if you've already instantiated an hdfs
handle, and this is NOT due to the caching system.
"""
from __future__ import print_function
import sys... | {
"repo_name": "elzaggo/pydoop",
"path": "test/hdfs/try_hdfs.py",
"copies": "1",
"size": "1699",
"license": "apache-2.0",
"hash": 3947000219088056000,
"line_mean": 26.8524590164,
"line_max": 77,
"alpha_frac": 0.6739258387,
"autogenerated": false,
"ratio": 3.3912175648702596,
"config_test": false... |
"""
Common hdfs utilities.
"""
import getpass
import pwd
import grp
import sys
__is_py3 = sys.version_info >= (3, 0)
BUFSIZE = 16384
DEFAULT_PORT = 8020 # org/apache/hadoop/hdfs/server/namenode/NameNode.java
DEFAULT_USER = getpass.getuser()
DEFAULT_LIBHDFS_OPTS = "-Xmx48m" # enough for most applications
# Unico... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/hdfs/common.py",
"copies": "1",
"size": "2520",
"license": "apache-2.0",
"hash": -2209695894396237000,
"line_mean": 24.7142857143,
"line_max": 79,
"alpha_frac": 0.6567460317,
"autogenerated": false,
"ratio": 3.5492957746478875,
"config_test": fals... |
"""
Convert text to upper or lower case. By default, the program will
switch text to upper case. Set the config property
'caseswitch.case=lower' if you prefer to switch to lower case.
Set --kv-separator to the empty string when running this example.
"""
def mapper(_, record, writer, conf):
if conf['caseswitch... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/pydoop_script/scripts/caseswitch.py",
"copies": "1",
"size": "1200",
"license": "apache-2.0",
"hash": -498018326523744300,
"line_mean": 31.4324324324,
"line_max": 77,
"alpha_frac": 0.7025,
"autogenerated": false,
"ratio": 3.883495145631068,
"con... |
"""
Generate an HDFS tree containing files of different block size.
"""
import sys
import random
import pydoop
import pydoop.hdfs as hdfs
from common import isdir, MB, TEST_ROOT
BS_RANGE = [_ * MB for _ in range(50, 101, 10)]
def treegen(fs, root, depth, span):
if isdir(fs, root) and depth > 0:
for ... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/hdfs/treegen.py",
"copies": "1",
"size": "2268",
"license": "apache-2.0",
"hash": -2530905343535696400,
"line_mean": 27,
"line_max": 77,
"alpha_frac": 0.557319224,
"autogenerated": false,
"ratio": 3.623003194888179,
"config_test": false,
"has_... |
import sys
from abc import ABCMeta
_is_py3 = sys.version_info[0] == 3
__all__ = [
"ABC",
"basestring",
"bintype",
"cfilter",
"clong",
"cmap",
"configparser",
"czip",
"iteritems",
"parser_read",
"pickle",
"socketserver",
"StringIO",
"unicode",
"xchr",
]
cl... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/utils/py3compat.py",
"copies": "1",
"size": "2187",
"license": "apache-2.0",
"hash": 1863231401896010200,
"line_mean": 20.0288461538,
"line_max": 77,
"alpha_frac": 0.6611796982,
"autogenerated": false,
"ratio": 3.700507614213198,
"config_test": fa... |
"""
Miscellaneous utilities for testing.
"""
from __future__ import print_function
import sys
import os
import tempfile
from pydoop.hdfs import default_is_local
from pydoop.utils.py3compat import iteritems
def __inject_pos(code, start=0):
pos = code.find("import", start)
if pos < 0:
return start
... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/test_support.py",
"copies": "1",
"size": "4659",
"license": "apache-2.0",
"hash": 488444464565173700,
"line_mean": 28.3018867925,
"line_max": 78,
"alpha_frac": 0.5876797596,
"autogenerated": false,
"ratio": 3.4846671652954377,
"config_test": false... |
"""
Miscellaneous utilities.
"""
import logging
import time
import uuid
DEFAULT_LOG_LEVEL = "WARNING"
class NullHandler(logging.Handler):
def emit(self, record):
pass
class NullLogger(logging.Logger):
def __init__(self):
logging.Logger.__init__(self, "null")
self.propagate = 0
... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/utils/misc.py",
"copies": "1",
"size": "2420",
"license": "apache-2.0",
"hash": 4513554768922499600,
"line_mean": 26.5,
"line_max": 77,
"alpha_frac": 0.6276859504,
"autogenerated": false,
"ratio": 3.7288135593220337,
"config_test": false,
"has_n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.